android チュートリアルで発見したこと

久しぶりにチュートリアルやると発見があったりしていいんだろうなぁ。

Flutterの理解が深まる

日本語で詳しく書いてある。プログラマ未経験の人にもわかりやすいくらい。

ビュー バインディングは findViewById の後継

ビュー バインディング  |  Android デベロッパー  |  Android Developers

if/else ステートメントを記述することもできますが、when 式を使用する方がはるかに簡単です。

チップを計算する  |  Android デベロッパー  |  Android Developers

一時変数は徹底的に排除、マテリアル デザイン ガイドラインに準拠させる

チップを計算する  |  Android デベロッパー  |  Android Developers

layout_constraintが大変

循環参照とか、要素が削除されたときの修正とかが大変そう。

まだ、宣言的UIでネストが深くなる方がマシに思える。

すべての行の高さの最小値は、マテリアル デザイン ガイドラインに従って 48 dp にする必要があります

より洗練されたユーザー エクスペリエンスを作成する  |  Android デベロッパー  |  Android Developers

styles.xmlwebデザイナーさんに用意してもらうのは無理そう

より洗練されたユーザー エクスペリエンスを作成する  |  Android デベロッパー  |  Android Developers

ビルダー パターン

Kotlin でリストを使用する  |  Android デベロッパー  |  Android Developers

呼び出しをチェーンできるようにメソッド内でthisをreturnする。

Datasourceクラス

自分が過去にいたチームとかだと付けさせてもらえないクラス名

RecyclerView を使用してスクロール可能なリストを表示する  |  Android デベロッパー

mysql, oracle, redshift, Treasure Dataなどなど沢山ある時に使いたくなる名前

アダプタ

RecyclerView を使用してスクロール可能なリストを表示する  |  Android デベロッパー

new resource directory called drawable-anydpi-v26

Display a list of images using cards  |  Android Developers

日本語で読むと若干間違ってる。少し前のチュートリアルの内容を覚えておくと間違いに気づける。

UI をモデルで操作する

Guide to app architecture  |  Android Developers

などの推奨アーキテクチャが紹介されている

ViewModel responsibilities

Store data in ViewModel  |  Android Developers

ViewModel is responsible for holding and processing all the data needed for the UI. It should never access your view hierarchy (like view binding object) or hold a reference to the activity or the fragment.

propertyを書き込みに対してprivateにしておくことの例

This is risky because an outside class could change the data in unexpected ways that don't follow the game rules specified in the view model. For example, an outside class could change the score to a negative value.

これに対して、「scoreを、絶対に負(negative)の値なんかにしないからpublicにして」という人もいるのでさらなる例が必要。

Backing property

Store data in ViewModel  |  Android Developers

LiveData is still our solution for Java developers, beginners, and simple situations

Migrating from LiveData to Kotlin’s Flow | by Jose Alcérreca | Android Developers | May, 2021 | Medium

レイアウトによってバインディングの手法を変える

ビュー バインディング  |  Android デベロッパー  |  Android Developers

エミュレータでtalkbackのテストするときにインストールする

Android Accessibility Suite - Apps on Google Play

Add a NavHost to the activity

Get started with the Navigation component  |  Android Developers

activity_main.xmlにFragmentContainerViewを追加

Syntax for property delegation

var <property-name> : <property-type> by <delegate-class>()

Property delegation in Kotlin helps you to handoff the getter-setter responsibility to a different class.

the back stack can also track the fragment destinations

Navigation and the back stack  |  Android Developers

In the same way that the back stack can keep track of activities that have been opened by the user, the back stack can also track the fragment destinations the user has visited with the help of the Jetpack Navigation component.