articles_list: move ArticlesListActivityComponent to SessionActivityComponent
authorDa Risk <da_risk@geekorum.com>
Sat, 13 Jun 2020 20:17:40 -0400
changeset 731 da6650120fef
parent 730 07121fa55527
child 732 8cd8b1a09cb5
articles_list: move ArticlesListActivityComponent to SessionActivityComponent
app/src/main/java/com/geekorum/ttrss/articles_list/ArticlesViewModel.kt
app/src/main/java/com/geekorum/ttrss/articles_list/FeedsViewModel.kt
app/src/main/java/com/geekorum/ttrss/articles_list/TagsViewModel.kt
app/src/main/java/com/geekorum/ttrss/articles_list/di.kt
app/src/main/java/com/geekorum/ttrss/articles_list/search/SearchViewModel.kt
app/src/main/java/com/geekorum/ttrss/di/FlavorLessModule.kt
app/src/main/java/com/geekorum/ttrss/session/di.kt
--- a/app/src/main/java/com/geekorum/ttrss/articles_list/ArticlesViewModel.kt	Sat Jun 13 19:40:48 2020 -0400
+++ b/app/src/main/java/com/geekorum/ttrss/articles_list/ArticlesViewModel.kt	Sat Jun 13 20:17:40 2020 -0400
@@ -41,6 +41,7 @@
 import com.geekorum.ttrss.data.Feed
 import com.geekorum.ttrss.providers.ArticlesContract
 import com.geekorum.ttrss.session.Action
+import com.geekorum.ttrss.session.SessionActivityComponent
 import com.geekorum.ttrss.session.UndoManager
 import kotlinx.coroutines.ExperimentalCoroutinesApi
 import kotlinx.coroutines.flow.combine
