Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parcelable support #44

Closed
amorenew opened this issue Jun 3, 2018 · 3 comments
Closed

Parcelable support #44

amorenew opened this issue Jun 3, 2018 · 3 comments

Comments

@amorenew
Copy link

amorenew commented Jun 3, 2018

I wonder If you could add Parcelable support to the data class
like below

@Parcelize
data class DataResponse(
        @SerializedName("Isvalid") var isValid: Boolean,
) : Parcelable
@wuseal
Copy link
Owner

wuseal commented Jun 3, 2018

@amorenew Hi, Now it could support adding @Parcelize annotation on the class by custom annotation option, But can't support parent class declaration, The parent class declaration will be supported next version soon. Good advice!

@wuseal
Copy link
Owner

wuseal commented Jun 25, 2018

@amorenew Hi, An EAP version has just released, And it could fix this issue, Have a try if it works for you.

First update the settings like this:

image
image

And then you could generate class code like this:

import android.os.Parcelable
import kotlinx.android.parcel.Parcelize

@Parcelize
data class Data(
        val feedbacks: Feedbacks = Feedbacks(),
        val liketeamlist: List<Liketeamlist> = listOf(),
        val partnerteamlist: List<Partnerteamlist> = listOf()
) : Parcelable {
    @Parcelize
    data class Feedbacks(
            val feedbacklist: List<Feedbacklist> = listOf(),
            val totalcount: Int = 0, // 1
            val totalscore: Int = 0 // 5
    ) : Parcelable {
        @Parcelize
        data class Feedbacklist(
                val comment: String = "", // 5分
                val createtime: String = "", // 2016.09.07 12:38
                val score: Int = 0, // 5
                val username: String = "" // 1331##11
        ) : Parcelable
    }

    @Parcelize
    data class Partnerteamlist(
            val pteamId: Int = 0, // 716
            val pteamprice: Int = 0, // 38
            val ptitle: String = "" // 后期持续更新!
    ) : Parcelable

    @Parcelize
    data class Liketeamlist(
            val limage: String = "", // http://baidu.com/37.jpg
            val lmarketprice: Int = 0, // 3380
            val lteamId: Int = 0, // 57133
            val lteamprice: Int = 0, // 580
            val ltitle: String = "" // 测试文本,15级软件开发!
    ) : Parcelable
}

If there any question ,welcome reply me directly. Thanks.

@amorenew
Copy link
Author

@wuseal
Great work it is working
1-I enabled @parcelable in gradle

androidExtensions {
        experimental = true
    }

I use Gson for parsing
implementation 'com.google.code.gson:gson:2.8.5'

2- In Annotation Import class section:

import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import kotlinx.android.parcel.Parcelize

3- In Class Annotation Format section:
@Parcelize
4- In Property Annotation Format:
@SerializedName("%s")
5- In Parent Class Template:
android.os.Parcelable

Thanks a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants