All Projects → miquelbeltran → Android Architecture Sample

miquelbeltran / Android Architecture Sample

Licence: gpl-3.0
Sample app using Kotlin, Coroutines, Architecture Components and more. With Unit and Instrumentation tests.

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Android Architecture Sample

WanAndroidJetpack
🔥 WanAndroid 客户端,Kotlin + MVVM + Jetpack + Retrofit + Glide。基于 MVVM 架构,用 Jetpack 实现,网络采用 Kotlin 的协程和 Retrofit 配合使用!精美的 UI,便捷突出的功能实现,欢迎下载体验!
Stars: ✭ 124 (+31.91%)
Mutual labels:  coroutines, retrofit
Sample Code Movies
This repository contains sample code. Its purpose being, to quickly demonstrate Android and software development in general, clean code, best practices, testing and all those other must know goodies.
Stars: ✭ 81 (-13.83%)
Mutual labels:  coroutines, retrofit
GitKtDroid
A sample Android application📱 built with Kotlin for #30DaysOfKotlin
Stars: ✭ 53 (-43.62%)
Mutual labels:  coroutines, architecture-components
ComposeMovie
Movie app that built with Jetpack Compose
Stars: ✭ 96 (+2.13%)
Mutual labels:  coroutines, retrofit
Alfonz
Mr. Alfonz is here to help you build your Android app, make the development process easier and avoid boilerplate code.
Stars: ✭ 90 (-4.26%)
Mutual labels:  retrofit, architecture-components
EasyTask MVVM Kotlin
Todo app based on MVVM, Kotlin Coroutines, Navigation Component, Room Database, Retrofit, Data Binding
Stars: ✭ 49 (-47.87%)
Mutual labels:  coroutines, retrofit
Architecturecomponentsdemo
Kotlin demo project that uses some Android Architecture Components (ViewModel and LiveData) with Dagger 2 and Coroutines
Stars: ✭ 269 (+186.17%)
Mutual labels:  coroutines, architecture-components
android-clean-architecture
🚀🚀🚀 The boilerplate for Android using Kotlin & Clean architecture.
Stars: ✭ 21 (-77.66%)
Mutual labels:  coroutines, retrofit
News
A sample News 🗞 app built using Modern Android Development [Architecture Components, Coroutines, Retrofit, Room, Kotlin, Dagger]
Stars: ✭ 774 (+723.4%)
Mutual labels:  coroutines, architecture-components
Archapp
Simple Android app to show how to design a multi-modules MVVM Android app (fully tested)
Stars: ✭ 551 (+486.17%)
Mutual labels:  coroutines, architecture-components
Superhero-App
🦸🏻‍♂️🦹🏻‍♀️Superhero app built with Kotlin, ViewModel, LiveData, ViewBinding, Room, and Hilt
Stars: ✭ 27 (-71.28%)
Mutual labels:  coroutines, architecture-components
Awesome Android Kotlin Apps
👓 A curated list of awesome android kotlin apps by open-source contributors.
Stars: ✭ 1,058 (+1025.53%)
Mutual labels:  coroutines, retrofit
GitMessengerBot-Android
타입스크립트, V8 엔진의 자바스크립트, 파이썬 그리고 Git을 지원하는 최첨단 메신저 봇!
Stars: ✭ 51 (-45.74%)
Mutual labels:  retrofit, architecture-components
Rick-and-Morty
The Rick And Morty - MVVM with a clean architecture approach using some of the best practices in Android Development.
Stars: ✭ 45 (-52.13%)
Mutual labels:  coroutines, architecture-components
Simple-Notes-Kotlin-App
✍️ Simple Note Making App use mvvm architecture , dagger , coroutines and navigation component. Features includes 🗒️ create , edit and ❌ delete notes
Stars: ✭ 40 (-57.45%)
Mutual labels:  coroutines, architecture-components
Paging-3-Sample
This app is created as a sample app which loads movies from Tmdb api and uses Paging 3 library to show it in a Recycler view.
Stars: ✭ 96 (+2.13%)
Mutual labels:  coroutines, architecture-components
Android-Assignment
This assignment gives you basically a post list and its detail with comments.🚀
Stars: ✭ 32 (-65.96%)
Mutual labels:  coroutines, architecture-components
DemoApp
An Android template project for fast development and test.
Stars: ✭ 33 (-64.89%)
Mutual labels:  coroutines, retrofit
Clean Mvvm Archcomponents
👽 Android app consuming Star Wars API.Built with clean architecture ,MVVM pattern, Koin , Coroutines + Flows ,Architecture Components, Data Binding , Firebase , Unit/UI Tests ,Motion Layout
Stars: ✭ 285 (+203.19%)
Mutual labels:  coroutines, architecture-components
Kotlin Coroutines Retrofit
Kotlin Coroutines await() extension for Retrofit Call
Stars: ✭ 812 (+763.83%)
Mutual labels:  coroutines, retrofit

