mirror of
https://github.com/melihaksoy/Android-Kotlin-Modulerized-CleanArchitecture.git
synced 2026-01-14 21:23:45 +01:00
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:
@@ -32,6 +32,7 @@ dependencies {
|
||||
androidTestImplementation testLibraries.espresso
|
||||
|
||||
// These libraries required by dagger to create dependency graph, but not by app
|
||||
compileOnly project(':repository')
|
||||
compileOnly libraries.retrofit
|
||||
compileOnly libraries.room
|
||||
compileOnly libraries.paging
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.melih.rocketscience.di
|
||||
|
||||
import com.melih.detail.di.DetailContributor
|
||||
import com.melih.list.di.LaunchesContributor
|
||||
import com.melih.launches.di.LaunchesContributor
|
||||
import com.melih.rocketscience.MainActivity
|
||||
import dagger.Module
|
||||
import dagger.android.ContributesAndroidInjector
|
||||
|
||||
@@ -14,7 +14,7 @@ android {
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
api project(":repository")
|
||||
implementation project(':repository')
|
||||
|
||||
implementation libraries.fragment
|
||||
implementation libraries.paging
|
||||
@@ -28,6 +28,4 @@ dependencies {
|
||||
testImplementation testLibraries.mockk
|
||||
testImplementation testLibraries.kluent
|
||||
testImplementation testLibraries.coroutinesTest
|
||||
|
||||
compileOnly libraries.room
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 50 KiB |
@@ -14,5 +14,7 @@ android {
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
implementation project(':repository')
|
||||
|
||||
testImplementation testLibraries.coroutinesTest
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.melih.detail.di
|
||||
|
||||
import com.melih.detail.di.modules.DetailFragmentModule
|
||||
import com.melih.detail.di.scopes.DetailFragmentScope
|
||||
import com.melih.detail.ui.DetailFragment
|
||||
import com.melih.list.di.scopes.DetailFragmentScope
|
||||
import dagger.Module
|
||||
import dagger.android.ContributesAndroidInjector
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.melih.list.di.scopes
|
||||
package com.melih.detail.di.scopes
|
||||
|
||||
import javax.inject.Scope
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.melih.list.di.scopes
|
||||
package com.melih.detail.di.scopes
|
||||
|
||||
import javax.inject.Scope
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ apply from: "$rootProject.projectDir/scripts/feature_module.gradle"
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
implementation project(':repository')
|
||||
|
||||
implementation libraries.paging
|
||||
implementation libraries.swipeRefreshLayout
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
<manifest package="com.melih.list" />
|
||||
<manifest package="com.melih.launches" />
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.melih.list.di
|
||||
package com.melih.launches.di
|
||||
|
||||
import com.melih.list.di.modules.LaunchesFragmentModule
|
||||
import com.melih.list.di.scopes.LaunchesFragmentScope
|
||||
import com.melih.list.ui.LaunchesFragment
|
||||
import com.melih.launches.di.modules.LaunchesFragmentModule
|
||||
import com.melih.launches.di.scopes.LaunchesFragmentScope
|
||||
import com.melih.launches.ui.LaunchesFragment
|
||||
import dagger.Module
|
||||
import dagger.android.ContributesAndroidInjector
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.melih.list.di.modules
|
||||
package com.melih.launches.di.modules
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.paging.Config
|
||||
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.GetLaunches
|
||||
import dagger.Binds
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.melih.list.di.scopes
|
||||
package com.melih.launches.di.scopes
|
||||
|
||||
import javax.inject.Scope
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.melih.list.di.scopes
|
||||
package com.melih.launches.di.scopes
|
||||
|
||||
import javax.inject.Scope
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.melih.list.ui
|
||||
package com.melih.launches.ui
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
@@ -7,10 +7,10 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
import com.melih.core.actions.openDetail
|
||||
import com.melih.core.base.lifecycle.BaseDaggerFragment
|
||||
import com.melih.core.extensions.observe
|
||||
import com.melih.list.R
|
||||
import com.melih.list.databinding.ListBinding
|
||||
import com.melih.list.ui.adapters.LaunchesAdapter
|
||||
import com.melih.list.ui.vm.LaunchesViewModel
|
||||
import com.melih.launches.R
|
||||
import com.melih.launches.databinding.ListBinding
|
||||
import com.melih.launches.ui.adapters.LaunchesAdapter
|
||||
import com.melih.launches.ui.vm.LaunchesViewModel
|
||||
import com.melih.repository.entities.LaunchEntity
|
||||
import com.melih.repository.interactors.base.PersistenceEmpty
|
||||
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
|
||||
binding.swipeRefreshLayout.isEnabled = false
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
binding.rocketList.adapter = null
|
||||
}
|
||||
//endregion
|
||||
|
||||
//region Functions
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.melih.list.ui.adapters
|
||||
package com.melih.launches.ui.adapters
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import com.melih.core.base.recycler.BasePagingListAdapter
|
||||
import com.melih.core.base.recycler.BaseViewHolder
|
||||
import com.melih.core.extensions.createDiffCallback
|
||||
import com.melih.list.databinding.LaunchRowBinding
|
||||
import com.melih.launches.databinding.LaunchRowBinding
|
||||
import com.melih.repository.entities.LaunchEntity
|
||||
|
||||
class LaunchesAdapter(itemClickListener: (LaunchEntity) -> Unit) : BasePagingListAdapter<LaunchEntity>(
|
||||
@@ -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.repository.entities.LaunchEntity
|
||||
@@ -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.BasePagingFactory
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.melih.list.ui.vm
|
||||
package com.melih.launches.ui.vm
|
||||
|
||||
import androidx.paging.PagedList
|
||||
import com.melih.core.base.paging.BasePagingFactory
|
||||
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 javax.inject.Inject
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="com.melih.list.ui.vm.LaunchesViewModel" />
|
||||
type="com.melih.launches.ui.vm.LaunchesViewModel" />
|
||||
</data>
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<navigation
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/nav_launches"
|
||||
app:startDestination="@id/launchesFragment">
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/nav_launches"
|
||||
app:startDestination="@id/launchesFragment"
|
||||
tools:ignore="UnusedNavigation">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/launchesFragment"
|
||||
android:name="com.melih.list.ui.LaunchesFragment"
|
||||
android:label="LaunchesFragment"
|
||||
tools:layout="@layout/fragment_launches" />
|
||||
</navigation>
|
||||
<fragment
|
||||
android:id="@+id/launchesFragment"
|
||||
android:name="com.melih.launches.ui.LaunchesFragment"
|
||||
android:label="LaunchesFragment"
|
||||
tools:layout="@layout/fragment_launches" />
|
||||
</navigation>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
@file:UseExperimental(ExperimentalCoroutinesApi::class)
|
||||
|
||||
package com.melih.list
|
||||
package com.melih.launches
|
||||
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
@@ -10,6 +10,7 @@ import kotlinx.coroutines.test.setMain
|
||||
import org.junit.jupiter.api.AfterEach
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
|
||||
@UseExperimental(ExperimentalCoroutinesApi::class)
|
||||
abstract class BaseTestWithMainThread {
|
||||
|
||||
protected val dispatcher = TestCoroutineDispatcher()
|
||||
Reference in New Issue
Block a user