Feature/core repository separation (#44)

* Fixed wrong package name. Fixes #43 

* Updated package name. Fixes #41 

* Ignoring not-used warning - this graph is included in main graph

* Separated repository from core. Fixes #42 

* Removing adapter from recyclerView when view is destroyed to prevent leak. Fixes #40 

* Updated new module graph

Signed-off-by: Melih Aksoy <aksoy.melihcan@gmail.com>
This commit is contained in:
Melih Aksoy
2019-09-26 17:23:53 +02:00
committed by GitHub
parent 8344e7f94b
commit 83e39400a9
22 changed files with 50 additions and 40 deletions

View File

@@ -32,6 +32,7 @@ dependencies {
androidTestImplementation testLibraries.espresso androidTestImplementation testLibraries.espresso
// These libraries required by dagger to create dependency graph, but not by app // These libraries required by dagger to create dependency graph, but not by app
compileOnly project(':repository')
compileOnly libraries.retrofit compileOnly libraries.retrofit
compileOnly libraries.room compileOnly libraries.room
compileOnly libraries.paging compileOnly libraries.paging

View File

@@ -1,7 +1,7 @@
package com.melih.rocketscience.di package com.melih.rocketscience.di
import com.melih.detail.di.DetailContributor import com.melih.detail.di.DetailContributor
import com.melih.list.di.LaunchesContributor import com.melih.launches.di.LaunchesContributor
import com.melih.rocketscience.MainActivity import com.melih.rocketscience.MainActivity
import dagger.Module import dagger.Module
import dagger.android.ContributesAndroidInjector import dagger.android.ContributesAndroidInjector

View File

@@ -14,7 +14,7 @@ android {
dependencies { dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
api project(":repository") implementation project(':repository')
implementation libraries.fragment implementation libraries.fragment
implementation libraries.paging implementation libraries.paging
@@ -28,6 +28,4 @@ dependencies {
testImplementation testLibraries.mockk testImplementation testLibraries.mockk
testImplementation testLibraries.kluent testImplementation testLibraries.kluent
testImplementation testLibraries.coroutinesTest testImplementation testLibraries.coroutinesTest
compileOnly libraries.room
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 50 KiB

View File

@@ -14,5 +14,7 @@ android {
dependencies { dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':repository')
testImplementation testLibraries.coroutinesTest testImplementation testLibraries.coroutinesTest
} }

View File

@@ -1,8 +1,8 @@
package com.melih.detail.di package com.melih.detail.di
import com.melih.detail.di.modules.DetailFragmentModule import com.melih.detail.di.modules.DetailFragmentModule
import com.melih.detail.di.scopes.DetailFragmentScope
import com.melih.detail.ui.DetailFragment import com.melih.detail.ui.DetailFragment
import com.melih.list.di.scopes.DetailFragmentScope
import dagger.Module import dagger.Module
import dagger.android.ContributesAndroidInjector import dagger.android.ContributesAndroidInjector

View File

@@ -1,4 +1,4 @@
package com.melih.list.di.scopes package com.melih.detail.di.scopes
import javax.inject.Scope import javax.inject.Scope

View File

@@ -1,4 +1,4 @@
package com.melih.list.di.scopes package com.melih.detail.di.scopes
import javax.inject.Scope import javax.inject.Scope

View File

@@ -7,6 +7,8 @@ apply from: "$rootProject.projectDir/scripts/feature_module.gradle"
dependencies { dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':repository')
implementation libraries.paging implementation libraries.paging
implementation libraries.swipeRefreshLayout implementation libraries.swipeRefreshLayout

View File

@@ -1 +1 @@
<manifest package="com.melih.list" /> <manifest package="com.melih.launches" />

View File

@@ -1,8 +1,8 @@
package com.melih.list.di package com.melih.launches.di
import com.melih.list.di.modules.LaunchesFragmentModule import com.melih.launches.di.modules.LaunchesFragmentModule
import com.melih.list.di.scopes.LaunchesFragmentScope import com.melih.launches.di.scopes.LaunchesFragmentScope
import com.melih.list.ui.LaunchesFragment import com.melih.launches.ui.LaunchesFragment
import dagger.Module import dagger.Module
import dagger.android.ContributesAndroidInjector import dagger.android.ContributesAndroidInjector

View File

@@ -1,9 +1,9 @@
package com.melih.list.di.modules package com.melih.launches.di.modules
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.paging.Config import androidx.paging.Config
import com.melih.core.di.keys.ViewModelKey import com.melih.core.di.keys.ViewModelKey
import com.melih.list.ui.vm.LaunchesViewModel import com.melih.launches.ui.vm.LaunchesViewModel
import com.melih.repository.interactors.DEFAULT_LAUNCHES_AMOUNT import com.melih.repository.interactors.DEFAULT_LAUNCHES_AMOUNT
import com.melih.repository.interactors.GetLaunches import com.melih.repository.interactors.GetLaunches
import dagger.Binds import dagger.Binds

View File

@@ -1,4 +1,4 @@
package com.melih.list.di.scopes package com.melih.launches.di.scopes
import javax.inject.Scope import javax.inject.Scope

View File

@@ -1,4 +1,4 @@
package com.melih.list.di.scopes package com.melih.launches.di.scopes
import javax.inject.Scope import javax.inject.Scope

View File

@@ -1,4 +1,4 @@
package com.melih.list.ui package com.melih.launches.ui
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
@@ -7,10 +7,10 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.melih.core.actions.openDetail import com.melih.core.actions.openDetail
import com.melih.core.base.lifecycle.BaseDaggerFragment import com.melih.core.base.lifecycle.BaseDaggerFragment
import com.melih.core.extensions.observe import com.melih.core.extensions.observe
import com.melih.list.R import com.melih.launches.R
import com.melih.list.databinding.ListBinding import com.melih.launches.databinding.ListBinding
import com.melih.list.ui.adapters.LaunchesAdapter import com.melih.launches.ui.adapters.LaunchesAdapter
import com.melih.list.ui.vm.LaunchesViewModel import com.melih.launches.ui.vm.LaunchesViewModel
import com.melih.repository.entities.LaunchEntity import com.melih.repository.entities.LaunchEntity
import com.melih.repository.interactors.base.PersistenceEmpty import com.melih.repository.interactors.base.PersistenceEmpty
import com.melih.repository.interactors.base.State import com.melih.repository.interactors.base.State
@@ -49,6 +49,11 @@ class LaunchesFragment : BaseDaggerFragment<ListBinding>(), SwipeRefreshLayout.O
// Workaround for SwipeRefreshLayout leak -> https://issuetracker.google.com/issues/136153683 // Workaround for SwipeRefreshLayout leak -> https://issuetracker.google.com/issues/136153683
binding.swipeRefreshLayout.isEnabled = false binding.swipeRefreshLayout.isEnabled = false
} }
override fun onDestroyView() {
super.onDestroyView()
binding.rocketList.adapter = null
}
//endregion //endregion
//region Functions //region Functions

View File

@@ -1,11 +1,11 @@
package com.melih.list.ui.adapters package com.melih.launches.ui.adapters
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.ViewGroup import android.view.ViewGroup
import com.melih.core.base.recycler.BasePagingListAdapter import com.melih.core.base.recycler.BasePagingListAdapter
import com.melih.core.base.recycler.BaseViewHolder import com.melih.core.base.recycler.BaseViewHolder
import com.melih.core.extensions.createDiffCallback import com.melih.core.extensions.createDiffCallback
import com.melih.list.databinding.LaunchRowBinding import com.melih.launches.databinding.LaunchRowBinding
import com.melih.repository.entities.LaunchEntity import com.melih.repository.entities.LaunchEntity
class LaunchesAdapter(itemClickListener: (LaunchEntity) -> Unit) : BasePagingListAdapter<LaunchEntity>( class LaunchesAdapter(itemClickListener: (LaunchEntity) -> Unit) : BasePagingListAdapter<LaunchEntity>(

View File

@@ -1,4 +1,4 @@
package com.melih.list.ui.paging package com.melih.launches.ui.paging
import com.melih.core.base.paging.BasePagingDataSource import com.melih.core.base.paging.BasePagingDataSource
import com.melih.repository.entities.LaunchEntity import com.melih.repository.entities.LaunchEntity

View File

@@ -1,4 +1,4 @@
package com.melih.list.ui.paging package com.melih.launches.ui.paging
import com.melih.core.base.paging.BasePagingDataSource import com.melih.core.base.paging.BasePagingDataSource
import com.melih.core.base.paging.BasePagingFactory import com.melih.core.base.paging.BasePagingFactory

View File

@@ -1,9 +1,9 @@
package com.melih.list.ui.vm package com.melih.launches.ui.vm
import androidx.paging.PagedList import androidx.paging.PagedList
import com.melih.core.base.paging.BasePagingFactory import com.melih.core.base.paging.BasePagingFactory
import com.melih.core.base.viewmodel.BasePagingViewModel import com.melih.core.base.viewmodel.BasePagingViewModel
import com.melih.list.ui.paging.LaunchesPagingSourceFactory import com.melih.launches.ui.paging.LaunchesPagingSourceFactory
import com.melih.repository.entities.LaunchEntity import com.melih.repository.entities.LaunchEntity
import javax.inject.Inject import javax.inject.Inject

View File

@@ -8,7 +8,7 @@
<variable <variable
name="viewModel" name="viewModel"
type="com.melih.list.ui.vm.LaunchesViewModel" /> type="com.melih.launches.ui.vm.LaunchesViewModel" />
</data> </data>
<androidx.coordinatorlayout.widget.CoordinatorLayout <androidx.coordinatorlayout.widget.CoordinatorLayout

View File

@@ -1,14 +1,15 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<navigation <navigation
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/nav_launches" android:id="@+id/nav_launches"
app:startDestination="@id/launchesFragment"> app:startDestination="@id/launchesFragment"
tools:ignore="UnusedNavigation">
<fragment <fragment
android:id="@+id/launchesFragment" android:id="@+id/launchesFragment"
android:name="com.melih.list.ui.LaunchesFragment" android:name="com.melih.launches.ui.LaunchesFragment"
android:label="LaunchesFragment" android:label="LaunchesFragment"
tools:layout="@layout/fragment_launches" /> tools:layout="@layout/fragment_launches" />
</navigation> </navigation>

View File

@@ -1,6 +1,6 @@
@file:UseExperimental(ExperimentalCoroutinesApi::class) @file:UseExperimental(ExperimentalCoroutinesApi::class)
package com.melih.list package com.melih.launches
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -10,6 +10,7 @@ import kotlinx.coroutines.test.setMain
import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
@UseExperimental(ExperimentalCoroutinesApi::class)
abstract class BaseTestWithMainThread { abstract class BaseTestWithMainThread {
protected val dispatcher = TestCoroutineDispatcher() protected val dispatcher = TestCoroutineDispatcher()