Retrofitを使って通信処理をしているのですが、booleanの記述方法が分かりません。
JavaをConvert Java File to Kotlin FileでKotlinに変換しエラーなど発生せずに動いているのですがbooleanのデータだけ渡せていない状況です。
Kotlin
1//kotlin 2class Word : Parcelable { 3 @Expose 4 var id: Int? = null 5 @Expose 6 var keyword: String? = null 7 @Expose 8 var type: Int? = null 9 @Expose 10 var level: Int? = null 11 @Expose 12 var summary: String? = null 13 @Expose 14 var description: String? = null 15 @Expose 16 var isAdult: Boolean = false 17 @Expose 18 var isGrotesque: Boolean = false 19 @Expose 20 var isMovie: Boolean = false 21 @Expose 22 var isNonfiction: Boolean = false 23 @Expose 24 var isFiction: Boolean = false 25 @Expose 26 var isAccident: Boolean = false 27 @Expose 28 var isCrime: Boolean = false 29 @Expose 30 var isExecution: Boolean = false 31 @Expose 32 var isHorror: Boolean = false 33 @Expose 34 var isSick: Boolean = false 35 @Expose 36 var isCreature: Boolean = false 37 @Expose 38 var isDrug: Boolean = false 39 @Expose 40 var isWar: Boolean = false 41 @Expose 42 var isNucleus: Boolean = false 43 @Expose 44 var isPsycho: Boolean = false 45 @Expose 46 var isFilth: Boolean = false 47 @Expose 48 var isFunny: Boolean = false 49 @Expose 50 var isViolence: Boolean = false 51 @Expose 52 var isSurprised: Boolean = false 53 @Expose 54 var isWord: Boolean = false 55 @Expose 56 var isMystery: Boolean = false 57 @Expose 58 var isDepression: Boolean = false 59 @Expose 60 var isParaphilia: Boolean = false 61 @Expose 62 var lang: String? = null 63 @Expose 64 var url: String? = null 65 66 override fun describeContents(): Int { 67 return 0 68 } 69 70 override fun writeToParcel(dest: Parcel, flags: Int) { 71 dest.writeValue(this.id) 72 dest.writeString(this.keyword) 73 dest.writeValue(this.type) 74 dest.writeValue(this.level) 75 dest.writeString(this.summary) 76 dest.writeString(this.description) 77 dest.writeByte(if (this.isAdult) 1.toByte() else 0.toByte()) 78 dest.writeByte(if (this.isGrotesque) 1.toByte() else 0.toByte()) 79 dest.writeByte(if (this.isMovie) 1.toByte() else 0.toByte()) 80 dest.writeByte(if (this.isNonfiction) 1.toByte() else 0.toByte()) 81 dest.writeByte(if (this.isFiction) 1.toByte() else 0.toByte()) 82 dest.writeByte(if (this.isAccident) 1.toByte() else 0.toByte()) 83 dest.writeByte(if (this.isCrime) 1.toByte() else 0.toByte()) 84 dest.writeByte(if (this.isExecution) 1.toByte() else 0.toByte()) 85 dest.writeByte(if (this.isHorror) 1.toByte() else 0.toByte()) 86 dest.writeByte(if (this.isSick) 1.toByte() else 0.toByte()) 87 dest.writeByte(if (this.isCreature) 1.toByte() else 0.toByte()) 88 dest.writeByte(if (this.isDrug) 1.toByte() else 0.toByte()) 89 dest.writeByte(if (this.isWar) 1.toByte() else 0.toByte()) 90 dest.writeByte(if (this.isNucleus) 1.toByte() else 0.toByte()) 91 dest.writeByte(if (this.isPsycho) 1.toByte() else 0.toByte()) 92 dest.writeByte(if (this.isFilth) 1.toByte() else 0.toByte()) 93 dest.writeByte(if (this.isFunny) 1.toByte() else 0.toByte()) 94 dest.writeByte(if (this.isViolence) 1.toByte() else 0.toByte()) 95 dest.writeByte(if (this.isSurprised) 1.toByte() else 0.toByte()) 96 dest.writeByte(if (this.isWord) 1.toByte() else 0.toByte()) 97 dest.writeByte(if (this.isMystery) 1.toByte() else 0.toByte()) 98 dest.writeByte(if (this.isDepression) 1.toByte() else 0.toByte()) 99 dest.writeByte(if (this.isParaphilia) 1.toByte() else 0.toByte()) 100 dest.writeString(this.lang) 101 dest.writeString(this.url) 102 } 103 104 constructor() {} 105 106 protected constructor(`in`: Parcel) { 107 this.id = `in`.readValue(Int::class.java.classLoader) as Int 108 this.keyword = `in`.readString() 109 this.type = `in`.readValue(Int::class.java.classLoader) as Int 110 this.level = `in`.readValue(Int::class.java.classLoader) as Int 111 this.summary = `in`.readString() 112 this.description = `in`.readString() 113 this.isAdult = `in`.readByte().toInt() != 0 114 this.isGrotesque = `in`.readByte().toInt() != 0 115 this.isMovie = `in`.readByte().toInt() != 0 116 this.isNonfiction = `in`.readByte().toInt() != 0 117 this.isFiction = `in`.readByte().toInt() != 0 118 this.isAccident = `in`.readByte().toInt() != 0 119 this.isCrime = `in`.readByte().toInt() != 0 120 this.isExecution = `in`.readByte().toInt() != 0 121 this.isHorror = `in`.readByte().toInt() != 0 122 this.isSick = `in`.readByte().toInt() != 0 123 this.isCreature = `in`.readByte().toInt() != 0 124 this.isDrug = `in`.readByte().toInt() != 0 125 this.isWar = `in`.readByte().toInt() != 0 126 this.isNucleus = `in`.readByte().toInt() != 0 127 this.isPsycho = `in`.readByte().toInt() != 0 128 this.isFilth = `in`.readByte().toInt() != 0 129 this.isFunny = `in`.readByte().toInt() != 0 130 this.isViolence = `in`.readByte().toInt() != 0 131 this.isSurprised = `in`.readByte().toInt() != 0 132 this.isWord = `in`.readByte().toInt() != 0 133 this.isMystery = `in`.readByte().toInt() != 0 134 this.isDepression = `in`.readByte().toInt() != 0 135 this.isParaphilia = `in`.readByte().toInt() != 0 136 this.lang = `in`.readString() 137 this.url = `in`.readString() 138 } 139 140 companion object { 141 142 @JvmField 143 val CREATOR: Parcelable.Creator<Word> = object : Parcelable.Creator<Word> { 144 override fun createFromParcel(source: Parcel): Word { 145 return Word(source) 146 } 147 148 override fun newArray(size: Int): Array<Word?> { 149 return arrayOfNulls(size) 150 } 151 } 152 } 153}
Stringやintのデータは渡ってきているのですがbooleanのデータだけ渡ってきていません。
解決策を教えてください。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。