From c1bfa9e23863ba07ff1fcc737d66a01e1fb5134c Mon Sep 17 00:00:00 2001 From: beomjo Date: Sun, 18 Apr 2021 23:39:40 +0900 Subject: [PATCH 01/31] feat: Setting Scabboard --- app/build.gradle | 6 ++++++ build.gradle | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/app/build.gradle b/app/build.gradle index ed6ba0b..97a03d0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,6 +5,7 @@ plugins { id 'com.google.gms.google-services' id 'kotlin-parcelize' id 'com.google.firebase.crashlytics' + id 'scabbard.gradle' } android { @@ -46,6 +47,11 @@ android { buildFeatures { dataBinding true } + scabbard { + enabled true + failOnError true + fullBindingGraphValidation true + } } dependencies { diff --git a/build.gradle b/build.gradle index 036e6a4..15dfeeb 100644 --- a/build.gradle +++ b/build.gradle @@ -3,12 +3,16 @@ buildscript { repositories { google() jcenter() + maven { + url "https://plugins.gradle.org/m2/" + } } dependencies { classpath "com.android.tools.build:gradle:${versions.gradle}" classpath deps.classpath.kotlin classpath 'com.google.gms:google-services:4.3.5' classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.2' + classpath "gradle.plugin.dev.arunkumar:scabbard-gradle-plugin:0.4.0" } } From 5dfd1748242858699acf24f2e923adc976158d5c Mon Sep 17 00:00:00 2001 From: beomjo Date: Wed, 9 Jun 2021 01:23:36 +0900 Subject: [PATCH 02/31] build: Update Submodule --- android-compilation | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android-compilation b/android-compilation index 918aee4..f46cd4c 160000 --- a/android-compilation +++ b/android-compilation @@ -1 +1 @@ -Subproject commit 918aee4fecba4290525ee216441d59c800c755f6 +Subproject commit f46cd4ca1501c37edd47a92aa58c9f5548b859a1 From b60a4cfbb0d6bb0919aac5d65ccda84d432f32c9 Mon Sep 17 00:00:00 2001 From: beomjo Date: Wed, 9 Jun 2021 02:11:21 +0900 Subject: [PATCH 03/31] =?UTF-8?q?chore:=20git=20ignore=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + .idea/compiler.xml | 2 +- .idea/misc.xml | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index e050e2f..e9fadbe 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ local.properties .idea/gradle.xml .idea/vcs.xml +.idea diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 61a9130..fb7f4a8 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index d5d35ec..860da66 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + From cf437545f60b0ba4cb65d7a064c9b2d5453a4e8a Mon Sep 17 00:00:00 2001 From: beomjo Date: Wed, 9 Jun 2021 02:14:33 +0900 Subject: [PATCH 04/31] =?UTF-8?q?build:=20gradle=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 97a03d0..62f0ee1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -71,11 +71,11 @@ dependencies { implementation "com.github.skydoves:bindables:1.0.5" implementation 'com.facebook.shimmer:shimmer:0.5.0' - implementation 'androidx.media:media:1.2.1' + implementation 'androidx.media:media:1.3.1' testImplementation deps.test.arch.core testImplementation deps.test.androidx_test_core testImplementation deps.test.coroutine_test testImplementation deps.test.mockk - testImplementation "org.jetbrains.kotlin:kotlin-reflect:1.4.31" + testImplementation "org.jetbrains.kotlin:kotlin-reflect:1.5.10" } \ No newline at end of file From f2568a5f15d1b553999444968bd0cc4166dbbf5a Mon Sep 17 00:00:00 2001 From: beomjo Date: Wed, 9 Jun 2021 02:16:16 +0900 Subject: [PATCH 05/31] =?UTF-8?q?build:=20Dagger=20Hilt=EB=A1=9C=20depende?= =?UTF-8?q?ncy=20=EB=B3=80=EA=B2=BD=20-=20#6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 62f0ee1..eab8c4e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -65,8 +65,8 @@ dependencies { implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.4.3' implementation 'com.google.firebase:firebase-crashlytics' - implementation deps.dagger2.android - kapt deps.dagger2.compiler + implementation deps.hilt.android + kapt deps.hilt.compiler implementation "com.github.skydoves:bindables:1.0.5" implementation 'com.facebook.shimmer:shimmer:0.5.0' From 4e64c83d077adf47d3cc0b549c8b34c0e0304588 Mon Sep 17 00:00:00 2001 From: beomjo Date: Wed, 9 Jun 2021 02:33:45 +0900 Subject: [PATCH 06/31] feat: Add InstallIn Annotation to SingletoneComponent - #6 --- app/src/main/java/com/beomjo/whitenoise/di/FirebaseModule.kt | 3 +++ .../main/java/com/beomjo/whitenoise/di/MediaPlayerModule.kt | 3 +++ app/src/main/java/com/beomjo/whitenoise/di/RepositoryModule.kt | 3 +++ .../java/com/beomjo/whitenoise/di/ViewModelFactoryModule.kt | 3 +++ app/src/main/java/com/beomjo/whitenoise/di/ViewModelModule.kt | 3 +++ 5 files changed, 15 insertions(+) diff --git a/app/src/main/java/com/beomjo/whitenoise/di/FirebaseModule.kt b/app/src/main/java/com/beomjo/whitenoise/di/FirebaseModule.kt index a15e379..8030e7e 100644 --- a/app/src/main/java/com/beomjo/whitenoise/di/FirebaseModule.kt +++ b/app/src/main/java/com/beomjo/whitenoise/di/FirebaseModule.kt @@ -10,7 +10,10 @@ import com.google.firebase.firestore.FirebaseFirestore import com.google.firebase.storage.FirebaseStorage import dagger.Module import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +@InstallIn(SingletonComponent::class) @Module object FirebaseModule { diff --git a/app/src/main/java/com/beomjo/whitenoise/di/MediaPlayerModule.kt b/app/src/main/java/com/beomjo/whitenoise/di/MediaPlayerModule.kt index 9945244..68b6e03 100644 --- a/app/src/main/java/com/beomjo/whitenoise/di/MediaPlayerModule.kt +++ b/app/src/main/java/com/beomjo/whitenoise/di/MediaPlayerModule.kt @@ -7,7 +7,10 @@ import com.beomjo.whitenoise.ui.player.PlayerService import com.beomjo.whitenoise.ui.player.PlayerServiceConnection import dagger.Module import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +@InstallIn(SingletonComponent::class) @Module object MediaPlayerModule { diff --git a/app/src/main/java/com/beomjo/whitenoise/di/RepositoryModule.kt b/app/src/main/java/com/beomjo/whitenoise/di/RepositoryModule.kt index a65e302..290d87e 100644 --- a/app/src/main/java/com/beomjo/whitenoise/di/RepositoryModule.kt +++ b/app/src/main/java/com/beomjo/whitenoise/di/RepositoryModule.kt @@ -10,7 +10,10 @@ import com.beomjo.whitenoise.repositories.track.TrackListRepository import com.beomjo.whitenoise.repositories.track.TrackListRepositoryImpl import dagger.Binds import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +@InstallIn(SingletonComponent::class) @Module abstract class RepositoryModule { diff --git a/app/src/main/java/com/beomjo/whitenoise/di/ViewModelFactoryModule.kt b/app/src/main/java/com/beomjo/whitenoise/di/ViewModelFactoryModule.kt index b2fba56..aa6fa6e 100644 --- a/app/src/main/java/com/beomjo/whitenoise/di/ViewModelFactoryModule.kt +++ b/app/src/main/java/com/beomjo/whitenoise/di/ViewModelFactoryModule.kt @@ -4,7 +4,10 @@ import androidx.lifecycle.ViewModelProvider import com.beomjo.whitenoise.factory.ViewModelFactory import dagger.Binds import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +@InstallIn(SingletonComponent::class) @Module abstract class ViewModelFactoryModule { diff --git a/app/src/main/java/com/beomjo/whitenoise/di/ViewModelModule.kt b/app/src/main/java/com/beomjo/whitenoise/di/ViewModelModule.kt index 215a234..ddca6d9 100644 --- a/app/src/main/java/com/beomjo/whitenoise/di/ViewModelModule.kt +++ b/app/src/main/java/com/beomjo/whitenoise/di/ViewModelModule.kt @@ -9,8 +9,11 @@ import com.beomjo.whitenoise.ui.main.track.TrackListViewModel import com.beomjo.whitenoise.ui.splash.SplashViewModel import dagger.Binds import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent import dagger.multibindings.IntoMap +@InstallIn(SingletonComponent::class) @Module abstract class ViewModelModule { From 31f571b2baacbfb9cf549c9ab06fbe1bd9b6162a Mon Sep 17 00:00:00 2001 From: beomjo Date: Wed, 9 Jun 2021 02:39:25 +0900 Subject: [PATCH 07/31] feat: Add HiltAndroidApp annotation - #6 --- app/src/main/java/com/beomjo/whitenoise/WhiteNoiseApp.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/com/beomjo/whitenoise/WhiteNoiseApp.kt b/app/src/main/java/com/beomjo/whitenoise/WhiteNoiseApp.kt index af027eb..96d6d73 100644 --- a/app/src/main/java/com/beomjo/whitenoise/WhiteNoiseApp.kt +++ b/app/src/main/java/com/beomjo/whitenoise/WhiteNoiseApp.kt @@ -5,7 +5,9 @@ import com.beomjo.compilation.util.LogUtil import com.beomjo.whitenoise.common.WhiteNoseConfig import com.beomjo.whitenoise.di.AppComponent import com.beomjo.whitenoise.di.DaggerAppComponent +import dagger.hilt.android.HiltAndroidApp +@HiltAndroidApp open class WhiteNoiseApp : Application() { val appComponent: AppComponent by lazy { DaggerAppComponent.factory().create(applicationContext) From b0adac0c88698eda01a881d8e0a396ab8b6b2a9c Mon Sep 17 00:00:00 2001 From: beomjo Date: Wed, 9 Jun 2021 02:46:11 +0900 Subject: [PATCH 08/31] feat: Add AndroidEntryPoints annotation - #6 --- app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt | 2 ++ .../main/java/com/beomjo/whitenoise/ui/auth/LoginActivity.kt | 2 ++ .../com/beomjo/whitenoise/ui/common/ProgressDialogFragment.kt | 2 ++ app/src/main/java/com/beomjo/whitenoise/ui/main/MainActivity.kt | 2 ++ .../java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt | 2 ++ .../com/beomjo/whitenoise/ui/main/setting/SettingFragment.kt | 2 ++ .../com/beomjo/whitenoise/ui/main/track/TrackListFragment.kt | 2 ++ .../main/java/com/beomjo/whitenoise/ui/player/PlayerActivity.kt | 2 ++ .../main/java/com/beomjo/whitenoise/ui/splash/SplashActivity.kt | 2 ++ 9 files changed, 18 insertions(+) diff --git a/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt b/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt index 09a18e7..57aa03a 100644 --- a/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt @@ -11,9 +11,11 @@ import androidx.lifecycle.ViewModelProvider import com.beomjo.whitenoise.factory.ViewModelFactory import com.beomjo.whitenoise.ui.common.ProgressDialogFragment import com.skydoves.bindables.BindingActivity +import dagger.hilt.android.AndroidEntryPoint import javax.inject.Inject import kotlin.reflect.KClass +@AndroidEntryPoint abstract class BaseActivity( @LayoutRes contentLayoutId: Int, private vararg var viewModels: KClass, diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginActivity.kt b/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginActivity.kt index 2798381..9e5e227 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginActivity.kt @@ -10,8 +10,10 @@ import com.beomjo.whitenoise.base.BaseActivity import com.beomjo.whitenoise.databinding.ActivityLoginBinding import com.beomjo.whitenoise.ui.main.MainActivity import com.beomjo.whitenoise.utilities.ext.getComponent +import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.FlowPreview +@AndroidEntryPoint class LoginActivity : BaseActivity( R.layout.activity_login, LoginViewModel::class diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/common/ProgressDialogFragment.kt b/app/src/main/java/com/beomjo/whitenoise/ui/common/ProgressDialogFragment.kt index c2a8036..7f92c58 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/common/ProgressDialogFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/common/ProgressDialogFragment.kt @@ -8,7 +8,9 @@ import com.beomjo.whitenoise.R import com.beomjo.whitenoise.base.BaseDialogFragment import com.beomjo.whitenoise.databinding.FragmentProgressDialogBinding import com.beomjo.whitenoise.utilities.ext.getComponent +import dagger.hilt.android.AndroidEntryPoint +@AndroidEntryPoint class ProgressDialogFragment : BaseDialogFragment( R.layout.fragment_progress_dialog, ProgressDialogViewModel::class diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/main/MainActivity.kt b/app/src/main/java/com/beomjo/whitenoise/ui/main/MainActivity.kt index 2061ef0..ba1f62f 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/main/MainActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/main/MainActivity.kt @@ -8,8 +8,10 @@ import com.beomjo.whitenoise.ui.player.PlayerActivity import com.beomjo.whitenoise.ui.player.PlayerManager import com.beomjo.whitenoise.utilities.ext.applyExitMaterialTransform import com.beomjo.whitenoise.utilities.ext.getComponent +import dagger.hilt.android.AndroidEntryPoint import javax.inject.Inject +@AndroidEntryPoint class MainActivity : BaseActivity( R.layout.activity_main, MainViewModel::class diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt b/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt index 9b97473..3d47b41 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt @@ -16,7 +16,9 @@ import com.beomjo.whitenoise.ui.adapters.HomeAdapter import com.beomjo.whitenoise.ui.main.setting.SettingFragment import com.beomjo.whitenoise.ui.main.track.TrackListFragment import com.beomjo.whitenoise.utilities.ext.getApplicationComponent +import dagger.hilt.android.AndroidEntryPoint +@AndroidEntryPoint class HomeFragment : BaseFragment( R.layout.fragment_home, HomeViewModel::class, diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/main/setting/SettingFragment.kt b/app/src/main/java/com/beomjo/whitenoise/ui/main/setting/SettingFragment.kt index 22cc51c..4525e06 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/main/setting/SettingFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/main/setting/SettingFragment.kt @@ -13,7 +13,9 @@ import com.beomjo.whitenoise.BuildConfig import com.beomjo.whitenoise.R import com.beomjo.whitenoise.base.BaseFragment import com.beomjo.whitenoise.databinding.FragmentSettingBinding +import dagger.hilt.android.AndroidEntryPoint +@AndroidEntryPoint class SettingFragment : BaseFragment( R.layout.fragment_setting ) { diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/main/track/TrackListFragment.kt b/app/src/main/java/com/beomjo/whitenoise/ui/main/track/TrackListFragment.kt index c826d84..b33978d 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/main/track/TrackListFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/main/track/TrackListFragment.kt @@ -18,8 +18,10 @@ import com.beomjo.whitenoise.ui.player.PlayerActivity import com.beomjo.whitenoise.ui.player.PlayerManager import com.beomjo.whitenoise.utilities.ext.applyMaterialTransform import com.beomjo.whitenoise.utilities.ext.getApplicationComponent +import dagger.hilt.android.AndroidEntryPoint import javax.inject.Inject +@AndroidEntryPoint class TrackListFragment : BaseFragment( R.layout.fragment_track_list, TrackListViewModel::class diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerActivity.kt b/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerActivity.kt index 7c7699c..d0d5b25 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerActivity.kt @@ -15,8 +15,10 @@ import com.beomjo.whitenoise.databinding.ActivityPlayerBinding import com.beomjo.whitenoise.model.Track import com.beomjo.whitenoise.utilities.ext.applyMaterialTransform import com.beomjo.whitenoise.utilities.ext.getComponent +import dagger.hilt.android.AndroidEntryPoint import javax.inject.Inject +@AndroidEntryPoint class PlayerActivity : BaseActivity( R.layout.activity_player ) { diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/splash/SplashActivity.kt b/app/src/main/java/com/beomjo/whitenoise/ui/splash/SplashActivity.kt index e0949b0..8ef3c2c 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/splash/SplashActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/splash/SplashActivity.kt @@ -8,7 +8,9 @@ import com.beomjo.whitenoise.databinding.ActivitySplashBinding import com.beomjo.whitenoise.ui.auth.LoginActivity import com.beomjo.whitenoise.ui.main.MainActivity import com.beomjo.whitenoise.utilities.ext.getComponent +import dagger.hilt.android.AndroidEntryPoint +@AndroidEntryPoint class SplashActivity : BaseActivity( R.layout.activity_splash, SplashViewModel::class, From 9090a9a1221171bbcbcca9878cf746e0318c8c5f Mon Sep 17 00:00:00 2001 From: beomjo Date: Wed, 9 Jun 2021 02:59:18 +0900 Subject: [PATCH 09/31] chore: Update Submodule --- android-compilation | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android-compilation b/android-compilation index f46cd4c..0af7a7f 160000 --- a/android-compilation +++ b/android-compilation @@ -1 +1 @@ -Subproject commit f46cd4ca1501c37edd47a92aa58c9f5548b859a1 +Subproject commit 0af7a7f8433b10bb07bcf0f1dd21cb963cde2753 From 3925c7ffa5395026b54f6100504ebf0ac2a86501 Mon Sep 17 00:00:00 2001 From: beomjo Date: Thu, 10 Jun 2021 03:24:16 +0900 Subject: [PATCH 10/31] chore: Remove AndroidEntryPoints Annotation - #6 --- app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt | 1 - app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginActivity.kt | 1 - .../com/beomjo/whitenoise/ui/common/ProgressDialogFragment.kt | 1 - app/src/main/java/com/beomjo/whitenoise/ui/main/MainActivity.kt | 1 - .../main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt | 1 - .../com/beomjo/whitenoise/ui/main/setting/SettingFragment.kt | 1 - .../com/beomjo/whitenoise/ui/main/track/TrackListFragment.kt | 1 - .../main/java/com/beomjo/whitenoise/ui/player/PlayerActivity.kt | 1 - .../main/java/com/beomjo/whitenoise/ui/splash/SplashActivity.kt | 1 - 9 files changed, 9 deletions(-) diff --git a/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt b/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt index 57aa03a..a9198db 100644 --- a/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt @@ -15,7 +15,6 @@ import dagger.hilt.android.AndroidEntryPoint import javax.inject.Inject import kotlin.reflect.KClass -@AndroidEntryPoint abstract class BaseActivity( @LayoutRes contentLayoutId: Int, private vararg var viewModels: KClass, diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginActivity.kt b/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginActivity.kt index 9e5e227..e7bdef3 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginActivity.kt @@ -13,7 +13,6 @@ import com.beomjo.whitenoise.utilities.ext.getComponent import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.FlowPreview -@AndroidEntryPoint class LoginActivity : BaseActivity( R.layout.activity_login, LoginViewModel::class diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/common/ProgressDialogFragment.kt b/app/src/main/java/com/beomjo/whitenoise/ui/common/ProgressDialogFragment.kt index 7f92c58..4ff57e2 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/common/ProgressDialogFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/common/ProgressDialogFragment.kt @@ -10,7 +10,6 @@ import com.beomjo.whitenoise.databinding.FragmentProgressDialogBinding import com.beomjo.whitenoise.utilities.ext.getComponent import dagger.hilt.android.AndroidEntryPoint -@AndroidEntryPoint class ProgressDialogFragment : BaseDialogFragment( R.layout.fragment_progress_dialog, ProgressDialogViewModel::class diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/main/MainActivity.kt b/app/src/main/java/com/beomjo/whitenoise/ui/main/MainActivity.kt index ba1f62f..9c7c1aa 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/main/MainActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/main/MainActivity.kt @@ -11,7 +11,6 @@ import com.beomjo.whitenoise.utilities.ext.getComponent import dagger.hilt.android.AndroidEntryPoint import javax.inject.Inject -@AndroidEntryPoint class MainActivity : BaseActivity( R.layout.activity_main, MainViewModel::class diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt b/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt index 3d47b41..8f77bd1 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt @@ -18,7 +18,6 @@ import com.beomjo.whitenoise.ui.main.track.TrackListFragment import com.beomjo.whitenoise.utilities.ext.getApplicationComponent import dagger.hilt.android.AndroidEntryPoint -@AndroidEntryPoint class HomeFragment : BaseFragment( R.layout.fragment_home, HomeViewModel::class, diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/main/setting/SettingFragment.kt b/app/src/main/java/com/beomjo/whitenoise/ui/main/setting/SettingFragment.kt index 4525e06..47c968d 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/main/setting/SettingFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/main/setting/SettingFragment.kt @@ -15,7 +15,6 @@ import com.beomjo.whitenoise.base.BaseFragment import com.beomjo.whitenoise.databinding.FragmentSettingBinding import dagger.hilt.android.AndroidEntryPoint -@AndroidEntryPoint class SettingFragment : BaseFragment( R.layout.fragment_setting ) { diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/main/track/TrackListFragment.kt b/app/src/main/java/com/beomjo/whitenoise/ui/main/track/TrackListFragment.kt index b33978d..10444ce 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/main/track/TrackListFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/main/track/TrackListFragment.kt @@ -21,7 +21,6 @@ import com.beomjo.whitenoise.utilities.ext.getApplicationComponent import dagger.hilt.android.AndroidEntryPoint import javax.inject.Inject -@AndroidEntryPoint class TrackListFragment : BaseFragment( R.layout.fragment_track_list, TrackListViewModel::class diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerActivity.kt b/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerActivity.kt index d0d5b25..0ea532a 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerActivity.kt @@ -18,7 +18,6 @@ import com.beomjo.whitenoise.utilities.ext.getComponent import dagger.hilt.android.AndroidEntryPoint import javax.inject.Inject -@AndroidEntryPoint class PlayerActivity : BaseActivity( R.layout.activity_player ) { diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/splash/SplashActivity.kt b/app/src/main/java/com/beomjo/whitenoise/ui/splash/SplashActivity.kt index 8ef3c2c..f0e36c0 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/splash/SplashActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/splash/SplashActivity.kt @@ -10,7 +10,6 @@ import com.beomjo.whitenoise.ui.main.MainActivity import com.beomjo.whitenoise.utilities.ext.getComponent import dagger.hilt.android.AndroidEntryPoint -@AndroidEntryPoint class SplashActivity : BaseActivity( R.layout.activity_splash, SplashViewModel::class, From e2efbe2708dbb1541beeaeb6815973a3cd17bb7c Mon Sep 17 00:00:00 2001 From: beomjo Date: Thu, 10 Jun 2021 04:09:54 +0900 Subject: [PATCH 11/31] build: Hilt gradle Setting - #6 --- app/build.gradle | 1 + build.gradle | 1 + 2 files changed, 2 insertions(+) diff --git a/app/build.gradle b/app/build.gradle index eab8c4e..ca4ce1d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,6 +6,7 @@ plugins { id 'kotlin-parcelize' id 'com.google.firebase.crashlytics' id 'scabbard.gradle' + id 'dagger.hilt.android.plugin' } android { diff --git a/build.gradle b/build.gradle index 15dfeeb..05cecdc 100644 --- a/build.gradle +++ b/build.gradle @@ -12,6 +12,7 @@ buildscript { classpath deps.classpath.kotlin classpath 'com.google.gms:google-services:4.3.5' classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.2' + classpath "com.google.dagger:hilt-android-gradle-plugin:${versions.hilt.core}" classpath "gradle.plugin.dev.arunkumar:scabbard-gradle-plugin:0.4.0" } } From 5f989afd418beaa51a06e38b17d7ac520d5caa15 Mon Sep 17 00:00:00 2001 From: beomjo Date: Thu, 10 Jun 2021 23:01:16 +0900 Subject: [PATCH 12/31] =?UTF-8?q?feat:=20EntryPointAccessor=EB=A1=9C=20Ent?= =?UTF-8?q?ryPoint=20Access=20=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20-=20#6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/beomjo/whitenoise/WhiteNoiseApp.kt | 8 +--- .../beomjo/whitenoise/base/BaseActivity.kt | 13 +++++ .../beomjo/whitenoise/base/BaseFragment.kt | 7 +++ .../com/beomjo/whitenoise/di/AppComponent.kt | 48 ------------------- .../beomjo/whitenoise/di/FirebaseModule.kt | 5 +- .../beomjo/whitenoise/di/MediaPlayerModule.kt | 3 +- .../com/beomjo/whitenoise/di/SubComponents.kt | 3 ++ .../whitenoise/di/auth/AuthComponent.kt | 8 ++-- .../whitenoise/di/common/CommonComponent.kt | 4 +- .../whitenoise/di/main/HomeComponent.kt | 4 +- .../whitenoise/di/main/MainComponent.kt | 3 +- .../whitenoise/di/player/PlayerComponent.kt | 4 +- .../whitenoise/di/track/TrackListComponent.kt | 4 +- .../whitenoise/factory/ViewModelFactory.kt | 7 ++- .../repositories/auth/AuthRepositoryImpl.kt | 3 +- .../whitenoise/ui/auth/LoginActivity.kt | 17 +++++-- .../ui/common/ProgressDialogFragment.kt | 19 ++++++-- .../beomjo/whitenoise/ui/main/MainActivity.kt | 23 +++++++-- .../whitenoise/ui/main/home/HomeFragment.kt | 18 +++++-- .../ui/main/track/TrackListFragment.kt | 19 ++++++-- .../whitenoise/ui/player/PlayerActivity.kt | 18 +++++-- .../whitenoise/ui/splash/SplashActivity.kt | 10 ++-- .../whitenoise/utilities/ext/ApplicationEx.kt | 14 ------ 23 files changed, 154 insertions(+), 108 deletions(-) delete mode 100644 app/src/main/java/com/beomjo/whitenoise/di/AppComponent.kt delete mode 100644 app/src/main/java/com/beomjo/whitenoise/utilities/ext/ApplicationEx.kt diff --git a/app/src/main/java/com/beomjo/whitenoise/WhiteNoiseApp.kt b/app/src/main/java/com/beomjo/whitenoise/WhiteNoiseApp.kt index 96d6d73..59ca032 100644 --- a/app/src/main/java/com/beomjo/whitenoise/WhiteNoiseApp.kt +++ b/app/src/main/java/com/beomjo/whitenoise/WhiteNoiseApp.kt @@ -3,19 +3,15 @@ package com.beomjo.whitenoise import android.app.Application import com.beomjo.compilation.util.LogUtil import com.beomjo.whitenoise.common.WhiteNoseConfig -import com.beomjo.whitenoise.di.AppComponent -import com.beomjo.whitenoise.di.DaggerAppComponent +import com.beomjo.whitenoise.ui.player.NotificationManager import dagger.hilt.android.HiltAndroidApp @HiltAndroidApp open class WhiteNoiseApp : Application() { - val appComponent: AppComponent by lazy { - DaggerAppComponent.factory().create(applicationContext) - } override fun onCreate() { super.onCreate() LogUtil.init(WhiteNoseConfig()) - com.beomjo.whitenoise.ui.player.NotificationManager.createNotificationChannel(this) + NotificationManager.createNotificationChannel(this) } } \ No newline at end of file diff --git a/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt b/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt index a9198db..08ea19a 100644 --- a/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt @@ -11,7 +11,11 @@ import androidx.lifecycle.ViewModelProvider import com.beomjo.whitenoise.factory.ViewModelFactory import com.beomjo.whitenoise.ui.common.ProgressDialogFragment import com.skydoves.bindables.BindingActivity +import dagger.hilt.EntryPoint +import dagger.hilt.InstallIn import dagger.hilt.android.AndroidEntryPoint +import dagger.hilt.android.EntryPointAccessors +import dagger.hilt.components.SingletonComponent import javax.inject.Inject import kotlin.reflect.KClass @@ -20,6 +24,12 @@ abstract class BaseActivity( private vararg var viewModels: KClass, ) : BindingActivity(contentLayoutId), LifecycleOwner { + @InstallIn(SingletonComponent::class) + @EntryPoint + interface BaseEntryPoints { + fun getViewModelFactory(): ViewModelFactory + } + @Inject lateinit var viewModelFactory: ViewModelFactory @@ -45,6 +55,9 @@ abstract class BaseActivity( @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { + val entryPoint = + EntryPointAccessors.fromApplication(applicationContext, BaseEntryPoints::class.java) + viewModelFactory = entryPoint.getViewModelFactory() super.onCreate(savedInstanceState) inject() createViewModels() diff --git a/app/src/main/java/com/beomjo/whitenoise/base/BaseFragment.kt b/app/src/main/java/com/beomjo/whitenoise/base/BaseFragment.kt index b1c3650..7d37a70 100644 --- a/app/src/main/java/com/beomjo/whitenoise/base/BaseFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/base/BaseFragment.kt @@ -14,6 +14,7 @@ import androidx.lifecycle.ViewModelStoreOwner import com.beomjo.whitenoise.factory.ViewModelFactory import com.beomjo.whitenoise.ui.common.ProgressDialogFragment import com.skydoves.bindables.BindingFragment +import dagger.hilt.android.EntryPointAccessors import javax.inject.Inject import kotlin.reflect.KClass @@ -57,6 +58,12 @@ abstract class BaseFragment( savedInstanceState: Bundle? ): View { return super.onCreateView(inflater, container, savedInstanceState).apply { + val entryPoint = + EntryPointAccessors.fromApplication( + this.context.applicationContext, + BaseActivity.BaseEntryPoints::class.java + ) + viewModelFactory = entryPoint.getViewModelFactory() inject() createViewModels() bindingLifeCycleOwner() diff --git a/app/src/main/java/com/beomjo/whitenoise/di/AppComponent.kt b/app/src/main/java/com/beomjo/whitenoise/di/AppComponent.kt deleted file mode 100644 index 96c1ef4..0000000 --- a/app/src/main/java/com/beomjo/whitenoise/di/AppComponent.kt +++ /dev/null @@ -1,48 +0,0 @@ -package com.beomjo.whitenoise.di - -import android.content.Context -import android.media.MediaPlayer -import com.beomjo.whitenoise.di.auth.AuthComponent -import com.beomjo.whitenoise.di.common.CommonComponent -import com.beomjo.whitenoise.di.main.HomeComponent -import com.beomjo.whitenoise.di.main.MainComponent -import com.beomjo.whitenoise.di.player.PlayerComponent -import com.beomjo.whitenoise.di.track.TrackListComponent -import com.beomjo.whitenoise.ui.player.PlayerManager -import dagger.BindsInstance -import dagger.Component -import javax.inject.Singleton - -@Singleton -@Component( - modules = [ - FirebaseModule::class, - ViewModelFactoryModule::class, - ViewModelModule::class, - RepositoryModule::class, - MediaPlayerModule::class, - ] -) -interface AppComponent { - - @Component.Factory - interface Factory { - fun create(@BindsInstance context: Context): AppComponent - } - - fun commonComponent(): CommonComponent.Factory - - fun authComponent(): AuthComponent.Factory - - fun mainComponent(): MainComponent.Factory - - fun homeComponent(): HomeComponent.Factory - - fun trackListComponent(): TrackListComponent.Factory - - fun playerComponent(): PlayerComponent.Factory - - fun playerManager(): PlayerManager - - fun mediaPlayer(): MediaPlayer -} diff --git a/app/src/main/java/com/beomjo/whitenoise/di/FirebaseModule.kt b/app/src/main/java/com/beomjo/whitenoise/di/FirebaseModule.kt index 8030e7e..9060fd7 100644 --- a/app/src/main/java/com/beomjo/whitenoise/di/FirebaseModule.kt +++ b/app/src/main/java/com/beomjo/whitenoise/di/FirebaseModule.kt @@ -11,6 +11,7 @@ import com.google.firebase.storage.FirebaseStorage import dagger.Module import dagger.Provides import dagger.hilt.InstallIn +import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent @InstallIn(SingletonComponent::class) @@ -23,7 +24,7 @@ object FirebaseModule { } @Provides - fun provideGoogleSignInOption(context: Context): GoogleSignInOptions { + fun provideGoogleSignInOption(@ApplicationContext context: Context): GoogleSignInOptions { return GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(context.getString(R.string.default_web_client_id)) .requestEmail() @@ -31,7 +32,7 @@ object FirebaseModule { } @Provides - fun provideGoogleSignInClient(context: Context, gso: GoogleSignInOptions): GoogleSignInClient { + fun provideGoogleSignInClient(@ApplicationContext context: Context, gso: GoogleSignInOptions): GoogleSignInClient { return GoogleSignIn.getClient(context, gso) } diff --git a/app/src/main/java/com/beomjo/whitenoise/di/MediaPlayerModule.kt b/app/src/main/java/com/beomjo/whitenoise/di/MediaPlayerModule.kt index 68b6e03..b2862ba 100644 --- a/app/src/main/java/com/beomjo/whitenoise/di/MediaPlayerModule.kt +++ b/app/src/main/java/com/beomjo/whitenoise/di/MediaPlayerModule.kt @@ -8,6 +8,7 @@ import com.beomjo.whitenoise.ui.player.PlayerServiceConnection import dagger.Module import dagger.Provides import dagger.hilt.InstallIn +import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent @InstallIn(SingletonComponent::class) @@ -20,7 +21,7 @@ object MediaPlayerModule { } @Provides - fun providePlayerServiceConnection(context: Context): PlayerServiceConnection { + fun providePlayerServiceConnection(@ApplicationContext context: Context): PlayerServiceConnection { return PlayerServiceConnection(context, ComponentName(context, PlayerService::class.java)) } } \ No newline at end of file diff --git a/app/src/main/java/com/beomjo/whitenoise/di/SubComponents.kt b/app/src/main/java/com/beomjo/whitenoise/di/SubComponents.kt index 26d9fda..8973d1f 100644 --- a/app/src/main/java/com/beomjo/whitenoise/di/SubComponents.kt +++ b/app/src/main/java/com/beomjo/whitenoise/di/SubComponents.kt @@ -2,6 +2,9 @@ package com.beomjo.whitenoise.di import com.beomjo.whitenoise.di.auth.AuthComponent import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +@InstallIn(SingletonComponent::class) @Module(subcomponents = [AuthComponent::class]) class SubComponents \ No newline at end of file diff --git a/app/src/main/java/com/beomjo/whitenoise/di/auth/AuthComponent.kt b/app/src/main/java/com/beomjo/whitenoise/di/auth/AuthComponent.kt index 8e373a7..6a6ed59 100644 --- a/app/src/main/java/com/beomjo/whitenoise/di/auth/AuthComponent.kt +++ b/app/src/main/java/com/beomjo/whitenoise/di/auth/AuthComponent.kt @@ -3,16 +3,14 @@ package com.beomjo.whitenoise.di.auth import com.beomjo.whitenoise.ui.auth.LoginActivity import com.beomjo.whitenoise.ui.splash.SplashActivity import dagger.Subcomponent +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent -@Subcomponent() +@Subcomponent interface AuthComponent { @Subcomponent.Factory interface Factory { fun create(): AuthComponent } - - fun inject(activity: SplashActivity) - - fun inject(activity: LoginActivity) } \ No newline at end of file diff --git a/app/src/main/java/com/beomjo/whitenoise/di/common/CommonComponent.kt b/app/src/main/java/com/beomjo/whitenoise/di/common/CommonComponent.kt index fa37e64..aa90673 100644 --- a/app/src/main/java/com/beomjo/whitenoise/di/common/CommonComponent.kt +++ b/app/src/main/java/com/beomjo/whitenoise/di/common/CommonComponent.kt @@ -2,6 +2,8 @@ package com.beomjo.whitenoise.di.common import com.beomjo.whitenoise.ui.common.ProgressDialogFragment import dagger.Subcomponent +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent @Subcomponent interface CommonComponent { @@ -10,6 +12,4 @@ interface CommonComponent { interface Factory { fun create(): CommonComponent } - - fun inject(fragment: ProgressDialogFragment) } \ No newline at end of file diff --git a/app/src/main/java/com/beomjo/whitenoise/di/main/HomeComponent.kt b/app/src/main/java/com/beomjo/whitenoise/di/main/HomeComponent.kt index 59f2727..9f6c1de 100644 --- a/app/src/main/java/com/beomjo/whitenoise/di/main/HomeComponent.kt +++ b/app/src/main/java/com/beomjo/whitenoise/di/main/HomeComponent.kt @@ -2,6 +2,8 @@ package com.beomjo.whitenoise.di.main import com.beomjo.whitenoise.ui.main.home.HomeFragment import dagger.Subcomponent +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent @Subcomponent interface HomeComponent { @@ -10,6 +12,4 @@ interface HomeComponent { interface Factory { fun create(): HomeComponent } - - fun inject(fragment: HomeFragment) } \ No newline at end of file diff --git a/app/src/main/java/com/beomjo/whitenoise/di/main/MainComponent.kt b/app/src/main/java/com/beomjo/whitenoise/di/main/MainComponent.kt index e055d1d..2100d92 100644 --- a/app/src/main/java/com/beomjo/whitenoise/di/main/MainComponent.kt +++ b/app/src/main/java/com/beomjo/whitenoise/di/main/MainComponent.kt @@ -2,6 +2,8 @@ package com.beomjo.whitenoise.di.main import com.beomjo.whitenoise.ui.main.MainActivity import dagger.Subcomponent +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent @Subcomponent interface MainComponent { @@ -11,5 +13,4 @@ interface MainComponent { fun create(): MainComponent } - fun inject(mainActivity: MainActivity) } \ No newline at end of file diff --git a/app/src/main/java/com/beomjo/whitenoise/di/player/PlayerComponent.kt b/app/src/main/java/com/beomjo/whitenoise/di/player/PlayerComponent.kt index fc20496..7b0ea3f 100644 --- a/app/src/main/java/com/beomjo/whitenoise/di/player/PlayerComponent.kt +++ b/app/src/main/java/com/beomjo/whitenoise/di/player/PlayerComponent.kt @@ -2,6 +2,8 @@ package com.beomjo.whitenoise.di.player import com.beomjo.whitenoise.ui.player.PlayerActivity import dagger.Subcomponent +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent @Subcomponent interface PlayerComponent { @@ -10,6 +12,4 @@ interface PlayerComponent { interface Factory { fun create(): PlayerComponent } - - fun inject(playerActivity: PlayerActivity) } \ No newline at end of file diff --git a/app/src/main/java/com/beomjo/whitenoise/di/track/TrackListComponent.kt b/app/src/main/java/com/beomjo/whitenoise/di/track/TrackListComponent.kt index 44b88a0..c85ff1a 100644 --- a/app/src/main/java/com/beomjo/whitenoise/di/track/TrackListComponent.kt +++ b/app/src/main/java/com/beomjo/whitenoise/di/track/TrackListComponent.kt @@ -2,6 +2,8 @@ package com.beomjo.whitenoise.di.track import com.beomjo.whitenoise.ui.main.track.TrackListFragment import dagger.Subcomponent +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent @Subcomponent interface TrackListComponent { @@ -10,6 +12,4 @@ interface TrackListComponent { interface Factory { fun create(): TrackListComponent } - - fun inject(fragment: TrackListFragment) } \ No newline at end of file diff --git a/app/src/main/java/com/beomjo/whitenoise/factory/ViewModelFactory.kt b/app/src/main/java/com/beomjo/whitenoise/factory/ViewModelFactory.kt index 93d4a4c..7d6e52d 100644 --- a/app/src/main/java/com/beomjo/whitenoise/factory/ViewModelFactory.kt +++ b/app/src/main/java/com/beomjo/whitenoise/factory/ViewModelFactory.kt @@ -2,10 +2,15 @@ package com.beomjo.whitenoise.factory import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider +import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent import javax.inject.Inject import javax.inject.Provider -class ViewModelFactory @Inject constructor(val viewModelMap: Map, @JvmSuppressWildcards Provider>) : +@InstallIn(SingletonComponent::class) +@Module +class ViewModelFactory @Inject constructor(private val viewModelMap: Map, @JvmSuppressWildcards Provider>) : ViewModelProvider.Factory { override fun create(modelClass: Class): T { return viewModelMap[modelClass]?.get() as T diff --git a/app/src/main/java/com/beomjo/whitenoise/repositories/auth/AuthRepositoryImpl.kt b/app/src/main/java/com/beomjo/whitenoise/repositories/auth/AuthRepositoryImpl.kt index acb1240..509146e 100644 --- a/app/src/main/java/com/beomjo/whitenoise/repositories/auth/AuthRepositoryImpl.kt +++ b/app/src/main/java/com/beomjo/whitenoise/repositories/auth/AuthRepositoryImpl.kt @@ -12,6 +12,7 @@ import com.google.firebase.auth.AuthCredential import com.google.firebase.auth.AuthResult import com.google.firebase.auth.FirebaseAuth import com.google.firebase.auth.GoogleAuthProvider +import dagger.hilt.android.qualifiers.ApplicationContext import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow @@ -20,7 +21,7 @@ import kotlinx.coroutines.flow.flow import javax.inject.Inject class AuthRepositoryImpl @Inject constructor( - private val context: Context, + @ApplicationContext private val context: Context, private val firebaseAuth: FirebaseAuth, private val googleSignInClient: GoogleSignInClient ) : AuthRepository { diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginActivity.kt b/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginActivity.kt index e7bdef3..7cabddd 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginActivity.kt @@ -8,9 +8,12 @@ import androidx.activity.result.contract.ActivityResultContracts import com.beomjo.whitenoise.R import com.beomjo.whitenoise.base.BaseActivity import com.beomjo.whitenoise.databinding.ActivityLoginBinding +import com.beomjo.whitenoise.di.auth.AuthComponent import com.beomjo.whitenoise.ui.main.MainActivity -import com.beomjo.whitenoise.utilities.ext.getComponent -import dagger.hilt.android.AndroidEntryPoint +import dagger.hilt.EntryPoint +import dagger.hilt.InstallIn +import dagger.hilt.android.EntryPointAccessors +import dagger.hilt.components.SingletonComponent import kotlinx.coroutines.FlowPreview class LoginActivity : BaseActivity( @@ -18,6 +21,12 @@ class LoginActivity : BaseActivity( LoginViewModel::class ) { + @InstallIn(SingletonComponent::class) + @EntryPoint + interface LoginEntryPoints { + fun authComponent(): AuthComponent.Factory + } + private val viewModel: LoginViewModel by getViewModel() @FlowPreview @@ -32,7 +41,9 @@ class LoginActivity : BaseActivity( } override fun inject() { - application.getComponent().authComponent().create().inject(this@LoginActivity) + val entryPoint = + EntryPointAccessors.fromApplication(application, LoginEntryPoints::class.java) + entryPoint.authComponent().create() } private fun bindingViewModel() { diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/common/ProgressDialogFragment.kt b/app/src/main/java/com/beomjo/whitenoise/ui/common/ProgressDialogFragment.kt index 4ff57e2..18e8ce8 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/common/ProgressDialogFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/common/ProgressDialogFragment.kt @@ -7,14 +7,23 @@ import android.view.ViewGroup import com.beomjo.whitenoise.R import com.beomjo.whitenoise.base.BaseDialogFragment import com.beomjo.whitenoise.databinding.FragmentProgressDialogBinding -import com.beomjo.whitenoise.utilities.ext.getComponent -import dagger.hilt.android.AndroidEntryPoint +import com.beomjo.whitenoise.di.common.CommonComponent +import dagger.hilt.EntryPoint +import dagger.hilt.InstallIn +import dagger.hilt.android.EntryPointAccessors +import dagger.hilt.components.SingletonComponent class ProgressDialogFragment : BaseDialogFragment( R.layout.fragment_progress_dialog, ProgressDialogViewModel::class ) { + @InstallIn(SingletonComponent::class) + @EntryPoint + interface ProgressDialogEntryPoints { + fun commonComponent(): CommonComponent.Factory + } + override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, @@ -27,7 +36,11 @@ class ProgressDialogFragment : BaseDialogFragment override fun inject() { activity?.application?.let { - it.getComponent().commonComponent().create().inject(this) + val entryPoint = EntryPointAccessors.fromApplication( + it, + ProgressDialogEntryPoints::class.java + ) + entryPoint.commonComponent().create() } ?: kotlin.run { dismiss() } } diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/main/MainActivity.kt b/app/src/main/java/com/beomjo/whitenoise/ui/main/MainActivity.kt index 9c7c1aa..9551907 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/main/MainActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/main/MainActivity.kt @@ -4,17 +4,26 @@ import android.os.Bundle import com.beomjo.whitenoise.R import com.beomjo.whitenoise.base.BaseActivity import com.beomjo.whitenoise.databinding.ActivityMainBinding +import com.beomjo.whitenoise.di.main.MainComponent import com.beomjo.whitenoise.ui.player.PlayerActivity import com.beomjo.whitenoise.ui.player.PlayerManager import com.beomjo.whitenoise.utilities.ext.applyExitMaterialTransform -import com.beomjo.whitenoise.utilities.ext.getComponent -import dagger.hilt.android.AndroidEntryPoint +import dagger.hilt.EntryPoint +import dagger.hilt.InstallIn +import dagger.hilt.android.EntryPointAccessors +import dagger.hilt.components.SingletonComponent import javax.inject.Inject class MainActivity : BaseActivity( R.layout.activity_main, MainViewModel::class ) { + @InstallIn(SingletonComponent::class) + @EntryPoint + interface MainEntryPoints { + fun mainComponent(): MainComponent.Factory + } + @Inject lateinit var playerManager: PlayerManager @@ -22,7 +31,15 @@ class MainActivity : BaseActivity( private val mainViewModel: MainViewModel by getViewModel() override fun inject() { - application.getComponent().mainComponent().create().inject(this) + val entryPoint = + EntryPointAccessors.fromApplication(applicationContext, MainEntryPoints::class.java) + entryPoint.mainComponent().create() + val playerEntryPoint = + EntryPointAccessors.fromApplication( + applicationContext, + PlayerActivity.PlayerEntryPoints::class.java + ) + playerManager = playerEntryPoint.playerManager() } override fun onCreate(savedInstanceState: Bundle?) { diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt b/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt index 8f77bd1..6a2efee 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt @@ -11,17 +11,25 @@ import androidx.lifecycle.ViewModelStoreOwner import com.beomjo.whitenoise.R import com.beomjo.whitenoise.base.BaseFragment import com.beomjo.whitenoise.databinding.FragmentHomeBinding +import com.beomjo.whitenoise.di.main.HomeComponent import com.beomjo.whitenoise.model.Category import com.beomjo.whitenoise.ui.adapters.HomeAdapter import com.beomjo.whitenoise.ui.main.setting.SettingFragment import com.beomjo.whitenoise.ui.main.track.TrackListFragment -import com.beomjo.whitenoise.utilities.ext.getApplicationComponent -import dagger.hilt.android.AndroidEntryPoint +import dagger.hilt.EntryPoint +import dagger.hilt.InstallIn +import dagger.hilt.android.EntryPointAccessors +import dagger.hilt.components.SingletonComponent class HomeFragment : BaseFragment( R.layout.fragment_home, HomeViewModel::class, ) { + @InstallIn(SingletonComponent::class) + @EntryPoint + interface HomeEntryPoints { + fun homeComponent(): HomeComponent.Factory + } private val homeViewModel: HomeViewModel by getViewModel() @@ -29,7 +37,11 @@ class HomeFragment : BaseFragment( get() = activity as ViewModelStoreOwner override fun inject() { - getApplicationComponent().homeComponent().create().inject(this) + val entryPoint = EntryPointAccessors.fromApplication( + this.context?.applicationContext, + HomeEntryPoints::class.java + ) + entryPoint.homeComponent().create() } override fun onStart() { diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/main/track/TrackListFragment.kt b/app/src/main/java/com/beomjo/whitenoise/ui/main/track/TrackListFragment.kt index 10444ce..835dc7b 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/main/track/TrackListFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/main/track/TrackListFragment.kt @@ -11,14 +11,17 @@ import androidx.lifecycle.ViewModelStoreOwner import com.beomjo.whitenoise.R import com.beomjo.whitenoise.base.BaseFragment import com.beomjo.whitenoise.databinding.FragmentTrackListBinding +import com.beomjo.whitenoise.di.track.TrackListComponent import com.beomjo.whitenoise.model.Category import com.beomjo.whitenoise.model.Track import com.beomjo.whitenoise.ui.adapters.TrackListAdapter import com.beomjo.whitenoise.ui.player.PlayerActivity import com.beomjo.whitenoise.ui.player.PlayerManager import com.beomjo.whitenoise.utilities.ext.applyMaterialTransform -import com.beomjo.whitenoise.utilities.ext.getApplicationComponent -import dagger.hilt.android.AndroidEntryPoint +import dagger.hilt.EntryPoint +import dagger.hilt.InstallIn +import dagger.hilt.android.EntryPointAccessors +import dagger.hilt.components.SingletonComponent import javax.inject.Inject class TrackListFragment : BaseFragment( @@ -26,6 +29,12 @@ class TrackListFragment : BaseFragment( TrackListViewModel::class ) { + @InstallIn(SingletonComponent::class) + @EntryPoint + interface TrackListEntryPoints { + fun trackListComponent(): TrackListComponent.Factory + } + @Inject lateinit var playerManager: PlayerManager @@ -36,7 +45,11 @@ class TrackListFragment : BaseFragment( private val category: Category by lazy { arguments?.getParcelable(KEY_HOME_CATEGORY)!! } override fun inject() { - getApplicationComponent().trackListComponent().create().inject(this) + val entryPoint = EntryPointAccessors.fromApplication( + this.context?.applicationContext, + TrackListEntryPoints::class.java + ) + entryPoint.trackListComponent().create() } override fun onCreate(savedInstanceState: Bundle?) { diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerActivity.kt b/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerActivity.kt index 0ea532a..6581574 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerActivity.kt @@ -12,15 +12,25 @@ import android.view.Window import com.beomjo.whitenoise.R import com.beomjo.whitenoise.base.BaseActivity import com.beomjo.whitenoise.databinding.ActivityPlayerBinding +import com.beomjo.whitenoise.di.player.PlayerComponent import com.beomjo.whitenoise.model.Track import com.beomjo.whitenoise.utilities.ext.applyMaterialTransform -import com.beomjo.whitenoise.utilities.ext.getComponent -import dagger.hilt.android.AndroidEntryPoint +import dagger.hilt.EntryPoint +import dagger.hilt.InstallIn +import dagger.hilt.android.EntryPointAccessors +import dagger.hilt.components.SingletonComponent import javax.inject.Inject class PlayerActivity : BaseActivity( R.layout.activity_player ) { + @InstallIn(SingletonComponent::class) + @EntryPoint + interface PlayerEntryPoints { + fun playerComponent(): PlayerComponent.Factory + + fun playerManager(): PlayerManager + } @Inject lateinit var playerManager: PlayerManager @@ -30,7 +40,9 @@ class PlayerActivity : BaseActivity( by lazy { intent.getBooleanExtra(KEY_BOTTOM_PLAYER_CLICK, false) } override fun inject() { - application.getComponent().playerComponent().create().inject(this) + val entryPoint = + EntryPointAccessors.fromApplication(applicationContext, PlayerEntryPoints::class.java) + entryPoint.playerComponent().create() } override fun onStart() { diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/splash/SplashActivity.kt b/app/src/main/java/com/beomjo/whitenoise/ui/splash/SplashActivity.kt index f0e36c0..180b19e 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/splash/SplashActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/splash/SplashActivity.kt @@ -7,8 +7,7 @@ import com.beomjo.whitenoise.base.BaseActivity import com.beomjo.whitenoise.databinding.ActivitySplashBinding import com.beomjo.whitenoise.ui.auth.LoginActivity import com.beomjo.whitenoise.ui.main.MainActivity -import com.beomjo.whitenoise.utilities.ext.getComponent -import dagger.hilt.android.AndroidEntryPoint +import dagger.hilt.android.EntryPointAccessors class SplashActivity : BaseActivity( R.layout.activity_splash, @@ -24,7 +23,12 @@ class SplashActivity : BaseActivity( } override fun inject() { - application.getComponent().authComponent().create().inject(this) + val entryPoint = + EntryPointAccessors.fromApplication( + application, + LoginActivity.LoginEntryPoints::class.java + ) + entryPoint.authComponent().create() } private fun bindingViewModel() { diff --git a/app/src/main/java/com/beomjo/whitenoise/utilities/ext/ApplicationEx.kt b/app/src/main/java/com/beomjo/whitenoise/utilities/ext/ApplicationEx.kt deleted file mode 100644 index 82b7d57..0000000 --- a/app/src/main/java/com/beomjo/whitenoise/utilities/ext/ApplicationEx.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.beomjo.whitenoise.utilities.ext - -import android.app.Application -import androidx.fragment.app.Fragment -import com.beomjo.whitenoise.WhiteNoiseApp -import com.beomjo.whitenoise.di.AppComponent - -fun Application.getComponent(): AppComponent { - return (applicationContext as WhiteNoiseApp).appComponent -} - -fun Fragment.getApplicationComponent(): AppComponent { - return (requireActivity().application as WhiteNoiseApp).appComponent -} \ No newline at end of file From adcf36b01f216a9b54f878a895155b16ce94cdc9 Mon Sep 17 00:00:00 2001 From: beomjo Date: Fri, 11 Jun 2021 00:11:29 +0900 Subject: [PATCH 13/31] chore: Update Submodule - #6 --- android-compilation | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android-compilation b/android-compilation index 0af7a7f..ff65d4b 160000 --- a/android-compilation +++ b/android-compilation @@ -1 +1 @@ -Subproject commit 0af7a7f8433b10bb07bcf0f1dd21cb963cde2753 +Subproject commit ff65d4b6f981cd050f6f72f972eacc92faedeeda From a6df074a2f2ce72bd6b329258a109a0017f5091b Mon Sep 17 00:00:00 2001 From: beomjo Date: Fri, 11 Jun 2021 00:12:38 +0900 Subject: [PATCH 14/31] =?UTF-8?q?refactor:=20AndroidEntryPoints=20Annotati?= =?UTF-8?q?on=20=EC=82=AC=EC=9A=A9=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=20-=20#6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../beomjo/whitenoise/base/BaseActivity.kt | 9 ++++----- .../whitenoise/base/BaseDialogFragment.kt | 10 +++++++--- .../beomjo/whitenoise/base/BaseFragment.kt | 3 --- .../whitenoise/ui/auth/LoginActivity.kt | 14 ++----------- .../ui/common/ProgressDialogFragment.kt | 18 ++--------------- .../beomjo/whitenoise/ui/main/MainActivity.kt | 20 ++----------------- .../whitenoise/ui/main/home/HomeFragment.kt | 16 ++------------- .../ui/main/setting/SettingFragment.kt | 3 +-- .../ui/main/track/TrackListFragment.kt | 16 ++------------- .../whitenoise/ui/player/PlayerActivity.kt | 15 ++------------ .../whitenoise/ui/player/PlayerManager.kt | 6 +++++- .../whitenoise/ui/splash/SplashActivity.kt | 11 ++-------- 12 files changed, 31 insertions(+), 110 deletions(-) diff --git a/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt b/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt index 08ea19a..f75b2dc 100644 --- a/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt @@ -55,18 +55,17 @@ abstract class BaseActivity( @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { - val entryPoint = - EntryPointAccessors.fromApplication(applicationContext, BaseEntryPoints::class.java) + val entryPoint = EntryPointAccessors.fromApplication( + applicationContext, + BaseEntryPoints::class.java + ) viewModelFactory = entryPoint.getViewModelFactory() super.onCreate(savedInstanceState) - inject() createViewModels() bindingLifeCycleOwner() observeViewModel() } - abstract fun inject() - private fun createViewModels() { for (vm in viewModels) { viewModelImpl.add(ViewModelProvider(this, viewModelFactory).get(vm.javaObjectType)) diff --git a/app/src/main/java/com/beomjo/whitenoise/base/BaseDialogFragment.kt b/app/src/main/java/com/beomjo/whitenoise/base/BaseDialogFragment.kt index 28b0933..619444b 100644 --- a/app/src/main/java/com/beomjo/whitenoise/base/BaseDialogFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/base/BaseDialogFragment.kt @@ -12,6 +12,7 @@ import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.ViewModelProvider import com.beomjo.whitenoise.factory.ViewModelFactory import com.skydoves.bindables.BindingDialogFragment +import dagger.hilt.android.EntryPointAccessors import javax.inject.Inject import kotlin.reflect.KClass @@ -38,15 +39,18 @@ abstract class BaseDialogFragment( savedInstanceState: Bundle? ): View { return super.onCreateView(inflater, container, savedInstanceState).apply { - inject() + val entryPoint = + EntryPointAccessors.fromApplication( + this.context.applicationContext, + BaseActivity.BaseEntryPoints::class.java + ) + viewModelFactory = entryPoint.getViewModelFactory() createViewModels() bindingLifeCycleOwner() bindingToast() } } - abstract fun inject() - private fun createViewModels() { for (vm in viewModels) { viewModelImpl.add(ViewModelProvider(this, viewModelFactory).get(vm.javaObjectType)) diff --git a/app/src/main/java/com/beomjo/whitenoise/base/BaseFragment.kt b/app/src/main/java/com/beomjo/whitenoise/base/BaseFragment.kt index 7d37a70..f1d3f5c 100644 --- a/app/src/main/java/com/beomjo/whitenoise/base/BaseFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/base/BaseFragment.kt @@ -64,15 +64,12 @@ abstract class BaseFragment( BaseActivity.BaseEntryPoints::class.java ) viewModelFactory = entryPoint.getViewModelFactory() - inject() createViewModels() bindingLifeCycleOwner() observeViewModel() } } - abstract fun inject() - private fun createViewModels() { for (vm in viewModels) { viewModelImpl.add( diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginActivity.kt b/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginActivity.kt index 7cabddd..3ea158e 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginActivity.kt @@ -12,21 +12,17 @@ import com.beomjo.whitenoise.di.auth.AuthComponent import com.beomjo.whitenoise.ui.main.MainActivity import dagger.hilt.EntryPoint import dagger.hilt.InstallIn +import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.EntryPointAccessors import dagger.hilt.components.SingletonComponent import kotlinx.coroutines.FlowPreview +@AndroidEntryPoint class LoginActivity : BaseActivity( R.layout.activity_login, LoginViewModel::class ) { - @InstallIn(SingletonComponent::class) - @EntryPoint - interface LoginEntryPoints { - fun authComponent(): AuthComponent.Factory - } - private val viewModel: LoginViewModel by getViewModel() @FlowPreview @@ -40,12 +36,6 @@ class LoginActivity : BaseActivity( bindingViewModel() } - override fun inject() { - val entryPoint = - EntryPointAccessors.fromApplication(application, LoginEntryPoints::class.java) - entryPoint.authComponent().create() - } - private fun bindingViewModel() { binding { vm = viewModel.apply { diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/common/ProgressDialogFragment.kt b/app/src/main/java/com/beomjo/whitenoise/ui/common/ProgressDialogFragment.kt index 18e8ce8..c609b74 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/common/ProgressDialogFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/common/ProgressDialogFragment.kt @@ -10,20 +10,16 @@ import com.beomjo.whitenoise.databinding.FragmentProgressDialogBinding import com.beomjo.whitenoise.di.common.CommonComponent import dagger.hilt.EntryPoint import dagger.hilt.InstallIn +import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.EntryPointAccessors import dagger.hilt.components.SingletonComponent +@AndroidEntryPoint class ProgressDialogFragment : BaseDialogFragment( R.layout.fragment_progress_dialog, ProgressDialogViewModel::class ) { - @InstallIn(SingletonComponent::class) - @EntryPoint - interface ProgressDialogEntryPoints { - fun commonComponent(): CommonComponent.Factory - } - override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, @@ -34,16 +30,6 @@ class ProgressDialogFragment : BaseDialogFragment return super.onCreateView(inflater, container, savedInstanceState) } - override fun inject() { - activity?.application?.let { - val entryPoint = EntryPointAccessors.fromApplication( - it, - ProgressDialogEntryPoints::class.java - ) - entryPoint.commonComponent().create() - } ?: kotlin.run { dismiss() } - } - companion object { @JvmStatic fun newInstance() = ProgressDialogFragment() diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/main/MainActivity.kt b/app/src/main/java/com/beomjo/whitenoise/ui/main/MainActivity.kt index 9551907..b9c99fd 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/main/MainActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/main/MainActivity.kt @@ -10,38 +10,22 @@ import com.beomjo.whitenoise.ui.player.PlayerManager import com.beomjo.whitenoise.utilities.ext.applyExitMaterialTransform import dagger.hilt.EntryPoint import dagger.hilt.InstallIn +import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.EntryPointAccessors import dagger.hilt.components.SingletonComponent import javax.inject.Inject +@AndroidEntryPoint class MainActivity : BaseActivity( R.layout.activity_main, MainViewModel::class ) { - @InstallIn(SingletonComponent::class) - @EntryPoint - interface MainEntryPoints { - fun mainComponent(): MainComponent.Factory - } - @Inject lateinit var playerManager: PlayerManager private val mainViewModel: MainViewModel by getViewModel() - override fun inject() { - val entryPoint = - EntryPointAccessors.fromApplication(applicationContext, MainEntryPoints::class.java) - entryPoint.mainComponent().create() - val playerEntryPoint = - EntryPointAccessors.fromApplication( - applicationContext, - PlayerActivity.PlayerEntryPoints::class.java - ) - playerManager = playerEntryPoint.playerManager() - } - override fun onCreate(savedInstanceState: Bundle?) { applyExitMaterialTransform() super.onCreate(savedInstanceState) diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt b/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt index 6a2efee..aff9e9b 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt @@ -18,32 +18,20 @@ import com.beomjo.whitenoise.ui.main.setting.SettingFragment import com.beomjo.whitenoise.ui.main.track.TrackListFragment import dagger.hilt.EntryPoint import dagger.hilt.InstallIn +import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.EntryPointAccessors import dagger.hilt.components.SingletonComponent +@AndroidEntryPoint class HomeFragment : BaseFragment( R.layout.fragment_home, HomeViewModel::class, ) { - @InstallIn(SingletonComponent::class) - @EntryPoint - interface HomeEntryPoints { - fun homeComponent(): HomeComponent.Factory - } - private val homeViewModel: HomeViewModel by getViewModel() override val viewModelProvideOwner: ViewModelStoreOwner get() = activity as ViewModelStoreOwner - override fun inject() { - val entryPoint = EntryPointAccessors.fromApplication( - this.context?.applicationContext, - HomeEntryPoints::class.java - ) - entryPoint.homeComponent().create() - } - override fun onStart() { super.onStart() setStatusBarColor(Color.WHITE) diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/main/setting/SettingFragment.kt b/app/src/main/java/com/beomjo/whitenoise/ui/main/setting/SettingFragment.kt index 47c968d..db76ee6 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/main/setting/SettingFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/main/setting/SettingFragment.kt @@ -15,14 +15,13 @@ import com.beomjo.whitenoise.base.BaseFragment import com.beomjo.whitenoise.databinding.FragmentSettingBinding import dagger.hilt.android.AndroidEntryPoint +@AndroidEntryPoint class SettingFragment : BaseFragment( R.layout.fragment_setting ) { override val viewModelProvideOwner: ViewModelStoreOwner get() = activity as ViewModelStoreOwner - override fun inject() {} - override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/main/track/TrackListFragment.kt b/app/src/main/java/com/beomjo/whitenoise/ui/main/track/TrackListFragment.kt index 835dc7b..fd9d105 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/main/track/TrackListFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/main/track/TrackListFragment.kt @@ -20,21 +20,17 @@ import com.beomjo.whitenoise.ui.player.PlayerManager import com.beomjo.whitenoise.utilities.ext.applyMaterialTransform import dagger.hilt.EntryPoint import dagger.hilt.InstallIn +import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.EntryPointAccessors import dagger.hilt.components.SingletonComponent import javax.inject.Inject +@AndroidEntryPoint class TrackListFragment : BaseFragment( R.layout.fragment_track_list, TrackListViewModel::class ) { - @InstallIn(SingletonComponent::class) - @EntryPoint - interface TrackListEntryPoints { - fun trackListComponent(): TrackListComponent.Factory - } - @Inject lateinit var playerManager: PlayerManager @@ -44,14 +40,6 @@ class TrackListFragment : BaseFragment( private val category: Category by lazy { arguments?.getParcelable(KEY_HOME_CATEGORY)!! } - override fun inject() { - val entryPoint = EntryPointAccessors.fromApplication( - this.context?.applicationContext, - TrackListEntryPoints::class.java - ) - entryPoint.trackListComponent().create() - } - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerActivity.kt b/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerActivity.kt index 6581574..3ec4663 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerActivity.kt @@ -17,20 +17,15 @@ import com.beomjo.whitenoise.model.Track import com.beomjo.whitenoise.utilities.ext.applyMaterialTransform import dagger.hilt.EntryPoint import dagger.hilt.InstallIn +import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.EntryPointAccessors import dagger.hilt.components.SingletonComponent import javax.inject.Inject +@AndroidEntryPoint class PlayerActivity : BaseActivity( R.layout.activity_player ) { - @InstallIn(SingletonComponent::class) - @EntryPoint - interface PlayerEntryPoints { - fun playerComponent(): PlayerComponent.Factory - - fun playerManager(): PlayerManager - } @Inject lateinit var playerManager: PlayerManager @@ -39,12 +34,6 @@ class PlayerActivity : BaseActivity( private val isEnterFromBottomPlayer: Boolean by lazy { intent.getBooleanExtra(KEY_BOTTOM_PLAYER_CLICK, false) } - override fun inject() { - val entryPoint = - EntryPointAccessors.fromApplication(applicationContext, PlayerEntryPoints::class.java) - entryPoint.playerComponent().create() - } - override fun onStart() { super.onStart() if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerManager.kt b/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerManager.kt index 94184b2..a915ab5 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerManager.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerManager.kt @@ -7,11 +7,15 @@ import androidx.lifecycle.Transformations import com.beomjo.whitenoise.model.Track import com.beomjo.whitenoise.repositories.player.PlayerRepository import com.beomjo.whitenoise.utilities.ext.isPlay +import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent import kotlinx.coroutines.* import javax.inject.Inject import javax.inject.Singleton -@Singleton +@InstallIn(SingletonComponent::class) +@Module class PlayerManager @Inject constructor( private val playerRepository: PlayerRepository, private val playerServiceConnection: PlayerServiceConnection diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/splash/SplashActivity.kt b/app/src/main/java/com/beomjo/whitenoise/ui/splash/SplashActivity.kt index 180b19e..2c2f3ce 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/splash/SplashActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/splash/SplashActivity.kt @@ -7,8 +7,10 @@ import com.beomjo.whitenoise.base.BaseActivity import com.beomjo.whitenoise.databinding.ActivitySplashBinding import com.beomjo.whitenoise.ui.auth.LoginActivity import com.beomjo.whitenoise.ui.main.MainActivity +import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.EntryPointAccessors +@AndroidEntryPoint class SplashActivity : BaseActivity( R.layout.activity_splash, SplashViewModel::class, @@ -22,15 +24,6 @@ class SplashActivity : BaseActivity( viewModel.init() } - override fun inject() { - val entryPoint = - EntryPointAccessors.fromApplication( - application, - LoginActivity.LoginEntryPoints::class.java - ) - entryPoint.authComponent().create() - } - private fun bindingViewModel() { binding { vm = viewModel From b96e2d1d7d410a38e7349a784d582fff3843f776 Mon Sep 17 00:00:00 2001 From: beomjo Date: Fri, 11 Jun 2021 00:41:17 +0900 Subject: [PATCH 15/31] =?UTF-8?q?feat:=20PlayerManager=20Singletone?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD=20-=20#6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/beomjo/whitenoise/di/MediaPlayerModule.kt | 12 ++++++++++++ .../com/beomjo/whitenoise/ui/main/MainActivity.kt | 1 + .../beomjo/whitenoise/ui/player/PlayerActivity.kt | 1 + .../com/beomjo/whitenoise/ui/player/PlayerManager.kt | 2 -- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/beomjo/whitenoise/di/MediaPlayerModule.kt b/app/src/main/java/com/beomjo/whitenoise/di/MediaPlayerModule.kt index b2862ba..cec0a9b 100644 --- a/app/src/main/java/com/beomjo/whitenoise/di/MediaPlayerModule.kt +++ b/app/src/main/java/com/beomjo/whitenoise/di/MediaPlayerModule.kt @@ -3,6 +3,8 @@ package com.beomjo.whitenoise.di import android.content.ComponentName import android.content.Context import android.media.MediaPlayer +import com.beomjo.whitenoise.repositories.player.PlayerRepository +import com.beomjo.whitenoise.ui.player.PlayerManager import com.beomjo.whitenoise.ui.player.PlayerService import com.beomjo.whitenoise.ui.player.PlayerServiceConnection import dagger.Module @@ -10,6 +12,7 @@ import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton @InstallIn(SingletonComponent::class) @Module @@ -20,6 +23,15 @@ object MediaPlayerModule { return MediaPlayer() } + @Singleton + @Provides + fun providePlayerManager( + repository: PlayerRepository, + connection: PlayerServiceConnection + ): PlayerManager { + return PlayerManager(repository, connection) + } + @Provides fun providePlayerServiceConnection(@ApplicationContext context: Context): PlayerServiceConnection { return PlayerServiceConnection(context, ComponentName(context, PlayerService::class.java)) diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/main/MainActivity.kt b/app/src/main/java/com/beomjo/whitenoise/ui/main/MainActivity.kt index b9c99fd..6d2d3be 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/main/MainActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/main/MainActivity.kt @@ -14,6 +14,7 @@ import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.EntryPointAccessors import dagger.hilt.components.SingletonComponent import javax.inject.Inject +import javax.inject.Singleton @AndroidEntryPoint class MainActivity : BaseActivity( diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerActivity.kt b/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerActivity.kt index 3ec4663..8e9c94e 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerActivity.kt @@ -21,6 +21,7 @@ import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.EntryPointAccessors import dagger.hilt.components.SingletonComponent import javax.inject.Inject +import javax.inject.Singleton @AndroidEntryPoint class PlayerActivity : BaseActivity( diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerManager.kt b/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerManager.kt index a915ab5..efb48d6 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerManager.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerManager.kt @@ -14,8 +14,6 @@ import kotlinx.coroutines.* import javax.inject.Inject import javax.inject.Singleton -@InstallIn(SingletonComponent::class) -@Module class PlayerManager @Inject constructor( private val playerRepository: PlayerRepository, private val playerServiceConnection: PlayerServiceConnection From fd60839348d477a87852619e4268ada0ec2e7490 Mon Sep 17 00:00:00 2001 From: beomjo Date: Fri, 11 Jun 2021 00:59:53 +0900 Subject: [PATCH 16/31] =?UTF-8?q?chore:=20SubComponents=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0-=20#6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/beomjo/whitenoise/base/BaseActivity.kt | 1 - .../com/beomjo/whitenoise/di/SubComponents.kt | 10 ---------- .../beomjo/whitenoise/di/auth/AuthComponent.kt | 16 ---------------- .../whitenoise/di/common/CommonComponent.kt | 15 --------------- .../beomjo/whitenoise/di/main/HomeComponent.kt | 15 --------------- .../beomjo/whitenoise/di/main/MainComponent.kt | 16 ---------------- .../whitenoise/di/player/PlayerComponent.kt | 15 --------------- .../whitenoise/di/track/TrackListComponent.kt | 15 --------------- .../beomjo/whitenoise/ui/auth/LoginActivity.kt | 5 ----- .../ui/common/ProgressDialogFragment.kt | 5 ----- .../beomjo/whitenoise/ui/main/MainActivity.kt | 6 ------ .../whitenoise/ui/main/home/HomeFragment.kt | 5 ----- .../ui/main/track/TrackListFragment.kt | 5 ----- .../whitenoise/ui/player/PlayerActivity.kt | 6 ------ .../beomjo/whitenoise/ui/player/PlayerManager.kt | 4 ---- .../whitenoise/ui/splash/SplashActivity.kt | 1 - .../whitenoise/utilities/ext/ActivityEx.kt | 1 - 17 files changed, 141 deletions(-) delete mode 100644 app/src/main/java/com/beomjo/whitenoise/di/SubComponents.kt delete mode 100644 app/src/main/java/com/beomjo/whitenoise/di/auth/AuthComponent.kt delete mode 100644 app/src/main/java/com/beomjo/whitenoise/di/common/CommonComponent.kt delete mode 100644 app/src/main/java/com/beomjo/whitenoise/di/main/HomeComponent.kt delete mode 100644 app/src/main/java/com/beomjo/whitenoise/di/main/MainComponent.kt delete mode 100644 app/src/main/java/com/beomjo/whitenoise/di/player/PlayerComponent.kt delete mode 100644 app/src/main/java/com/beomjo/whitenoise/di/track/TrackListComponent.kt diff --git a/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt b/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt index f75b2dc..fca07cf 100644 --- a/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt @@ -13,7 +13,6 @@ import com.beomjo.whitenoise.ui.common.ProgressDialogFragment import com.skydoves.bindables.BindingActivity import dagger.hilt.EntryPoint import dagger.hilt.InstallIn -import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.EntryPointAccessors import dagger.hilt.components.SingletonComponent import javax.inject.Inject diff --git a/app/src/main/java/com/beomjo/whitenoise/di/SubComponents.kt b/app/src/main/java/com/beomjo/whitenoise/di/SubComponents.kt deleted file mode 100644 index 8973d1f..0000000 --- a/app/src/main/java/com/beomjo/whitenoise/di/SubComponents.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.beomjo.whitenoise.di - -import com.beomjo.whitenoise.di.auth.AuthComponent -import dagger.Module -import dagger.hilt.InstallIn -import dagger.hilt.components.SingletonComponent - -@InstallIn(SingletonComponent::class) -@Module(subcomponents = [AuthComponent::class]) -class SubComponents \ No newline at end of file diff --git a/app/src/main/java/com/beomjo/whitenoise/di/auth/AuthComponent.kt b/app/src/main/java/com/beomjo/whitenoise/di/auth/AuthComponent.kt deleted file mode 100644 index 6a6ed59..0000000 --- a/app/src/main/java/com/beomjo/whitenoise/di/auth/AuthComponent.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.beomjo.whitenoise.di.auth - -import com.beomjo.whitenoise.ui.auth.LoginActivity -import com.beomjo.whitenoise.ui.splash.SplashActivity -import dagger.Subcomponent -import dagger.hilt.InstallIn -import dagger.hilt.components.SingletonComponent - -@Subcomponent -interface AuthComponent { - - @Subcomponent.Factory - interface Factory { - fun create(): AuthComponent - } -} \ No newline at end of file diff --git a/app/src/main/java/com/beomjo/whitenoise/di/common/CommonComponent.kt b/app/src/main/java/com/beomjo/whitenoise/di/common/CommonComponent.kt deleted file mode 100644 index aa90673..0000000 --- a/app/src/main/java/com/beomjo/whitenoise/di/common/CommonComponent.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.beomjo.whitenoise.di.common - -import com.beomjo.whitenoise.ui.common.ProgressDialogFragment -import dagger.Subcomponent -import dagger.hilt.InstallIn -import dagger.hilt.components.SingletonComponent - -@Subcomponent -interface CommonComponent { - - @Subcomponent.Factory - interface Factory { - fun create(): CommonComponent - } -} \ No newline at end of file diff --git a/app/src/main/java/com/beomjo/whitenoise/di/main/HomeComponent.kt b/app/src/main/java/com/beomjo/whitenoise/di/main/HomeComponent.kt deleted file mode 100644 index 9f6c1de..0000000 --- a/app/src/main/java/com/beomjo/whitenoise/di/main/HomeComponent.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.beomjo.whitenoise.di.main - -import com.beomjo.whitenoise.ui.main.home.HomeFragment -import dagger.Subcomponent -import dagger.hilt.InstallIn -import dagger.hilt.components.SingletonComponent - -@Subcomponent -interface HomeComponent { - - @Subcomponent.Factory - interface Factory { - fun create(): HomeComponent - } -} \ No newline at end of file diff --git a/app/src/main/java/com/beomjo/whitenoise/di/main/MainComponent.kt b/app/src/main/java/com/beomjo/whitenoise/di/main/MainComponent.kt deleted file mode 100644 index 2100d92..0000000 --- a/app/src/main/java/com/beomjo/whitenoise/di/main/MainComponent.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.beomjo.whitenoise.di.main - -import com.beomjo.whitenoise.ui.main.MainActivity -import dagger.Subcomponent -import dagger.hilt.InstallIn -import dagger.hilt.components.SingletonComponent - -@Subcomponent -interface MainComponent { - - @Subcomponent.Factory - interface Factory { - fun create(): MainComponent - } - -} \ No newline at end of file diff --git a/app/src/main/java/com/beomjo/whitenoise/di/player/PlayerComponent.kt b/app/src/main/java/com/beomjo/whitenoise/di/player/PlayerComponent.kt deleted file mode 100644 index 7b0ea3f..0000000 --- a/app/src/main/java/com/beomjo/whitenoise/di/player/PlayerComponent.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.beomjo.whitenoise.di.player - -import com.beomjo.whitenoise.ui.player.PlayerActivity -import dagger.Subcomponent -import dagger.hilt.InstallIn -import dagger.hilt.components.SingletonComponent - -@Subcomponent -interface PlayerComponent { - - @Subcomponent.Factory - interface Factory { - fun create(): PlayerComponent - } -} \ No newline at end of file diff --git a/app/src/main/java/com/beomjo/whitenoise/di/track/TrackListComponent.kt b/app/src/main/java/com/beomjo/whitenoise/di/track/TrackListComponent.kt deleted file mode 100644 index c85ff1a..0000000 --- a/app/src/main/java/com/beomjo/whitenoise/di/track/TrackListComponent.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.beomjo.whitenoise.di.track - -import com.beomjo.whitenoise.ui.main.track.TrackListFragment -import dagger.Subcomponent -import dagger.hilt.InstallIn -import dagger.hilt.components.SingletonComponent - -@Subcomponent -interface TrackListComponent { - - @Subcomponent.Factory - interface Factory { - fun create(): TrackListComponent - } -} \ No newline at end of file diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginActivity.kt b/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginActivity.kt index 3ea158e..ddf386a 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginActivity.kt @@ -8,13 +8,8 @@ import androidx.activity.result.contract.ActivityResultContracts import com.beomjo.whitenoise.R import com.beomjo.whitenoise.base.BaseActivity import com.beomjo.whitenoise.databinding.ActivityLoginBinding -import com.beomjo.whitenoise.di.auth.AuthComponent import com.beomjo.whitenoise.ui.main.MainActivity -import dagger.hilt.EntryPoint -import dagger.hilt.InstallIn import dagger.hilt.android.AndroidEntryPoint -import dagger.hilt.android.EntryPointAccessors -import dagger.hilt.components.SingletonComponent import kotlinx.coroutines.FlowPreview @AndroidEntryPoint diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/common/ProgressDialogFragment.kt b/app/src/main/java/com/beomjo/whitenoise/ui/common/ProgressDialogFragment.kt index c609b74..5b3c0ee 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/common/ProgressDialogFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/common/ProgressDialogFragment.kt @@ -7,12 +7,7 @@ import android.view.ViewGroup import com.beomjo.whitenoise.R import com.beomjo.whitenoise.base.BaseDialogFragment import com.beomjo.whitenoise.databinding.FragmentProgressDialogBinding -import com.beomjo.whitenoise.di.common.CommonComponent -import dagger.hilt.EntryPoint -import dagger.hilt.InstallIn import dagger.hilt.android.AndroidEntryPoint -import dagger.hilt.android.EntryPointAccessors -import dagger.hilt.components.SingletonComponent @AndroidEntryPoint class ProgressDialogFragment : BaseDialogFragment( diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/main/MainActivity.kt b/app/src/main/java/com/beomjo/whitenoise/ui/main/MainActivity.kt index 6d2d3be..7f7b662 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/main/MainActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/main/MainActivity.kt @@ -4,17 +4,11 @@ import android.os.Bundle import com.beomjo.whitenoise.R import com.beomjo.whitenoise.base.BaseActivity import com.beomjo.whitenoise.databinding.ActivityMainBinding -import com.beomjo.whitenoise.di.main.MainComponent import com.beomjo.whitenoise.ui.player.PlayerActivity import com.beomjo.whitenoise.ui.player.PlayerManager import com.beomjo.whitenoise.utilities.ext.applyExitMaterialTransform -import dagger.hilt.EntryPoint -import dagger.hilt.InstallIn import dagger.hilt.android.AndroidEntryPoint -import dagger.hilt.android.EntryPointAccessors -import dagger.hilt.components.SingletonComponent import javax.inject.Inject -import javax.inject.Singleton @AndroidEntryPoint class MainActivity : BaseActivity( diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt b/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt index aff9e9b..882901a 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt @@ -11,16 +11,11 @@ import androidx.lifecycle.ViewModelStoreOwner import com.beomjo.whitenoise.R import com.beomjo.whitenoise.base.BaseFragment import com.beomjo.whitenoise.databinding.FragmentHomeBinding -import com.beomjo.whitenoise.di.main.HomeComponent import com.beomjo.whitenoise.model.Category import com.beomjo.whitenoise.ui.adapters.HomeAdapter import com.beomjo.whitenoise.ui.main.setting.SettingFragment import com.beomjo.whitenoise.ui.main.track.TrackListFragment -import dagger.hilt.EntryPoint -import dagger.hilt.InstallIn import dagger.hilt.android.AndroidEntryPoint -import dagger.hilt.android.EntryPointAccessors -import dagger.hilt.components.SingletonComponent @AndroidEntryPoint class HomeFragment : BaseFragment( diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/main/track/TrackListFragment.kt b/app/src/main/java/com/beomjo/whitenoise/ui/main/track/TrackListFragment.kt index fd9d105..1f2bca7 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/main/track/TrackListFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/main/track/TrackListFragment.kt @@ -11,18 +11,13 @@ import androidx.lifecycle.ViewModelStoreOwner import com.beomjo.whitenoise.R import com.beomjo.whitenoise.base.BaseFragment import com.beomjo.whitenoise.databinding.FragmentTrackListBinding -import com.beomjo.whitenoise.di.track.TrackListComponent import com.beomjo.whitenoise.model.Category import com.beomjo.whitenoise.model.Track import com.beomjo.whitenoise.ui.adapters.TrackListAdapter import com.beomjo.whitenoise.ui.player.PlayerActivity import com.beomjo.whitenoise.ui.player.PlayerManager import com.beomjo.whitenoise.utilities.ext.applyMaterialTransform -import dagger.hilt.EntryPoint -import dagger.hilt.InstallIn import dagger.hilt.android.AndroidEntryPoint -import dagger.hilt.android.EntryPointAccessors -import dagger.hilt.components.SingletonComponent import javax.inject.Inject @AndroidEntryPoint diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerActivity.kt b/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerActivity.kt index 8e9c94e..b380e7b 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerActivity.kt @@ -12,16 +12,10 @@ import android.view.Window import com.beomjo.whitenoise.R import com.beomjo.whitenoise.base.BaseActivity import com.beomjo.whitenoise.databinding.ActivityPlayerBinding -import com.beomjo.whitenoise.di.player.PlayerComponent import com.beomjo.whitenoise.model.Track import com.beomjo.whitenoise.utilities.ext.applyMaterialTransform -import dagger.hilt.EntryPoint -import dagger.hilt.InstallIn import dagger.hilt.android.AndroidEntryPoint -import dagger.hilt.android.EntryPointAccessors -import dagger.hilt.components.SingletonComponent import javax.inject.Inject -import javax.inject.Singleton @AndroidEntryPoint class PlayerActivity : BaseActivity( diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerManager.kt b/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerManager.kt index efb48d6..c4113a8 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerManager.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/player/PlayerManager.kt @@ -7,12 +7,8 @@ import androidx.lifecycle.Transformations import com.beomjo.whitenoise.model.Track import com.beomjo.whitenoise.repositories.player.PlayerRepository import com.beomjo.whitenoise.utilities.ext.isPlay -import dagger.Module -import dagger.hilt.InstallIn -import dagger.hilt.components.SingletonComponent import kotlinx.coroutines.* import javax.inject.Inject -import javax.inject.Singleton class PlayerManager @Inject constructor( private val playerRepository: PlayerRepository, diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/splash/SplashActivity.kt b/app/src/main/java/com/beomjo/whitenoise/ui/splash/SplashActivity.kt index 2c2f3ce..f1d855b 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/splash/SplashActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/splash/SplashActivity.kt @@ -8,7 +8,6 @@ import com.beomjo.whitenoise.databinding.ActivitySplashBinding import com.beomjo.whitenoise.ui.auth.LoginActivity import com.beomjo.whitenoise.ui.main.MainActivity import dagger.hilt.android.AndroidEntryPoint -import dagger.hilt.android.EntryPointAccessors @AndroidEntryPoint class SplashActivity : BaseActivity( diff --git a/app/src/main/java/com/beomjo/whitenoise/utilities/ext/ActivityEx.kt b/app/src/main/java/com/beomjo/whitenoise/utilities/ext/ActivityEx.kt index 7f84e25..5b240ec 100644 --- a/app/src/main/java/com/beomjo/whitenoise/utilities/ext/ActivityEx.kt +++ b/app/src/main/java/com/beomjo/whitenoise/utilities/ext/ActivityEx.kt @@ -1,6 +1,5 @@ package com.beomjo.whitenoise.utilities.ext -import android.graphics.Color import android.view.View import android.view.Window import androidx.appcompat.app.AppCompatActivity From ec68a8393899e3b8f6d3bff7dd3fe58b27c15e04 Mon Sep 17 00:00:00 2001 From: beomjo Date: Fri, 2 Jul 2021 02:31:24 +0900 Subject: [PATCH 17/31] =?UTF-8?q?feat:=20=EA=B8=B0=EB=B0=98=ED=81=B4?= =?UTF-8?q?=EB=9E=98=EC=8A=A4=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../beomjo/whitenoise/base/BaseActivity.kt | 26 ++++---------- .../whitenoise/base/BaseDialogFragment.kt | 36 +++++++++---------- .../beomjo/whitenoise/base/BaseFragment.kt | 33 +++++------------ .../whitenoise/ui/auth/LoginActivity.kt | 1 - .../ui/common/ProgressDialogFragment.kt | 6 +++- .../beomjo/whitenoise/ui/main/MainActivity.kt | 1 - .../whitenoise/ui/main/home/HomeFragment.kt | 1 - .../ui/main/track/TrackListFragment.kt | 1 - .../whitenoise/ui/splash/SplashActivity.kt | 1 - 9 files changed, 36 insertions(+), 70 deletions(-) diff --git a/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt b/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt index fca07cf..430756c 100644 --- a/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt @@ -20,7 +20,6 @@ import kotlin.reflect.KClass abstract class BaseActivity( @LayoutRes contentLayoutId: Int, - private vararg var viewModels: KClass, ) : BindingActivity(contentLayoutId), LifecycleOwner { @InstallIn(SingletonComponent::class) @@ -32,14 +31,13 @@ abstract class BaseActivity( @Inject lateinit var viewModelFactory: ViewModelFactory - val viewModelImpl: MutableList = mutableListOf() - protected var progressDialog: ProgressDialogFragment? = null - protected inline fun getViewModel(): Lazy { + inline fun getViewModel(): Lazy { return lazy { - viewModelImpl.find { it is T }?.let { it as T } - ?: kotlin.run { throw IllegalStateException("Can't find [${T::class.java.simpleName}] type ViewModel") } + ViewModelProvider(this, viewModelFactory) + .get(T::class.javaObjectType) + .apply { observeViewModel(this) } } } @@ -60,15 +58,7 @@ abstract class BaseActivity( ) viewModelFactory = entryPoint.getViewModelFactory() super.onCreate(savedInstanceState) - createViewModels() bindingLifeCycleOwner() - observeViewModel() - } - - private fun createViewModels() { - for (vm in viewModels) { - viewModelImpl.add(ViewModelProvider(this, viewModelFactory).get(vm.javaObjectType)) - } } private fun bindingLifeCycleOwner() { @@ -77,11 +67,9 @@ abstract class BaseActivity( } } - private fun observeViewModel() { - for (vm in viewModelImpl) { - observeToast(vm) - observeProgress(vm) - } + fun observeViewModel(viewModel: BaseViewModel) { + observeToast(viewModel) + observeProgress(viewModel) } private fun observeToast(vm: BaseViewModel) { diff --git a/app/src/main/java/com/beomjo/whitenoise/base/BaseDialogFragment.kt b/app/src/main/java/com/beomjo/whitenoise/base/BaseDialogFragment.kt index 619444b..95970b0 100644 --- a/app/src/main/java/com/beomjo/whitenoise/base/BaseDialogFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/base/BaseDialogFragment.kt @@ -10,7 +10,9 @@ import androidx.databinding.ViewDataBinding import androidx.fragment.app.FragmentManager import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.ViewModelProvider +import androidx.lifecycle.ViewModelStoreOwner import com.beomjo.whitenoise.factory.ViewModelFactory +import com.beomjo.whitenoise.ui.common.ProgressDialogFragment import com.skydoves.bindables.BindingDialogFragment import dagger.hilt.android.EntryPointAccessors import javax.inject.Inject @@ -18,25 +20,25 @@ import kotlin.reflect.KClass abstract class BaseDialogFragment( @LayoutRes private val contentLayoutId: Int, - private vararg var viewModels: KClass, ) : BindingDialogFragment(contentLayoutId), LifecycleOwner { @Inject lateinit var viewModelFactory: ViewModelFactory - val viewModelImpl: MutableList = mutableListOf() + abstract val viewModelProvideOwner: ViewModelStoreOwner - protected inline fun getViewModel(): Lazy { + inline fun getViewModel(): Lazy { return lazy { - viewModelImpl.find { it is T }?.let { it as T } - ?: kotlin.run { throw IllegalStateException("Can't find [${T::class.java.simpleName}] type ViewModel") } + ViewModelProvider(viewModelProvideOwner, viewModelFactory) + .get(T::class.javaObjectType) + .apply { observeViewModel(this) } } } override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? + savedInstanceState: Bundle?, ): View { return super.onCreateView(inflater, container, savedInstanceState).apply { val entryPoint = @@ -45,15 +47,7 @@ abstract class BaseDialogFragment( BaseActivity.BaseEntryPoints::class.java ) viewModelFactory = entryPoint.getViewModelFactory() - createViewModels() bindingLifeCycleOwner() - bindingToast() - } - } - - private fun createViewModels() { - for (vm in viewModels) { - viewModelImpl.add(ViewModelProvider(this, viewModelFactory).get(vm.javaObjectType)) } } @@ -63,12 +57,14 @@ abstract class BaseDialogFragment( } } - private fun bindingToast() { - for (vm in viewModelImpl) { - vm.toast.observe(this) { event -> - event.getContentIfNotHandled()?.let { msg -> - Toast.makeText(context, msg, Toast.LENGTH_SHORT).show() - } + fun observeViewModel(viewModel: BaseViewModel) { + observeToast(viewModel) + } + + private fun observeToast(vm: BaseViewModel) { + vm.toast.observe(viewLifecycleOwner) { event -> + event.getContentIfNotHandled()?.let { msg -> + Toast.makeText(context, msg, Toast.LENGTH_SHORT).show() } } } diff --git a/app/src/main/java/com/beomjo/whitenoise/base/BaseFragment.kt b/app/src/main/java/com/beomjo/whitenoise/base/BaseFragment.kt index f1d3f5c..48eb8a1 100644 --- a/app/src/main/java/com/beomjo/whitenoise/base/BaseFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/base/BaseFragment.kt @@ -20,22 +20,20 @@ import kotlin.reflect.KClass abstract class BaseFragment( @LayoutRes contentLayoutId: Int, - private vararg var viewModels: KClass, ) : BindingFragment(contentLayoutId), LifecycleOwner { @Inject lateinit var viewModelFactory: ViewModelFactory - val viewModelImpl: MutableList = mutableListOf() - protected var progressDialog: ProgressDialogFragment? = null abstract val viewModelProvideOwner: ViewModelStoreOwner - protected inline fun getViewModel(): Lazy { + inline fun getViewModel(): Lazy { return lazy { - viewModelImpl.find { it is T }?.let { it as T } - ?: kotlin.run { throw IllegalStateException("Can't find [${T::class.java.simpleName}] type ViewModel") } + ViewModelProvider(viewModelProvideOwner, viewModelFactory) + .get(T::class.javaObjectType) + .apply { observeViewModel(this) } } } @@ -55,7 +53,7 @@ abstract class BaseFragment( override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? + savedInstanceState: Bundle?, ): View { return super.onCreateView(inflater, container, savedInstanceState).apply { val entryPoint = @@ -64,20 +62,7 @@ abstract class BaseFragment( BaseActivity.BaseEntryPoints::class.java ) viewModelFactory = entryPoint.getViewModelFactory() - createViewModels() bindingLifeCycleOwner() - observeViewModel() - } - } - - private fun createViewModels() { - for (vm in viewModels) { - viewModelImpl.add( - ViewModelProvider( - viewModelProvideOwner, - viewModelFactory - ).get(vm.javaObjectType) - ) } } @@ -87,11 +72,9 @@ abstract class BaseFragment( } } - private fun observeViewModel() { - for (vm in viewModelImpl) { - observeToast(vm) - observeProgress(vm) - } + fun observeViewModel(viewModel: BaseViewModel) { + observeToast(viewModel) + observeProgress(viewModel) } private fun observeToast(vm: BaseViewModel) { diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginActivity.kt b/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginActivity.kt index ddf386a..e8ed265 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginActivity.kt @@ -15,7 +15,6 @@ import kotlinx.coroutines.FlowPreview @AndroidEntryPoint class LoginActivity : BaseActivity( R.layout.activity_login, - LoginViewModel::class ) { private val viewModel: LoginViewModel by getViewModel() diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/common/ProgressDialogFragment.kt b/app/src/main/java/com/beomjo/whitenoise/ui/common/ProgressDialogFragment.kt index 5b3c0ee..9c0bc51 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/common/ProgressDialogFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/common/ProgressDialogFragment.kt @@ -4,6 +4,7 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.lifecycle.ViewModelStoreOwner import com.beomjo.whitenoise.R import com.beomjo.whitenoise.base.BaseDialogFragment import com.beomjo.whitenoise.databinding.FragmentProgressDialogBinding @@ -12,9 +13,11 @@ import dagger.hilt.android.AndroidEntryPoint @AndroidEntryPoint class ProgressDialogFragment : BaseDialogFragment( R.layout.fragment_progress_dialog, - ProgressDialogViewModel::class ) { + override val viewModelProvideOwner: ViewModelStoreOwner + get() = this + override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, @@ -29,4 +32,5 @@ class ProgressDialogFragment : BaseDialogFragment @JvmStatic fun newInstance() = ProgressDialogFragment() } + } \ No newline at end of file diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/main/MainActivity.kt b/app/src/main/java/com/beomjo/whitenoise/ui/main/MainActivity.kt index 7f7b662..b54f45e 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/main/MainActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/main/MainActivity.kt @@ -13,7 +13,6 @@ import javax.inject.Inject @AndroidEntryPoint class MainActivity : BaseActivity( R.layout.activity_main, - MainViewModel::class ) { @Inject diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt b/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt index 882901a..7c7cf2c 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt @@ -20,7 +20,6 @@ import dagger.hilt.android.AndroidEntryPoint @AndroidEntryPoint class HomeFragment : BaseFragment( R.layout.fragment_home, - HomeViewModel::class, ) { private val homeViewModel: HomeViewModel by getViewModel() diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/main/track/TrackListFragment.kt b/app/src/main/java/com/beomjo/whitenoise/ui/main/track/TrackListFragment.kt index 1f2bca7..4fef26d 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/main/track/TrackListFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/main/track/TrackListFragment.kt @@ -23,7 +23,6 @@ import javax.inject.Inject @AndroidEntryPoint class TrackListFragment : BaseFragment( R.layout.fragment_track_list, - TrackListViewModel::class ) { @Inject diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/splash/SplashActivity.kt b/app/src/main/java/com/beomjo/whitenoise/ui/splash/SplashActivity.kt index f1d855b..705c379 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/splash/SplashActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/splash/SplashActivity.kt @@ -12,7 +12,6 @@ import dagger.hilt.android.AndroidEntryPoint @AndroidEntryPoint class SplashActivity : BaseActivity( R.layout.activity_splash, - SplashViewModel::class, ) { private val viewModel: SplashViewModel by getViewModel() From 4ff68b894560729680229b5a4a959b8d7d92dffb Mon Sep 17 00:00:00 2001 From: beomjo Date: Fri, 2 Jul 2021 02:39:25 +0900 Subject: [PATCH 18/31] =?UTF-8?q?*=20=EB=B6=88=ED=95=84=EC=9A=94=20EntryPo?= =?UTF-8?q?int=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/beomjo/whitenoise/base/BaseActivity.kt | 13 ------------- .../beomjo/whitenoise/base/BaseDialogFragment.kt | 9 --------- .../java/com/beomjo/whitenoise/base/BaseFragment.kt | 8 -------- 3 files changed, 30 deletions(-) diff --git a/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt b/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt index 430756c..7de4f2b 100644 --- a/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt @@ -13,21 +13,13 @@ import com.beomjo.whitenoise.ui.common.ProgressDialogFragment import com.skydoves.bindables.BindingActivity import dagger.hilt.EntryPoint import dagger.hilt.InstallIn -import dagger.hilt.android.EntryPointAccessors import dagger.hilt.components.SingletonComponent import javax.inject.Inject -import kotlin.reflect.KClass abstract class BaseActivity( @LayoutRes contentLayoutId: Int, ) : BindingActivity(contentLayoutId), LifecycleOwner { - @InstallIn(SingletonComponent::class) - @EntryPoint - interface BaseEntryPoints { - fun getViewModelFactory(): ViewModelFactory - } - @Inject lateinit var viewModelFactory: ViewModelFactory @@ -52,11 +44,6 @@ abstract class BaseActivity( @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { - val entryPoint = EntryPointAccessors.fromApplication( - applicationContext, - BaseEntryPoints::class.java - ) - viewModelFactory = entryPoint.getViewModelFactory() super.onCreate(savedInstanceState) bindingLifeCycleOwner() } diff --git a/app/src/main/java/com/beomjo/whitenoise/base/BaseDialogFragment.kt b/app/src/main/java/com/beomjo/whitenoise/base/BaseDialogFragment.kt index 95970b0..428adf8 100644 --- a/app/src/main/java/com/beomjo/whitenoise/base/BaseDialogFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/base/BaseDialogFragment.kt @@ -12,11 +12,8 @@ import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelStoreOwner import com.beomjo.whitenoise.factory.ViewModelFactory -import com.beomjo.whitenoise.ui.common.ProgressDialogFragment import com.skydoves.bindables.BindingDialogFragment -import dagger.hilt.android.EntryPointAccessors import javax.inject.Inject -import kotlin.reflect.KClass abstract class BaseDialogFragment( @LayoutRes private val contentLayoutId: Int, @@ -41,12 +38,6 @@ abstract class BaseDialogFragment( savedInstanceState: Bundle?, ): View { return super.onCreateView(inflater, container, savedInstanceState).apply { - val entryPoint = - EntryPointAccessors.fromApplication( - this.context.applicationContext, - BaseActivity.BaseEntryPoints::class.java - ) - viewModelFactory = entryPoint.getViewModelFactory() bindingLifeCycleOwner() } } diff --git a/app/src/main/java/com/beomjo/whitenoise/base/BaseFragment.kt b/app/src/main/java/com/beomjo/whitenoise/base/BaseFragment.kt index 48eb8a1..24cdb2c 100644 --- a/app/src/main/java/com/beomjo/whitenoise/base/BaseFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/base/BaseFragment.kt @@ -14,9 +14,7 @@ import androidx.lifecycle.ViewModelStoreOwner import com.beomjo.whitenoise.factory.ViewModelFactory import com.beomjo.whitenoise.ui.common.ProgressDialogFragment import com.skydoves.bindables.BindingFragment -import dagger.hilt.android.EntryPointAccessors import javax.inject.Inject -import kotlin.reflect.KClass abstract class BaseFragment( @LayoutRes contentLayoutId: Int, @@ -56,12 +54,6 @@ abstract class BaseFragment( savedInstanceState: Bundle?, ): View { return super.onCreateView(inflater, container, savedInstanceState).apply { - val entryPoint = - EntryPointAccessors.fromApplication( - this.context.applicationContext, - BaseActivity.BaseEntryPoints::class.java - ) - viewModelFactory = entryPoint.getViewModelFactory() bindingLifeCycleOwner() } } From ddbcb6832c79b70ec368baf1fa3b2c2c4bc40651 Mon Sep 17 00:00:00 2001 From: beomjo Date: Fri, 2 Jul 2021 03:04:56 +0900 Subject: [PATCH 19/31] =?UTF-8?q?feat:=20HiltViewModel=20=EC=96=B4?= =?UTF-8?q?=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98=20=EC=82=AC=EC=9A=A9,=20?= =?UTF-8?q?=EB=B6=88=ED=95=84=EC=9A=94=20=EB=B0=94=EC=9D=B8=EB=94=A9=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../beomjo/whitenoise/base/BaseActivity.kt | 32 +++++------- .../whitenoise/base/BaseDialogFragment.kt | 9 +--- .../beomjo/whitenoise/base/BaseFragment.kt | 10 ++-- .../whitenoise/base/BaseSingleBindActivity.kt | 46 ----------------- .../whitenoise/di/ViewModelFactoryModule.kt | 17 ------- .../com/beomjo/whitenoise/di/ViewModelKey.kt | 14 ------ .../beomjo/whitenoise/di/ViewModelModule.kt | 49 ------------------- .../whitenoise/factory/ViewModelFactory.kt | 19 ------- .../whitenoise/ui/auth/LoginActivity.kt | 1 + .../whitenoise/ui/auth/LoginViewModel.kt | 2 + .../whitenoise/ui/main/MainViewModel.kt | 5 +- .../whitenoise/ui/main/home/HomeViewModel.kt | 2 + .../ui/main/track/TrackListViewModel.kt | 2 + .../whitenoise/ui/splash/SplashViewModel.kt | 7 ++- 14 files changed, 31 insertions(+), 184 deletions(-) delete mode 100644 app/src/main/java/com/beomjo/whitenoise/base/BaseSingleBindActivity.kt delete mode 100644 app/src/main/java/com/beomjo/whitenoise/di/ViewModelFactoryModule.kt delete mode 100644 app/src/main/java/com/beomjo/whitenoise/di/ViewModelKey.kt delete mode 100644 app/src/main/java/com/beomjo/whitenoise/di/ViewModelModule.kt delete mode 100644 app/src/main/java/com/beomjo/whitenoise/factory/ViewModelFactory.kt diff --git a/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt b/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt index 7de4f2b..4b1ce03 100644 --- a/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/base/BaseActivity.kt @@ -1,6 +1,5 @@ package com.beomjo.whitenoise.base -import android.annotation.SuppressLint import android.os.Bundle import android.view.WindowManager import android.widget.Toast @@ -8,41 +7,23 @@ import androidx.annotation.LayoutRes import androidx.databinding.ViewDataBinding import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.ViewModelProvider -import com.beomjo.whitenoise.factory.ViewModelFactory import com.beomjo.whitenoise.ui.common.ProgressDialogFragment import com.skydoves.bindables.BindingActivity -import dagger.hilt.EntryPoint -import dagger.hilt.InstallIn -import dagger.hilt.components.SingletonComponent -import javax.inject.Inject abstract class BaseActivity( @LayoutRes contentLayoutId: Int, ) : BindingActivity(contentLayoutId), LifecycleOwner { - @Inject - lateinit var viewModelFactory: ViewModelFactory - protected var progressDialog: ProgressDialogFragment? = null inline fun getViewModel(): Lazy { return lazy { - ViewModelProvider(this, viewModelFactory) - .get(T::class.javaObjectType) + ViewModelProvider(this) + .get(T::class.java) .apply { observeViewModel(this) } } } - protected fun setStatusBarColor(color: Int) { - if (!isFinishing) { - val window = window - window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) - window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) - window.statusBarColor = color - } - } - - @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) bindingLifeCycleOwner() @@ -54,6 +35,15 @@ abstract class BaseActivity( } } + protected fun setStatusBarColor(color: Int) { + if (!isFinishing) { + val window = window + window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) + window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) + window.statusBarColor = color + } + } + fun observeViewModel(viewModel: BaseViewModel) { observeToast(viewModel) observeProgress(viewModel) diff --git a/app/src/main/java/com/beomjo/whitenoise/base/BaseDialogFragment.kt b/app/src/main/java/com/beomjo/whitenoise/base/BaseDialogFragment.kt index 428adf8..c819419 100644 --- a/app/src/main/java/com/beomjo/whitenoise/base/BaseDialogFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/base/BaseDialogFragment.kt @@ -11,23 +11,18 @@ import androidx.fragment.app.FragmentManager import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelStoreOwner -import com.beomjo.whitenoise.factory.ViewModelFactory import com.skydoves.bindables.BindingDialogFragment -import javax.inject.Inject abstract class BaseDialogFragment( @LayoutRes private val contentLayoutId: Int, ) : BindingDialogFragment(contentLayoutId), LifecycleOwner { - @Inject - lateinit var viewModelFactory: ViewModelFactory - abstract val viewModelProvideOwner: ViewModelStoreOwner inline fun getViewModel(): Lazy { return lazy { - ViewModelProvider(viewModelProvideOwner, viewModelFactory) - .get(T::class.javaObjectType) + ViewModelProvider(viewModelProvideOwner) + .get(T::class.java) .apply { observeViewModel(this) } } } diff --git a/app/src/main/java/com/beomjo/whitenoise/base/BaseFragment.kt b/app/src/main/java/com/beomjo/whitenoise/base/BaseFragment.kt index 24cdb2c..3fcd0c3 100644 --- a/app/src/main/java/com/beomjo/whitenoise/base/BaseFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/base/BaseFragment.kt @@ -8,29 +8,25 @@ import android.view.WindowManager import android.widget.Toast import androidx.annotation.LayoutRes import androidx.databinding.ViewDataBinding +import androidx.fragment.app.viewModels import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelStoreOwner -import com.beomjo.whitenoise.factory.ViewModelFactory import com.beomjo.whitenoise.ui.common.ProgressDialogFragment import com.skydoves.bindables.BindingFragment -import javax.inject.Inject abstract class BaseFragment( @LayoutRes contentLayoutId: Int, ) : BindingFragment(contentLayoutId), LifecycleOwner { - @Inject - lateinit var viewModelFactory: ViewModelFactory - protected var progressDialog: ProgressDialogFragment? = null abstract val viewModelProvideOwner: ViewModelStoreOwner inline fun getViewModel(): Lazy { return lazy { - ViewModelProvider(viewModelProvideOwner, viewModelFactory) - .get(T::class.javaObjectType) + ViewModelProvider(viewModelProvideOwner) + .get(T::class.java) .apply { observeViewModel(this) } } } diff --git a/app/src/main/java/com/beomjo/whitenoise/base/BaseSingleBindActivity.kt b/app/src/main/java/com/beomjo/whitenoise/base/BaseSingleBindActivity.kt deleted file mode 100644 index d7168d0..0000000 --- a/app/src/main/java/com/beomjo/whitenoise/base/BaseSingleBindActivity.kt +++ /dev/null @@ -1,46 +0,0 @@ -package com.beomjo.whitenoise.base - -import android.annotation.SuppressLint -import android.os.Bundle -import androidx.annotation.LayoutRes -import androidx.databinding.ViewDataBinding -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.ViewModelProvider -import com.beomjo.whitenoise.factory.ViewModelFactory -import com.skydoves.bindables.BindingActivity -import java.lang.reflect.ParameterizedType -import javax.inject.Inject - -@Deprecated(message = "Use BaseActivity") -abstract class BaseSingleBindActivity constructor( - @LayoutRes private val contentLayoutId: Int -) : BindingActivity(contentLayoutId), LifecycleOwner { - - @Inject - lateinit var viewModelFactory: ViewModelFactory - - lateinit var viewModel: VM - - @SuppressLint("MissingSuperCall") - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - inject() - createViewModel() - bindingLifeCycleOwner() - } - - private fun createViewModel() { - val clazz = ((javaClass.genericSuperclass as ParameterizedType?) - ?.actualTypeArguments - ?.get(1) as Class) - viewModel = ViewModelProvider(this, viewModelFactory).get(clazz) - } - - abstract fun inject() - - private fun bindingLifeCycleOwner() { - binding { - lifecycleOwner = this@BaseSingleBindActivity - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/beomjo/whitenoise/di/ViewModelFactoryModule.kt b/app/src/main/java/com/beomjo/whitenoise/di/ViewModelFactoryModule.kt deleted file mode 100644 index aa6fa6e..0000000 --- a/app/src/main/java/com/beomjo/whitenoise/di/ViewModelFactoryModule.kt +++ /dev/null @@ -1,17 +0,0 @@ -package com.beomjo.whitenoise.di - -import androidx.lifecycle.ViewModelProvider -import com.beomjo.whitenoise.factory.ViewModelFactory -import dagger.Binds -import dagger.Module -import dagger.hilt.InstallIn -import dagger.hilt.components.SingletonComponent - -@InstallIn(SingletonComponent::class) -@Module -abstract class ViewModelFactoryModule { - - @Binds - abstract fun bindViewModelFactory(viewModelFactory: ViewModelFactory): ViewModelProvider.Factory - -} \ No newline at end of file diff --git a/app/src/main/java/com/beomjo/whitenoise/di/ViewModelKey.kt b/app/src/main/java/com/beomjo/whitenoise/di/ViewModelKey.kt deleted file mode 100644 index e791967..0000000 --- a/app/src/main/java/com/beomjo/whitenoise/di/ViewModelKey.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.beomjo.whitenoise.di - -import androidx.lifecycle.ViewModel -import dagger.MapKey -import kotlin.reflect.KClass - -@MapKey -@Target( - AnnotationTarget.FUNCTION, - AnnotationTarget.PROPERTY_GETTER, - AnnotationTarget.PROPERTY_SETTER -) -annotation class ViewModelKey(val value: KClass) - diff --git a/app/src/main/java/com/beomjo/whitenoise/di/ViewModelModule.kt b/app/src/main/java/com/beomjo/whitenoise/di/ViewModelModule.kt deleted file mode 100644 index ddca6d9..0000000 --- a/app/src/main/java/com/beomjo/whitenoise/di/ViewModelModule.kt +++ /dev/null @@ -1,49 +0,0 @@ -package com.beomjo.whitenoise.di - -import androidx.lifecycle.ViewModel -import com.beomjo.whitenoise.ui.auth.LoginViewModel -import com.beomjo.whitenoise.ui.common.ProgressDialogViewModel -import com.beomjo.whitenoise.ui.main.MainViewModel -import com.beomjo.whitenoise.ui.main.home.HomeViewModel -import com.beomjo.whitenoise.ui.main.track.TrackListViewModel -import com.beomjo.whitenoise.ui.splash.SplashViewModel -import dagger.Binds -import dagger.Module -import dagger.hilt.InstallIn -import dagger.hilt.components.SingletonComponent -import dagger.multibindings.IntoMap - -@InstallIn(SingletonComponent::class) -@Module -abstract class ViewModelModule { - - @Binds - @IntoMap - @ViewModelKey(SplashViewModel::class) - abstract fun provideSplashViewModel(splashViewModel: SplashViewModel): ViewModel - - @Binds - @IntoMap - @ViewModelKey(LoginViewModel::class) - abstract fun provideLoginViewModel(loginViewModel: LoginViewModel): ViewModel - - @Binds - @IntoMap - @ViewModelKey(MainViewModel::class) - abstract fun provideMainViewModel(mainViewModel: MainViewModel): ViewModel - - @Binds - @IntoMap - @ViewModelKey(HomeViewModel::class) - abstract fun provideHomeViewModel(homeViewModel: HomeViewModel): ViewModel - - @Binds - @IntoMap - @ViewModelKey(TrackListViewModel::class) - abstract fun provideTrackListViewModel(trackViewModel: TrackListViewModel): ViewModel - - @Binds - @IntoMap - @ViewModelKey(ProgressDialogViewModel::class) - abstract fun provideProgressDialogViewModel(progressDialogViewModel: ProgressDialogViewModel): ViewModel -} \ No newline at end of file diff --git a/app/src/main/java/com/beomjo/whitenoise/factory/ViewModelFactory.kt b/app/src/main/java/com/beomjo/whitenoise/factory/ViewModelFactory.kt deleted file mode 100644 index 7d6e52d..0000000 --- a/app/src/main/java/com/beomjo/whitenoise/factory/ViewModelFactory.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.beomjo.whitenoise.factory - -import androidx.lifecycle.ViewModel -import androidx.lifecycle.ViewModelProvider -import dagger.Module -import dagger.hilt.InstallIn -import dagger.hilt.components.SingletonComponent -import javax.inject.Inject -import javax.inject.Provider - -@InstallIn(SingletonComponent::class) -@Module -class ViewModelFactory @Inject constructor(private val viewModelMap: Map, @JvmSuppressWildcards Provider>) : - ViewModelProvider.Factory { - override fun create(modelClass: Class): T { - return viewModelMap[modelClass]?.get() as T - } -} - diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginActivity.kt b/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginActivity.kt index e8ed265..ea6b070 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginActivity.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginActivity.kt @@ -5,6 +5,7 @@ import android.content.Intent import android.os.Bundle import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.contract.ActivityResultContracts +import androidx.activity.viewModels import com.beomjo.whitenoise.R import com.beomjo.whitenoise.base.BaseActivity import com.beomjo.whitenoise.databinding.ActivityLoginBinding diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginViewModel.kt b/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginViewModel.kt index 45e0a76..3526591 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginViewModel.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/auth/LoginViewModel.kt @@ -7,6 +7,7 @@ import androidx.lifecycle.viewModelScope import com.beomjo.compilation.util.Event import com.beomjo.whitenoise.base.BaseViewModel import com.beomjo.whitenoise.repositories.auth.AuthRepository +import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.flatMapConcat @@ -14,6 +15,7 @@ import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import javax.inject.Inject +@HiltViewModel class LoginViewModel @Inject constructor( private val authRepository: AuthRepository ) : BaseViewModel() { diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/main/MainViewModel.kt b/app/src/main/java/com/beomjo/whitenoise/ui/main/MainViewModel.kt index 252daf0..0ad89cb 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/main/MainViewModel.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/main/MainViewModel.kt @@ -1,7 +1,8 @@ package com.beomjo.whitenoise.ui.main import com.beomjo.whitenoise.base.BaseViewModel +import dagger.hilt.android.lifecycle.HiltViewModel import javax.inject.Inject -class MainViewModel @Inject constructor() : BaseViewModel() { -} \ No newline at end of file +@HiltViewModel +class MainViewModel @Inject constructor() : BaseViewModel() \ No newline at end of file diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeViewModel.kt b/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeViewModel.kt index f6f821c..72f05a2 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeViewModel.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeViewModel.kt @@ -7,8 +7,10 @@ import com.beomjo.whitenoise.model.Category import com.beomjo.whitenoise.model.User import com.beomjo.whitenoise.repositories.auth.AuthRepository import com.beomjo.whitenoise.repositories.home.HomeRepository +import dagger.hilt.android.lifecycle.HiltViewModel import javax.inject.Inject +@HiltViewModel class HomeViewModel @Inject constructor( private val authRepository: AuthRepository, private val homeRepository: HomeRepository, diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/main/track/TrackListViewModel.kt b/app/src/main/java/com/beomjo/whitenoise/ui/main/track/TrackListViewModel.kt index 299dcd1..72a933c 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/main/track/TrackListViewModel.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/main/track/TrackListViewModel.kt @@ -5,8 +5,10 @@ import androidx.lifecycle.MutableLiveData import com.beomjo.whitenoise.base.BaseViewModel import com.beomjo.whitenoise.model.Track import com.beomjo.whitenoise.repositories.track.TrackListRepository +import dagger.hilt.android.lifecycle.HiltViewModel import javax.inject.Inject +@HiltViewModel class TrackListViewModel @Inject constructor( private val trackListRepository: TrackListRepository ) : BaseViewModel() { diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/splash/SplashViewModel.kt b/app/src/main/java/com/beomjo/whitenoise/ui/splash/SplashViewModel.kt index f20e39a..77d98a2 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/splash/SplashViewModel.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/splash/SplashViewModel.kt @@ -5,12 +5,15 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.viewModelScope import com.beomjo.whitenoise.base.BaseViewModel import com.beomjo.whitenoise.repositories.auth.AuthRepository +import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.delay import kotlinx.coroutines.launch import javax.inject.Inject -class SplashViewModel @Inject constructor(private val authRepository: AuthRepository) : - BaseViewModel() { +@HiltViewModel +class SplashViewModel @Inject constructor( + private val authRepository: AuthRepository, +) : BaseViewModel() { private val _loginState = MutableLiveData() val loginState: LiveData get() = _loginState From 2a89b792790a052509b4ac539ceddf234971137f Mon Sep 17 00:00:00 2001 From: beomjo Date: Tue, 6 Jul 2021 02:44:54 +0900 Subject: [PATCH 20/31] =?UTF-8?q?feat:=20=EC=95=8C=EB=A6=BC=EC=B1=84?= =?UTF-8?q?=EB=84=90=20=EC=9A=B0=EC=84=A0=EC=88=9C=EC=9C=84=20Low=EB=A1=9C?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/release_note.txt | 24 +++++++++++++++++++ .../ui/player/NotificationManager.kt | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 app/release_note.txt diff --git a/app/release_note.txt b/app/release_note.txt new file mode 100644 index 0000000..88325b9 --- /dev/null +++ b/app/release_note.txt @@ -0,0 +1,24 @@ +# Features + * + + + + +# Changes + * + + + +# Bug Fixes + * [#31] 트랙 재생, 멈춤시 진동, 알림 오는현상 수정 + * 알림채널 우선순위 LOW로 변경 + + + +# Add + * + + + +# Deprecations + * \ No newline at end of file diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/player/NotificationManager.kt b/app/src/main/java/com/beomjo/whitenoise/ui/player/NotificationManager.kt index 8529702..2f9027e 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/player/NotificationManager.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/player/NotificationManager.kt @@ -114,7 +114,7 @@ object NotificationManager { fun createNotificationChannel(context: Context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val appName = context.getString(R.string.app_name) - val importance = android.app.NotificationManager.IMPORTANCE_DEFAULT + val importance = android.app.NotificationManager.IMPORTANCE_LOW val channel = NotificationChannel(CHANNEL_ID, appName, importance) val notificationManager = context.getSystemService(AppCompatActivity.NOTIFICATION_SERVICE) as SystemNotificationManager From 5273adf9b0e29e7a9be31e3ed3af0962864e07a9 Mon Sep 17 00:00:00 2001 From: beomjo Date: Tue, 6 Jul 2021 02:54:44 +0900 Subject: [PATCH 21/31] =?UTF-8?q?bugfix:=20isLoading=EC=9C=BC=EB=A1=9C=20L?= =?UTF-8?q?ist,=20Shimmer=20=ED=91=9C=EC=8B=9C=EC=97=AC=EB=B6=80=20?= =?UTF-8?q?=EA=B2=B0=EC=A0=95=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - isRefresh 제거 --- .../whitenoise/ui/main/home/HomeViewModel.kt | 5 --- app/src/main/res/layout/fragment_home.xml | 31 ++++++++++--------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeViewModel.kt b/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeViewModel.kt index 72f05a2..6aa1308 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeViewModel.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeViewModel.kt @@ -22,9 +22,6 @@ class HomeViewModel @Inject constructor( private val _user = MutableLiveData() val user: LiveData get() = _user - private val _isRefreshing = MutableLiveData() - val isRefreshing: LiveData get() = _isRefreshing - private val _isLoading = MutableLiveData() val isLoading: LiveData get() = _isLoading @@ -41,13 +38,11 @@ class HomeViewModel @Inject constructor( launch { _isLoading.value = true _categories.value = homeRepository.getHomeCategoryList() - _isRefreshing.value = false _isLoading.value = false } } fun onRefresh() { - _isRefreshing.value = true loadHomeCategoryList() } } \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index 0120ce1..e29821b 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -89,30 +89,18 @@ android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" app:onRefreshListener="@{() -> homeVM.onRefresh()}" - app:refreshing="@{homeVM.isRefreshing}"> + app:refreshing="@{homeVM.isLoading}"> - - - - + + + + + - \ No newline at end of file From 5d53a3faf50f2813ae2038244e8854e6d1087dbf Mon Sep 17 00:00:00 2001 From: beomjo Date: Tue, 6 Jul 2021 02:54:56 +0900 Subject: [PATCH 22/31] =?UTF-8?q?test:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../whitenoise/viewmodel/HomeViewModelTest.kt | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/app/src/test/java/com/beomjo/whitenoise/viewmodel/HomeViewModelTest.kt b/app/src/test/java/com/beomjo/whitenoise/viewmodel/HomeViewModelTest.kt index 38a95b5..8f33bbe 100644 --- a/app/src/test/java/com/beomjo/whitenoise/viewmodel/HomeViewModelTest.kt +++ b/app/src/test/java/com/beomjo/whitenoise/viewmodel/HomeViewModelTest.kt @@ -91,14 +91,10 @@ class HomeViewModelTest : BaseTest() { val homeCategory = mockk() val homeCategories = listOf(homeCategory) coEvery { homeRepository.getHomeCategoryList() } returns homeCategories - val refreshObserver = mockk> { - every { onChanged(false) } just Runs - } val loadingObserver = mockk> { every { onChanged(true) } just Runs every { onChanged(false) } just Runs } - viewModel.isRefreshing.observeForever(refreshObserver) viewModel.isLoading.observeForever(loadingObserver) //when @@ -108,7 +104,6 @@ class HomeViewModelTest : BaseTest() { coVerifyOrder { loadingObserver.onChanged(true) homeRepository.getHomeCategoryList() - refreshObserver.onChanged(eq(false)) loadingObserver.onChanged(false) } } @@ -120,9 +115,6 @@ class HomeViewModelTest : BaseTest() { val errorMsg = "Fail" every { exception.message } returns errorMsg coEvery { homeRepository.getHomeCategoryList() } throws exception - val refreshObserver = mockk> { - every { onChanged(false) } just Runs - } val loadingObserver = mockk> { every { onChanged(true) } just Runs every { onChanged(false) } just Runs @@ -130,7 +122,6 @@ class HomeViewModelTest : BaseTest() { val toastObserver = mockk>> { every { onChanged(Event(errorMsg)) } just Runs } - viewModel.isRefreshing.observeForever(refreshObserver) viewModel.toast.observeForever(toastObserver) viewModel.isLoading.observeForever(loadingObserver) @@ -149,16 +140,11 @@ class HomeViewModelTest : BaseTest() { fun `Refresh 하여 재로딩`() { //given justRun { viewModel invokeNoArgs "loadHomeCategoryList" } - val refreshObserver = mockk> { - every { onChanged(true) } just Runs - } - viewModel.isRefreshing.observeForever(refreshObserver) //when viewModel.onRefresh() //then - verify { refreshObserver.onChanged(eq(true)) } verify { viewModel invokeNoArgs "loadHomeCategoryList" } } } \ No newline at end of file From 3cf40f51de55c47b46594b7ff9b5cf1df451186a Mon Sep 17 00:00:00 2001 From: beomjo Date: Tue, 6 Jul 2021 02:57:23 +0900 Subject: [PATCH 23/31] =?UTF-8?q?chore:=20ReleaseNote=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/release_note.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/release_note.txt b/app/release_note.txt index 88325b9..82563c9 100644 --- a/app/release_note.txt +++ b/app/release_note.txt @@ -12,6 +12,7 @@ # Bug Fixes * [#31] 트랙 재생, 멈춤시 진동, 알림 오는현상 수정 * 알림채널 우선순위 LOW로 변경 + * [#32] 홈화면 Pull to Refersh시 shimmer가 뒤쪽에 표시되는 현상 수정 From 726df2b720f43cb99ebc3a050cebe7e79825cd5f Mon Sep 17 00:00:00 2001 From: beomjo Date: Tue, 6 Jul 2021 03:03:02 +0900 Subject: [PATCH 24/31] =?UTF-8?q?feat:=20=EB=94=94=EB=B0=94=EC=9D=B4?= =?UTF-8?q?=EC=8A=A4=20=EA=B0=80=EB=A1=9C=ED=9A=8C=EC=A0=84=20=EB=A7=89?= =?UTF-8?q?=EC=9D=8C=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/release_note.txt | 3 ++- app/src/main/AndroidManifest.xml | 15 +++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/release_note.txt b/app/release_note.txt index 82563c9..33743fe 100644 --- a/app/release_note.txt +++ b/app/release_note.txt @@ -11,8 +11,9 @@ # Bug Fixes * [#31] 트랙 재생, 멈춤시 진동, 알림 오는현상 수정 - * 알림채널 우선순위 LOW로 변경 + * 알림채널 우선순위 LOW로 변 * [#32] 홈화면 Pull to Refersh시 shimmer가 뒤쪽에 표시되는 현상 수정 + * [#26] 디바이스 가로회전 막음처리 diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5e0f94b..47a756a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -14,18 +14,25 @@ android:roundIcon="@mipmap/ic_launcher" android:supportsRtl="true" android:theme="@style/Theme.WhiteNoisePlayer"> - + - - + + + android:launchMode="singleTop" + android:screenOrientation="portrait" /> Date: Tue, 6 Jul 2021 03:04:33 +0900 Subject: [PATCH 25/31] =?UTF-8?q?chore:=20ReleaseNote=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/release_note.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/release_note.txt b/app/release_note.txt index 33743fe..24bb5dd 100644 --- a/app/release_note.txt +++ b/app/release_note.txt @@ -11,9 +11,9 @@ # Bug Fixes * [#31] 트랙 재생, 멈춤시 진동, 알림 오는현상 수정 - * 알림채널 우선순위 LOW로 변 + * 알림채널 우선순위 LOW로 변경 * [#32] 홈화면 Pull to Refersh시 shimmer가 뒤쪽에 표시되는 현상 수정 - * [#26] 디바이스 가로회전 막음처리 + * [#26] 디바이스 가로회전 막음처 From 1e7b7427f596c94a538850ac75ac37d5b3a81979 Mon Sep 17 00:00:00 2001 From: beomjo Date: Tue, 6 Jul 2021 03:04:56 +0900 Subject: [PATCH 26/31] =?UTF-8?q?chore:=20ReleaseNote=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/release_note.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/release_note.txt b/app/release_note.txt index 24bb5dd..8c5f9ae 100644 --- a/app/release_note.txt +++ b/app/release_note.txt @@ -13,7 +13,7 @@ * [#31] 트랙 재생, 멈춤시 진동, 알림 오는현상 수정 * 알림채널 우선순위 LOW로 변경 * [#32] 홈화면 Pull to Refersh시 shimmer가 뒤쪽에 표시되는 현상 수정 - * [#26] 디바이스 가로회전 막음처 + * [#26] 디바이스 가로회전 막음처리 From 0499724c99abb6af1238b635e8fab9fbba9c67cd Mon Sep 17 00:00:00 2001 From: beomjo Date: Tue, 6 Jul 2021 03:25:57 +0900 Subject: [PATCH 27/31] =?UTF-8?q?bugfix:=20Pull=20to=20Refresh=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../whitenoise/ui/main/home/HomeFragment.kt | 5 ++-- app/src/main/res/layout/fragment_home.xml | 28 +++++++++---------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt b/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt index 7c7cf2c..881635b 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt @@ -34,7 +34,7 @@ class HomeFragment : BaseFragment( override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? + savedInstanceState: Bundle?, ): View { super.onCreateView(inflater, container, savedInstanceState) return binding { bindingViewModel() }.root @@ -48,10 +48,11 @@ class HomeFragment : BaseFragment( parentFragmentManager.commit { setReorderingAllowed(true) addSharedElement(view, item.id.toString()) - replace( + add( R.id.fragment_container_layout, TrackListFragment.newInstance(item) ) + hide(this@HomeFragment) addToBackStack(null) } } diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index e29821b..6ea46ff 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -95,6 +95,20 @@ android:layout_width="match_parent" android:layout_height="match_parent"> + + + + + - - - - - From 1d3cb318f0e53051528054769f9436b8909c2086 Mon Sep 17 00:00:00 2001 From: beomjo Date: Tue, 6 Jul 2021 03:27:18 +0900 Subject: [PATCH 28/31] =?UTF-8?q?bugfix:=20=EC=84=B8=ED=8C=85=ED=99=94?= =?UTF-8?q?=EB=A9=B4=20=EC=9D=B4=EB=8F=99=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt b/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt index 881635b..d516f2f 100644 --- a/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt +++ b/app/src/main/java/com/beomjo/whitenoise/ui/main/home/HomeFragment.kt @@ -67,10 +67,11 @@ class HomeFragment : BaseFragment( fun moveToSettingFragment() { parentFragmentManager.commit { - replace( + add( R.id.fragment_container_layout, SettingFragment.newInstance() ) + hide(this@HomeFragment) addToBackStack(null) } } From 4bfedbdc2bb09113bd4489dd5cc673b58040d143 Mon Sep 17 00:00:00 2001 From: beomjo Date: Tue, 6 Jul 2021 23:43:15 +0900 Subject: [PATCH 29/31] chore: Version Update --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index ca4ce1d..c087c12 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -26,7 +26,7 @@ android { minSdkVersion versions.min_sdk_version targetSdkVersion versions.target_sdk_version versionCode 1 - versionName "1.0.0" + versionName "1.0.1" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } From 111e0a8bdd8fe335f8acf64dad74eff91c704f7e Mon Sep 17 00:00:00 2001 From: beomjo Date: Wed, 7 Jul 2021 01:03:29 +0900 Subject: [PATCH 30/31] =?UTF-8?q?build:=20Version=20Property=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 36 +++++++++++++++++++++++++++++++++-- app/config/version.properties | 2 ++ 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 app/config/version.properties diff --git a/app/build.gradle b/app/build.gradle index c087c12..019d389 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,6 +9,35 @@ plugins { id 'dagger.hilt.android.plugin' } +class Version { + static final String FILE_NAME = 'version.properties' + int code + String name +} + +def loadConfigFile(String fileName) { + String projPath = getProjectDir().getPath() + "/config" + Properties prop = new Properties() + FileInputStream fis + try { + fis = new FileInputStream(projPath + "/" + fileName) + prop.load(fis) + } catch (IOException e) { + System.out.println(e.toString()) + } + return prop +} + +def getVersionProperty() { + Properties prop = loadConfigFile(Version.FILE_NAME) + + Version version = new Version() + version.code = prop.getProperty("version.code", "1").toInteger() + version.name = prop.getProperty("version.name", "1") + + return version +} + android { signingConfigs { upload { @@ -18,15 +47,18 @@ android { storeFile file('../keystore/upload-key.jks') } } + compileSdkVersion versions.compile_sdk_version buildToolsVersion versions.build_tool_version + Version version = getVersionProperty() + defaultConfig { applicationId "com.beomjo.whitenoise" minSdkVersion versions.min_sdk_version targetSdkVersion versions.target_sdk_version - versionCode 1 - versionName "1.0.1" + versionCode version.code + versionName version.name testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/config/version.properties b/app/config/version.properties new file mode 100644 index 0000000..a0e2c5d --- /dev/null +++ b/app/config/version.properties @@ -0,0 +1,2 @@ +version.code=2021070901 +version.name=1.0.1 From b72866e2bc5d5a39c9bbdadeb8af9d583aa51c74 Mon Sep 17 00:00:00 2001 From: beomjo Date: Wed, 7 Jul 2021 01:09:22 +0900 Subject: [PATCH 31/31] =?UTF-8?q?docs:=20README.md=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 - android-compilation | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 18b4138..9a0897f 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,6 @@ You can hear sounds that can help you study, concentrate, and sleep. - Architecture - MVVM Architecture (View - DataBinding - ViewModel - Model) - Repository pattern - - [Dagger 2](https://dagger.dev/dev-guide) - dependency injection. - [Dagger Hilt](https://dagger.dev/hilt/) - dependency injection. - Firebase - FireStore, Storage - [Glide](https://github.com/bumptech/glide) - loading images. diff --git a/android-compilation b/android-compilation index ff65d4b..918aee4 160000 --- a/android-compilation +++ b/android-compilation @@ -1 +1 @@ -Subproject commit ff65d4b6f981cd050f6f72f972eacc92faedeeda +Subproject commit 918aee4fecba4290525ee216441d59c800c755f6