All Projects → KucherenkoIhor → Android Architecture Components

KucherenkoIhor / Android Architecture Components

The template project that uses Android Architecture Components with Repository pattern. The simple app that uses awesome Fuel library instead of Retrofit for perfoming HTTP request. The app also persists data using the Room library and display data in RecyclerView.

Programming Languages

java
68154 projects - #9 most used programming language
kotlin
9241 projects

Projects that are alternatives of or similar to Android Architecture Components

GithubApp-android-architecture
Let's learn a deep look at the Android architecture
Stars: ✭ 16 (-95.14%)
Mutual labels:  aac, android-architecture, repository-pattern, livedata
Mvvmframe
🏰 MVVMFrame for Android 是一个基于Google官方推出的Architecture Components dependencies(现在叫JetPack){ Lifecycle,LiveData,ViewModel,Room } 构建的快速开发框架。有了MVVMFrame的加持,从此构建一个MVVM模式的项目变得快捷简单。
Stars: ✭ 218 (-33.74%)
Mutual labels:  lifecycle, livedata, android-architecture-components, repository
Dagger2 Sample
A sample app to demo how to implement dagger in Android using Dagger Android Support library
Stars: ✭ 72 (-78.12%)
Mutual labels:  android-architecture, repository-pattern, livedata
Android Mvvm Coroutine
Kotlin android application example with MVVM pattern, android architecture, kotlin coroutine, unit test, and UI test
Stars: ✭ 111 (-66.26%)
Mutual labels:  android-architecture, repository-pattern, livedata
Aachulk
️🔥️🔥️🔥AACHulk是以Google的ViewModel+DataBinding+LiveData+Lifecycles框架为基础, 结合Okhttp+Retrofit+BaseRecyclerViewAdapterHelper+SmartRefreshLayout+ARouter打造的一款快速MVVM开发框架
Stars: ✭ 109 (-66.87%)
Mutual labels:  lifecycle, aac, livedata
Lifecyclin
A Extension of Android Lifecycle Management for Kotlin
Stars: ✭ 14 (-95.74%)
Mutual labels:  aac, lifecycle, android-architecture-components
Android Architecture Components Kotlin
Clean code App with Kotlin and Android Architecture Components
Stars: ✭ 23 (-93.01%)
Mutual labels:  android-architecture, livedata, android-architecture-components
Easychatandroidclient
EasyChat是一个开源的社交类的App。主要包含消息、好友、群组等相关的IM核心功能。部分界面参照了QQ、微信等相关社交APP。EasyChat APP整体采用MVVM模式,基于JetPack(Lifecycle,LiveData,ViewModel,Room)构建
Stars: ✭ 64 (-80.55%)
Mutual labels:  lifecycle, livedata, android-architecture-components
RestaurantsExplorer
Android application build with MVVM Pattern, using Zomato API to enable search cities arround the world and display the city restaurants on a map.
Stars: ✭ 32 (-90.27%)
Mutual labels:  repository-pattern, livedata, android-architecture-components
ReactiveLiveData
An RxJava Extension for the LiveData observer introduced by Google.
Stars: ✭ 17 (-94.83%)
Mutual labels:  aac, livedata, android-architecture-components
KTAndroidArchitecture
A Kotlin android architecture with Google Architecture Components
Stars: ✭ 33 (-89.97%)
Mutual labels:  android-architecture, livedata, android-architecture-components
Mvvmarms
Android MVVM Architecture Components based on MVPArms and Android Architecture Components.
Stars: ✭ 425 (+29.18%)
Mutual labels:  lifecycle, android-architecture, livedata
Daggerandroidmvvm
Demonstrates using Dagger 2.11+ in MVVM app with Android Architecture Components, Clean Architecture, RxJava
Stars: ✭ 255 (-22.49%)
Mutual labels:  aac, android-architecture, livedata
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 (-87.84%)
Mutual labels:  repository-pattern, livedata, android-architecture-components
Android Architecture Components Kotlin
Sample used to practice Kotlin and Android Architecture Components.
Stars: ✭ 326 (-0.91%)
Mutual labels:  livedata, android-architecture-components, repository
Instagram
Instagram Project is a mini version of real Instagram app for Android 📱 built with latest Android Development Tools. Kotlin, MVVM, LiveData, GSON, Retrofit, Dagger2
Stars: ✭ 20 (-93.92%)
Mutual labels:  livedata, android-architecture-components
movies
An example approach for modularization, reactive clean architecture and persistancy.
Stars: ✭ 110 (-66.57%)
Mutual labels:  repository-pattern, livedata
laravel-repository
Repository pattern implementation for Laravel
Stars: ✭ 49 (-85.11%)
Mutual labels:  repository, repository-pattern
GraphQL.RepoDB
A set of extensions for working with HotChocolate GraphQL and Database access with micro-orms such as RepoDb (or Dapper). This extension pack provides access to key elements such as Selections/Projections, Sort arguments, & Paging arguments in a significantly simplified facade so this logic can be leveraged in the Serivces/Repositories that enca…
Stars: ✭ 25 (-92.4%)
Mutual labels:  repository, repository-pattern
BetterRepository
Better Enhanced Repository Pattern Implementation in .NET C#
Stars: ✭ 27 (-91.79%)
Mutual labels:  repository, repository-pattern

