Android アーキテクチャ コンポーネントを活用して簡潔で効率的なコードベースを作成した iHeartRadio
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。

ニューヨーク市に拠点を置く iHeartRadio は、無制限の音楽と数千のラジオ局のすべてを 1 つのアプリで提供しています。同社では、ラジオ放送、オンライン、モバイル、デジタル、ソーシャル メディア、ライブ コンサートやイベント、シンジケーション、音楽研究サービス、インディペンデント メディア表現などの事業を運営しています。
同社のアプリは、2008 年の公開以来、世界中のリスナーに 10 億回以上ダウンロードされています。しかし 2017 年末の時点で、コードベースの老朽化が目立つようになっており、コードのメンテナンスや新機能の追加が難しい状況となっていました。
iHeartRadio の取り組み
iHeartRadio は、コードの刷新に着手するにあたり、Android アーキテクチャ コンポーネントの導入を決断しました。iHeartRadio がコードで幅広く使用している非同期クエリや RxJava のサポートといった処理が可能な Room 永続性ライブラリが、簡単で実装も容易でした。
また iHeartRadio では、別のコンポーネントのライフサイクル ステータスの変化に対応してアクションを実行するライフサイクル対応コンポーネントも導入しています。同社のエンジニアがこのコンポーネントを特に高く評価しているのは、アクティビティやフラグメントの依存関係を少なくできる点です。さらに、ViewModel を使用してプロトタイプを作成することで、画面の回転などの構成変更後にもデータを引き継ぐことができます。
結果
iHeartRadio は、アーキテクチャ コンポーネントへの移行が簡単になったことと、ライブラリを使用して統合が正しく機能しているかどうかをテストすることで確認しました。Room などのコンポーネントでは、必要なボイラープレート コードがほとんどありません。つまり、アプリのコードが大幅に短縮されています。アーキテクチャ コンポーネントでは、メモリリークも減少しました。さらなるメリットとして、新たにチームに加わったデベロッパーが直ちに状況を把握し、コーディングを開始できるようになりました。
全体として、アーキテクチャ コンポーネントの導入により、iHeartRadio はクリーンで無駄のないコードベースを作成し、エラーを防止できるようになりました。これはどのアプリにとっても良いことです。特に、世界中のユーザーにオールインワンのデジタル オーディオを提供するアプリにとっては好都合です。
始める
Android アーキテクチャ コンポーネントは、Android Jetpack の一部として、全デベロッパーに公開されています。Android アーキテクチャ コンポーネントを使ってみるをご覧ください。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2018-05-03 UTC。
[null,null,["最終更新日 2018-05-03 UTC。"],[],[],null,["# iHeartRadio creates a cleaner, leaner code base with Android Architecture Components\n\nNew York City-based [iHeartRadio](https://www.iheart.com/) provides\nunlimited music and thousands of radio stations, all in one app. The company's\noperations include radio broadcasting, online, mobile, digital and social media,\nlive concerts and events, syndication, music-research services, and\nindependent media representation.\n\nListeners around the world have downloaded the app over a billion times\nsince it launched in 2008. By late 2017, however, the codebase was aging,\nand managing the code and integrating new features proved to be difficult.\n\nWhat they did\n-------------\n\niHeartRadio chose\n[Android Architecture Components](/topic/libraries/architecture) as they\nbegan upgrading their code. The straightforward, easy-to-implement\n[Room](/topic/libraries/architecture/room) persistency library was\nattractive to their engineers for its\ncapabilities for handling such things as asynchronous queries and support for\nRxJava, which iHeartRadio uses extensively in their code.\n\nThey also adopted\n[lifecycle-aware components](/topic/libraries/architecture/lifecycle),\nwhich perform actions in response to a change in the\nlifecycle status of another component. The iHeartRadio\nengineers found these components very useful for shrinking dependencies\ninjected into activities and fragments. In addition, the company created\nprototypes using [ViewModel](/topic/libraries/architecture/viewmodel),\nwhich allows data to survive configuration changes, such as screen rotations.\n\nResults\n-------\n\niHeartRadio found it easy to migrate over to\n[Architecture Components](/jetpack/arch)\nand to use the libraries to test how well integration was working.\n[Room](/topic/libraries/architecture/room) and other components require\nthe use of very little boilerplate code, meaning that the app's code is\nnow significantly shorter. [Architecture Components](/jetpack/arch)\nalso resulted in fewer memory leaks. An additional benefit was that new\ndevelopers joining the team could quickly get ramped up and start coding.\n\nOverall, adopting [Architecture Components](/jetpack/arch) has helped\niHeartRadio to create a cleaner, leaner code base that helps them to prevent errors.\nThat's good news for any app, especially for one offering\nall-in-one digital audio to a worldwide audience.\n\nGet started\n-----------\n\nAndroid Architecture Components is open to all developers as part of\n[Android Jetpack](/jetpack). [Get\nstarted with Android Architecture Components](/jetpack/arch)."]]