NOTICE

This project has been archived due to the lack of activity.

Feel free to fork and do any changes or continue supporting it by yourself, but please keep the license and copyright notices.

Miguel, author of the project.


Android Architecture Sample

Sample Android App to access Discogs API.

This app performs basic REST call to obtain a public list of records from Discogs API, with the idea to test and showcase some Android architecture and coding patterns.

Code Features

  • Kotlin.
  • Coroutines.
  • Dependency injection with Koin.
  • Retrofit + Moshi.
  • Architecture Components.
  • Modularization.
  • Unit Testing.
  • Instrumentation Testing with Espresso.

App Modules

- app                  (App and MainActivity; Android)
- api                  (Retrofit Service; Kotlin)
- common-domain        (Kotlin)
- collection           
  | - collection-ui    (Fragment and ViewModel; Android)
  | - collection-data  (Use case; Kotlin)

graph

Cool Examples

Dependency Injection with Koin

https://github.com/miquelbeltran/android-discogsbrowser/blob/master/app/src/main/java/work/beltran/discogsbrowser/App.kt#L11

startKoin(this, listOf(
    collectionKoinModule
))

https://github.com/miquelbeltran/android-discogsbrowser/blob/master/collection/collection-ui/src/main/java/work/beltran/discogsbrowser/collection/CollectionFragment.kt#L20

private val viewModel: CollectionViewModel by viewModel()

Retrofit with Coroutines

https://github.com/miquelbeltran/android-discogsbrowser/blob/master/api/src/main/java/work/beltran/discogsbrowser/api/DiscogsService.kt#L22

@GET("users/{username}/collection/folders/{folder_id}/releases")
fun getCollectionItemsByFolder(
    @Path("username") username: String,
    @Path("folder_id") folderId: String,
    @Query("page") page: Int,
    @Query("per_page") perPage: Int
) : Deferred<Response<CollectionItemsByFolderResponse>>

Use Case Implementation with Coroutines and Arrow

https://github.com/miquelbeltran/android-discogsbrowser/blob/master/collection/collection-data/src/main/java/work/beltran/discogsbrowser/collection/data/GetCollectionUseCase.kt#L17

private suspend fun requestItems(
    folder: String,
    page: Int
): Response<CollectionItemsByFolderResponse> {
    return discogsService.getCollectionItemsByFolder(
        username = "mike513",
        folderId = folder,
        page = page,
        perPage = PAGE_SIZE
    ).await()
}

Use Case Unit Test using Mockk and Coroutines

https://github.com/miquelbeltran/android-discogsbrowser/blob/master/collection/collection-data/src/test/kotlin/work/beltran/discogsbrowser/collection/data/GetCollectionUseCaseImplTest.kt

every {
    service.getCollectionItemsByFolder(
        username = "mike513",
        folderId = "0",
        page = 1,
        perPage = 20
    )
} returns CompletableDeferred(
    Response.success(
        collectionItemsByFolderResponse
    )
)

ViewModel and LiveData with Coroutines (Kotlin 1.3)

https://github.com/miquelbeltran/android-discogsbrowser/blob/master/collection/collection-ui/src/main/java/work/beltran/discogsbrowser/collection/CollectionViewModel.kt

loadingJob = launch(dispatcher) {
    val result = collectionUseCase.getCollectionPage("0", page)
    when (result) {
        is Either.Left -> Log.e("CollectionViewModel", result.a)
        is Either.Right -> {
            pages[page] = result.b.data
            nextPage = result.b.nextPage
        }
    }
    updateCollectionScreenState()
}

ViewModel Unit Test

https://github.com/miquelbeltran/android-discogsbrowser/blob/master/collection/collection-ui/src/test/java/work/beltran/discogsbrowser/collection/CollectionViewModelTest.kt

val viewModel = CollectionViewModel(
    collectionUseCase = useCase,
    dispatcher = Dispatchers.Unconfined
)

val data = viewModel.liveData.value!!
assertEquals(1, data.size)

val item = data[0] as CollectionItem.AlbumItem
assertEquals(album, item.album)

Fragment Instrumentation Test with Espresso

https://github.com/miquelbeltran/android-discogsbrowser/blob/master/collection/collection-ui/src/androidTest/java/work/beltran/discogsbrowser/collection/CollectionFragmentTest.kt

@Test
fun load_single_item_page() {

    // Mock the use case to return a single item
    val collectionUseCase = mockUseCaseForSingleItem()

    // Configure dependency injection to provide ViewModel with Use Case
    configureKoin(collectionUseCase)

    // Launch Fragment in a Test Activity
    launchFragment()

    // Assert Album title is displayed in the list
    onView(withText("title")).check(matches(isDisplayed()))
}

License

Android Architecute Sample  Copyright (C) 2018  Miguel Beltran Febrer
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].