From 95526a0541839c23633c4cc3a603925565d195f7 Mon Sep 17 00:00:00 2001 From: KDW03 Date: Wed, 15 Feb 2023 22:38:46 +0900 Subject: [PATCH] =?UTF-8?q?MIN-49]=20feat:=20story=20=EC=A4=91=EC=B2=A9=20?= =?UTF-8?q?=EB=A6=AC=EC=82=AC=EC=9D=B4=ED=81=B4=EB=9F=AC=EB=B7=B0=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84(#23)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/najudoryeong/mineme/MainActivity.kt | 3 - .../com/najudoryeong/mineme/MainViewModel.kt | 2 - .../najudoryeong/mineme/MineMeApplication.kt | 4 +- .../mineme/common_ui/MainActivityUtil.kt | 2 - .../common_ui/RecyclerViewBindingAdapter.kt | 3 +- common/build.gradle | 3 + .../common/ExampleInstrumentedTest.kt | 2 +- .../example/common/data/dto/HomeResponse.kt | 8 -- .../example/common/data/dto/LoginResponse.kt | 8 -- .../common/data/dto/StoryListResponse.kt | 8 -- .../common/data/entity/StoryWithDate.kt | 7 -- .../common/data/source/StoryService.kt | 13 --- .../mineme}/common/data/dto/CodeRequest.kt | 2 +- .../mineme/common/data/dto/CommonResponse.kt | 6 + .../mineme}/common/data/dto/LoginRequest.kt | 2 +- .../mineme/common/data/dto/LoginResponse.kt | 8 ++ .../mineme}/common/data/dto/NullResponse.kt | 2 +- .../common/data/dto/UserInfoRequest.kt | 2 +- .../mineme}/common/data/entity/LoginData.kt | 2 +- .../common/data/entity/ProviderName.kt | 2 +- .../mineme}/common/data/source/AuthService.kt | 6 +- .../mineme}/common/data/source/UserService.kt | 17 +-- .../mineme}/common/di/DataStoreModule.kt | 4 +- .../mineme}/common/di/NetworkModule.kt | 15 +-- .../mineme/common/domain/entity/Story.kt | 4 +- .../common/domain/usecase/DataStoreUseCase.kt | 4 +- .../common/domain/usecase/UserUseCase.kt | 6 +- .../mineme}/common/util/Constant.kt | 2 +- .../common/ExampleUnitTest.kt | 2 +- .../foundation/ExampleInstrumentedTest.kt | 2 +- .../mineme}/foundation/di/NetworkModule.kt | 4 +- .../mineme}/foundation/util/Constant.kt | 2 +- .../foundation/ExampleUnitTest.kt | 2 +- home/build.gradle | 2 - .../mineme/home/data/HomeService.kt | 16 +++ .../mineme/home/di/NetworkModule.kt | 21 ++++ .../mineme/home/domain}/entity/HomeData.kt | 12 +- .../mineme/home/domain/usecase/HomeUseCase.kt | 16 +++ .../mineme/home/{ => ui}/HomeFragment.kt | 7 +- .../mineme/home/{ => ui}/HomeViewModel.kt | 27 ++--- .../mineme/home/{ => util}/FragmentObject.kt | 0 home/src/main/res/layout/fragment_home.xml | 4 +- home/src/main/res/navigation/nav_home.xml | 2 +- onboarding/src/main/AndroidManifest.xml | 2 +- .../mineme/onboarding/LoginUtil.kt | 2 +- .../onboarding/{ => ui}/InputCodeFragment.kt | 8 +- .../{ => ui}/InputUserInfoFragment.kt | 11 +- .../onboarding/{ => ui}/LoginFragment.kt | 8 +- .../{ => ui}/OnBoardingViewPagerFragment.kt | 9 +- .../onboarding/{ => ui}/SplashActivity.kt | 15 ++- .../onboarding/{ => ui}/SplashViewModel.kt | 17 +-- .../viewpagerfragment/OnBoarding1Fragment.kt | 2 +- .../viewpagerfragment/OnBoarding2Fragment.kt | 2 +- .../viewpagerfragment/OnBoarding3Fragment.kt | 2 +- .../src/main/res/layout/activity_splash.xml | 2 +- .../main/res/layout/fragment_input_code.xml | 2 +- .../src/main/res/layout/fragment_login.xml | 2 +- .../main/res/layout/fragment_on_boarding1.xml | 2 +- .../main/res/layout/fragment_on_boarding2.xml | 2 +- .../main/res/layout/fragment_on_boarding3.xml | 2 +- .../fragment_on_boarding_view_pager.xml | 2 +- .../main/res/navigation/nav_onboarding.xml | 8 +- .../mineme/story/StoryFragment.kt | 37 ------- .../{StoryAdapter.kt => StoryInAdapter.kt} | 28 +++-- .../mineme/story/StoryOutAdapter.kt | 67 +++++++++++ .../mineme/story/StoryViewModel.kt | 41 ------- .../mineme/story/data/StoryService.kt | 15 +++ .../mineme/story/di/NetworkModule.kt | 21 ++++ .../story/domain/entity/StoryListWithDate.kt | 9 ++ .../story/domain/usecase/StoryUseCase.kt | 14 +++ .../mineme/story/ui/StoryFragment.kt | 32 ++++++ .../mineme/story/ui/StoryViewModel.kt | 104 ++++++++++++++++++ .../mineme/story/{ => util}/FragmentObject.kt | 6 +- story/src/main/res/layout/fragment_story.xml | 26 +++-- .../{test_story.xml => item_story_in.xml} | 19 ++-- story/src/main/res/layout/item_story_out.xml | 38 +++++++ story/src/main/res/navigation/nav_story.xml | 2 +- 77 files changed, 516 insertions(+), 309 deletions(-) rename common/src/androidTest/java/com/{example => najudoryeong}/common/ExampleInstrumentedTest.kt (95%) delete mode 100644 common/src/main/java/com/example/common/data/dto/HomeResponse.kt delete mode 100644 common/src/main/java/com/example/common/data/dto/LoginResponse.kt delete mode 100644 common/src/main/java/com/example/common/data/dto/StoryListResponse.kt delete mode 100644 common/src/main/java/com/example/common/data/entity/StoryWithDate.kt delete mode 100644 common/src/main/java/com/example/common/data/source/StoryService.kt rename common/src/main/java/com/{example => najudoryeong/mineme}/common/data/dto/CodeRequest.kt (50%) create mode 100644 common/src/main/java/com/najudoryeong/mineme/common/data/dto/CommonResponse.kt rename common/src/main/java/com/{example => najudoryeong/mineme}/common/data/dto/LoginRequest.kt (69%) create mode 100644 common/src/main/java/com/najudoryeong/mineme/common/data/dto/LoginResponse.kt rename common/src/main/java/com/{example => najudoryeong/mineme}/common/data/dto/NullResponse.kt (60%) rename common/src/main/java/com/{example => najudoryeong/mineme}/common/data/dto/UserInfoRequest.kt (62%) rename common/src/main/java/com/{example => najudoryeong/mineme}/common/data/entity/LoginData.kt (56%) rename common/src/main/java/com/{example => najudoryeong/mineme}/common/data/entity/ProviderName.kt (57%) rename common/src/main/java/com/{example => najudoryeong/mineme}/common/data/source/AuthService.kt (51%) rename common/src/main/java/com/{example => najudoryeong/mineme}/common/data/source/UserService.kt (54%) rename common/src/main/java/com/{example => najudoryeong/mineme}/common/di/DataStoreModule.kt (87%) rename common/src/main/java/com/{example => najudoryeong/mineme}/common/di/NetworkModule.kt (60%) rename story/src/main/java/com/najudoryeong/mineme/story/StoryModel.kt => common/src/main/java/com/najudoryeong/mineme/common/domain/entity/Story.kt (58%) rename common/src/main/java/com/{example => najudoryeong/mineme}/common/domain/usecase/DataStoreUseCase.kt (93%) rename common/src/main/java/com/{example => najudoryeong/mineme}/common/domain/usecase/UserUseCase.kt (62%) rename common/src/main/java/com/{example => najudoryeong/mineme}/common/util/Constant.kt (58%) rename common/src/test/java/com/{example => najudoryeong}/common/ExampleUnitTest.kt (90%) rename foundation/src/androidTest/java/com/{example => najudoryeong}/foundation/ExampleInstrumentedTest.kt (94%) rename foundation/src/main/java/com/{example => najudoryeong/mineme}/foundation/di/NetworkModule.kt (90%) rename foundation/src/main/java/com/{example => najudoryeong/mineme}/foundation/util/Constant.kt (52%) rename foundation/src/test/java/com/{example => najudoryeong}/foundation/ExampleUnitTest.kt (89%) create mode 100644 home/src/main/java/com/najudoryeong/mineme/home/data/HomeService.kt create mode 100644 home/src/main/java/com/najudoryeong/mineme/home/di/NetworkModule.kt rename {common/src/main/java/com/example/common/data => home/src/main/java/com/najudoryeong/mineme/home/domain}/entity/HomeData.kt (75%) create mode 100644 home/src/main/java/com/najudoryeong/mineme/home/domain/usecase/HomeUseCase.kt rename home/src/main/java/com/najudoryeong/mineme/home/{ => ui}/HomeFragment.kt (87%) rename home/src/main/java/com/najudoryeong/mineme/home/{ => ui}/HomeViewModel.kt (58%) rename home/src/main/java/com/najudoryeong/mineme/home/{ => util}/FragmentObject.kt (100%) rename onboarding/src/main/java/com/najudoryeong/mineme/onboarding/{ => ui}/InputCodeFragment.kt (81%) rename onboarding/src/main/java/com/najudoryeong/mineme/onboarding/{ => ui}/InputUserInfoFragment.kt (76%) rename onboarding/src/main/java/com/najudoryeong/mineme/onboarding/{ => ui}/LoginFragment.kt (78%) rename onboarding/src/main/java/com/najudoryeong/mineme/onboarding/{ => ui}/OnBoardingViewPagerFragment.kt (91%) rename onboarding/src/main/java/com/najudoryeong/mineme/onboarding/{ => ui}/SplashActivity.kt (81%) rename onboarding/src/main/java/com/najudoryeong/mineme/onboarding/{ => ui}/SplashViewModel.kt (82%) rename onboarding/src/main/java/com/najudoryeong/mineme/onboarding/{ => ui}/viewpagerfragment/OnBoarding1Fragment.kt (95%) rename onboarding/src/main/java/com/najudoryeong/mineme/onboarding/{ => ui}/viewpagerfragment/OnBoarding2Fragment.kt (93%) rename onboarding/src/main/java/com/najudoryeong/mineme/onboarding/{ => ui}/viewpagerfragment/OnBoarding3Fragment.kt (93%) delete mode 100644 story/src/main/java/com/najudoryeong/mineme/story/StoryFragment.kt rename story/src/main/java/com/najudoryeong/mineme/story/{StoryAdapter.kt => StoryInAdapter.kt} (59%) create mode 100644 story/src/main/java/com/najudoryeong/mineme/story/StoryOutAdapter.kt delete mode 100644 story/src/main/java/com/najudoryeong/mineme/story/StoryViewModel.kt create mode 100644 story/src/main/java/com/najudoryeong/mineme/story/data/StoryService.kt create mode 100644 story/src/main/java/com/najudoryeong/mineme/story/di/NetworkModule.kt create mode 100644 story/src/main/java/com/najudoryeong/mineme/story/domain/entity/StoryListWithDate.kt create mode 100644 story/src/main/java/com/najudoryeong/mineme/story/domain/usecase/StoryUseCase.kt create mode 100644 story/src/main/java/com/najudoryeong/mineme/story/ui/StoryFragment.kt create mode 100644 story/src/main/java/com/najudoryeong/mineme/story/ui/StoryViewModel.kt rename story/src/main/java/com/najudoryeong/mineme/story/{ => util}/FragmentObject.kt (74%) rename story/src/main/res/layout/{test_story.xml => item_story_in.xml} (78%) create mode 100644 story/src/main/res/layout/item_story_out.xml diff --git a/app/src/main/java/com/najudoryeong/mineme/MainActivity.kt b/app/src/main/java/com/najudoryeong/mineme/MainActivity.kt index 7091cbd..c85da26 100644 --- a/app/src/main/java/com/najudoryeong/mineme/MainActivity.kt +++ b/app/src/main/java/com/najudoryeong/mineme/MainActivity.kt @@ -3,13 +3,10 @@ package com.najudoryeong.mineme import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.view.View -import android.view.WindowManager import androidx.activity.viewModels import androidx.databinding.DataBindingUtil -import androidx.fragment.app.Fragment import androidx.navigation.NavController import androidx.navigation.fragment.NavHostFragment -import androidx.navigation.fragment.findNavController import androidx.navigation.ui.AppBarConfiguration import androidx.navigation.ui.NavigationUI import androidx.navigation.ui.setupWithNavController diff --git a/app/src/main/java/com/najudoryeong/mineme/MainViewModel.kt b/app/src/main/java/com/najudoryeong/mineme/MainViewModel.kt index 8bf586b..a4827d0 100644 --- a/app/src/main/java/com/najudoryeong/mineme/MainViewModel.kt +++ b/app/src/main/java/com/najudoryeong/mineme/MainViewModel.kt @@ -1,7 +1,5 @@ package com.najudoryeong.mineme -import androidx.lifecycle.LiveData -import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel diff --git a/app/src/main/java/com/najudoryeong/mineme/MineMeApplication.kt b/app/src/main/java/com/najudoryeong/mineme/MineMeApplication.kt index 5502347..ec7fa45 100644 --- a/app/src/main/java/com/najudoryeong/mineme/MineMeApplication.kt +++ b/app/src/main/java/com/najudoryeong/mineme/MineMeApplication.kt @@ -2,7 +2,7 @@ package com.najudoryeong.mineme import android.app.Application import android.util.Log -import com.example.common.util.NATIVE_APP_KEY +import com.najudoryeong.mineme.common.util.NATIVE_APP_KEY import com.kakao.sdk.common.KakaoSdk import com.kakao.sdk.common.util.Utility import dagger.hilt.android.HiltAndroidApp @@ -12,7 +12,7 @@ class MineMeApplication : Application() { override fun onCreate() { super.onCreate() KakaoSdk.init(this, NATIVE_APP_KEY) - //printAppKeyHash() + printAppKeyHash() } private fun printAppKeyHash() { diff --git a/common-ui/src/main/java/com/najudoryeong/mineme/common_ui/MainActivityUtil.kt b/common-ui/src/main/java/com/najudoryeong/mineme/common_ui/MainActivityUtil.kt index 18613b8..d422180 100644 --- a/common-ui/src/main/java/com/najudoryeong/mineme/common_ui/MainActivityUtil.kt +++ b/common-ui/src/main/java/com/najudoryeong/mineme/common_ui/MainActivityUtil.kt @@ -1,7 +1,5 @@ package com.najudoryeong.mineme.common_ui -import androidx.fragment.app.Fragment - interface MainActivityUtil{ fun setToolbarTitle(newTitle: String) fun setVisibilityBottomAppbar(visibilityMode : Int) diff --git a/common-ui/src/main/java/com/najudoryeong/mineme/common_ui/RecyclerViewBindingAdapter.kt b/common-ui/src/main/java/com/najudoryeong/mineme/common_ui/RecyclerViewBindingAdapter.kt index 54d3d49..04e9874 100644 --- a/common-ui/src/main/java/com/najudoryeong/mineme/common_ui/RecyclerViewBindingAdapter.kt +++ b/common-ui/src/main/java/com/najudoryeong/mineme/common_ui/RecyclerViewBindingAdapter.kt @@ -10,4 +10,5 @@ fun bindRecyclerView(view: RecyclerView, adapter: RecyclerView.Adapter<*>, submi stateRestorationPolicy = RecyclerView.Adapter.StateRestorationPolicy.PREVENT_WHEN_EMPTY (this as ListAdapter).submitList(submitList?.toMutableList()) } -} \ No newline at end of file +} + diff --git a/common/build.gradle b/common/build.gradle index 33da4fd..07d8fef 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -32,6 +32,9 @@ android { kotlinOptions { jvmTarget = '1.8' } + buildFeatures { + dataBinding true + } } dependencies { diff --git a/common/src/androidTest/java/com/example/common/ExampleInstrumentedTest.kt b/common/src/androidTest/java/com/najudoryeong/common/ExampleInstrumentedTest.kt similarity index 95% rename from common/src/androidTest/java/com/example/common/ExampleInstrumentedTest.kt rename to common/src/androidTest/java/com/najudoryeong/common/ExampleInstrumentedTest.kt index 0886bf6..6f6b0a8 100644 --- a/common/src/androidTest/java/com/example/common/ExampleInstrumentedTest.kt +++ b/common/src/androidTest/java/com/najudoryeong/common/ExampleInstrumentedTest.kt @@ -1,4 +1,4 @@ -package com.example.common +package com.najudoryeong.common import androidx.test.platform.app.InstrumentationRegistry import androidx.test.ext.junit.runners.AndroidJUnit4 diff --git a/common/src/main/java/com/example/common/data/dto/HomeResponse.kt b/common/src/main/java/com/example/common/data/dto/HomeResponse.kt deleted file mode 100644 index a918119..0000000 --- a/common/src/main/java/com/example/common/data/dto/HomeResponse.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.example.common.data.dto - -import com.example.common.data.entity.HomeData - -data class HomeResponse( - val data: HomeData, - val success: Boolean -) \ No newline at end of file diff --git a/common/src/main/java/com/example/common/data/dto/LoginResponse.kt b/common/src/main/java/com/example/common/data/dto/LoginResponse.kt deleted file mode 100644 index 249dc22..0000000 --- a/common/src/main/java/com/example/common/data/dto/LoginResponse.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.example.common.data.dto - -import com.example.common.data.entity.LoginData - -data class LoginResponse( - val success: Boolean, - val data: LoginData -) \ No newline at end of file diff --git a/common/src/main/java/com/example/common/data/dto/StoryListResponse.kt b/common/src/main/java/com/example/common/data/dto/StoryListResponse.kt deleted file mode 100644 index 37bed55..0000000 --- a/common/src/main/java/com/example/common/data/dto/StoryListResponse.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.example.common.data.dto - -import com.example.common.data.entity.StoryWithDate - -data class StoryListResponse( - val success: Boolean, - val data: List -) \ No newline at end of file diff --git a/common/src/main/java/com/example/common/data/entity/StoryWithDate.kt b/common/src/main/java/com/example/common/data/entity/StoryWithDate.kt deleted file mode 100644 index 2afbfc2..0000000 --- a/common/src/main/java/com/example/common/data/entity/StoryWithDate.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.example.common.data.entity - -data class StoryWithDate( - val year : String, - val month : String, - val posts : List -) \ No newline at end of file diff --git a/common/src/main/java/com/example/common/data/source/StoryService.kt b/common/src/main/java/com/example/common/data/source/StoryService.kt deleted file mode 100644 index 35464d1..0000000 --- a/common/src/main/java/com/example/common/data/source/StoryService.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.example.common.data.source - -import com.example.common.data.dto.StoryListResponse -import retrofit2.http.GET -import retrofit2.http.Header - -interface StoryService { - @GET("api/v1/story/list") - suspend fun getStoryList( - @Header("Authorization") token: String, - ) : StoryListResponse - -} \ No newline at end of file diff --git a/common/src/main/java/com/example/common/data/dto/CodeRequest.kt b/common/src/main/java/com/najudoryeong/mineme/common/data/dto/CodeRequest.kt similarity index 50% rename from common/src/main/java/com/example/common/data/dto/CodeRequest.kt rename to common/src/main/java/com/najudoryeong/mineme/common/data/dto/CodeRequest.kt index 557aeeb..1645044 100644 --- a/common/src/main/java/com/example/common/data/dto/CodeRequest.kt +++ b/common/src/main/java/com/najudoryeong/mineme/common/data/dto/CodeRequest.kt @@ -1,4 +1,4 @@ -package com.example.common.data.dto +package com.najudoryeong.mineme.common.data.dto data class CodeRequest( val code : String diff --git a/common/src/main/java/com/najudoryeong/mineme/common/data/dto/CommonResponse.kt b/common/src/main/java/com/najudoryeong/mineme/common/data/dto/CommonResponse.kt new file mode 100644 index 0000000..d9ae1a4 --- /dev/null +++ b/common/src/main/java/com/najudoryeong/mineme/common/data/dto/CommonResponse.kt @@ -0,0 +1,6 @@ +package com.najudoryeong.mineme.common.data.dto + +data class CommonResponse( + val data: T, + val success: Boolean +) diff --git a/common/src/main/java/com/example/common/data/dto/LoginRequest.kt b/common/src/main/java/com/najudoryeong/mineme/common/data/dto/LoginRequest.kt similarity index 69% rename from common/src/main/java/com/example/common/data/dto/LoginRequest.kt rename to common/src/main/java/com/najudoryeong/mineme/common/data/dto/LoginRequest.kt index 177ab77..21aaf25 100644 --- a/common/src/main/java/com/example/common/data/dto/LoginRequest.kt +++ b/common/src/main/java/com/najudoryeong/mineme/common/data/dto/LoginRequest.kt @@ -1,4 +1,4 @@ -package com.example.common.data.dto +package com.najudoryeong.mineme.common.data.dto data class LoginRequest( val accessToken: String, diff --git a/common/src/main/java/com/najudoryeong/mineme/common/data/dto/LoginResponse.kt b/common/src/main/java/com/najudoryeong/mineme/common/data/dto/LoginResponse.kt new file mode 100644 index 0000000..97e4163 --- /dev/null +++ b/common/src/main/java/com/najudoryeong/mineme/common/data/dto/LoginResponse.kt @@ -0,0 +1,8 @@ +package com.najudoryeong.mineme.common.data.dto + +import com.najudoryeong.mineme.common.data.entity.LoginData + +data class LoginResponse( + val success: Boolean, + val data: LoginData +) \ No newline at end of file diff --git a/common/src/main/java/com/example/common/data/dto/NullResponse.kt b/common/src/main/java/com/najudoryeong/mineme/common/data/dto/NullResponse.kt similarity index 60% rename from common/src/main/java/com/example/common/data/dto/NullResponse.kt rename to common/src/main/java/com/najudoryeong/mineme/common/data/dto/NullResponse.kt index 7ea3135..15e32ae 100644 --- a/common/src/main/java/com/example/common/data/dto/NullResponse.kt +++ b/common/src/main/java/com/najudoryeong/mineme/common/data/dto/NullResponse.kt @@ -1,4 +1,4 @@ -package com.example.common.data.dto +package com.najudoryeong.mineme.common.data.dto data class NullResponse( val success: Boolean, diff --git a/common/src/main/java/com/example/common/data/dto/UserInfoRequest.kt b/common/src/main/java/com/najudoryeong/mineme/common/data/dto/UserInfoRequest.kt similarity index 62% rename from common/src/main/java/com/example/common/data/dto/UserInfoRequest.kt rename to common/src/main/java/com/najudoryeong/mineme/common/data/dto/UserInfoRequest.kt index 4ac4985..1d88045 100644 --- a/common/src/main/java/com/example/common/data/dto/UserInfoRequest.kt +++ b/common/src/main/java/com/najudoryeong/mineme/common/data/dto/UserInfoRequest.kt @@ -1,4 +1,4 @@ -package com.example.common.data.dto +package com.najudoryeong.mineme.common.data.dto data class UserInfoRequest( val nickname: String, diff --git a/common/src/main/java/com/example/common/data/entity/LoginData.kt b/common/src/main/java/com/najudoryeong/mineme/common/data/entity/LoginData.kt similarity index 56% rename from common/src/main/java/com/example/common/data/entity/LoginData.kt rename to common/src/main/java/com/najudoryeong/mineme/common/data/entity/LoginData.kt index 22420d5..7a6af3a 100644 --- a/common/src/main/java/com/example/common/data/entity/LoginData.kt +++ b/common/src/main/java/com/najudoryeong/mineme/common/data/entity/LoginData.kt @@ -1,4 +1,4 @@ -package com.example.common.data.entity +package com.najudoryeong.mineme.common.data.entity data class LoginData( val jwt: String, diff --git a/common/src/main/java/com/example/common/data/entity/ProviderName.kt b/common/src/main/java/com/najudoryeong/mineme/common/data/entity/ProviderName.kt similarity index 57% rename from common/src/main/java/com/example/common/data/entity/ProviderName.kt rename to common/src/main/java/com/najudoryeong/mineme/common/data/entity/ProviderName.kt index 89a9288..4ed76f9 100644 --- a/common/src/main/java/com/example/common/data/entity/ProviderName.kt +++ b/common/src/main/java/com/najudoryeong/mineme/common/data/entity/ProviderName.kt @@ -1,4 +1,4 @@ -package com.example.common.data.entity +package com.najudoryeong.mineme.common.data.entity enum class ProviderType(providerType: String) { KAKAO("KAKAO") diff --git a/common/src/main/java/com/example/common/data/source/AuthService.kt b/common/src/main/java/com/najudoryeong/mineme/common/data/source/AuthService.kt similarity index 51% rename from common/src/main/java/com/example/common/data/source/AuthService.kt rename to common/src/main/java/com/najudoryeong/mineme/common/data/source/AuthService.kt index 55a82c3..e80ec17 100644 --- a/common/src/main/java/com/example/common/data/source/AuthService.kt +++ b/common/src/main/java/com/najudoryeong/mineme/common/data/source/AuthService.kt @@ -1,7 +1,7 @@ -package com.example.common.data.source +package com.najudoryeong.mineme.common.data.source -import com.example.common.data.dto.LoginRequest -import com.example.common.data.dto.LoginResponse +import com.najudoryeong.mineme.common.data.dto.LoginRequest +import com.najudoryeong.mineme.common.data.dto.LoginResponse import retrofit2.http.Body import retrofit2.http.POST diff --git a/common/src/main/java/com/example/common/data/source/UserService.kt b/common/src/main/java/com/najudoryeong/mineme/common/data/source/UserService.kt similarity index 54% rename from common/src/main/java/com/example/common/data/source/UserService.kt rename to common/src/main/java/com/najudoryeong/mineme/common/data/source/UserService.kt index 9176de6..232785e 100644 --- a/common/src/main/java/com/example/common/data/source/UserService.kt +++ b/common/src/main/java/com/najudoryeong/mineme/common/data/source/UserService.kt @@ -1,11 +1,9 @@ -package com.example.common.data.source +package com.najudoryeong.mineme.common.data.source -import com.example.common.data.dto.CodeRequest -import com.example.common.data.dto.HomeResponse -import com.example.common.data.dto.UserInfoRequest -import com.example.common.data.dto.NullResponse +import com.najudoryeong.mineme.common.data.dto.CodeRequest +import com.najudoryeong.mineme.common.data.dto.UserInfoRequest +import com.najudoryeong.mineme.common.data.dto.NullResponse import retrofit2.http.Body -import retrofit2.http.GET import retrofit2.http.Header import retrofit2.http.POST @@ -24,11 +22,4 @@ interface UserService { @Body userCodeRequest: CodeRequest ): NullResponse - - @GET("api/test/main/info") - suspend fun getHomeInfo( - @Header("Authorization") token: String, - ): HomeResponse - - } \ No newline at end of file diff --git a/common/src/main/java/com/example/common/di/DataStoreModule.kt b/common/src/main/java/com/najudoryeong/mineme/common/di/DataStoreModule.kt similarity index 87% rename from common/src/main/java/com/example/common/di/DataStoreModule.kt rename to common/src/main/java/com/najudoryeong/mineme/common/di/DataStoreModule.kt index 0063ed8..f87a946 100644 --- a/common/src/main/java/com/example/common/di/DataStoreModule.kt +++ b/common/src/main/java/com/najudoryeong/mineme/common/di/DataStoreModule.kt @@ -1,10 +1,10 @@ -package com.example.common.di +package com.najudoryeong.mineme.common.di import android.content.Context import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.preferencesDataStore -import com.example.common.domain.usecase.DataStoreUseCase +import com.najudoryeong.mineme.common.domain.usecase.DataStoreUseCase import dagger.Module import dagger.Provides import dagger.hilt.InstallIn diff --git a/common/src/main/java/com/example/common/di/NetworkModule.kt b/common/src/main/java/com/najudoryeong/mineme/common/di/NetworkModule.kt similarity index 60% rename from common/src/main/java/com/example/common/di/NetworkModule.kt rename to common/src/main/java/com/najudoryeong/mineme/common/di/NetworkModule.kt index f906878..376b3ce 100644 --- a/common/src/main/java/com/example/common/di/NetworkModule.kt +++ b/common/src/main/java/com/najudoryeong/mineme/common/di/NetworkModule.kt @@ -1,14 +1,12 @@ -package com.example.common.di +package com.najudoryeong.mineme.common.di -import com.example.common.data.source.AuthService -import com.example.common.data.source.StoryService -import com.example.common.data.source.UserService +import com.najudoryeong.mineme.common.data.source.AuthService +import com.najudoryeong.mineme.common.data.source.UserService import dagger.Module import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent import retrofit2.Retrofit -import retrofit2.create import javax.inject.Singleton @Module @@ -27,11 +25,4 @@ class NetworkModule { return retrofit.create(UserService::class.java) } - - @Singleton - @Provides - fun provideStoryService(retrofit: Retrofit): StoryService { - return retrofit.create(StoryService::class.java) - } - } \ No newline at end of file diff --git a/story/src/main/java/com/najudoryeong/mineme/story/StoryModel.kt b/common/src/main/java/com/najudoryeong/mineme/common/domain/entity/Story.kt similarity index 58% rename from story/src/main/java/com/najudoryeong/mineme/story/StoryModel.kt rename to common/src/main/java/com/najudoryeong/mineme/common/domain/entity/Story.kt index 63c4688..51f365e 100644 --- a/story/src/main/java/com/najudoryeong/mineme/story/StoryModel.kt +++ b/common/src/main/java/com/najudoryeong/mineme/common/domain/entity/Story.kt @@ -1,6 +1,6 @@ -package com.najudoryeong.mineme.story +package com.najudoryeong.mineme.common.domain.entity -data class StoryModel( +data class Story( val date: String, val postId: Int, val region: String, diff --git a/common/src/main/java/com/example/common/domain/usecase/DataStoreUseCase.kt b/common/src/main/java/com/najudoryeong/mineme/common/domain/usecase/DataStoreUseCase.kt similarity index 93% rename from common/src/main/java/com/example/common/domain/usecase/DataStoreUseCase.kt rename to common/src/main/java/com/najudoryeong/mineme/common/domain/usecase/DataStoreUseCase.kt index 2e577ee..cf7f389 100644 --- a/common/src/main/java/com/example/common/domain/usecase/DataStoreUseCase.kt +++ b/common/src/main/java/com/najudoryeong/mineme/common/domain/usecase/DataStoreUseCase.kt @@ -1,5 +1,6 @@ -package com.example.common.domain.usecase +package com.najudoryeong.mineme.common.domain.usecase +import android.util.Log import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.intPreferencesKey @@ -30,6 +31,7 @@ class DataStoreUseCase @Inject constructor( suspend fun editJsonWebToken(jwt: String) { dataStore.edit { + Log.d("test", "edijwt") it[jsonWebToken_key] = jwt } } diff --git a/common/src/main/java/com/example/common/domain/usecase/UserUseCase.kt b/common/src/main/java/com/najudoryeong/mineme/common/domain/usecase/UserUseCase.kt similarity index 62% rename from common/src/main/java/com/example/common/domain/usecase/UserUseCase.kt rename to common/src/main/java/com/najudoryeong/mineme/common/domain/usecase/UserUseCase.kt index 852b0cd..f5ab5b8 100644 --- a/common/src/main/java/com/example/common/domain/usecase/UserUseCase.kt +++ b/common/src/main/java/com/najudoryeong/mineme/common/domain/usecase/UserUseCase.kt @@ -1,8 +1,6 @@ -package com.example.common.domain.usecase +package com.najudoryeong.mineme.common.domain.usecase -import com.example.common.data.dto.HomeResponse -import com.example.common.data.source.UserService -import kotlinx.coroutines.launch +import com.najudoryeong.mineme.common.data.source.UserService import javax.inject.Inject import javax.inject.Singleton diff --git a/common/src/main/java/com/example/common/util/Constant.kt b/common/src/main/java/com/najudoryeong/mineme/common/util/Constant.kt similarity index 58% rename from common/src/main/java/com/example/common/util/Constant.kt rename to common/src/main/java/com/najudoryeong/mineme/common/util/Constant.kt index f951182..7952321 100644 --- a/common/src/main/java/com/example/common/util/Constant.kt +++ b/common/src/main/java/com/najudoryeong/mineme/common/util/Constant.kt @@ -1,3 +1,3 @@ -package com.example.common.util +package com.najudoryeong.mineme.common.util const val NATIVE_APP_KEY = "5162225c94277a85e12566f227145303" \ No newline at end of file diff --git a/common/src/test/java/com/example/common/ExampleUnitTest.kt b/common/src/test/java/com/najudoryeong/common/ExampleUnitTest.kt similarity index 90% rename from common/src/test/java/com/example/common/ExampleUnitTest.kt rename to common/src/test/java/com/najudoryeong/common/ExampleUnitTest.kt index 6c9f3e0..5dfd46b 100644 --- a/common/src/test/java/com/example/common/ExampleUnitTest.kt +++ b/common/src/test/java/com/najudoryeong/common/ExampleUnitTest.kt @@ -1,4 +1,4 @@ -package com.example.common +package com.najudoryeong.common import org.junit.Test diff --git a/foundation/src/androidTest/java/com/example/foundation/ExampleInstrumentedTest.kt b/foundation/src/androidTest/java/com/najudoryeong/foundation/ExampleInstrumentedTest.kt similarity index 94% rename from foundation/src/androidTest/java/com/example/foundation/ExampleInstrumentedTest.kt rename to foundation/src/androidTest/java/com/najudoryeong/foundation/ExampleInstrumentedTest.kt index 8379c8f..aaf319f 100644 --- a/foundation/src/androidTest/java/com/example/foundation/ExampleInstrumentedTest.kt +++ b/foundation/src/androidTest/java/com/najudoryeong/foundation/ExampleInstrumentedTest.kt @@ -1,4 +1,4 @@ -package com.example.foundation +package com.najudoryeong.foundation import androidx.test.platform.app.InstrumentationRegistry import androidx.test.ext.junit.runners.AndroidJUnit4 diff --git a/foundation/src/main/java/com/example/foundation/di/NetworkModule.kt b/foundation/src/main/java/com/najudoryeong/mineme/foundation/di/NetworkModule.kt similarity index 90% rename from foundation/src/main/java/com/example/foundation/di/NetworkModule.kt rename to foundation/src/main/java/com/najudoryeong/mineme/foundation/di/NetworkModule.kt index 868a0d8..32108c3 100644 --- a/foundation/src/main/java/com/example/foundation/di/NetworkModule.kt +++ b/foundation/src/main/java/com/najudoryeong/mineme/foundation/di/NetworkModule.kt @@ -1,6 +1,6 @@ -package com.example.foundation.di +package com.najudoryeong.mineme.foundation.di -import com.example.foundation.util.BASE_URL +import com.najudoryeong.mineme.foundation.util.BASE_URL import dagger.Module import dagger.Provides import dagger.hilt.InstallIn diff --git a/foundation/src/main/java/com/example/foundation/util/Constant.kt b/foundation/src/main/java/com/najudoryeong/mineme/foundation/util/Constant.kt similarity index 52% rename from foundation/src/main/java/com/example/foundation/util/Constant.kt rename to foundation/src/main/java/com/najudoryeong/mineme/foundation/util/Constant.kt index 3fb9bfe..8600db9 100644 --- a/foundation/src/main/java/com/example/foundation/util/Constant.kt +++ b/foundation/src/main/java/com/najudoryeong/mineme/foundation/util/Constant.kt @@ -1,4 +1,4 @@ -package com.example.foundation.util +package com.najudoryeong.mineme.foundation.util const val BASE_URL = "http://13.125.67.47:18080/" diff --git a/foundation/src/test/java/com/example/foundation/ExampleUnitTest.kt b/foundation/src/test/java/com/najudoryeong/foundation/ExampleUnitTest.kt similarity index 89% rename from foundation/src/test/java/com/example/foundation/ExampleUnitTest.kt rename to foundation/src/test/java/com/najudoryeong/foundation/ExampleUnitTest.kt index 756bb8c..9f6738d 100644 --- a/foundation/src/test/java/com/example/foundation/ExampleUnitTest.kt +++ b/foundation/src/test/java/com/najudoryeong/foundation/ExampleUnitTest.kt @@ -1,4 +1,4 @@ -package com.example.foundation +package com.najudoryeong.foundation import org.junit.Test diff --git a/home/build.gradle b/home/build.gradle index 8f10e2d..3375255 100644 --- a/home/build.gradle +++ b/home/build.gradle @@ -40,12 +40,10 @@ dependencies { api project(path: ':common-ui') api project(path: ':common') - // Hilt implementation "com.google.dagger:hilt-android:$rootProject.hiltVersion" kapt "com.google.dagger:hilt-android-compiler:$rootProject.hiltVersion" - api project(path: ':common-ui') implementation 'androidx.core:core-ktx:1.9.0' implementation 'androidx.appcompat:appcompat:1.6.0' diff --git a/home/src/main/java/com/najudoryeong/mineme/home/data/HomeService.kt b/home/src/main/java/com/najudoryeong/mineme/home/data/HomeService.kt new file mode 100644 index 0000000..5d5bc4f --- /dev/null +++ b/home/src/main/java/com/najudoryeong/mineme/home/data/HomeService.kt @@ -0,0 +1,16 @@ +package com.najudoryeong.mineme.home.data + +import com.najudoryeong.mineme.common.data.dto.CommonResponse +import com.najudoryeong.mineme.home.domain.entity.HomeData +import retrofit2.http.GET +import retrofit2.http.Header + +interface HomeService { + + @GET("api/test/main/info") + suspend fun readHomeInfo( + @Header("Authorization") token: String, + ): CommonResponse + + +} \ No newline at end of file diff --git a/home/src/main/java/com/najudoryeong/mineme/home/di/NetworkModule.kt b/home/src/main/java/com/najudoryeong/mineme/home/di/NetworkModule.kt new file mode 100644 index 0000000..2b9ce98 --- /dev/null +++ b/home/src/main/java/com/najudoryeong/mineme/home/di/NetworkModule.kt @@ -0,0 +1,21 @@ +package com.najudoryeong.mineme.home.di + +import com.najudoryeong.mineme.home.data.HomeService +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import retrofit2.Retrofit +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +class NetworkModule { + + @Singleton + @Provides + fun provideHomeService(retrofit: Retrofit): HomeService { + return retrofit.create(HomeService::class.java) + } + +} \ No newline at end of file diff --git a/common/src/main/java/com/example/common/data/entity/HomeData.kt b/home/src/main/java/com/najudoryeong/mineme/home/domain/entity/HomeData.kt similarity index 75% rename from common/src/main/java/com/example/common/data/entity/HomeData.kt rename to home/src/main/java/com/najudoryeong/mineme/home/domain/entity/HomeData.kt index 8554b18..9dff144 100644 --- a/common/src/main/java/com/example/common/data/entity/HomeData.kt +++ b/home/src/main/java/com/najudoryeong/mineme/home/domain/entity/HomeData.kt @@ -1,6 +1,7 @@ -package com.example.common.data.entity +package com.najudoryeong.mineme.home.domain.entity + +import com.najudoryeong.mineme.common.domain.entity.Story -import com.kakao.sdk.user.model.User data class HomeData( val couple: Couple, @@ -17,12 +18,7 @@ data class Couple( ) -data class Story( - val date: String, - val postId: Int, - val region: String, - val thumbnailImage: String -) + data class UserInfo( diff --git a/home/src/main/java/com/najudoryeong/mineme/home/domain/usecase/HomeUseCase.kt b/home/src/main/java/com/najudoryeong/mineme/home/domain/usecase/HomeUseCase.kt new file mode 100644 index 0000000..a9ce706 --- /dev/null +++ b/home/src/main/java/com/najudoryeong/mineme/home/domain/usecase/HomeUseCase.kt @@ -0,0 +1,16 @@ +package com.najudoryeong.mineme.home.domain.usecase + + +import com.najudoryeong.mineme.home.data.HomeService +import com.najudoryeong.mineme.home.domain.entity.HomeData +import javax.inject.Inject + +class HomeUseCase @Inject constructor( + private val homeService: HomeService +) { + // response를 entity로 변경하는 mapper 역할까지 + suspend fun readHomeInfo(token: String): HomeData? { + val homeInfo = homeService.readHomeInfo(token) + return if (homeInfo.success) homeInfo.data else null + } +} \ No newline at end of file diff --git a/home/src/main/java/com/najudoryeong/mineme/home/HomeFragment.kt b/home/src/main/java/com/najudoryeong/mineme/home/ui/HomeFragment.kt similarity index 87% rename from home/src/main/java/com/najudoryeong/mineme/home/HomeFragment.kt rename to home/src/main/java/com/najudoryeong/mineme/home/ui/HomeFragment.kt index 433f8a8..0a74db2 100644 --- a/home/src/main/java/com/najudoryeong/mineme/home/HomeFragment.kt +++ b/home/src/main/java/com/najudoryeong/mineme/home/ui/HomeFragment.kt @@ -1,12 +1,9 @@ -package com.najudoryeong.mineme.home +package com.najudoryeong.mineme.home.ui -import android.os.Bundle -import android.view.View import androidx.activity.OnBackPressedCallback -import androidx.activity.viewModels import androidx.fragment.app.viewModels import com.najudoryeong.mineme.common_ui.BaseFragment -import com.najudoryeong.mineme.common_ui.MainActivityUtil +import com.najudoryeong.mineme.home.Home import com.najudoryeong.mineme.home.databinding.FragmentHomeBinding import dagger.hilt.android.AndroidEntryPoint diff --git a/home/src/main/java/com/najudoryeong/mineme/home/HomeViewModel.kt b/home/src/main/java/com/najudoryeong/mineme/home/ui/HomeViewModel.kt similarity index 58% rename from home/src/main/java/com/najudoryeong/mineme/home/HomeViewModel.kt rename to home/src/main/java/com/najudoryeong/mineme/home/ui/HomeViewModel.kt index 69a0baa..381b181 100644 --- a/home/src/main/java/com/najudoryeong/mineme/home/HomeViewModel.kt +++ b/home/src/main/java/com/najudoryeong/mineme/home/ui/HomeViewModel.kt @@ -1,17 +1,12 @@ -package com.najudoryeong.mineme.home +package com.najudoryeong.mineme.home.ui -import android.content.Context import android.util.Log -import androidx.databinding.Bindable import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.example.common.data.dto.HomeResponse -import com.example.common.data.entity.HomeData -import com.example.common.data.source.AuthService -import com.example.common.data.source.UserService -import com.example.common.domain.usecase.DataStoreUseCase +import com.najudoryeong.mineme.common.domain.usecase.DataStoreUseCase +import com.najudoryeong.mineme.home.domain.entity.HomeData +import com.najudoryeong.mineme.home.domain.usecase.HomeUseCase import dagger.hilt.android.lifecycle.HiltViewModel -import dagger.hilt.android.qualifiers.ApplicationContext import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.first @@ -20,8 +15,7 @@ import javax.inject.Inject @HiltViewModel class HomeViewModel @Inject constructor( - @ApplicationContext private val context: Context, - private val userService: UserService, + private val homeUseCase: HomeUseCase, private val dataStoreUseCase: DataStoreUseCase ) : ViewModel() { @@ -31,19 +25,16 @@ class HomeViewModel @Inject constructor( private val _homeData = MutableStateFlow(null) val homeData: StateFlow = _homeData - fun settingHomeData() { viewModelScope.launch { var jwt = dataStoreUseCase.bearerJsonWebToken.first() if (jwt == null) jwt = "bearer test" - userService.getHomeInfo(jwt).let { - if (it.success){ - Log.d("TESTAPI","API넣음") - if (it.data.newStory.postId == -1){ + homeUseCase.readHomeInfo(jwt).let { + if (it != null){ + if (it.newStory.postId == -1){ _isNewStory.value = true } - _homeData.value = it.data - + _homeData.value = it } else { Log.d("TESTAPI","API실패") } diff --git a/home/src/main/java/com/najudoryeong/mineme/home/FragmentObject.kt b/home/src/main/java/com/najudoryeong/mineme/home/util/FragmentObject.kt similarity index 100% rename from home/src/main/java/com/najudoryeong/mineme/home/FragmentObject.kt rename to home/src/main/java/com/najudoryeong/mineme/home/util/FragmentObject.kt diff --git a/home/src/main/res/layout/fragment_home.xml b/home/src/main/res/layout/fragment_home.xml index 814f833..aaeb5b2 100644 --- a/home/src/main/res/layout/fragment_home.xml +++ b/home/src/main/res/layout/fragment_home.xml @@ -10,7 +10,7 @@ + type="com.najudoryeong.mineme.home.ui.HomeViewModel" /> @@ -18,7 +18,7 @@ + tools:context=".ui.HomeFragment"> \ No newline at end of file diff --git a/onboarding/src/main/AndroidManifest.xml b/onboarding/src/main/AndroidManifest.xml index 06a6e6d..430bea6 100644 --- a/onboarding/src/main/AndroidManifest.xml +++ b/onboarding/src/main/AndroidManifest.xml @@ -5,7 +5,7 @@ diff --git a/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/LoginUtil.kt b/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/LoginUtil.kt index 5292be4..aebd0d6 100644 --- a/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/LoginUtil.kt +++ b/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/LoginUtil.kt @@ -25,7 +25,7 @@ class LoginUtil { context: Context, onLoginSuccess: (String?) -> Unit ) { - + Log.d("test","로그인시도") // 카카오계정으로 로그인 공통 callback 구성 // 카카오톡으로 로그인 할 수 없어 카카오계정으로 로그인할 경우 사용됨 val callback: (OAuthToken?, Throwable?) -> Unit = { token, error -> diff --git a/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/InputCodeFragment.kt b/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/InputCodeFragment.kt similarity index 81% rename from onboarding/src/main/java/com/najudoryeong/mineme/onboarding/InputCodeFragment.kt rename to onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/InputCodeFragment.kt index 0f1d51a..92fe94c 100644 --- a/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/InputCodeFragment.kt +++ b/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/InputCodeFragment.kt @@ -1,4 +1,4 @@ -package com.najudoryeong.mineme.onboarding +package com.najudoryeong.mineme.onboarding.ui import android.os.Bundle import androidx.fragment.app.Fragment @@ -6,9 +6,7 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.viewModels -import androidx.navigation.fragment.findNavController -import com.example.common.data.dto.CodeRequest -import com.najudoryeong.mineme.common_ui.MainActivityUtil +import com.najudoryeong.mineme.common.data.dto.CodeRequest import com.najudoryeong.mineme.onboarding.databinding.FragmentInputCodeBinding import dagger.hilt.android.AndroidEntryPoint @@ -37,7 +35,7 @@ class InputCodeFragment : Fragment() { binding.nextButton.setOnClickListener { viewModel.getJsonWebToken { JWT -> viewModel.inputCode( - JWT!!,CodeRequest(binding.code.text.toString()) + JWT!!, CodeRequest(binding.code.text.toString()) ){ (requireActivity() as SplashActivity).startHomeActivity() } diff --git a/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/InputUserInfoFragment.kt b/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/InputUserInfoFragment.kt similarity index 76% rename from onboarding/src/main/java/com/najudoryeong/mineme/onboarding/InputUserInfoFragment.kt rename to onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/InputUserInfoFragment.kt index f70360d..90c1a85 100644 --- a/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/InputUserInfoFragment.kt +++ b/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/InputUserInfoFragment.kt @@ -1,4 +1,4 @@ -package com.najudoryeong.mineme.onboarding +package com.najudoryeong.mineme.onboarding.ui import android.os.Bundle import androidx.fragment.app.Fragment @@ -7,10 +7,9 @@ import android.view.View import android.view.ViewGroup import androidx.fragment.app.viewModels import androidx.navigation.fragment.findNavController -import com.example.common.data.dto.UserInfoRequest -import com.najudoryeong.mineme.common_ui.MainActivityUtil +import com.najudoryeong.mineme.common.data.dto.UserInfoRequest +import com.najudoryeong.mineme.onboarding.R import com.najudoryeong.mineme.onboarding.databinding.FragmentInputUserInfoBinding -import com.najudoryeong.mineme.onboarding.databinding.FragmentLoginBinding import dagger.hilt.android.AndroidEntryPoint @AndroidEntryPoint @@ -33,7 +32,9 @@ class InputUserInfoFragment : Fragment() { super.onViewCreated(view, savedInstanceState) binding.nextButton.setOnClickListener { viewModel.getJsonWebToken { JWT -> - viewModel.inputUserInfo(JWT!!,UserInfoRequest(binding.userName.text.toString(),binding.userBirthDay.text.toString())){ + viewModel.inputUserInfo(JWT!!, + UserInfoRequest(binding.userName.text.toString(),binding.userBirthDay.text.toString()) + ){ findNavController().navigate(R.id.next) } } diff --git a/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/LoginFragment.kt b/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/LoginFragment.kt similarity index 78% rename from onboarding/src/main/java/com/najudoryeong/mineme/onboarding/LoginFragment.kt rename to onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/LoginFragment.kt index 96dc472..f7c2420 100644 --- a/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/LoginFragment.kt +++ b/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/LoginFragment.kt @@ -1,18 +1,12 @@ -package com.najudoryeong.mineme.onboarding +package com.najudoryeong.mineme.onboarding.ui import android.os.Bundle -import android.util.Log import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.activity.OnBackPressedCallback -import androidx.activity.addCallback -import androidx.navigation.fragment.findNavController -import com.najudoryeong.mineme.common_ui.MainActivityUtil -import com.najudoryeong.mineme.onboarding.R import com.najudoryeong.mineme.onboarding.databinding.FragmentLoginBinding -import com.najudoryeong.mineme.onboarding.databinding.FragmentOnBoardingViewPagerBinding import dagger.hilt.android.AndroidEntryPoint diff --git a/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/OnBoardingViewPagerFragment.kt b/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/OnBoardingViewPagerFragment.kt similarity index 91% rename from onboarding/src/main/java/com/najudoryeong/mineme/onboarding/OnBoardingViewPagerFragment.kt rename to onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/OnBoardingViewPagerFragment.kt index 17fe269..af64aac 100644 --- a/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/OnBoardingViewPagerFragment.kt +++ b/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/OnBoardingViewPagerFragment.kt @@ -1,4 +1,4 @@ -package com.najudoryeong.mineme.onboarding +package com.najudoryeong.mineme.onboarding.ui import android.Manifest import android.os.Build @@ -13,10 +13,11 @@ import androidx.navigation.fragment.findNavController import androidx.viewpager2.adapter.FragmentStateAdapter import com.google.android.material.snackbar.Snackbar import com.najudoryeong.mineme.common_ui.DialogForPermission +import com.najudoryeong.mineme.onboarding.R import com.najudoryeong.mineme.onboarding.databinding.FragmentOnBoardingViewPagerBinding -import com.najudoryeong.mineme.onboarding.viewpagerfragment.OnBoarding1Fragment -import com.najudoryeong.mineme.onboarding.viewpagerfragment.OnBoarding2Fragment -import com.najudoryeong.mineme.onboarding.viewpagerfragment.OnBoarding3Fragment +import com.najudoryeong.mineme.onboarding.ui.viewpagerfragment.OnBoarding1Fragment +import com.najudoryeong.mineme.onboarding.ui.viewpagerfragment.OnBoarding2Fragment +import com.najudoryeong.mineme.onboarding.ui.viewpagerfragment.OnBoarding3Fragment import dagger.hilt.android.AndroidEntryPoint diff --git a/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/SplashActivity.kt b/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/SplashActivity.kt similarity index 81% rename from onboarding/src/main/java/com/najudoryeong/mineme/onboarding/SplashActivity.kt rename to onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/SplashActivity.kt index b1e6fe9..14aedab 100644 --- a/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/SplashActivity.kt +++ b/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/SplashActivity.kt @@ -1,7 +1,6 @@ -package com.najudoryeong.mineme.onboarding +package com.najudoryeong.mineme.onboarding.ui import android.annotation.SuppressLint -import android.content.Intent import android.os.Bundle import android.util.Log import android.view.View @@ -10,6 +9,8 @@ import androidx.appcompat.app.AppCompatActivity import androidx.databinding.DataBindingUtil import androidx.navigation.NavController import androidx.navigation.fragment.NavHostFragment +import com.najudoryeong.mineme.onboarding.LoginUtil +import com.najudoryeong.mineme.onboarding.R import com.najudoryeong.mineme.onboarding.databinding.ActivitySplashBinding import dagger.hilt.android.AndroidEntryPoint import javax.inject.Inject @@ -35,14 +36,19 @@ class SplashActivity : AppCompatActivity() { Log.d("test", "checkJWT") viewModel.getJsonWebToken { JWT -> if (JWT != null) { + Log.d("test", "startHome") startHomeActivity() } else { + Log.d("test", "nojwt") isFirst { permissionNum -> // 처음이아님 => 카카오 로그인만 다시 if (permissionNum == OnBoardingViewPagerFragment.viewpagerNum) { + Log.d("test", "nofirst") LoginUtil.loginWithKaKao(this) { token -> viewModel.signup(token = token!!) { // 로그인 됐다면 다시 jwt 확인 + Log.d("test", "startHome") + startHomeActivity() checkJWT() } } @@ -56,12 +62,11 @@ class SplashActivity : AppCompatActivity() { } fun startHomeActivity(){ - LoginUtil.startMainActivity(this,mainActivityClass) + LoginUtil.startMainActivity(this, mainActivityClass) } private fun initNav() { - val navHostFragment = - supportFragmentManager.findFragmentById(R.id.fragment_containerView) as NavHostFragment + val navHostFragment = supportFragmentManager.findFragmentById(R.id.fragment_containerView) as NavHostFragment navController = navHostFragment.navController binding.splashScreen.visibility = View.GONE binding.fragmentContainerView.visibility = View.VISIBLE diff --git a/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/SplashViewModel.kt b/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/SplashViewModel.kt similarity index 82% rename from onboarding/src/main/java/com/najudoryeong/mineme/onboarding/SplashViewModel.kt rename to onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/SplashViewModel.kt index af0c95f..9b329ff 100644 --- a/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/SplashViewModel.kt +++ b/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/SplashViewModel.kt @@ -1,23 +1,18 @@ -package com.najudoryeong.mineme.onboarding +package com.najudoryeong.mineme.onboarding.ui -import android.content.Context import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.example.common.data.dto.CodeRequest -import com.example.common.data.dto.UserInfoRequest -import com.example.common.data.source.AuthService -import com.example.common.data.source.UserService -import com.example.common.domain.usecase.DataStoreUseCase +import com.najudoryeong.mineme.common.data.dto.CodeRequest +import com.najudoryeong.mineme.common.data.dto.UserInfoRequest +import com.najudoryeong.mineme.common.data.source.UserService +import com.najudoryeong.mineme.common.domain.usecase.DataStoreUseCase import dagger.hilt.android.lifecycle.HiltViewModel -import dagger.hilt.android.qualifiers.ApplicationContext import kotlinx.coroutines.flow.first import kotlinx.coroutines.launch import javax.inject.Inject @HiltViewModel class SplashViewModel @Inject constructor( - @ApplicationContext private val context: Context, - private val authService: AuthService, private val userService: UserService, private val dataStoreUseCase: DataStoreUseCase ) : ViewModel() { @@ -51,7 +46,6 @@ class SplashViewModel @Inject constructor( dataStoreUseCase.editJsonWebToken("testtoken123") dataStoreUseCase.editUserCode("testcode123") callback.invoke() - /* //todo userName authService.login(LoginRequest(token,ProviderType.KAKAO.name,"test123")).let { @@ -62,7 +56,6 @@ class SplashViewModel @Inject constructor( } } */ - } } diff --git a/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/viewpagerfragment/OnBoarding1Fragment.kt b/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/viewpagerfragment/OnBoarding1Fragment.kt similarity index 95% rename from onboarding/src/main/java/com/najudoryeong/mineme/onboarding/viewpagerfragment/OnBoarding1Fragment.kt rename to onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/viewpagerfragment/OnBoarding1Fragment.kt index 0acccca..9ee576d 100644 --- a/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/viewpagerfragment/OnBoarding1Fragment.kt +++ b/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/viewpagerfragment/OnBoarding1Fragment.kt @@ -1,4 +1,4 @@ -package com.najudoryeong.mineme.onboarding.viewpagerfragment +package com.najudoryeong.mineme.onboarding.ui.viewpagerfragment import android.os.Bundle diff --git a/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/viewpagerfragment/OnBoarding2Fragment.kt b/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/viewpagerfragment/OnBoarding2Fragment.kt similarity index 93% rename from onboarding/src/main/java/com/najudoryeong/mineme/onboarding/viewpagerfragment/OnBoarding2Fragment.kt rename to onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/viewpagerfragment/OnBoarding2Fragment.kt index 821b52e..9048c6c 100644 --- a/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/viewpagerfragment/OnBoarding2Fragment.kt +++ b/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/viewpagerfragment/OnBoarding2Fragment.kt @@ -1,4 +1,4 @@ -package com.najudoryeong.mineme.onboarding.viewpagerfragment +package com.najudoryeong.mineme.onboarding.ui.viewpagerfragment import android.os.Bundle import androidx.fragment.app.Fragment diff --git a/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/viewpagerfragment/OnBoarding3Fragment.kt b/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/viewpagerfragment/OnBoarding3Fragment.kt similarity index 93% rename from onboarding/src/main/java/com/najudoryeong/mineme/onboarding/viewpagerfragment/OnBoarding3Fragment.kt rename to onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/viewpagerfragment/OnBoarding3Fragment.kt index fb549dc..277ba74 100644 --- a/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/viewpagerfragment/OnBoarding3Fragment.kt +++ b/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/viewpagerfragment/OnBoarding3Fragment.kt @@ -1,4 +1,4 @@ -package com.najudoryeong.mineme.onboarding.viewpagerfragment +package com.najudoryeong.mineme.onboarding.ui.viewpagerfragment import android.os.Bundle diff --git a/onboarding/src/main/res/layout/activity_splash.xml b/onboarding/src/main/res/layout/activity_splash.xml index a5f2842..48863d3 100644 --- a/onboarding/src/main/res/layout/activity_splash.xml +++ b/onboarding/src/main/res/layout/activity_splash.xml @@ -6,7 +6,7 @@ + tools:context=".ui.SplashActivity"> + tools:context=".ui.InputCodeFragment"> + tools:context=".ui.LoginFragment"> + tools:context=".ui.viewpagerfragment.OnBoarding1Fragment"> + tools:context=".ui.viewpagerfragment.OnBoarding2Fragment"> + tools:context=".ui.viewpagerfragment.OnBoarding3Fragment"> + tools:context=".ui.OnBoardingViewPagerFragment"> diff --git a/onboarding/src/main/res/navigation/nav_onboarding.xml b/onboarding/src/main/res/navigation/nav_onboarding.xml index ff0ca43..0d2967c 100644 --- a/onboarding/src/main/res/navigation/nav_onboarding.xml +++ b/onboarding/src/main/res/navigation/nav_onboarding.xml @@ -7,7 +7,7 @@ \ No newline at end of file diff --git a/story/src/main/java/com/najudoryeong/mineme/story/StoryFragment.kt b/story/src/main/java/com/najudoryeong/mineme/story/StoryFragment.kt deleted file mode 100644 index f8350f3..0000000 --- a/story/src/main/java/com/najudoryeong/mineme/story/StoryFragment.kt +++ /dev/null @@ -1,37 +0,0 @@ -package com.najudoryeong.mineme.story - -import androidx.fragment.app.viewModels -import com.najudoryeong.mineme.common_ui.BaseFragment -import com.najudoryeong.mineme.story.databinding.FragmentStoryBinding -import com.example.common.data.entity.Story -import dagger.hilt.android.AndroidEntryPoint - -@AndroidEntryPoint -class StoryFragment : BaseFragment(Story) { - - private val viewModel: StoryViewModel by viewModels() - - private val myListAdapter: StoryAdapter by lazy { - StoryAdapter() - } - - private val dataSet = arrayListOf().apply { - add(StoryModel("2022-01-03",1, "마산","https://images.unsplash.com/photo-1511739001486-6bfe10ce785f?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=987&q=80")) - add(StoryModel("2022-01-04",1, "마산1","https://images.unsplash.com/photo-1511739001486-6bfe10ce785f?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=987&q=80")) - add(StoryModel("2022-01-05",1, "마산2","https://images.unsplash.com/photo-1511739001486-6bfe10ce785f?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=987&q=80")) - add(StoryModel("2022-01-06",1, "마산3","https://images.unsplash.com/photo-1511739001486-6bfe10ce785f?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=987&q=80")) - add(StoryModel("2022-01-07",1, "마산4","https://images.unsplash.com/photo-1511739001486-6bfe10ce785f?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=987&q=80")) - - } - - override fun initView() { - binding.apply { - //todo callback - this.lifecycleOwner = viewLifecycleOwner - this.adapter = myListAdapter - this.viewModel = viewModel - } - viewModel.raedStory() - } - -} \ No newline at end of file diff --git a/story/src/main/java/com/najudoryeong/mineme/story/StoryAdapter.kt b/story/src/main/java/com/najudoryeong/mineme/story/StoryInAdapter.kt similarity index 59% rename from story/src/main/java/com/najudoryeong/mineme/story/StoryAdapter.kt rename to story/src/main/java/com/najudoryeong/mineme/story/StoryInAdapter.kt index 87fbbdc..476ae35 100644 --- a/story/src/main/java/com/najudoryeong/mineme/story/StoryAdapter.kt +++ b/story/src/main/java/com/najudoryeong/mineme/story/StoryInAdapter.kt @@ -6,15 +6,15 @@ import android.view.ViewGroup import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView -import com.example.common.data.entity.Story -import com.najudoryeong.mineme.common_ui.databinding.ItemStoryBinding -import com.najudoryeong.mineme.story.databinding.TestStoryBinding +import com.najudoryeong.mineme.common.domain.entity.Story +import com.najudoryeong.mineme.story.databinding.ItemStoryInBinding -class StoryAdapter : ListAdapter(StoryDiffCallback()) { +class StoryInAdapter : ListAdapter(StoryInDiffCallback()){ + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { - return StoryViewHolder( - TestStoryBinding.inflate( + return StoryInViewHolder( + ItemStoryInBinding.inflate( LayoutInflater.from(parent.context), parent, false @@ -23,36 +23,34 @@ class StoryAdapter : ListAdapter(StoryDiffC } override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { - if (holder is StoryViewHolder){ + if (holder is StoryInViewHolder){ val story = getItem(position) holder.bind(story) } } - class StoryViewHolder(private val binding: TestStoryBinding) : + inner class StoryInViewHolder(private val binding: ItemStoryInBinding) : RecyclerView.ViewHolder(binding.root) { - fun bind(storyModel: StoryModel) { + fun bind(storyModel: Story) { with(binding) { story = storyModel - executePendingBindings() itemView.setOnClickListener { // story 상세보기 Log.d("testStory","상세보기 클릭") } + executePendingBindings() } } } - } - -private class StoryDiffCallback : DiffUtil.ItemCallback() { - override fun areItemsTheSame(oldItem: StoryModel, newItem: StoryModel): Boolean { +private class StoryInDiffCallback : DiffUtil.ItemCallback() { + override fun areItemsTheSame(oldItem: Story, newItem: Story): Boolean { return oldItem === newItem } - override fun areContentsTheSame(oldItem: StoryModel, newItem: StoryModel): Boolean { + override fun areContentsTheSame(oldItem: Story, newItem: Story): Boolean { return oldItem == newItem } } \ No newline at end of file diff --git a/story/src/main/java/com/najudoryeong/mineme/story/StoryOutAdapter.kt b/story/src/main/java/com/najudoryeong/mineme/story/StoryOutAdapter.kt new file mode 100644 index 0000000..fabdea7 --- /dev/null +++ b/story/src/main/java/com/najudoryeong/mineme/story/StoryOutAdapter.kt @@ -0,0 +1,67 @@ +package com.najudoryeong.mineme.story + +import android.util.Log +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.lifecycle.LifecycleOwner +import androidx.recyclerview.widget.DiffUtil +import androidx.recyclerview.widget.ListAdapter +import androidx.recyclerview.widget.RecyclerView +import com.najudoryeong.mineme.story.databinding.ItemStoryOutBinding +import com.najudoryeong.mineme.story.domain.entity.StoryListWithDate +import com.najudoryeong.mineme.story.ui.dummy + + +class StoryOutAdapter: ListAdapter(StoryOutDiffCallback()) { + + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { + Log.d("testStory","홀더 만듬") + + return StoryOutViewHolder( + ItemStoryOutBinding.inflate( + LayoutInflater.from(parent.context), + parent, + false + ) + ) + } + + override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { + if (holder is StoryOutViewHolder){ + val storyListWithDate = getItem(position) + holder.bind(storyListWithDate) + } + } + + override fun getItemCount(): Int { + Log.d("testStory", super.getItemCount().toString()) + return super.getItemCount() + } + + inner class StoryOutViewHolder(private val binding: ItemStoryOutBinding) : RecyclerView.ViewHolder(binding.root) { + fun bind(storyListWithDate : StoryListWithDate){ + // 외부 이제 나눈다 날짜별로 + with(binding) { + outRecyclerView.adapter = StoryInAdapter().apply { submitList(storyListWithDate.posts) } + yearMonth = getYearMonth(storyListWithDate.year,storyListWithDate.month) + executePendingBindings() + } + } + + private fun getYearMonth(year : String, month : String) : String { + return "$year $month" + } + } + +} + +private class StoryOutDiffCallback : DiffUtil.ItemCallback() { + override fun areItemsTheSame(oldItem: StoryListWithDate, newItem: StoryListWithDate): Boolean { + return oldItem === newItem + } + + override fun areContentsTheSame(oldItem: StoryListWithDate, newItem: StoryListWithDate): Boolean { + return oldItem == newItem + } +} \ No newline at end of file diff --git a/story/src/main/java/com/najudoryeong/mineme/story/StoryViewModel.kt b/story/src/main/java/com/najudoryeong/mineme/story/StoryViewModel.kt deleted file mode 100644 index a069c20..0000000 --- a/story/src/main/java/com/najudoryeong/mineme/story/StoryViewModel.kt +++ /dev/null @@ -1,41 +0,0 @@ -package com.najudoryeong.mineme.story - -import android.content.Context -import androidx.lifecycle.ViewModel -import androidx.lifecycle.viewModelScope -import com.example.common.data.entity.StoryWithDate -import com.example.common.data.source.StoryService -import com.example.common.domain.usecase.DataStoreUseCase - -import dagger.hilt.android.lifecycle.HiltViewModel -import dagger.hilt.android.qualifiers.ApplicationContext -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.StateFlow -import kotlinx.coroutines.flow.first -import kotlinx.coroutines.launch -import javax.inject.Inject - - -@HiltViewModel -class StoryViewModel @Inject constructor( - @ApplicationContext private val context: Context, - private val storyService: StoryService, - private val dataStoreUseCase: DataStoreUseCase -) : ViewModel() { - - private val _storyList: MutableStateFlow> = MutableStateFlow(mutableListOf()) - val storyList: StateFlow> = _storyList - - fun raedStory() { - //todo isuploading - viewModelScope.launch { - storyService.getStoryList(dataStoreUseCase.bearerJsonWebToken.first()!!).let { - if (it.success) { - _storyList.value = it.data - } - } - } - } - - -} \ No newline at end of file diff --git a/story/src/main/java/com/najudoryeong/mineme/story/data/StoryService.kt b/story/src/main/java/com/najudoryeong/mineme/story/data/StoryService.kt new file mode 100644 index 0000000..fee39da --- /dev/null +++ b/story/src/main/java/com/najudoryeong/mineme/story/data/StoryService.kt @@ -0,0 +1,15 @@ +package com.najudoryeong.mineme.story.data + +import com.najudoryeong.mineme.common.data.dto.CommonResponse +import com.najudoryeong.mineme.story.domain.entity.StoryListWithDate +import retrofit2.http.GET +import retrofit2.http.Header + +interface StoryService { + + @GET("api/v1/story/list") + suspend fun readStoryList( + @Header("Authorization") token: String, + ) : CommonResponse> + +} \ No newline at end of file diff --git a/story/src/main/java/com/najudoryeong/mineme/story/di/NetworkModule.kt b/story/src/main/java/com/najudoryeong/mineme/story/di/NetworkModule.kt new file mode 100644 index 0000000..e5b4128 --- /dev/null +++ b/story/src/main/java/com/najudoryeong/mineme/story/di/NetworkModule.kt @@ -0,0 +1,21 @@ +package com.najudoryeong.mineme.story.di + +import com.najudoryeong.mineme.story.data.StoryService +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import retrofit2.Retrofit +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +class NetworkModule { + + @Singleton + @Provides + fun provideStoryService(retrofit: Retrofit): StoryService { + return retrofit.create(StoryService::class.java) + } + +} \ No newline at end of file diff --git a/story/src/main/java/com/najudoryeong/mineme/story/domain/entity/StoryListWithDate.kt b/story/src/main/java/com/najudoryeong/mineme/story/domain/entity/StoryListWithDate.kt new file mode 100644 index 0000000..a229895 --- /dev/null +++ b/story/src/main/java/com/najudoryeong/mineme/story/domain/entity/StoryListWithDate.kt @@ -0,0 +1,9 @@ +package com.najudoryeong.mineme.story.domain.entity + +import com.najudoryeong.mineme.common.domain.entity.Story + +data class StoryListWithDate( + val year : String, + val month : String, + val posts : List +) \ No newline at end of file diff --git a/story/src/main/java/com/najudoryeong/mineme/story/domain/usecase/StoryUseCase.kt b/story/src/main/java/com/najudoryeong/mineme/story/domain/usecase/StoryUseCase.kt new file mode 100644 index 0000000..e9195aa --- /dev/null +++ b/story/src/main/java/com/najudoryeong/mineme/story/domain/usecase/StoryUseCase.kt @@ -0,0 +1,14 @@ +package com.najudoryeong.mineme.story.domain.usecase + +import com.najudoryeong.mineme.story.domain.entity.StoryListWithDate +import com.najudoryeong.mineme.story.data.StoryService +import javax.inject.Inject + +class StoryUseCase @Inject constructor( + private val storyService : StoryService +){ + suspend fun readStoryList(token: String): List? { + val storyList = storyService.readStoryList(token) + return if (storyList.success) storyList.data else null + } +} \ No newline at end of file diff --git a/story/src/main/java/com/najudoryeong/mineme/story/ui/StoryFragment.kt b/story/src/main/java/com/najudoryeong/mineme/story/ui/StoryFragment.kt new file mode 100644 index 0000000..ce6e424 --- /dev/null +++ b/story/src/main/java/com/najudoryeong/mineme/story/ui/StoryFragment.kt @@ -0,0 +1,32 @@ +package com.najudoryeong.mineme.story.ui + +import androidx.fragment.app.viewModels +import com.najudoryeong.mineme.common_ui.BaseFragment +import com.najudoryeong.mineme.story.databinding.FragmentStoryBinding +import com.najudoryeong.mineme.story.StoryOutAdapter +import com.najudoryeong.mineme.story.util.Story_Foundation_Info +import dagger.hilt.android.AndroidEntryPoint + +@AndroidEntryPoint +class StoryFragment : BaseFragment(Story_Foundation_Info) { + + private val viewModel: StoryViewModel by viewModels() + private val storyOutAdapter : StoryOutAdapter by lazy { + StoryOutAdapter() + } + + + override fun initView() { + /// 이거는 바깥 그거에 넣어줄 데이터 + viewModel.raedStory() + + binding.apply { + //todo callback + this.adapter = storyOutAdapter + this.list = dummy + this.lifecycleOwner = viewLifecycleOwner + } + + } + +} \ No newline at end of file diff --git a/story/src/main/java/com/najudoryeong/mineme/story/ui/StoryViewModel.kt b/story/src/main/java/com/najudoryeong/mineme/story/ui/StoryViewModel.kt new file mode 100644 index 0000000..3de4941 --- /dev/null +++ b/story/src/main/java/com/najudoryeong/mineme/story/ui/StoryViewModel.kt @@ -0,0 +1,104 @@ +package com.najudoryeong.mineme.story.ui + +import android.util.Log +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import com.najudoryeong.mineme.common.domain.entity.Story +import com.najudoryeong.mineme.story.domain.entity.StoryListWithDate +import com.najudoryeong.mineme.common.domain.usecase.DataStoreUseCase +import com.najudoryeong.mineme.story.domain.usecase.StoryUseCase + +import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.launch +import javax.inject.Inject + +var dummy = mutableListOf( + StoryListWithDate( + "2020", "03", listOf( + Story( + "2020-03-01", + 1, + "마산", + "https://upload3.inven.co.kr/upload/2022/03/15/bbs/i16343629296.jpg?MW=800" + ), + Story( + "2020-03-02", + 1, + "마산1", + "https://upload3.inven.co.kr/upload/2022/03/15/bbs/i16343629296.jpg?MW=800" + ), + Story( + "2020-03-03", + 1, + "마산2", + "https://upload3.inven.co.kr/upload/2022/03/15/bbs/i16343629296.jpg?MW=800" + ), + Story( + "2020-03-04", + 1, + "마산3", + "https://upload3.inven.co.kr/upload/2022/03/15/bbs/i16343629296.jpg?MW=800" + ), + ) + ), + + StoryListWithDate( + "2020", "04", listOf( + Story( + "2020-04-01", + 1, + "마산", + "https://upload3.inven.co.kr/upload/2022/03/15/bbs/i16343629296.jpg?MW=800" + ), + Story( + "2020-04-02", + 1, + "마산11", + "https://upload3.inven.co.kr/upload/2022/03/15/bbs/i16343629296.jpg?MW=800" + ), + Story( + "2020-04-03", + 1, + "마산21", + "https://upload3.inven.co.kr/upload/2022/03/15/bbs/i16343629296.jpg?MW=800" + ), + Story( + "2020-04-04", + 1, + "마산31", + "https://upload3.inven.co.kr/upload/2022/03/15/bbs/i16343629296.jpg?MW=800" + ), + ) + ) +) + +@HiltViewModel +class StoryViewModel @Inject constructor( + private val storyUseCase: StoryUseCase, + private val dataStoreUseCase: DataStoreUseCase +) : ViewModel() { + + private val _storyList = MutableStateFlow>(mutableListOf()) + val storyList: StateFlow> = _storyList + + + //todo isuploading + fun raedStory() { + Log.d("testStory", "데이터 넣음") + _storyList.value = dummy + + +// viewModelScope.launch { +// storyUseCase.readStoryList(dataStoreUseCase.bearerJsonWebToken.first()!!).let { +// if (it != null) { +// _storyList.value = it +// } else { +// +// } +// } +// } + } +} \ No newline at end of file diff --git a/story/src/main/java/com/najudoryeong/mineme/story/FragmentObject.kt b/story/src/main/java/com/najudoryeong/mineme/story/util/FragmentObject.kt similarity index 74% rename from story/src/main/java/com/najudoryeong/mineme/story/FragmentObject.kt rename to story/src/main/java/com/najudoryeong/mineme/story/util/FragmentObject.kt index d1da140..277b663 100644 --- a/story/src/main/java/com/najudoryeong/mineme/story/FragmentObject.kt +++ b/story/src/main/java/com/najudoryeong/mineme/story/util/FragmentObject.kt @@ -1,11 +1,11 @@ -package com.najudoryeong.mineme.story +package com.najudoryeong.mineme.story.util import android.view.View import com.najudoryeong.mineme.common_ui.FragmentInfoUtil +import com.najudoryeong.mineme.story.R - -object Story : FragmentInfoUtil { +object Story_Foundation_Info : FragmentInfoUtil { override val layoutID: Int get() = R.layout.fragment_story override val toolbarText: Int diff --git a/story/src/main/res/layout/fragment_story.xml b/story/src/main/res/layout/fragment_story.xml index ef6feae..1a5e31a 100644 --- a/story/src/main/res/layout/fragment_story.xml +++ b/story/src/main/res/layout/fragment_story.xml @@ -8,10 +8,15 @@ + type="com.najudoryeong.mineme.story.ui.StoryViewModel" /> + + + + type="com.najudoryeong.mineme.story.StoryOutAdapter" /> @@ -24,6 +29,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/img_nostory" + android:visibility="gone" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -31,7 +37,6 @@ @@ -41,15 +46,18 @@ + android:orientation="vertical" + app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" + app:layout_constraintTop_toTopOf="parent" + tools:listitem="@layout/item_story_out" + /> + diff --git a/story/src/main/res/layout/test_story.xml b/story/src/main/res/layout/item_story_in.xml similarity index 78% rename from story/src/main/res/layout/test_story.xml rename to story/src/main/res/layout/item_story_in.xml index 37e6ef5..1610687 100644 --- a/story/src/main/res/layout/test_story.xml +++ b/story/src/main/res/layout/item_story_in.xml @@ -6,7 +6,7 @@ + type="com.najudoryeong.mineme.common.domain.entity.Story" /> @@ -33,29 +33,30 @@ @@ -65,3 +66,5 @@ + + diff --git a/story/src/main/res/layout/item_story_out.xml b/story/src/main/res/layout/item_story_out.xml new file mode 100644 index 0000000..6abb35a --- /dev/null +++ b/story/src/main/res/layout/item_story_out.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + diff --git a/story/src/main/res/navigation/nav_story.xml b/story/src/main/res/navigation/nav_story.xml index 4fe5b65..e42683e 100644 --- a/story/src/main/res/navigation/nav_story.xml +++ b/story/src/main/res/navigation/nav_story.xml @@ -6,6 +6,6 @@ \ No newline at end of file