From 600d5e738c5b7b40aae2a4afd3842252b392d76b Mon Sep 17 00:00:00 2001 From: madroid Date: Tue, 31 May 2022 23:28:25 +0800 Subject: [PATCH] Rename NiaPreferencesLocalDataSource to NiaPreferencesDataSource read more #71 --- .../core/data/repository/OfflineFirstAuthorsRepository.kt | 4 ++-- .../core/data/repository/OfflineFirstTopicsRepository.kt | 4 ++-- .../core/data/repository/fake/FakeAuthorsRepository.kt | 4 ++-- .../core/data/repository/fake/FakeTopicsRepository.kt | 4 ++-- .../data/repository/OfflineFirstAuthorsRepositoryTest.kt | 4 ++-- .../core/data/repository/OfflineFirstNewsRepositoryTest.kt | 4 ++-- .../data/repository/OfflineFirstTopicsRepositoryTest.kt | 6 +++--- .../nowinandroid/core/data/repository/TestSynchronizer.kt | 6 +++--- ...rencesLocalDataSource.kt => NiaPreferencesDataSource.kt} | 2 +- .../samples/apps/nowinandroid/sync/workers/SyncWorker.kt | 4 ++-- 10 files changed, 21 insertions(+), 21 deletions(-) rename core-datastore/src/main/java/com/google/samples/apps/nowinandroid/core/datastore/{NiaPreferencesLocalDataSource.kt => NiaPreferencesDataSource.kt} (98%) diff --git a/core-data/src/main/java/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstAuthorsRepository.kt b/core-data/src/main/java/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstAuthorsRepository.kt index 6fd6b69bf..5344810f3 100644 --- a/core-data/src/main/java/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstAuthorsRepository.kt +++ b/core-data/src/main/java/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstAuthorsRepository.kt @@ -23,7 +23,7 @@ import com.google.samples.apps.nowinandroid.core.database.dao.AuthorDao import com.google.samples.apps.nowinandroid.core.database.model.AuthorEntity import com.google.samples.apps.nowinandroid.core.database.model.asExternalModel import com.google.samples.apps.nowinandroid.core.datastore.ChangeListVersions -import com.google.samples.apps.nowinandroid.core.datastore.NiaPreferencesLocalDataSource +import com.google.samples.apps.nowinandroid.core.datastore.NiaPreferencesDataSource import com.google.samples.apps.nowinandroid.core.model.data.Author import com.google.samples.apps.nowinandroid.core.network.NiaNetworkDataSource import com.google.samples.apps.nowinandroid.core.network.model.NetworkAuthor @@ -38,7 +38,7 @@ import kotlinx.coroutines.flow.map class OfflineFirstAuthorsRepository @Inject constructor( private val authorDao: AuthorDao, private val network: NiaNetworkDataSource, - private val niaPreferences: NiaPreferencesLocalDataSource, + private val niaPreferences: NiaPreferencesDataSource, ) : AuthorsRepository { override fun getAuthorStream(id: String): Flow = diff --git a/core-data/src/main/java/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstTopicsRepository.kt b/core-data/src/main/java/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstTopicsRepository.kt index 157632b31..4e2c64c9d 100644 --- a/core-data/src/main/java/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstTopicsRepository.kt +++ b/core-data/src/main/java/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstTopicsRepository.kt @@ -23,7 +23,7 @@ import com.google.samples.apps.nowinandroid.core.database.dao.TopicDao import com.google.samples.apps.nowinandroid.core.database.model.TopicEntity import com.google.samples.apps.nowinandroid.core.database.model.asExternalModel import com.google.samples.apps.nowinandroid.core.datastore.ChangeListVersions -import com.google.samples.apps.nowinandroid.core.datastore.NiaPreferencesLocalDataSource +import com.google.samples.apps.nowinandroid.core.datastore.NiaPreferencesDataSource import com.google.samples.apps.nowinandroid.core.model.data.Topic import com.google.samples.apps.nowinandroid.core.network.NiaNetworkDataSource import com.google.samples.apps.nowinandroid.core.network.model.NetworkTopic @@ -38,7 +38,7 @@ import kotlinx.coroutines.flow.map class OfflineFirstTopicsRepository @Inject constructor( private val topicDao: TopicDao, private val network: NiaNetworkDataSource, - private val niaPreferences: NiaPreferencesLocalDataSource, + private val niaPreferences: NiaPreferencesDataSource, ) : TopicsRepository { override fun getTopicsStream(): Flow> = diff --git a/core-data/src/main/java/com/google/samples/apps/nowinandroid/core/data/repository/fake/FakeAuthorsRepository.kt b/core-data/src/main/java/com/google/samples/apps/nowinandroid/core/data/repository/fake/FakeAuthorsRepository.kt index 6970a46d7..4a0ebf0ba 100644 --- a/core-data/src/main/java/com/google/samples/apps/nowinandroid/core/data/repository/fake/FakeAuthorsRepository.kt +++ b/core-data/src/main/java/com/google/samples/apps/nowinandroid/core/data/repository/fake/FakeAuthorsRepository.kt @@ -18,7 +18,7 @@ package com.google.samples.apps.nowinandroid.core.data.repository.fake import com.google.samples.apps.nowinandroid.core.data.Synchronizer import com.google.samples.apps.nowinandroid.core.data.repository.AuthorsRepository -import com.google.samples.apps.nowinandroid.core.datastore.NiaPreferencesLocalDataSource +import com.google.samples.apps.nowinandroid.core.datastore.NiaPreferencesDataSource import com.google.samples.apps.nowinandroid.core.model.data.Author import com.google.samples.apps.nowinandroid.core.network.Dispatcher import com.google.samples.apps.nowinandroid.core.network.NiaDispatchers.IO @@ -41,7 +41,7 @@ import kotlinx.serialization.json.Json */ class FakeAuthorsRepository @Inject constructor( @Dispatcher(IO) private val ioDispatcher: CoroutineDispatcher, - private val niaPreferences: NiaPreferencesLocalDataSource, + private val niaPreferences: NiaPreferencesDataSource, private val networkJson: Json, ) : AuthorsRepository { diff --git a/core-data/src/main/java/com/google/samples/apps/nowinandroid/core/data/repository/fake/FakeTopicsRepository.kt b/core-data/src/main/java/com/google/samples/apps/nowinandroid/core/data/repository/fake/FakeTopicsRepository.kt index d71dc022f..ec18600f0 100644 --- a/core-data/src/main/java/com/google/samples/apps/nowinandroid/core/data/repository/fake/FakeTopicsRepository.kt +++ b/core-data/src/main/java/com/google/samples/apps/nowinandroid/core/data/repository/fake/FakeTopicsRepository.kt @@ -18,7 +18,7 @@ package com.google.samples.apps.nowinandroid.core.data.repository.fake import com.google.samples.apps.nowinandroid.core.data.Synchronizer import com.google.samples.apps.nowinandroid.core.data.repository.TopicsRepository -import com.google.samples.apps.nowinandroid.core.datastore.NiaPreferencesLocalDataSource +import com.google.samples.apps.nowinandroid.core.datastore.NiaPreferencesDataSource import com.google.samples.apps.nowinandroid.core.model.data.Topic import com.google.samples.apps.nowinandroid.core.network.Dispatcher import com.google.samples.apps.nowinandroid.core.network.NiaDispatchers.IO @@ -43,7 +43,7 @@ import kotlinx.serialization.json.Json class FakeTopicsRepository @Inject constructor( @Dispatcher(IO) private val ioDispatcher: CoroutineDispatcher, private val networkJson: Json, - private val niaPreferences: NiaPreferencesLocalDataSource + private val niaPreferences: NiaPreferencesDataSource ) : TopicsRepository { override fun getTopicsStream(): Flow> = flow> { emit( diff --git a/core-data/src/test/java/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstAuthorsRepositoryTest.kt b/core-data/src/test/java/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstAuthorsRepositoryTest.kt index 2f5f7f348..1d7bc0407 100644 --- a/core-data/src/test/java/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstAuthorsRepositoryTest.kt +++ b/core-data/src/test/java/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstAuthorsRepositoryTest.kt @@ -24,7 +24,7 @@ import com.google.samples.apps.nowinandroid.core.data.testdoubles.TestNiaNetwork import com.google.samples.apps.nowinandroid.core.database.dao.AuthorDao import com.google.samples.apps.nowinandroid.core.database.model.AuthorEntity import com.google.samples.apps.nowinandroid.core.database.model.asExternalModel -import com.google.samples.apps.nowinandroid.core.datastore.NiaPreferencesLocalDataSource +import com.google.samples.apps.nowinandroid.core.datastore.NiaPreferencesDataSource import com.google.samples.apps.nowinandroid.core.datastore.test.testUserPreferencesDataStore import com.google.samples.apps.nowinandroid.core.model.data.Author import com.google.samples.apps.nowinandroid.core.network.model.NetworkAuthor @@ -54,7 +54,7 @@ class OfflineFirstAuthorsRepositoryTest { fun setup() { authorDao = TestAuthorDao() network = TestNiaNetworkDataSource() - val niaPreferencesDataSource = NiaPreferencesLocalDataSource( + val niaPreferencesDataSource = NiaPreferencesDataSource( tmpFolder.testUserPreferencesDataStore() ) synchronizer = TestSynchronizer(niaPreferencesDataSource) diff --git a/core-data/src/test/java/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstNewsRepositoryTest.kt b/core-data/src/test/java/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstNewsRepositoryTest.kt index e26e57939..7f4db0d90 100644 --- a/core-data/src/test/java/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstNewsRepositoryTest.kt +++ b/core-data/src/test/java/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstNewsRepositoryTest.kt @@ -38,7 +38,7 @@ import com.google.samples.apps.nowinandroid.core.database.model.PopulatedEpisode import com.google.samples.apps.nowinandroid.core.database.model.PopulatedNewsResource import com.google.samples.apps.nowinandroid.core.database.model.TopicEntity import com.google.samples.apps.nowinandroid.core.database.model.asExternalModel -import com.google.samples.apps.nowinandroid.core.datastore.NiaPreferencesLocalDataSource +import com.google.samples.apps.nowinandroid.core.datastore.NiaPreferencesDataSource import com.google.samples.apps.nowinandroid.core.datastore.test.testUserPreferencesDataStore import com.google.samples.apps.nowinandroid.core.model.data.NewsResource import com.google.samples.apps.nowinandroid.core.network.model.NetworkChangeList @@ -78,7 +78,7 @@ class OfflineFirstNewsRepositoryTest { topicDao = TestTopicDao() network = TestNiaNetworkDataSource() synchronizer = TestSynchronizer( - NiaPreferencesLocalDataSource( + NiaPreferencesDataSource( tmpFolder.testUserPreferencesDataStore() ) ) diff --git a/core-data/src/test/java/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstTopicsRepositoryTest.kt b/core-data/src/test/java/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstTopicsRepositoryTest.kt index f17769491..9481af62f 100644 --- a/core-data/src/test/java/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstTopicsRepositoryTest.kt +++ b/core-data/src/test/java/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstTopicsRepositoryTest.kt @@ -24,7 +24,7 @@ import com.google.samples.apps.nowinandroid.core.data.testdoubles.TestTopicDao import com.google.samples.apps.nowinandroid.core.database.dao.TopicDao import com.google.samples.apps.nowinandroid.core.database.model.TopicEntity import com.google.samples.apps.nowinandroid.core.database.model.asExternalModel -import com.google.samples.apps.nowinandroid.core.datastore.NiaPreferencesLocalDataSource +import com.google.samples.apps.nowinandroid.core.datastore.NiaPreferencesDataSource import com.google.samples.apps.nowinandroid.core.datastore.test.testUserPreferencesDataStore import com.google.samples.apps.nowinandroid.core.model.data.Topic import com.google.samples.apps.nowinandroid.core.network.model.NetworkTopic @@ -44,7 +44,7 @@ class OfflineFirstTopicsRepositoryTest { private lateinit var network: TestNiaNetworkDataSource - private lateinit var niaPreferences: NiaPreferencesLocalDataSource + private lateinit var niaPreferences: NiaPreferencesDataSource private lateinit var synchronizer: Synchronizer @@ -55,7 +55,7 @@ class OfflineFirstTopicsRepositoryTest { fun setup() { topicDao = TestTopicDao() network = TestNiaNetworkDataSource() - niaPreferences = NiaPreferencesLocalDataSource( + niaPreferences = NiaPreferencesDataSource( tmpFolder.testUserPreferencesDataStore() ) synchronizer = TestSynchronizer(niaPreferences) diff --git a/core-data/src/test/java/com/google/samples/apps/nowinandroid/core/data/repository/TestSynchronizer.kt b/core-data/src/test/java/com/google/samples/apps/nowinandroid/core/data/repository/TestSynchronizer.kt index 6b210bb5b..e50a3776b 100644 --- a/core-data/src/test/java/com/google/samples/apps/nowinandroid/core/data/repository/TestSynchronizer.kt +++ b/core-data/src/test/java/com/google/samples/apps/nowinandroid/core/data/repository/TestSynchronizer.kt @@ -18,13 +18,13 @@ package com.google.samples.apps.nowinandroid.core.data.repository import com.google.samples.apps.nowinandroid.core.data.Synchronizer import com.google.samples.apps.nowinandroid.core.datastore.ChangeListVersions -import com.google.samples.apps.nowinandroid.core.datastore.NiaPreferencesLocalDataSource +import com.google.samples.apps.nowinandroid.core.datastore.NiaPreferencesDataSource /** - * Test synchronizer that delegates to [NiaPreferencesLocalDataSource] + * Test synchronizer that delegates to [NiaPreferencesDataSource] */ class TestSynchronizer( - private val niaPreferences: NiaPreferencesLocalDataSource + private val niaPreferences: NiaPreferencesDataSource ) : Synchronizer { override suspend fun getChangeListVersions(): ChangeListVersions = niaPreferences.getChangeListVersions() diff --git a/core-datastore/src/main/java/com/google/samples/apps/nowinandroid/core/datastore/NiaPreferencesLocalDataSource.kt b/core-datastore/src/main/java/com/google/samples/apps/nowinandroid/core/datastore/NiaPreferencesDataSource.kt similarity index 98% rename from core-datastore/src/main/java/com/google/samples/apps/nowinandroid/core/datastore/NiaPreferencesLocalDataSource.kt rename to core-datastore/src/main/java/com/google/samples/apps/nowinandroid/core/datastore/NiaPreferencesDataSource.kt index 23e107188..938e85af6 100644 --- a/core-datastore/src/main/java/com/google/samples/apps/nowinandroid/core/datastore/NiaPreferencesLocalDataSource.kt +++ b/core-datastore/src/main/java/com/google/samples/apps/nowinandroid/core/datastore/NiaPreferencesDataSource.kt @@ -25,7 +25,7 @@ import kotlinx.coroutines.flow.firstOrNull import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.retry -class NiaPreferencesLocalDataSource @Inject constructor( +class NiaPreferencesDataSource @Inject constructor( private val userPreferences: DataStore ) { suspend fun setFollowedTopicIds(followedTopicIds: Set) { diff --git a/sync/src/main/java/com/google/samples/apps/nowinandroid/sync/workers/SyncWorker.kt b/sync/src/main/java/com/google/samples/apps/nowinandroid/sync/workers/SyncWorker.kt index 43a48ab1a..5b99e603b 100644 --- a/sync/src/main/java/com/google/samples/apps/nowinandroid/sync/workers/SyncWorker.kt +++ b/sync/src/main/java/com/google/samples/apps/nowinandroid/sync/workers/SyncWorker.kt @@ -28,7 +28,7 @@ import com.google.samples.apps.nowinandroid.core.data.repository.AuthorsReposito import com.google.samples.apps.nowinandroid.core.data.repository.NewsRepository import com.google.samples.apps.nowinandroid.core.data.repository.TopicsRepository import com.google.samples.apps.nowinandroid.core.datastore.ChangeListVersions -import com.google.samples.apps.nowinandroid.core.datastore.NiaPreferencesLocalDataSource +import com.google.samples.apps.nowinandroid.core.datastore.NiaPreferencesDataSource import com.google.samples.apps.nowinandroid.core.network.Dispatcher import com.google.samples.apps.nowinandroid.core.network.NiaDispatchers.IO import com.google.samples.apps.nowinandroid.sync.initializers.SyncConstraints @@ -48,7 +48,7 @@ import kotlinx.coroutines.withContext class SyncWorker @AssistedInject constructor( @Assisted private val appContext: Context, @Assisted workerParams: WorkerParameters, - private val niaPreferences: NiaPreferencesLocalDataSource, + private val niaPreferences: NiaPreferencesDataSource, private val topicRepository: TopicsRepository, private val newsRepository: NewsRepository, private val authorsRepository: AuthorsRepository,