A simple Master-Detail Android Application using search results from iTunes Store API
iTunes API Documentation: https://affiliate.itunes.apple.com/res/doc/itunes-search-api
Download APK
Users are able to use the application to do the following
- Search for music using keywords
- View track details from the results
- Go to the iTunes website for song, artist, or collection details
This application uses Model-View-ViewModel (MVVM) architecture with the following package structure
- data - Data classes for mapping API responses, type converters, and database management classes
- di - Dependency provider modules using Dagger
- network - Service for accessing API
- ui - View classes, adapters, and their respective view models
The user's last search results and the date and time of when that search occurred are retained so that the user can tell how up to date the data is the next time they return to the app.
The list of music tracks was retained using Room which was chosen for good synergy with the other Jetpack components and the date and time of when the last search occurred was retained using SharedPreferences which was chosen because it's very straightforward and easy to use for primitive data types with it's key/value pairs.
{
"trackId": 1440857797,
"trackName": "Good People",
"artistName": "Jack Johnson",
"collectionName": "In Between Dreams (Bonus Track Version)",
"trackPrice": 1.29,
"trackExplicitness": "notExplicit",
"trackTimeMillis": 208509,
"trackViewUrl": "https://music.apple.com/us/album/good-people/1440857781?i=1440857797&uo=4",
"artistViewUrl": "https://music.apple.com/us/artist/jack-johnson/909253?uo=4",
"collectionViewUrl": "https://music.apple.com/us/album/good-people/1440857781?i=1440857797&uo=4",
"artworkUrl100": "https://is2-ssl.mzstatic.com/image/thumb/Music118/v4/24/46/97/24469731-f56f-29f6-67bd-53438f59ebcb/source/100x100bb.jpg",
"collectionPrice": 11.99,
"currency": "USD",
"releaseDate": "2005-03-01T12:00:00Z",
"primaryGenreName": "Rock"
}
- Android KTX - Kotlin extensions for more concise code
- AppCompat - Backward compatibility
- Coroutines - Background operations and handling network calls
- Dagger & Hilt - Dependency injection
- Glide - Image loading
- Lifecycle - Reactive UI that responds to lifecycle events
- Navigation with SafeArgs - In-app navigation
- Retrofit & OkHttp - HTTP client for API calls
- Note that versions 2.6.4 and 3.12.13 were used because later versions do not support Android 4.4
- See Retrofit 2.7.0 changelog and OkHttp 3.13.0 changelog for details
- SharedPreferences and Room - Data persistence
// build.gradle(Module: app)
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
implementation "androidx.core:core-ktx:$rootProject.ktxVersion"
implementation "androidx.appcompat:appcompat:$rootProject.appCompatVersion"
implementation "androidx.hilt:hilt-lifecycle-viewmodel:$rootProject.hiltViewModelVersion"
implementation "androidx.lifecycle:lifecycle-extensions:$rootProject.lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$rootProject.lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$rootProject.lifecycleVersion"
implementation "androidx.navigation:navigation-fragment-ktx:$rootProject.navigationVersion"
implementation "androidx.navigation:navigation-ui-ktx:$rootProject.navigationVersion"
implementation "com.google.android.material:material:$rootProject.materialVersion"
//Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$rootProject.coroutineVersion"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$rootProject.coroutineVersion"
//Dagger
implementation "com.google.dagger:hilt-android:$rootProject.hiltVersion"
compileOnly "com.squareup.inject:assisted-inject-annotations-dagger2:$rootProject.daggerVersion"
kapt "com.squareup.inject:assisted-inject-processor-dagger2:$rootProject.daggerVersion"
kapt "com.google.dagger:hilt-android-compiler:$rootProject.hiltVersion"
kapt "androidx.hilt:hilt-compiler:$rootProject.hiltViewModelVersion"
//Glide
implementation "com.github.bumptech.glide:glide:$rootProject.glideVersion"
//Retrofit2
implementation "com.squareup.retrofit2:retrofit:$rootProject.retrofitVersion"
implementation "com.squareup.retrofit2:converter-moshi:$rootProject.retrofitVersion"
implementation "com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:$rootProject.retrofitCoroutineAdapterVersion"
//Okhttp3
implementation "com.squareup.okhttp3:okhttp:$rootProject.okhttpVersion"
implementation "com.squareup.okhttp3:logging-interceptor:$rootProject.okhttpVersion"
//Room
implementation "androidx.room:room-runtime:$rootProject.roomVersion"
implementation "androidx.room:room-ktx:$rootProject.roomVersion"
kapt "androidx.room:room-compiler:$rootProject.roomVersion"
testImplementation "junit:junit:$rootProject.junitVersion"
androidTestImplementation "androidx.test.ext:junit:$rootProject.testExtVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$rootProject.testEspressoVersion"
}
- Android MVVM Architecture - Detailed sample app that implements MVVM architecture using Dagger2, Room, RxJava, FastAndroidNetworking, PlaceHolderView and AndroidDebugDatabase
- Android Sunflower - Gardening app illustrating Android development best practices with Android Jetpack
- Plaid - Showcase of material design that demonstrates the use of material principles to create tactile, bold, understandable UIs
- RetrofitKotlinDeferred - Simple to Complex Tutorial for making network calls in Android using Retrofit2, Kotlin and its Deferred Type