【Retrofit】データクラス エンティティ フィールド名の付け替え @SerializedName @Json @SerialName

同じ Retrofit を使うにしても、パーサーによってアノテーション記述が変わるので、ググると無駄に時間がかかってしまう。

【Retrofit】データクラス エンティティ フィールド名の付け替え @SerializedName @Json @SerialName

 

🔄 Gson


data class User (
    @SerializedName("id")
    long userId;
    @SerializedName("fullName")
    String name;
)

👉 gson/UserGuide.md at master · google/gson hatena-bookmark

 

🔄 Moshi


@JsonClass(generateAdapter = true)
data class User (
    @Json(name = "id")
    long userId;
    @@Json(name = "fullName")
    String name;
)

👉 square/moshi: A modern JSON library for Kotlin and Java. hatena-bookmark

 

🔄 kotlinx.serialization


@Serializable
data class User (
    @SerialName("id")
    long userId;
    @SerialName("fullName")
    String name;
)

👉 kotlinx.serialization/basic-serialization.md at master · Kotlin/kotlinx.serialization hatena-bookmark

 

🔄 まとめ

初めて使うときは混乱するだろうと思います。

今となっては、JSONパーサーは、Kotlin 内蔵の kotlinx.serialization を使いたいですね。

👉 「Kotlinx Json」の登場でサードパーティJSONライブラリは不要となる。 hatena-bookmark


【Jetpack Compose】ChatGPT のようなアニメーションの @Composable AnimationText

画面がなんとなく元気になります。

Jetpack Compose AnimationText like ChatGPT



 

💬 実装

LaunchedEffect() のラムダ内は CoroutineScope なので delay() でお好みのスピードで。

JaetpackCompose は、なかなかメモリーリークしないのがいいところ。

 

💬 まとめ

アプリで公開するとすれば、最低でも WEB の UI を超えた機能を実装しなければなりません。

先人たちが公開されている UI の機能を取り込んでいきましょう。


Android Studio Flamingo 隠された新デザイン「New UI」を有効化する2つの方法 🐦

安定版「Android Studio Flamingo | 2022.2.1」にアップデートしてがっかりしていましたが。

👉 Android Studio Flamingo | 2022.2.1 安定版公開される hatena-bookmark

元々、IDEA Intellij に入ってた「New UI」ですが、

Update: The beta version of the new UI is available to all users in the 2022.3 release.
Go to Settings | Appearance & Behavior | New UI to enable it.

👉 Take Part in the New UI Preview for Your JetBrains IDE | The IntelliJ IDEA Blog hatena-bookmark

今現在「Android Studio Flamingo | 2022.2.1」では、デフォルトで無効化しているようで、実際には機能は同梱されてるようです。

有効化してみましょう。

 

🐦 Registry から適用する

上部メニューから、


[Help]

  ↓

[Find Action]

  ↓

[Registry...]

  ↓

[ide.experimental.ui.***] をチェック

以下のように進んでいきチェックを入れたら Android Studio 再起動です。

How to enable Android Studio new ui

GUI部分のテーマやアイコンが新しいものになり、構成もすっきりした感じになります。

または、キーボードショートカットからでも、Registry 画面にいけます。

👉 How to enable Android Studio new ui - Stack Overflow hatena-bookmark

 

🐦 プラグインを使う

このツイート。


WEBページから .jar をダウンロードして、Plugins から import します。

Enable new UI
Android Studio 2022.2 has a new UI that can be unlocked with a plugin. While the official plugin is in closed beta, we’ve made an equivalent plugin that does the job and unlocks the new UI with the same settings and new color schemes.

👉 Hueflake for Android Studio · Hueflake hatena-bookmark

こちらも再起動で綺麗に適用されます。

 

🐦 まとめ

どこか具合が悪いのか、未検証なのか謎ですが、新デザインでまあモチベーションは上がります。

問題あるようなら戻したいと思います。