@@ -55,7 +56,7 @@
  */
 abstract class BaseArticlesViewModel(
     private val state: SavedStateHandle,
-    componentFactory: ArticleListActivityComponent.Factory
+    componentFactory: SessionActivityComponent.Factory
 ) : ViewModel() {
 
     protected val component = componentFactory.newComponent()
@@ -253,7 +254,7 @@
     @Assisted private val state: SavedStateHandle,
     private val feedsRepository: FeedsRepository,
     private val backgroundJobManager: BackgroundJobManager,
-    componentFactory: ArticleListActivityComponent.Factory
+    componentFactory: SessionActivityComponent.Factory
 ) : BaseArticlesViewModel(state, componentFactory) {
 
     val feedId = state.getLiveData(STATE_FEED_ID, Feed.FEED_ID_ALL_ARTICLES).apply {
@@ -326,7 +327,7 @@
 class ArticlesListByTagViewModel @ViewModelInject constructor(
     @Assisted private val state: SavedStateHandle,
     private val backgroundJobManager: BackgroundJobManager,
-    componentFactory: ArticleListActivityComponent.Factory
+    componentFactory: SessionActivityComponent.Factory
 ) : BaseArticlesViewModel(state, componentFactory) {
 
     val tag = state.getLiveData<String>(STATE_TAG).apply {
--- a/app/src/main/java/com/geekorum/ttrss/articles_list/FeedsViewModel.kt	Sat Jun 13 19:40:48 2020 -0400
+++ b/app/src/main/java/com/geekorum/ttrss/articles_list/FeedsViewModel.kt	Sat Jun 13 20:17:40 2020 -0400
@@ -30,6 +30,7 @@
 import com.geekorum.ttrss.data.Category
 import com.geekorum.ttrss.data.Feed
 import com.geekorum.ttrss.network.ApiService
+import com.geekorum.ttrss.session.SessionActivityComponent
 import com.geekorum.ttrss.webapi.ApiCallException
 import kotlinx.coroutines.ExperimentalCoroutinesApi
 import kotlinx.coroutines.async
@@ -52,7 +53,7 @@
     @Assisted private val state: SavedStateHandle,
     private val dispatchers: CoroutineDispatchersProvider,
     private val feedsRepository: FeedsRepository,
-    componentFactory: ArticleListActivityComponent.Factory
+    componentFactory: SessionActivityComponent.Factory
 ) : ViewModel() {
 
     private val component = componentFactory.newComponent()
--- a/app/src/main/java/com/geekorum/ttrss/articles_list/TagsViewModel.kt	Sat Jun 13 19:40:48 2020 -0400
+++ b/app/src/main/java/com/geekorum/ttrss/articles_list/TagsViewModel.kt	Sat Jun 13 20:17:40 2020 -0400
@@ -25,6 +25,7 @@
 import androidx.lifecycle.SavedStateHandle
 import androidx.lifecycle.ViewModel
 import androidx.lifecycle.asLiveData
+import com.geekorum.ttrss.session.SessionActivityComponent
 import kotlinx.coroutines.ExperimentalCoroutinesApi
 import kotlinx.coroutines.channels.ConflatedBroadcastChannel
 import kotlinx.coroutines.flow.asFlow
@@ -38,7 +39,7 @@
 @OptIn(ExperimentalCoroutinesApi::class)
 class TagsViewModel @ViewModelInject constructor(
     @Assisted private val state: SavedStateHandle,
-    componentFactory: ArticleListActivityComponent.Factory
+    componentFactory: SessionActivityComponent.Factory
 ) : ViewModel() {
 
     private val articlesRepository: ArticlesRepository = componentFactory.newComponent().articleRepository
--- a/app/src/main/java/com/geekorum/ttrss/articles_list/di.kt	Sat Jun 13 19:40:48 2020 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/*
- * Geekttrss is a RSS feed reader application on the Android Platform.
- *
- * Copyright (C) 2017-2020 by Frederic-Charles Barthelery.
- *
- * This file is part of Geekttrss.
- *
- * Geekttrss is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Geekttrss is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Geekttrss.  If not, see <http://www.gnu.org/licenses/>.
- */
-@file:JvmName("Di")
-
-package com.geekorum.ttrss.articles_list
-
-import android.accounts.Account
-import android.app.Activity
-import com.geekorum.ttrss.accounts.NetworkLoginModule
-import com.geekorum.ttrss.accounts.PerAccount
-import com.geekorum.ttrss.di.AssistedFactoriesModule
-import com.geekorum.ttrss.network.ApiService
-import com.geekorum.ttrss.network.TinyrssApiModule
-import com.geekorum.ttrss.session.SessionActivity
-import dagger.Module
-import dagger.Provides
-import dagger.Subcomponent
-import dagger.hilt.InstallIn
-import dagger.hilt.android.components.ActivityComponent
-import dagger.hilt.migration.DisableInstallInCheck
-
-
-/**
- * Dependency injection pieces for the article_list functionality.
- *
- * ArticleListActivity has a SubComponent of the ActivityComponent.
- * This component is bount to the lifecycle of the activity
- *
- * ArticleListActivity's component provides the Account selected
- */
-
-@Module(subcomponents = [ArticleListActivityComponent::class])
-@InstallIn(ActivityComponent::class)
-class ArticleListActivityModule
-
-
-@Subcomponent(modules = [
-    AssistedFactoriesModule::class,
-    TinyrssApiModule::class,
-    NetworkLoginModule::class,
-    AccountModule::class
-])
-@PerAccount
-interface ArticleListActivityComponent {
-
-    val account: Account
-    val apiService: ApiService
-    val articleRepository: ArticlesRepository
-
-    @Subcomponent.Factory
-    interface Factory {
-        fun newComponent(): ArticleListActivityComponent
-    }
-}
-
-@Module
-@DisableInstallInCheck
-internal class AccountModule {
-    @Provides
-    fun providesAccount(activity: Activity) : Account {
-        return (activity as SessionActivity).account!!
-    }
-}
-
--- a/app/src/main/java/com/geekorum/ttrss/articles_list/search/SearchViewModel.kt	Sat Jun 13 19:40:48 2020 -0400
+++ b/app/src/main/java/com/geekorum/ttrss/articles_list/search/SearchViewModel.kt	Sat Jun 13 20:17:40 2020 -0400
@@ -28,13 +28,12 @@
 import androidx.lifecycle.ViewModel
 import androidx.paging.LivePagedListBuilder
 import androidx.paging.PagedList
-import com.geekorum.ttrss.articles_list.ArticleListActivityComponent
+import com.geekorum.ttrss.session.SessionActivityComponent
 import com.geekorum.ttrss.articles_list.ArticlesRepository
 import com.geekorum.ttrss.data.Article
-import javax.inject.Inject
 
 class SearchViewModel @ViewModelInject constructor(
-    componentFactory: ArticleListActivityComponent.Factory
+    componentFactory: SessionActivityComponent.Factory
 ) : ViewModel() {
 
     private val articlesRepository: ArticlesRepository = componentFactory.newComponent().articleRepository
--- a/app/src/main/java/com/geekorum/ttrss/di/FlavorLessModule.kt	Sat Jun 13 19:40:48 2020 -0400
+++ b/app/src/main/java/com/geekorum/ttrss/di/FlavorLessModule.kt	Sat Jun 13 20:17:40 2020 -0400
@@ -35,8 +35,6 @@
 //    AndroidBindingsModule::class,
     com.geekorum.geekdroid.dagger.ViewModelsModule::class,
 //    ViewModelsModule::class,
-    com.geekorum.ttrss.article_details.ActivitiesInjectorModule::class,
-//    com.geekorum.ttrss.articles_list.ActivitiesInjectorModule::class,
     com.geekorum.ttrss.accounts.ServicesInjectorModule::class,
     com.geekorum.ttrss.add_feed.AndroidInjectorsModule::class,
     com.geekorum.ttrss.providers.AndroidInjectorsModule::class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/java/com/geekorum/ttrss/session/di.kt	Sat Jun 13 20:17:40 2020 -0400
@@ -0,0 +1,81 @@
+/*
+ * Geekttrss is a RSS feed reader application on the Android Platform.
+ *
+ * Copyright (C) 2017-2020 by Frederic-Charles Barthelery.
+ *
+ * This file is part of Geekttrss.
+ *
+ * Geekttrss is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Geekttrss is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Geekttrss.  If not, see <http://www.gnu.org/licenses/>.
+ */
+@file:JvmName("Di")
+
+package com.geekorum.ttrss.session
+
+import android.accounts.Account
+import android.app.Activity
+import com.geekorum.ttrss.accounts.NetworkLoginModule
+import com.geekorum.ttrss.accounts.PerAccount
+import com.geekorum.ttrss.articles_list.ArticlesRepository
+import com.geekorum.ttrss.di.AssistedFactoriesModule
+import com.geekorum.ttrss.network.ApiService
+import com.geekorum.ttrss.network.TinyrssApiModule
+import dagger.Module
+import dagger.Provides
+import dagger.Subcomponent
+import dagger.hilt.InstallIn
+import dagger.hilt.android.components.ActivityComponent
+import dagger.hilt.migration.DisableInstallInCheck
+
+/**
+ * Dependency injection pieces for a SessionActivity
+ *
+ * SessionActivity has a SubComponent of the ActivityComponent.
+ * This component is bound to the lifecycle of the activity
+ *
+ * SessionActivity's  provides the selected Account to the component
+ */
+
+@Module(subcomponents = [SessionActivityComponent::class])
+@InstallIn(ActivityComponent::class)
+class SessionActivityModule
+
+
+@Subcomponent(modules = [
+    AssistedFactoriesModule::class,
+    TinyrssApiModule::class,
+    NetworkLoginModule::class,
+    AccountModule::class
+])
+@PerAccount
+interface SessionActivityComponent {
+
+    val account: Account
+    val apiService: ApiService
+    val articleRepository: ArticlesRepository
+
+    @Subcomponent.Factory
+    interface Factory {
+        fun newComponent(): SessionActivityComponent
+    }
+}
+
+@Module
+@DisableInstallInCheck
+internal class AccountModule {
+    @Provides
+    fun providesAccount(activity: Activity) : Account {
+        return (activity as SessionActivity).account!!
+    }
+}
+