Android Architecture Components

Read article here

Android Architecture Components (AAC) is a new collection of libraries that contains the lifecycle-aware components. It can solve problems with configuration changes, supports data persistence, reduces boilerplate code, helps to prevent memory leaks and simplifies async data loading into your UI. I can’t say that it brings absolutely new approaches for solving these issues, but, finally, we have a formal, single and official direction.

AAC provides some abstractions to deal with Android lifecycle:

  • LifecycleOwner
  • LiveData
  • ViewModel

The main benefit is the fact that our UI components, like TextView or RecycleView, observe LiveData, which, in turn, observes the lifecycle of an Activity or Fragment, using a LifecycleObserver.

Combination of these components solves main challenges faced by Android developers, such as boilerplate code or modular. To explore and check an example of this concept, I decided to create the sample project. It just gets a list of repositories from Github and shows one using RecyclerView.

As you can see, it handles configuration changes without any problems, and an Activity looks very simple:

class ReposActivity : BaseLifecycleActivity<ReposViewModel>(), SwipeRefreshLayout.OnRefreshListener {

    override val viewModelClass = ReposViewModel::class.java

    private val rv by unsafeLazy { findViewById<RecyclerView>(R.id.rv) }

    private val vRefresh by unsafeLazy { findViewById<SwipeRefreshLayout>(R.id.lRefresh) }

    private val adapter = ReposAdapter()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_repos)
        rv.setHasFixedSize(true)
        rv.adapter = adapter
        vRefresh.setOnRefreshListener(this)

        if (savedInstanceState == null) {
            viewModel.setOrganization("yalantis")
        }
        observeLiveData()
    }

    private fun observeLiveData() {
        viewModel.isLoadingLiveData.observe(this, Observer<Boolean> {
            it?.let { vRefresh.isRefreshing = it }
        })
        viewModel.reposLiveData.observe(this, Observer<List<Repo>> {
            it?.let { adapter.dataSource = it }
        })
        viewModel.throwableLiveData.observe(this, Observer<Throwable> {
            it?.let { Snackbar.make(rv, it.localizedMessage, Snackbar.LENGTH_LONG).show() }
        })
    }

    override fun onRefresh() {
        viewModel.setOrganization("yalantis")
    }
}

How you have probably noticed, our activity assumes minimum responsibilities. ReposViewModel holds state and view data in the following way:

open class ReposViewModel(application: Application?) : AndroidViewModel(application) {

    private val organizationLiveData = MutableLiveData<String>()

    val resultLiveData = ReposLiveData().apply {
        this.addSource(organizationLiveData) { it?.let { this.organization = it } }
    }

    val isLoadingLiveData = MediatorLiveData<Boolean>().apply {
        this.addSource(resultLiveData) { this.value = false }
    }

    val throwableLiveData = MediatorLiveData<Throwable>().apply {
        this.addSource(resultLiveData) { it?.second?.let { this.value = it } }
    }

    val reposLiveData = MediatorLiveData<List<Repo>>().apply {
        this.addSource(resultLiveData) { it?.first?.let { this.value = it } }
    }

    fun setOrganization(organization: String) {
        organizationLiveData.value = organization
        isLoadingLiveData.value = true
    }

}

Testability

@RunWith(AndroidJUnit4::class)
class SampleInstrumentedTest {

    @get:Rule
    val activityRule = ActivityTestRule<ReposActivity>(ReposActivity::class.java, true, true)

    private var viewModel: ReposViewModel? = null

    @Before
    fun init() {
        viewModel = ViewModelProviders.of(activityRule.activity).get(ReposViewModel::class.java)
    }

    @Test
    fun testNotNull() {
        activityRule.activity.runOnUiThread {
            viewModel?.setOrganization("yalantis")
            viewModel?.reposLiveData?.observe(activityRule.activity, Observer<List<Repo>> {
               assertNotNull(it)
            })
        }
    }
}
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].