From 111df0e2a3daeba50126b14d5a1bfad3a4d0b3fb Mon Sep 17 00:00:00 2001 From: kimdowoo Date: Sun, 12 Feb 2023 17:51:56 +0900 Subject: [PATCH 1/9] =?UTF-8?q?[MIN-49]=20feat:=20story=20=EB=A6=AC?= =?UTF-8?q?=EC=82=AC=EC=9D=B4=ED=81=B4=EB=9F=AC=20=EB=B7=B0=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84(#23)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/values/themes.xml | 2 + build.gradle | 2 +- common-ui/build.gradle | 4 ++ common-ui/src/main/res/layout/item_story.xml | 5 +- .../common/data/dto/StoryListResponse.kt | 8 +++ .../example/common/data/entity/HomeData.kt | 22 ++---- .../common/data/entity/StoryWithDate.kt | 7 ++ .../najudoryeong/mineme/story/StoryAdapter.kt | 58 ++++++++++++++++ .../mineme/story/StoryFragment.kt | 20 +++++- .../najudoryeong/mineme/story/StoryModel.kt | 8 +++ story/src/main/res/layout/fragment_story.xml | 36 +++++++--- story/src/main/res/layout/test_story.xml | 67 +++++++++++++++++++ 12 files changed, 209 insertions(+), 30 deletions(-) create mode 100644 common/src/main/java/com/example/common/data/dto/StoryListResponse.kt create mode 100644 common/src/main/java/com/example/common/data/entity/StoryWithDate.kt create mode 100644 story/src/main/java/com/najudoryeong/mineme/story/StoryAdapter.kt create mode 100644 story/src/main/java/com/najudoryeong/mineme/story/StoryModel.kt create mode 100644 story/src/main/res/layout/test_story.xml diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index df5071e..015dc35 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -12,6 +12,8 @@ @color/black + @color/black + diff --git a/build.gradle b/build.gradle index d4a77ef..0b85693 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ buildscript { kakao_version = '2.12.1' dataStorePreferences_version = '1.0.0' retrofit2Version = '2.9.0' - + recyclerViewVersion = '1.2.1' } dependencies { diff --git a/common-ui/build.gradle b/common-ui/build.gradle index bd1fcd6..85af470 100644 --- a/common-ui/build.gradle +++ b/common-ui/build.gradle @@ -38,6 +38,10 @@ android { dependencies { + api project(path: ':common') + + + api "androidx.recyclerview:recyclerview:$rootProject.recyclerViewVersion" // Fragment api "androidx.fragment:fragment:$rootProject.fragment_version" diff --git a/common-ui/src/main/res/layout/item_story.xml b/common-ui/src/main/res/layout/item_story.xml index b9fb288..4e41fb7 100644 --- a/common-ui/src/main/res/layout/item_story.xml +++ b/common-ui/src/main/res/layout/item_story.xml @@ -18,9 +18,7 @@ - + - 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 new file mode 100644 index 0000000..37bed55 --- /dev/null +++ b/common/src/main/java/com/example/common/data/dto/StoryListResponse.kt @@ -0,0 +1,8 @@ +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/HomeData.kt b/common/src/main/java/com/example/common/data/entity/HomeData.kt index 49b7b56..8554b18 100644 --- a/common/src/main/java/com/example/common/data/entity/HomeData.kt +++ b/common/src/main/java/com/example/common/data/entity/HomeData.kt @@ -1,21 +1,23 @@ package com.example.common.data.entity +import com.kakao.sdk.user.model.User + data class HomeData( val couple: Couple, - val newStory: NewStory, + val newStory: Story, val widgets: List ) data class Couple( - val me: Me, - val mine: Mine, + val me: UserInfo, + val mine: UserInfo, val name: String, val startDate: String ) -data class NewStory( +data class Story( val date: String, val postId: Int, val region: String, @@ -23,17 +25,7 @@ data class NewStory( ) -data class Mine( - val birthday: String, - val description: String, - val gender: String, - val instaId: String, - val nickname: String, - val profileImage: String -) - - -data class Me( +data class UserInfo( val birthday: String, val description: String, val gender: String, 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 new file mode 100644 index 0000000..2afbfc2 --- /dev/null +++ b/common/src/main/java/com/example/common/data/entity/StoryWithDate.kt @@ -0,0 +1,7 @@ +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/story/src/main/java/com/najudoryeong/mineme/story/StoryAdapter.kt b/story/src/main/java/com/najudoryeong/mineme/story/StoryAdapter.kt new file mode 100644 index 0000000..87fbbdc --- /dev/null +++ b/story/src/main/java/com/najudoryeong/mineme/story/StoryAdapter.kt @@ -0,0 +1,58 @@ +package com.najudoryeong.mineme.story + +import android.util.Log +import android.view.LayoutInflater +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 + + +class StoryAdapter : ListAdapter(StoryDiffCallback()) { + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { + return StoryViewHolder( + TestStoryBinding.inflate( + LayoutInflater.from(parent.context), + parent, + false + ) + ) + } + + override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { + if (holder is StoryViewHolder){ + val story = getItem(position) + holder.bind(story) + } + } + + class StoryViewHolder(private val binding: TestStoryBinding) : + RecyclerView.ViewHolder(binding.root) { + fun bind(storyModel: StoryModel) { + with(binding) { + story = storyModel + executePendingBindings() + itemView.setOnClickListener { + // story 상세보기 + Log.d("testStory","상세보기 클릭") + } + } + } + } + + +} + + +private class StoryDiffCallback : DiffUtil.ItemCallback() { + override fun areItemsTheSame(oldItem: StoryModel, newItem: StoryModel): Boolean { + return oldItem === newItem + } + + override fun areContentsTheSame(oldItem: StoryModel, newItem: StoryModel): Boolean { + return oldItem == newItem + } +} \ 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 index fd6d19c..5960063 100644 --- a/story/src/main/java/com/najudoryeong/mineme/story/StoryFragment.kt +++ b/story/src/main/java/com/najudoryeong/mineme/story/StoryFragment.kt @@ -2,11 +2,29 @@ package com.najudoryeong.mineme.story import com.najudoryeong.mineme.common_ui.BaseFragment import com.najudoryeong.mineme.story.databinding.FragmentStoryBinding +import com.example.common.data.entity.Story class StoryFragment : BaseFragment(Story) { + + 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 + recyclerView.adapter = myListAdapter } + myListAdapter.submitList(dataSet) + } } \ No newline at end of file diff --git a/story/src/main/java/com/najudoryeong/mineme/story/StoryModel.kt b/story/src/main/java/com/najudoryeong/mineme/story/StoryModel.kt new file mode 100644 index 0000000..63c4688 --- /dev/null +++ b/story/src/main/java/com/najudoryeong/mineme/story/StoryModel.kt @@ -0,0 +1,8 @@ +package com.najudoryeong.mineme.story + +data class StoryModel( + val date: String, + val postId: Int, + val region: String, + val thumbnailImage: String +) diff --git a/story/src/main/res/layout/fragment_story.xml b/story/src/main/res/layout/fragment_story.xml index 82d4fa7..095d4da 100644 --- a/story/src/main/res/layout/fragment_story.xml +++ b/story/src/main/res/layout/fragment_story.xml @@ -1,18 +1,36 @@ - + android:layout_height="match_parent"> - - - + android:layout_height="match_parent"> + + + + + + + + + + + diff --git a/story/src/main/res/layout/test_story.xml b/story/src/main/res/layout/test_story.xml new file mode 100644 index 0000000..37e6ef5 --- /dev/null +++ b/story/src/main/res/layout/test_story.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From aaae56e6acc8c6e5163d362656e2beee38cecb79 Mon Sep 17 00:00:00 2001 From: kimdowoo Date: Sun, 12 Feb 2023 20:00:37 +0900 Subject: [PATCH 2/9] =?UTF-8?q?[MIN-49]=20feat:=20story=20Api=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84(#23)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/najudoryeong/mineme/MainActivity.kt | 2 +- .../common_ui/RecyclerViewBindingAdapter.kt | 13 ++ .../common/data/source/StoryService.kt | 13 ++ .../com/example/common/di/NetworkModule.kt | 8 ++ .../najudoryeong/mineme/home/HomeViewModel.kt | 6 +- .../mineme/story/StoryFragment.kt | 13 +- .../mineme/story/StoryViewModel.kt | 36 +++++- story/src/main/res/drawable/img_nostory.xml | 121 ++++++++++++++++++ story/src/main/res/layout/fragment_story.xml | 32 ++++- 9 files changed, 231 insertions(+), 13 deletions(-) create mode 100644 common-ui/src/main/java/com/najudoryeong/mineme/common_ui/RecyclerViewBindingAdapter.kt create mode 100644 common/src/main/java/com/example/common/data/source/StoryService.kt create mode 100644 story/src/main/res/drawable/img_nostory.xml diff --git a/app/src/main/java/com/najudoryeong/mineme/MainActivity.kt b/app/src/main/java/com/najudoryeong/mineme/MainActivity.kt index 1eab185..7091cbd 100644 --- a/app/src/main/java/com/najudoryeong/mineme/MainActivity.kt +++ b/app/src/main/java/com/najudoryeong/mineme/MainActivity.kt @@ -47,7 +47,7 @@ class MainActivity : AppCompatActivity(), MainActivityUtil { // appbar 구성 요소 설정 // 바텀네비게이션과 연결하면 해당 프래그먼트에 네비게이션으로는 backButton x appBarConfiguration = AppBarConfiguration( - setOf(R.id.nav_home, R.id.nav_setting, R.id.nav_setting) + setOf(R.id.nav_home, R.id.nav_story, R.id.nav_setting) ) // navController 와 actionbar 연결 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 new file mode 100644 index 0000000..54d3d49 --- /dev/null +++ b/common-ui/src/main/java/com/najudoryeong/mineme/common_ui/RecyclerViewBindingAdapter.kt @@ -0,0 +1,13 @@ +package com.najudoryeong.mineme.common_ui + +import androidx.databinding.BindingAdapter +import androidx.recyclerview.widget.ListAdapter +import androidx.recyclerview.widget.RecyclerView + +@BindingAdapter("adapter", "submitList", requireAll = true) +fun bindRecyclerView(view: RecyclerView, adapter: RecyclerView.Adapter<*>, submitList: List?) { + view.adapter = adapter.apply { + stateRestorationPolicy = RecyclerView.Adapter.StateRestorationPolicy.PREVENT_WHEN_EMPTY + (this as ListAdapter).submitList(submitList?.toMutableList()) + } +} \ 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 new file mode 100644 index 0000000..35464d1 --- /dev/null +++ b/common/src/main/java/com/example/common/data/source/StoryService.kt @@ -0,0 +1,13 @@ +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/di/NetworkModule.kt b/common/src/main/java/com/example/common/di/NetworkModule.kt index c8a30f6..f906878 100644 --- a/common/src/main/java/com/example/common/di/NetworkModule.kt +++ b/common/src/main/java/com/example/common/di/NetworkModule.kt @@ -1,6 +1,7 @@ package com.example.common.di import com.example.common.data.source.AuthService +import com.example.common.data.source.StoryService import com.example.common.data.source.UserService import dagger.Module import dagger.Provides @@ -26,4 +27,11 @@ 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/home/src/main/java/com/najudoryeong/mineme/home/HomeViewModel.kt b/home/src/main/java/com/najudoryeong/mineme/home/HomeViewModel.kt index 071922a..69a0baa 100644 --- a/home/src/main/java/com/najudoryeong/mineme/home/HomeViewModel.kt +++ b/home/src/main/java/com/najudoryeong/mineme/home/HomeViewModel.kt @@ -34,9 +34,9 @@ class HomeViewModel @Inject constructor( fun settingHomeData() { viewModelScope.launch { - var a = dataStoreUseCase.bearerJsonWebToken.first() - if (a == null) a = "bearer test" - userService.getHomeInfo(a).let { + 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){ diff --git a/story/src/main/java/com/najudoryeong/mineme/story/StoryFragment.kt b/story/src/main/java/com/najudoryeong/mineme/story/StoryFragment.kt index 5960063..f8350f3 100644 --- a/story/src/main/java/com/najudoryeong/mineme/story/StoryFragment.kt +++ b/story/src/main/java/com/najudoryeong/mineme/story/StoryFragment.kt @@ -1,11 +1,16 @@ 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() } @@ -22,9 +27,11 @@ class StoryFragment : BaseFragment(Story) { override fun initView() { binding.apply { //todo callback - recyclerView.adapter = myListAdapter + this.lifecycleOwner = viewLifecycleOwner + this.adapter = myListAdapter + this.viewModel = viewModel } - myListAdapter.submitList(dataSet) - + viewModel.raedStory() } + } \ 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 index d9253c8..a069c20 100644 --- a/story/src/main/java/com/najudoryeong/mineme/story/StoryViewModel.kt +++ b/story/src/main/java/com/najudoryeong/mineme/story/StoryViewModel.kt @@ -1,7 +1,41 @@ 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 + } + } + } + } -class StoryViewModel : ViewModel(){ } \ No newline at end of file diff --git a/story/src/main/res/drawable/img_nostory.xml b/story/src/main/res/drawable/img_nostory.xml new file mode 100644 index 0000000..45c9ed1 --- /dev/null +++ b/story/src/main/res/drawable/img_nostory.xml @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/story/src/main/res/layout/fragment_story.xml b/story/src/main/res/layout/fragment_story.xml index 095d4da..ef6feae 100644 --- a/story/src/main/res/layout/fragment_story.xml +++ b/story/src/main/res/layout/fragment_story.xml @@ -3,12 +3,35 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"> + + + + + + + + + android:layout_height="match_parent" + android:padding="4dp"> + + + @@ -16,7 +39,6 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - - From 95526a0541839c23633c4cc3a603925565d195f7 Mon Sep 17 00:00:00 2001 From: KDW03 Date: Wed, 15 Feb 2023 22:38:46 +0900 Subject: [PATCH 3/9] =?UTF-8?q?MIN-49]=20feat:=20story=20=EC=A4=91?= =?UTF-8?q?=EC=B2=A9=20=EB=A6=AC=EC=82=AC=EC=9D=B4=ED=81=B4=EB=9F=AC?= =?UTF-8?q?=EB=B7=B0=20=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 From 0fb655fc9200aa8f14b6953be82792d7ac24f71e Mon Sep 17 00:00:00 2001 From: KDW03 Date: Thu, 16 Feb 2023 00:21:06 +0900 Subject: [PATCH 4/9] =?UTF-8?q?[MIN-49]=20feat:=20=EC=98=A8=EB=B3=B4?= =?UTF-8?q?=EB=94=A9=20=EB=B7=B0=20=EC=88=98=EC=A0=95(#23)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/res/layout/dialog_for_permission.xml | 10 ++++++-- .../ui/OnBoardingViewPagerFragment.kt | 11 +++++++-- .../src/main/res/layout/fragment_login.xml | 9 +++++--- .../fragment_on_boarding_view_pager.xml | 1 + .../mineme/story/ui/StoryFragment.kt | 23 +++++++++++++++---- .../mineme/story/ui/StoryViewModel.kt | 4 ---- story/src/main/res/layout/fragment_story.xml | 2 +- 7 files changed, 44 insertions(+), 16 deletions(-) diff --git a/common-ui/src/main/res/layout/dialog_for_permission.xml b/common-ui/src/main/res/layout/dialog_for_permission.xml index 346d6f4..693e118 100644 --- a/common-ui/src/main/res/layout/dialog_for_permission.xml +++ b/common-ui/src/main/res/layout/dialog_for_permission.xml @@ -27,22 +27,26 @@ app:layout_constraintTop_toTopOf="parent" /> @@ -52,10 +56,12 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" + android:lineSpacingExtra="2sp" android:text="확인을 누르시면 동의 및 다음 단계로 넘어갑니다." + android:textSize="10sp" app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/dialog_button" /> diff --git a/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/OnBoardingViewPagerFragment.kt b/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/OnBoardingViewPagerFragment.kt index af64aac..ed2eaf5 100644 --- a/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/OnBoardingViewPagerFragment.kt +++ b/onboarding/src/main/java/com/najudoryeong/mineme/onboarding/ui/OnBoardingViewPagerFragment.kt @@ -24,7 +24,7 @@ import dagger.hilt.android.AndroidEntryPoint @AndroidEntryPoint class OnBoardingViewPagerFragment : Fragment() { - companion object{ + companion object { var viewpagerNum = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) 3 else 2 } @@ -36,7 +36,14 @@ class OnBoardingViewPagerFragment : Fragment() { //todo companion? - private val messageArray = arrayOf("gps 권한", "알림 권한", "카메라 권한") + private val messageArray = arrayOf( + "기록을 위해서 갤러리 및\n" + + " 위치 접근 동의가 필요해요. ", + "사진을 찍기 위해서\n" + + "카메라 접근 동의가 필요해요", + "알림을 하기 위해서\n" + + "푸시 동의가 필요해요." + ) private val imageArray = arrayOf(R.drawable.img_gps, R.drawable.img_gps, R.drawable.img_gps) private val permissionArray = arrayOf( arrayOf( diff --git a/onboarding/src/main/res/layout/fragment_login.xml b/onboarding/src/main/res/layout/fragment_login.xml index 60364c7..afd9615 100644 --- a/onboarding/src/main/res/layout/fragment_login.xml +++ b/onboarding/src/main/res/layout/fragment_login.xml @@ -14,6 +14,7 @@ android:id="@+id/app_name" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_marginTop="16dp" android:text="Mineme" android:textColor="@color/black" android:textSize="24sp" @@ -21,11 +22,13 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> - diff --git a/onboarding/src/main/res/layout/fragment_on_boarding_view_pager.xml b/onboarding/src/main/res/layout/fragment_on_boarding_view_pager.xml index 21bbf71..e8edf55 100644 --- a/onboarding/src/main/res/layout/fragment_on_boarding_view_pager.xml +++ b/onboarding/src/main/res/layout/fragment_on_boarding_view_pager.xml @@ -11,6 +11,7 @@ (Story_Foundation_Info) { private val viewModel: StoryViewModel by viewModels() - private val storyOutAdapter : StoryOutAdapter by lazy { + private val storyOutAdapter: StoryOutAdapter by lazy { StoryOutAdapter() } override fun initView() { - /// 이거는 바깥 그거에 넣어줄 데이터 + viewModel.raedStory() + /// 이거는 바깥 그거에 넣어줄 데이터 + lifecycleScope.launch { + repeatOnLifecycle(Lifecycle.State.STARTED) { + launch { + viewModel.storyList.collect() + } + } + } + + binding.apply { //todo callback - this.adapter = storyOutAdapter - this.list = dummy this.lifecycleOwner = viewLifecycleOwner + this.adapter = storyOutAdapter + this.viewModel = viewModel } } 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 index 3de4941..b73a4dc 100644 --- a/story/src/main/java/com/najudoryeong/mineme/story/ui/StoryViewModel.kt +++ b/story/src/main/java/com/najudoryeong/mineme/story/ui/StoryViewModel.kt @@ -2,17 +2,13 @@ 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( diff --git a/story/src/main/res/layout/fragment_story.xml b/story/src/main/res/layout/fragment_story.xml index 1a5e31a..870fcc8 100644 --- a/story/src/main/res/layout/fragment_story.xml +++ b/story/src/main/res/layout/fragment_story.xml @@ -47,7 +47,7 @@ Date: Thu, 16 Feb 2023 12:35:19 +0900 Subject: [PATCH 5/9] =?UTF-8?q?[MIN-49]=20feat:=20Story=20refreshLayout=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9=20=EB=B0=8F=20api=20=EC=A0=81=EC=9A=A9(#23)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/deploymentTargetDropDown.xml | 17 ++++ build.gradle | 2 + common-ui/build.gradle | 2 + .../mineme/common_ui/BindingAdapter.kt | 17 ++++ .../common_ui/RecyclerViewBindingAdapter.kt | 14 ---- .../{ => ui}/SettingAccountFragment.kt | 2 +- .../fragment/{ => ui}/SettingFragment.kt | 2 +- .../{ => ui}/SettingInquiryFragment.kt | 2 +- .../{ => ui}/SettingNoticeFragment.kt | 2 +- .../{ => ui}/SettingNotificationFragment.kt | 2 +- .../{ => ui}/SettingSecurityFragment.kt | 2 +- .../src/main/res/layout/fragment_setting.xml | 2 +- .../res/layout/fragment_setting_inquiry.xml | 2 +- .../res/layout/fragment_setting_notice.xml | 2 +- .../layout/fragment_setting_notification.xml | 2 +- .../res/layout/fragment_setting_security.xml | 2 +- .../src/main/res/navigation/nav_setting.xml | 12 +-- .../story/domain/usecase/StoryUseCase.kt | 6 +- .../mineme/story/ui/StoryFragment.kt | 35 +++++--- .../mineme/story/ui/StoryViewModel.kt | 45 +++++++---- story/src/main/res/layout/fragment_story.xml | 81 ++++++++++++------- story/src/main/res/layout/item_story_out.xml | 13 +-- 22 files changed, 169 insertions(+), 97 deletions(-) create mode 100644 .idea/deploymentTargetDropDown.xml delete mode 100644 common-ui/src/main/java/com/najudoryeong/mineme/common_ui/RecyclerViewBindingAdapter.kt rename setting/src/main/java/com/najudoryeong/mineme/setting/fragment/{ => ui}/SettingAccountFragment.kt (96%) rename setting/src/main/java/com/najudoryeong/mineme/setting/fragment/{ => ui}/SettingFragment.kt (95%) rename setting/src/main/java/com/najudoryeong/mineme/setting/fragment/{ => ui}/SettingInquiryFragment.kt (87%) rename setting/src/main/java/com/najudoryeong/mineme/setting/fragment/{ => ui}/SettingNoticeFragment.kt (87%) rename setting/src/main/java/com/najudoryeong/mineme/setting/fragment/{ => ui}/SettingNotificationFragment.kt (88%) rename setting/src/main/java/com/najudoryeong/mineme/setting/fragment/{ => ui}/SettingSecurityFragment.kt (87%) diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml new file mode 100644 index 0000000..4c3cb79 --- /dev/null +++ b/.idea/deploymentTargetDropDown.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle index 0b85693..8118bd6 100644 --- a/build.gradle +++ b/build.gradle @@ -18,6 +18,8 @@ buildscript { dataStorePreferences_version = '1.0.0' retrofit2Version = '2.9.0' recyclerViewVersion = '1.2.1' + swipeRefreshLayoutVersion = '1.1.0' + } dependencies { diff --git a/common-ui/build.gradle b/common-ui/build.gradle index 85af470..8e1b59f 100644 --- a/common-ui/build.gradle +++ b/common-ui/build.gradle @@ -61,6 +61,8 @@ dependencies { implementation "com.google.dagger:hilt-android:$rootProject.hiltVersion" kapt "com.google.dagger:hilt-android-compiler:$rootProject.hiltVersion" + // Refresh + api "androidx.swiperefreshlayout:swiperefreshlayout:$rootProject.swipeRefreshLayoutVersion" // Glide implementation 'com.github.bumptech.glide:glide:4.14.2' diff --git a/common-ui/src/main/java/com/najudoryeong/mineme/common_ui/BindingAdapter.kt b/common-ui/src/main/java/com/najudoryeong/mineme/common_ui/BindingAdapter.kt index a1c0ead..96aa52a 100644 --- a/common-ui/src/main/java/com/najudoryeong/mineme/common_ui/BindingAdapter.kt +++ b/common-ui/src/main/java/com/najudoryeong/mineme/common_ui/BindingAdapter.kt @@ -1,7 +1,10 @@ package com.najudoryeong.mineme.common_ui +import android.view.View import android.widget.ImageView import androidx.databinding.BindingAdapter +import androidx.recyclerview.widget.ListAdapter +import androidx.recyclerview.widget.RecyclerView import com.bumptech.glide.Glide @@ -13,3 +16,17 @@ fun bindImageView(imageView: ImageView, photoUrl: String?) { .into(imageView) } +@BindingAdapter("visible") +fun setVisibility(view: View, flag: Boolean) { + view.visibility = if (flag) View.VISIBLE else View.GONE +} + +@BindingAdapter("adapter", "submitList", requireAll = true) +fun bindRecyclerView(view: RecyclerView, adapter: RecyclerView.Adapter<*>, submitList: List?) { + view.adapter = adapter.apply { + stateRestorationPolicy = RecyclerView.Adapter.StateRestorationPolicy.PREVENT_WHEN_EMPTY + (this as ListAdapter).submitList(submitList?.toMutableList()) + } +} + + 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 deleted file mode 100644 index 04e9874..0000000 --- a/common-ui/src/main/java/com/najudoryeong/mineme/common_ui/RecyclerViewBindingAdapter.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.najudoryeong.mineme.common_ui - -import androidx.databinding.BindingAdapter -import androidx.recyclerview.widget.ListAdapter -import androidx.recyclerview.widget.RecyclerView - -@BindingAdapter("adapter", "submitList", requireAll = true) -fun bindRecyclerView(view: RecyclerView, adapter: RecyclerView.Adapter<*>, submitList: List?) { - view.adapter = adapter.apply { - stateRestorationPolicy = RecyclerView.Adapter.StateRestorationPolicy.PREVENT_WHEN_EMPTY - (this as ListAdapter).submitList(submitList?.toMutableList()) - } -} - diff --git a/setting/src/main/java/com/najudoryeong/mineme/setting/fragment/SettingAccountFragment.kt b/setting/src/main/java/com/najudoryeong/mineme/setting/fragment/ui/SettingAccountFragment.kt similarity index 96% rename from setting/src/main/java/com/najudoryeong/mineme/setting/fragment/SettingAccountFragment.kt rename to setting/src/main/java/com/najudoryeong/mineme/setting/fragment/ui/SettingAccountFragment.kt index 7d43f0c..8940fa6 100644 --- a/setting/src/main/java/com/najudoryeong/mineme/setting/fragment/SettingAccountFragment.kt +++ b/setting/src/main/java/com/najudoryeong/mineme/setting/fragment/ui/SettingAccountFragment.kt @@ -1,4 +1,4 @@ -package com.najudoryeong.mineme.setting.fragment +package com.najudoryeong.mineme.setting.fragment.ui import android.content.ClipData diff --git a/setting/src/main/java/com/najudoryeong/mineme/setting/fragment/SettingFragment.kt b/setting/src/main/java/com/najudoryeong/mineme/setting/fragment/ui/SettingFragment.kt similarity index 95% rename from setting/src/main/java/com/najudoryeong/mineme/setting/fragment/SettingFragment.kt rename to setting/src/main/java/com/najudoryeong/mineme/setting/fragment/ui/SettingFragment.kt index 0622489..fd0519d 100644 --- a/setting/src/main/java/com/najudoryeong/mineme/setting/fragment/SettingFragment.kt +++ b/setting/src/main/java/com/najudoryeong/mineme/setting/fragment/ui/SettingFragment.kt @@ -1,4 +1,4 @@ -package com.najudoryeong.mineme.setting.fragment +package com.najudoryeong.mineme.setting.fragment.ui import androidx.navigation.fragment.findNavController import com.najudoryeong.mineme.common_ui.BaseFragment diff --git a/setting/src/main/java/com/najudoryeong/mineme/setting/fragment/SettingInquiryFragment.kt b/setting/src/main/java/com/najudoryeong/mineme/setting/fragment/ui/SettingInquiryFragment.kt similarity index 87% rename from setting/src/main/java/com/najudoryeong/mineme/setting/fragment/SettingInquiryFragment.kt rename to setting/src/main/java/com/najudoryeong/mineme/setting/fragment/ui/SettingInquiryFragment.kt index d3ca010..8b04ca4 100644 --- a/setting/src/main/java/com/najudoryeong/mineme/setting/fragment/SettingInquiryFragment.kt +++ b/setting/src/main/java/com/najudoryeong/mineme/setting/fragment/ui/SettingInquiryFragment.kt @@ -1,4 +1,4 @@ -package com.najudoryeong.mineme.setting.fragment +package com.najudoryeong.mineme.setting.fragment.ui import com.najudoryeong.mineme.common_ui.BaseFragment diff --git a/setting/src/main/java/com/najudoryeong/mineme/setting/fragment/SettingNoticeFragment.kt b/setting/src/main/java/com/najudoryeong/mineme/setting/fragment/ui/SettingNoticeFragment.kt similarity index 87% rename from setting/src/main/java/com/najudoryeong/mineme/setting/fragment/SettingNoticeFragment.kt rename to setting/src/main/java/com/najudoryeong/mineme/setting/fragment/ui/SettingNoticeFragment.kt index 9602db5..2cd2f5d 100644 --- a/setting/src/main/java/com/najudoryeong/mineme/setting/fragment/SettingNoticeFragment.kt +++ b/setting/src/main/java/com/najudoryeong/mineme/setting/fragment/ui/SettingNoticeFragment.kt @@ -1,4 +1,4 @@ -package com.najudoryeong.mineme.setting.fragment +package com.najudoryeong.mineme.setting.fragment.ui import com.najudoryeong.mineme.common_ui.BaseFragment import com.najudoryeong.mineme.setting.SettingNotice diff --git a/setting/src/main/java/com/najudoryeong/mineme/setting/fragment/SettingNotificationFragment.kt b/setting/src/main/java/com/najudoryeong/mineme/setting/fragment/ui/SettingNotificationFragment.kt similarity index 88% rename from setting/src/main/java/com/najudoryeong/mineme/setting/fragment/SettingNotificationFragment.kt rename to setting/src/main/java/com/najudoryeong/mineme/setting/fragment/ui/SettingNotificationFragment.kt index f9700a8..c09a9f7 100644 --- a/setting/src/main/java/com/najudoryeong/mineme/setting/fragment/SettingNotificationFragment.kt +++ b/setting/src/main/java/com/najudoryeong/mineme/setting/fragment/ui/SettingNotificationFragment.kt @@ -1,4 +1,4 @@ -package com.najudoryeong.mineme.setting.fragment +package com.najudoryeong.mineme.setting.fragment.ui import com.najudoryeong.mineme.common_ui.BaseFragment import com.najudoryeong.mineme.setting.SettingNotification diff --git a/setting/src/main/java/com/najudoryeong/mineme/setting/fragment/SettingSecurityFragment.kt b/setting/src/main/java/com/najudoryeong/mineme/setting/fragment/ui/SettingSecurityFragment.kt similarity index 87% rename from setting/src/main/java/com/najudoryeong/mineme/setting/fragment/SettingSecurityFragment.kt rename to setting/src/main/java/com/najudoryeong/mineme/setting/fragment/ui/SettingSecurityFragment.kt index e3f4fe8..83d3542 100644 --- a/setting/src/main/java/com/najudoryeong/mineme/setting/fragment/SettingSecurityFragment.kt +++ b/setting/src/main/java/com/najudoryeong/mineme/setting/fragment/ui/SettingSecurityFragment.kt @@ -1,4 +1,4 @@ -package com.najudoryeong.mineme.setting.fragment +package com.najudoryeong.mineme.setting.fragment.ui import com.najudoryeong.mineme.common_ui.BaseFragment import com.najudoryeong.mineme.setting.SettingSecurity diff --git a/setting/src/main/res/layout/fragment_setting.xml b/setting/src/main/res/layout/fragment_setting.xml index 39d833a..883d233 100644 --- a/setting/src/main/res/layout/fragment_setting.xml +++ b/setting/src/main/res/layout/fragment_setting.xml @@ -8,7 +8,7 @@ android:layout_height="match_parent" android:orientation="vertical" android:paddingTop="22dp" - tools:context=".fragment.SettingFragment"> + tools:context=".fragment.ui.SettingFragment"> + tools:context=".fragment.ui.SettingInquiryFragment"> + tools:context=".fragment.ui.SettingNoticeFragment"> + tools:context=".fragment.ui.SettingNotificationFragment"> + tools:context=".fragment.ui.SettingSecurityFragment"> \ 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 index e9195aa..800d741 100644 --- 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 @@ -7,8 +7,6 @@ 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 - } + suspend fun readStoryList(token: String): List? = storyService.readStoryList(token).data + } \ 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 index d9dd094..f28c76d 100644 --- a/story/src/main/java/com/najudoryeong/mineme/story/ui/StoryFragment.kt +++ b/story/src/main/java/com/najudoryeong/mineme/story/ui/StoryFragment.kt @@ -1,5 +1,6 @@ package com.najudoryeong.mineme.story.ui +import android.widget.Toast import androidx.fragment.app.viewModels import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope @@ -10,38 +11,48 @@ import com.najudoryeong.mineme.story.StoryOutAdapter import com.najudoryeong.mineme.story.util.Story_Foundation_Info import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.flow.collect +import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.launch @AndroidEntryPoint class StoryFragment : BaseFragment(Story_Foundation_Info) { - private val viewModel: StoryViewModel by viewModels() + private val storyViewModel: StoryViewModel by viewModels() private val storyOutAdapter: StoryOutAdapter by lazy { StoryOutAdapter() } + override fun initView() { - viewModel.raedStory() - - /// 이거는 바깥 그거에 넣어줄 데이터 - lifecycleScope.launch { - repeatOnLifecycle(Lifecycle.State.STARTED) { - launch { - viewModel.storyList.collect() - } - } - } binding.apply { //todo callback this.lifecycleOwner = viewLifecycleOwner this.adapter = storyOutAdapter - this.viewModel = viewModel + this.viewModel = storyViewModel + this.swiperefreshlayout.setOnRefreshListener { + storyViewModel.raedStory{ + swiperefreshlayout.isRefreshing = false + } + } } + storyViewModel.raedStory() + toastObserve() + + } + + private fun toastObserve() { + lifecycleScope.launch{ + storyViewModel.toastMessage.collectLatest { + if (it.isNotEmpty()){ + Toast.makeText(context,it,Toast.LENGTH_SHORT).show() + } + } + } } } \ 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 index b73a4dc..215a8a2 100644 --- a/story/src/main/java/com/najudoryeong/mineme/story/ui/StoryViewModel.kt +++ b/story/src/main/java/com/najudoryeong/mineme/story/ui/StoryViewModel.kt @@ -1,7 +1,7 @@ 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 @@ -9,9 +9,11 @@ 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( +var dummy: MutableList = mutableListOf( StoryListWithDate( "2020", "03", listOf( Story( @@ -80,21 +82,34 @@ class StoryViewModel @Inject constructor( private val _storyList = MutableStateFlow>(mutableListOf()) val storyList: StateFlow> = _storyList + private val _isApiLoading = MutableStateFlow(true) + val isApiLoading: StateFlow = _isApiLoading - //todo isuploading - fun raedStory() { - Log.d("testStory", "데이터 넣음") - _storyList.value = dummy + private val _toastMessage = MutableStateFlow("") + val toastMessage: StateFlow = _toastMessage + + fun raedStory(endApiCallBack: () -> Unit = {}) { + viewModelScope.launch { + _isApiLoading.value = true + + //_storyList.value = dummy + + try { + storyUseCase.readStoryList(dataStoreUseCase.bearerJsonWebToken.first()!!).let { + if (it != null) { + _storyList.value = it.toMutableList() + } else { + + } + } + } catch (e: Exception) { + _toastMessage.value = "스토리리스트 가져오는 거 실패" + } + endApiCallBack.invoke() + _isApiLoading.value = false + } -// 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/res/layout/fragment_story.xml b/story/src/main/res/layout/fragment_story.xml index 870fcc8..fc63729 100644 --- a/story/src/main/res/layout/fragment_story.xml +++ b/story/src/main/res/layout/fragment_story.xml @@ -25,42 +25,65 @@ android:layout_height="match_parent" android:padding="4dp"> - - - - - - - - - - + android:layout_height="match_parent"> + + + + + + + + + + + + + + + + + + + diff --git a/story/src/main/res/layout/item_story_out.xml b/story/src/main/res/layout/item_story_out.xml index 6abb35a..703855d 100644 --- a/story/src/main/res/layout/item_story_out.xml +++ b/story/src/main/res/layout/item_story_out.xml @@ -1,6 +1,7 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools"> @@ -19,20 +20,20 @@ android:id="@+id/date" android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_marginBottom="16dp" android:gravity="center" android:text="@{yearMonth}" android:textSize="17sp" - app:layout_constraintTop_toTopOf="parent" - android:layout_marginBottom="16dp" - /> + app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toBottomOf="@id/date" + tools:listitem="@layout/item_story_in" + app:spanCount="2" /> From 2875dfd47b6d3453eb673f52b4566cd1d74b2e5c Mon Sep 17 00:00:00 2001 From: kimdowoo Date: Thu, 16 Feb 2023 21:59:40 +0900 Subject: [PATCH 6/9] =?UTF-8?q?[MIN-49]=20WriteStoryFragment=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84(#23)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/git_toolbox_prj.xml | 15 +++ .../com/najudoryeong/mineme/MainActivity.kt | 4 +- app/src/main/res/values/themes.xml | 4 +- build.gradle | 2 + common-ui/build.gradle | 5 + .../mineme/common_ui/BaseFragment.kt | 17 ++- .../com/najudoryeong/mineme/common_ui/Util.kt | 36 +++++++ .../src/main/res/drawable/img_dropdown.xml | 9 ++ .../src/main/res/drawable/spinner_shape.xml | 16 +++ .../src/main/res/layout/item_dropdown.xml | 9 ++ common-ui/src/main/res/layout/item_story.xml | 83 +++++++-------- .../story/domain/usecase/StoryUseCase.kt | 2 +- .../mineme/story/ui/StoryFragment.kt | 20 ++-- .../mineme/story/ui/StoryViewModel.kt | 10 +- .../mineme/story/ui/WriteStoryFragment.kt | 64 +++++++++++ .../mineme/story/util/FragmentObject.kt | 16 ++- story/src/main/res/drawable/img_complete.xml | 9 ++ .../main/res/drawable/img_select_picture.xml | 100 ++++++++++++++++++ .../main/res/layout/fragment_write_story.xml | 89 ++++++++++++++++ story/src/main/res/menu/write_story_menu.xml | 12 +++ story/src/main/res/navigation/nav_story.xml | 11 +- story/src/main/res/values/strings.xml | 1 + 22 files changed, 466 insertions(+), 68 deletions(-) create mode 100644 .idea/git_toolbox_prj.xml create mode 100644 common-ui/src/main/java/com/najudoryeong/mineme/common_ui/Util.kt create mode 100644 common-ui/src/main/res/drawable/img_dropdown.xml create mode 100644 common-ui/src/main/res/drawable/spinner_shape.xml create mode 100644 common-ui/src/main/res/layout/item_dropdown.xml create mode 100644 story/src/main/java/com/najudoryeong/mineme/story/ui/WriteStoryFragment.kt create mode 100644 story/src/main/res/drawable/img_complete.xml create mode 100644 story/src/main/res/drawable/img_select_picture.xml create mode 100644 story/src/main/res/layout/fragment_write_story.xml create mode 100644 story/src/main/res/menu/write_story_menu.xml diff --git a/.idea/git_toolbox_prj.xml b/.idea/git_toolbox_prj.xml new file mode 100644 index 0000000..02b915b --- /dev/null +++ b/.idea/git_toolbox_prj.xml @@ -0,0 +1,15 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/najudoryeong/mineme/MainActivity.kt b/app/src/main/java/com/najudoryeong/mineme/MainActivity.kt index c85da26..942b5cb 100644 --- a/app/src/main/java/com/najudoryeong/mineme/MainActivity.kt +++ b/app/src/main/java/com/najudoryeong/mineme/MainActivity.kt @@ -13,6 +13,8 @@ import androidx.navigation.ui.setupWithNavController import com.najudoryeong.mineme.common_ui.MainActivityUtil import com.najudoryeong.mineme.databinding.ActivityMainBinding import dagger.hilt.android.AndroidEntryPoint +import com.najudoryeong.mineme.story.R.id.storyFragment +import com.najudoryeong.mineme.home.R.id.homeFragment // 하위 모듈이 MainViewModel 코드에 접근할 수 있게 MainViewModelUtil 상속 구현 @@ -44,7 +46,7 @@ class MainActivity : AppCompatActivity(), MainActivityUtil { // appbar 구성 요소 설정 // 바텀네비게이션과 연결하면 해당 프래그먼트에 네비게이션으로는 backButton x appBarConfiguration = AppBarConfiguration( - setOf(R.id.nav_home, R.id.nav_story, R.id.nav_setting) + setOf(homeFragment, storyFragment, R.id.nav_setting) ) // navController 와 actionbar 연결 diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 015dc35..5387261 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -1,9 +1,9 @@ -