From 3fb938cc85e8b46866092bcce2937125514e3382 Mon Sep 17 00:00:00 2001 From: hanseuk-Choi Date: Sun, 19 Feb 2023 12:57:08 +0900 Subject: [PATCH 01/40] feat : backup paging --- app/build.gradle | 4 ++ .../teampome/pome/network/RecordService.kt | 4 +- .../record/RecordRemoteDataSource.kt | 2 +- .../record/paging/RecordPagingSource.kt | 40 +++++++++++++++++++ 4 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/com/teampome/pome/repository/record/paging/RecordPagingSource.kt diff --git a/app/build.gradle b/app/build.gradle index fc013604..51f7210f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -103,4 +103,8 @@ dependencies { // DataStore implementation "androidx.datastore:datastore-preferences:1.0.0" + + // Paging + def paging_version = '3.2.0-alpha04' + implementation "androidx.paging:paging-runtime:$paging_version" } \ No newline at end of file diff --git a/app/src/main/java/com/teampome/pome/network/RecordService.kt b/app/src/main/java/com/teampome/pome/network/RecordService.kt index 0d814148..d9bf076b 100644 --- a/app/src/main/java/com/teampome/pome/network/RecordService.kt +++ b/app/src/main/java/com/teampome/pome/network/RecordService.kt @@ -15,7 +15,9 @@ interface RecordService { */ @GET("api/v1/records/users/{userId}") suspend fun getRecordDataByUserId( - @Path("userId") userId: String + @Path("userId") userId: String, + @Query("page_number") pageNumber: Int?, + @Query("page_size") pageSize: Int? ) : Response>> /** diff --git a/app/src/main/java/com/teampome/pome/repository/record/RecordRemoteDataSource.kt b/app/src/main/java/com/teampome/pome/repository/record/RecordRemoteDataSource.kt index 0c44bb35..95cee608 100644 --- a/app/src/main/java/com/teampome/pome/repository/record/RecordRemoteDataSource.kt +++ b/app/src/main/java/com/teampome/pome/repository/record/RecordRemoteDataSource.kt @@ -15,7 +15,7 @@ class RecordRemoteDataSource @Inject constructor( private val service: RecordService ): RecordDataSource { override fun getRecordDataByUserId(userId: String): Flow>>> = apiRequestFlow { - service.getRecordDataByUserId(userId) + service.getRecordDataByUserId(userId, null, null) } override fun writeConsumeRecord(consumeRecordDataBody: ConsumeRecordDataBody): Flow>> = apiRequestFlow { diff --git a/app/src/main/java/com/teampome/pome/repository/record/paging/RecordPagingSource.kt b/app/src/main/java/com/teampome/pome/repository/record/paging/RecordPagingSource.kt new file mode 100644 index 00000000..160da08c --- /dev/null +++ b/app/src/main/java/com/teampome/pome/repository/record/paging/RecordPagingSource.kt @@ -0,0 +1,40 @@ +//package com.teampome.pome.repository.record.paging +// +//import androidx.paging.PagingSource +//import androidx.paging.PagingState +//import com.teampome.pome.model.RecordData +//import com.teampome.pome.model.base.BasePomeResponse +//import com.teampome.pome.network.RecordService +//import retrofit2.HttpException +//import java.io.IOException +//import javax.inject.Inject +// +//const val DEFAULT_PAGE_INDEX = 1 +// +//class RecordPagingSource @Inject constructor( +// private val service: RecordService, +// private val userId: String +//) : PagingSource>() { +// override suspend fun load(params: LoadParams): LoadResult> { +// val page = params.key ?: DEFAULT_PAGE_INDEX +// +// return try { +// val response = service.getRecordDataByUserId(userId, page, params.loadSize).body() +// +// LoadResult.Page( +// response, prevKey = if (page == DEFAULT_PAGE_INDEX) null else page - 1, +// nextKey = if (response.isEmpty()) null else page + 1 +// ) +// } catch(e : IOException) { +// return LoadResult.Error(e) +// } catch(e : HttpException) { +// return LoadResult.Error(e) +// } +// } +// +// override fun getRefreshKey(state: PagingState>): Int? { +// return state.anchorPosition?.let { anchorPosition -> +// state.closestItemToPosition(anchorPosition)?. +// } +// } +//} \ No newline at end of file From 8bfd7d738285fbcd80a9abaa4f12e7350714bb0b Mon Sep 17 00:00:00 2001 From: hanseulchoi Date: Mon, 20 Feb 2023 10:14:05 +0900 Subject: [PATCH 02/40] =?UTF-8?q?fix=20:=20RecyclerViewAdapter=20=EB=A9=94?= =?UTF-8?q?=EB=AA=A8=EB=A6=AC=20=EB=88=84=EC=88=98=20=EC=9A=B0=EB=A0=A4=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pome/presentation/record/RecordCategoryAdapter.kt | 4 +--- .../pome/presentation/record/RecordContentsCardAdapter.kt | 8 +++++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/teampome/pome/presentation/record/RecordCategoryAdapter.kt b/app/src/main/java/com/teampome/pome/presentation/record/RecordCategoryAdapter.kt index 91dbc717..9a37ca66 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/RecordCategoryAdapter.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/RecordCategoryAdapter.kt @@ -11,8 +11,6 @@ import com.teampome.pome.model.goal.GoalCategoryResponse import com.teampome.pome.presentation.remind.OnCategoryItemClickListener class RecordCategoryAdapter : ListAdapter(RecordCategoryDiffCallback()) { - lateinit var bind: ItemRecordCategoryChipBinding - // category click 관리 변수 private var onCategoryItemClickListener: OnCategoryItemClickListener? = null private var selectedPosition = 0 @@ -22,7 +20,7 @@ class RecordCategoryAdapter : ListAdapter( RecordContentsCardDiffCallback() ) { - private lateinit var binding: ItemRecordEmotionCardBinding + // 절대 Adapter 내부에 lateinit var을 넣지 말자. + // bind를 lateinit하고 onCreateViewHolder에서 재사용하고 있어 메모리 누수가 발생됨 + // ex) RecyclerView에서 아이템이 추가될 때 마다 Binding 인스턴스가 할당되고 이전에 할당된 인스턴스가 GC로 회수되지 않을 가능성이 매우 큼 private var moreItemClickListener: OnMoreItemClickListener? = null private var bodyClickListener: OnRecordItemClickListener? = null @@ -29,7 +31,7 @@ class RecordContentsCardAdapter : ListAdapter Date: Mon, 20 Feb 2023 10:56:16 +0900 Subject: [PATCH 03/40] =?UTF-8?q?fix=20:=20Duplication=20class=20error=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 4 ++-- build.gradle | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 51f7210f..55d9a0e6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -90,7 +90,7 @@ dependencies { implementation "androidx.navigation:navigation-ui-ktx:$nav_version" // Hilt - def hilt_version = '2.42' + def hilt_version = '2.44' implementation "com.google.dagger:hilt-android:$hilt_version" kapt "com.google.dagger:hilt-android-compiler:$hilt_version" @@ -105,6 +105,6 @@ dependencies { implementation "androidx.datastore:datastore-preferences:1.0.0" // Paging - def paging_version = '3.2.0-alpha04' + def paging_version = '3.1.1' implementation "androidx.paging:paging-runtime:$paging_version" } \ No newline at end of file diff --git a/build.gradle b/build.gradle index d2209c93..390b7711 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ plugins { id 'com.android.application' version '7.3.1' apply false id 'com.android.library' version '7.3.1' apply false - id 'org.jetbrains.kotlin.android' version '1.7.10' apply false + id 'org.jetbrains.kotlin.android' version '1.7.20' apply false id 'androidx.navigation.safeargs' version '2.4.2' apply false id 'com.google.dagger.hilt.android' version '2.42' apply false } From 06038e8ff496aeca50a1a383d421598660b4a553 Mon Sep 17 00:00:00 2001 From: hanseuk-Choi Date: Wed, 1 Mar 2023 01:10:23 +0900 Subject: [PATCH 04/40] =?UTF-8?q?fix=20:=20=EC=84=9C=EB=B2=84=20api=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=EC=97=90=20=EB=94=B0=EB=A5=B8=20GoalCategory?= =?UTF-8?q?Response=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pome/model/goal/GoalCategoryResponse.kt | 11 ----------- .../java/com/teampome/pome/model/goal/GoalData.kt | 2 +- .../presentation/record/RecordCategoryAdapter.kt | 1 - .../com/teampome/pome/viewmodel/RemindViewModel.kt | 4 ++-- .../pome/viewmodel/record/RecordViewModel.kt | 14 ++++++++++---- 5 files changed, 13 insertions(+), 19 deletions(-) delete mode 100644 app/src/main/java/com/teampome/pome/model/goal/GoalCategoryResponse.kt diff --git a/app/src/main/java/com/teampome/pome/model/goal/GoalCategoryResponse.kt b/app/src/main/java/com/teampome/pome/model/goal/GoalCategoryResponse.kt deleted file mode 100644 index ff34515b..00000000 --- a/app/src/main/java/com/teampome/pome/model/goal/GoalCategoryResponse.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.teampome.pome.model.goal - -import android.os.Parcelable -import kotlinx.parcelize.Parcelize - -@Parcelize -data class GoalCategoryResponse( - val id: Int, - val name: String, - var isSelected: Boolean? = false -) : Parcelable \ No newline at end of file diff --git a/app/src/main/java/com/teampome/pome/model/goal/GoalData.kt b/app/src/main/java/com/teampome/pome/model/goal/GoalData.kt index 16c24893..50d00786 100644 --- a/app/src/main/java/com/teampome/pome/model/goal/GoalData.kt +++ b/app/src/main/java/com/teampome/pome/model/goal/GoalData.kt @@ -6,7 +6,7 @@ import kotlinx.parcelize.Parcelize @Parcelize data class GoalData( val endDate: String, - val goalCategoryResponse: GoalCategoryResponse, + val name: String, val id: Int, val isEnd: Boolean, val isPublic: Boolean, diff --git a/app/src/main/java/com/teampome/pome/presentation/record/RecordCategoryAdapter.kt b/app/src/main/java/com/teampome/pome/presentation/record/RecordCategoryAdapter.kt index 9a37ca66..bff658bd 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/RecordCategoryAdapter.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/RecordCategoryAdapter.kt @@ -7,7 +7,6 @@ import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView import com.teampome.pome.databinding.ItemRecordCategoryChipBinding import com.teampome.pome.model.goal.GoalCategory -import com.teampome.pome.model.goal.GoalCategoryResponse import com.teampome.pome.presentation.remind.OnCategoryItemClickListener class RecordCategoryAdapter : ListAdapter(RecordCategoryDiffCallback()) { diff --git a/app/src/main/java/com/teampome/pome/viewmodel/RemindViewModel.kt b/app/src/main/java/com/teampome/pome/viewmodel/RemindViewModel.kt index e8aec766..c47dbe49 100644 --- a/app/src/main/java/com/teampome/pome/viewmodel/RemindViewModel.kt +++ b/app/src/main/java/com/teampome/pome/viewmodel/RemindViewModel.kt @@ -42,8 +42,8 @@ class RemindViewModel @Inject constructor( allGoalData.content.map { data -> data?.let { gd -> GoalCategory( - gd.goalCategoryResponse.id, - gd.goalCategoryResponse.name, + gd.id, + gd.name, false, gd.id, CommonUtil.calDiffDate(gd.endDate) == 0 diff --git a/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt b/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt index f4fe029b..ef7473e8 100644 --- a/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt +++ b/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt @@ -1,5 +1,6 @@ package com.teampome.pome.viewmodel.record +import android.util.Log import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations @@ -40,16 +41,20 @@ class RecordViewModel @Inject constructor( when(it) { is ApiResponse.Success -> { it.data.data?.let { allGoalData -> - allGoalData.content.map { data -> + allGoalData.content.filter { data -> + data?.let { gd -> // filter 내에서 testData 분리 + gd.endDate != "string" + } ?: false + }.map { data -> data?.let { gd -> GoalCategory( - gd.goalCategoryResponse.id, - gd.goalCategoryResponse.name, + gd.id, + gd.name, false, gd.id, CommonUtil.calDiffDate(gd.endDate) == 0 ) - } ?: run { null } + } } } ?: run { null } } @@ -58,6 +63,7 @@ class RecordViewModel @Inject constructor( } } + val goalDetails: LiveData> = Transformations.map(_findAllGoalByUserResponse) { when(it) { is ApiResponse.Success -> { From 9da497b13a9de9b7f2ed4d951b36135b7ac52eeb Mon Sep 17 00:00:00 2001 From: hanseuk-Choi Date: Wed, 1 Mar 2023 13:40:51 +0900 Subject: [PATCH 05/40] =?UTF-8?q?feat=20:=20token=20refresh=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20=EC=A3=BC=EC=84=9D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/teampome/pome/util/base/ApiRequestFlow.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/teampome/pome/util/base/ApiRequestFlow.kt b/app/src/main/java/com/teampome/pome/util/base/ApiRequestFlow.kt index 898787f5..39ccb60b 100644 --- a/app/src/main/java/com/teampome/pome/util/base/ApiRequestFlow.kt +++ b/app/src/main/java/com/teampome/pome/util/base/ApiRequestFlow.kt @@ -6,9 +6,7 @@ import com.teampome.pome.model.base.BaseAllData import com.teampome.pome.model.base.BasePomeResponse import com.teampome.pome.model.base.ErrorResponse import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flow -import kotlinx.coroutines.flow.flowOn +import kotlinx.coroutines.flow.* import kotlinx.coroutines.withTimeoutOrNull import retrofit2.Response @@ -38,6 +36,10 @@ fun apiRequestFlow(call: suspend () -> Response): Flow> = f emit(ApiResponse.Success(data)) } } else if (!(response.body() as BasePomeResponse<*>).success) { + if((response.body() as BasePomeResponse<*>).errorCode == "T0001") { // TokenRefresh 해야하는 부분 + // 토큰을 변경하고 재시도하는 작업이 필요 + } + emit(ApiResponse.Failure((response.body() as BasePomeResponse<*>).message, (response.body() as BasePomeResponse<*>).errorCode ?: "400")) } else { response.errorBody()?.let { error -> From 24a77791dda7e9852ea263731391ea22f2fdc852 Mon Sep 17 00:00:00 2001 From: hanseuk-Choi Date: Wed, 1 Mar 2023 13:51:34 +0900 Subject: [PATCH 06/40] =?UTF-8?q?fix=20:=20enableOnBackInvokedCallback=3D"?= =?UTF-8?q?true"=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2b270900..dc7a75ad 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -24,6 +24,7 @@ android:theme="@style/Theme.Pome" tools:targetApi="33" android:usesCleartextTraffic="true" + android:enableOnBackInvokedCallback="true" android:name=".PomeApplication"> Date: Thu, 2 Mar 2023 17:26:51 +0900 Subject: [PATCH 07/40] feat : backup RecordPagingSource --- .../record/paging/RecordPagingSource.kt | 99 +++++++++++-------- 1 file changed, 59 insertions(+), 40 deletions(-) diff --git a/app/src/main/java/com/teampome/pome/repository/record/paging/RecordPagingSource.kt b/app/src/main/java/com/teampome/pome/repository/record/paging/RecordPagingSource.kt index 160da08c..520f9a30 100644 --- a/app/src/main/java/com/teampome/pome/repository/record/paging/RecordPagingSource.kt +++ b/app/src/main/java/com/teampome/pome/repository/record/paging/RecordPagingSource.kt @@ -1,40 +1,59 @@ -//package com.teampome.pome.repository.record.paging -// -//import androidx.paging.PagingSource -//import androidx.paging.PagingState -//import com.teampome.pome.model.RecordData -//import com.teampome.pome.model.base.BasePomeResponse -//import com.teampome.pome.network.RecordService -//import retrofit2.HttpException -//import java.io.IOException -//import javax.inject.Inject -// -//const val DEFAULT_PAGE_INDEX = 1 -// -//class RecordPagingSource @Inject constructor( -// private val service: RecordService, -// private val userId: String -//) : PagingSource>() { -// override suspend fun load(params: LoadParams): LoadResult> { -// val page = params.key ?: DEFAULT_PAGE_INDEX -// -// return try { -// val response = service.getRecordDataByUserId(userId, page, params.loadSize).body() -// -// LoadResult.Page( -// response, prevKey = if (page == DEFAULT_PAGE_INDEX) null else page - 1, -// nextKey = if (response.isEmpty()) null else page + 1 -// ) -// } catch(e : IOException) { -// return LoadResult.Error(e) -// } catch(e : HttpException) { -// return LoadResult.Error(e) -// } -// } -// -// override fun getRefreshKey(state: PagingState>): Int? { -// return state.anchorPosition?.let { anchorPosition -> -// state.closestItemToPosition(anchorPosition)?. -// } -// } -//} \ No newline at end of file +package com.teampome.pome.repository.record.paging + +import androidx.paging.PagingSource +import androidx.paging.PagingState +import com.teampome.pome.model.RecordData +import com.teampome.pome.network.RecordService +import dagger.assisted.Assisted +import dagger.assisted.AssistedInject +import retrofit2.HttpException +import java.io.IOException + +class RecordPagingSource @AssistedInject constructor( + private val service: RecordService, + @Assisted("goalId") private val goalId: Int // Assisted는 Hilt를 통해 주입되지 않는다는 Annotation +) : PagingSource() { + override suspend fun load(params: LoadParams): LoadResult { + return try { + val pageNumber = params.key ?: 0 + val pageSize = params.loadSize + val response = service.getRecordByGoalId(goalId, pageNumber, pageSize) + + if (response.isSuccessful) { + val baseAllData = response.body()?.data + val items = baseAllData?.content?.filterNotNull() ?: emptyList() + val prevKey = if (pageNumber == 0) null else pageNumber - 1 + val nextKey = if (items.isEmpty() || response.body()?.data?.empty == true) null else pageNumber + 1 + + LoadResult.Page(items, prevKey, nextKey) + } else { + LoadResult.Error(Exception("Error loading data")) + } + } catch(e : IOException) { + return LoadResult.Error(e) + } catch(e : HttpException) { + return LoadResult.Error(e) + } + } + + override fun getRefreshKey(state: PagingState): Int? { + return state.anchorPosition?.let { anchorPosition -> + val anchorPage = state.closestPageToPosition(anchorPosition) + anchorPage?.prevKey?.plus(1) ?: anchorPage?.nextKey?.minus(1) + } + } + + @com.squareup.inject.assisted.AssistedInject.Factory + interface Factory { + fun create(goalId: Int): RecordPagingSource + } + + companion object { + fun provideFactory( + assistedFactory: Factory, + goalId: Int + ): () -> RecordPagingSource = { + assistedFactory.create(goalId) + } + } +} \ No newline at end of file From 1a06eb6dd9e3001ca3574c43cc786a5eb231cd84 Mon Sep 17 00:00:00 2001 From: hanseulchoi Date: Mon, 6 Mar 2023 17:32:42 +0900 Subject: [PATCH 08/40] feat : backup Paging3 --- app/build.gradle | 7 + .../teampome/pome/network/RecordService.kt | 8 +- .../record/RecordContentsCardAdapter.kt | 15 +- .../presentation/record/RecordFragment.kt | 132 +++++++++++------- .../repository/record/RecordDataSource.kt | 2 + .../record/RecordRemoteDataSource.kt | 22 ++- .../repository/record/RecordRepository.kt | 6 + .../record/paging/RecordPagingSource.kt | 23 +-- .../pome/viewmodel/record/RecordViewModel.kt | 27 ++++ 9 files changed, 168 insertions(+), 74 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 55d9a0e6..0fce4db4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -107,4 +107,11 @@ dependencies { // Paging def paging_version = '3.1.1' implementation "androidx.paging:paging-runtime:$paging_version" + + implementation 'com.squareup.inject:assisted-inject-annotations-dagger2:0.6.0' + kapt 'com.squareup.inject:assisted-inject-processor-dagger2:0.6.0' + kapt "com.google.dagger:dagger-compiler:2.44" + kapt "com.google.dagger:dagger-android-processor:2.44" + kapt "com.squareup.inject:assisted-inject-processor-dagger2:0.6.0" + kapt 'com.google.dagger:hilt-android-compiler:2.44' } \ No newline at end of file diff --git a/app/src/main/java/com/teampome/pome/network/RecordService.kt b/app/src/main/java/com/teampome/pome/network/RecordService.kt index d9bf076b..e85c048d 100644 --- a/app/src/main/java/com/teampome/pome/network/RecordService.kt +++ b/app/src/main/java/com/teampome/pome/network/RecordService.kt @@ -15,9 +15,7 @@ interface RecordService { */ @GET("api/v1/records/users/{userId}") suspend fun getRecordDataByUserId( - @Path("userId") userId: String, - @Query("page_number") pageNumber: Int?, - @Query("page_size") pageSize: Int? + @Path("userId") userId: String ) : Response>> /** @@ -51,7 +49,9 @@ interface RecordService { */ @GET("api/v1/records/goal/{goalId}/record-tab") suspend fun getRecordByGoalId( - @Path("goalId") goalId: Int + @Path("goalId") goalId: Int, + @Query("page") pageNumber: Int?, + @Query("size") pageSize: Int? ) : Response>> /** diff --git a/app/src/main/java/com/teampome/pome/presentation/record/RecordContentsCardAdapter.kt b/app/src/main/java/com/teampome/pome/presentation/record/RecordContentsCardAdapter.kt index d79a2d00..c1eb6002 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/RecordContentsCardAdapter.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/RecordContentsCardAdapter.kt @@ -1,5 +1,6 @@ package com.teampome.pome.presentation.record +import android.util.Log import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.DiffUtil @@ -12,6 +13,7 @@ import com.teampome.pome.util.OnItemClickListener class RecordContentsCardAdapter : ListAdapter( RecordContentsCardDiffCallback() ) { + private lateinit var binding: ItemRecordEmotionCardBinding // 절대 Adapter 내부에 lateinit var을 넣지 말자. // bind를 lateinit하고 onCreateViewHolder에서 재사용하고 있어 메모리 누수가 발생됨 // ex) RecyclerView에서 아이템이 추가될 때 마다 Binding 인스턴스가 할당되고 이전에 할당된 인스턴스가 GC로 회수되지 않을 가능성이 매우 큼 @@ -31,18 +33,27 @@ class RecordContentsCardAdapter : ListAdapter(R.layout.fragment_record) { @@ -95,6 +104,18 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec } }) + viewModel.getRecordPagingData(275) + + viewModel.records.observe(viewLifecycleOwner) { pagingData -> + // Update the data in the RecyclerView adapter +// adapter.submitData(viewLifecycleOwner.lifecycle, pagingData) + pagingData.map { recordData -> + Log.d("PagingData", "recordData: $recordData") + } + } + + + makeBottomSheetDialog() makeRecordDialog() makeGoalRemoveDialog() @@ -109,11 +130,38 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec override fun onCategoryItemClick(item: GoalCategory, position: Int) { currentCategory = item.name currentCategoryPosition = position - viewModel.getRecordByGoalId(item.goalId, object : CoroutineErrorHandler { - override fun onError(message: String) { - Log.e("record", "record error $message") - } - }) +// viewModel.getRecordByGoalId(item.goalId, object : CoroutineErrorHandler { +// override fun onError(message: String) { +// Log.e("record", "record error $message") +// } +// }) + + lifecycleScope.launch { +// val pagingConfig = PagingConfig( +// pageSize = 15, +// enablePlaceholders = false +// ) +// +// val recordPagingSourceFactory = RecordPagingSource.provideFactory(recordPagingSourceFactory, item.goalId) +// +// val recordPager = Pager( +// config = pagingConfig, +// pagingSourceFactory = recordPagingSourceFactory).liveData +// +// Log.d("test", "pager : ${recordPager.value}") + +// pagingData.let { contents -> +// binding.recordData = contents.content +// viewModel.setRecordData(contents.content) +// +// binding.executePendingBindings() +// } +// +// (binding.recordEmotionRv.adapter as RecordContentsCardAdapter).submitList( +// it.data.data?.content?.toMutableList() ?: mutableListOf() +// ) + + } viewModel.getOneWeekRecordByGoalId(item.goalId, object : CoroutineErrorHandler { override fun onError(message: String) { @@ -177,12 +225,12 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec currentCategory = it[0]!!.name currentCategoryPosition = 0 - // 카테고리 데이터 받은 후 목표 가져오는 작업 진행 - viewModel.getRecordByGoalId(it[0]!!.goalId, object : CoroutineErrorHandler { - override fun onError(message: String) { - Log.e("record", "record error $message") - } - }) +// // 카테고리 데이터 받은 후 목표 가져오는 작업 진행 +// viewModel.getRecordByGoalId(it[0]!!.goalId, object : CoroutineErrorHandler { +// override fun onError(message: String) { +// Log.e("record", "record error $message") +// } +// }) viewModel.getOneWeekRecordByGoalId(it[0]!!.goalId, object : CoroutineErrorHandler { override fun onError(message: String) { @@ -196,43 +244,31 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec } } - viewModel.getRecordByGoalIdResponse.observe(viewLifecycleOwner) { it -> - when(it) { - is ApiResponse.Success -> { - it.data.data?.let { contents -> - binding.recordData = contents.content - viewModel.setRecordData(contents.content) - - binding.executePendingBindings() - } - -// submit list하는 list는 다른 값인데, 이전 값이 currentList임... -// submitList의 list는 정상, 계속 카테고리를 변경하다보면 list값이 아예 섞임.. -// debuging시에는 정상? 그러면 충분한 업데이트 시간이 없어서? -// 1 - 2 - 1 - 3 정상, 3 - 2 - 3 비정상 => null을 받을 때, submitList가 이상하게 동작? -// notifyDataSetChanged, invalidateAll, executePendingBinding 다 동작 x -// currentList는 정상.. - // 임시 처리 : 데이터 변경 시 새로운 어댑터 객체 생성 - binding.recordEmotionRv.adapter = RecordContentsCardAdapter().apply { - setOnBodyClickListener(itemClickListener) - setOnMoreItemClickListener(moreItemClickListener) - } - - (binding.recordEmotionRv.adapter as RecordContentsCardAdapter).submitList( - it.data.data?.content?.toMutableList() ?: mutableListOf() - ) - - hideLoading() - } - is ApiResponse.Failure -> { - Toast.makeText(requireContext(), it.errorMessage, Toast.LENGTH_SHORT).show() - Log.d("recordData", "failure RecordData : $it") - - hideLoading() - } - is ApiResponse.Loading -> { showLoading() } - } - } +// viewModel.getRecordByGoalIdResponse.observe(viewLifecycleOwner) { it -> +// when(it) { +// is ApiResponse.Success -> { +// it.data.data?.let { contents -> +// binding.recordData = contents.content +// viewModel.setRecordData(contents.content) +// +// binding.executePendingBindings() +// } +// +// (binding.recordEmotionRv.adapter as RecordContentsCardAdapter).submitList( +// it.data.data?.content?.toMutableList() ?: mutableListOf() +// ) +// +// hideLoading() +// } +// is ApiResponse.Failure -> { +// Toast.makeText(requireContext(), it.errorMessage, Toast.LENGTH_SHORT).show() +// Log.d("recordData", "failure RecordData : $it") +// +// hideLoading() +// } +// is ApiResponse.Loading -> { showLoading() } +// } +// } viewModel.getOneWeekRecordByGoalIdResponse.observe(viewLifecycleOwner) { when(it) { diff --git a/app/src/main/java/com/teampome/pome/repository/record/RecordDataSource.kt b/app/src/main/java/com/teampome/pome/repository/record/RecordDataSource.kt index 8fd97cde..16c2df99 100644 --- a/app/src/main/java/com/teampome/pome/repository/record/RecordDataSource.kt +++ b/app/src/main/java/com/teampome/pome/repository/record/RecordDataSource.kt @@ -1,5 +1,6 @@ package com.teampome.pome.repository.record +import androidx.paging.PagingData import com.teampome.pome.model.RecordData import com.teampome.pome.model.base.BaseAllData import com.teampome.pome.model.base.BasePomeResponse @@ -15,4 +16,5 @@ interface RecordDataSource { fun updateRecord(recordId: Int, recordDataBody: ConsumeRecordDataBody): Flow>> fun getRecordByGoalId(goalId: Int): Flow>>> fun getOneWeekGoalByGoalId(goalId: Int): Flow>>> + fun getRecordPagingData(goalId: Int): Flow> } \ No newline at end of file diff --git a/app/src/main/java/com/teampome/pome/repository/record/RecordRemoteDataSource.kt b/app/src/main/java/com/teampome/pome/repository/record/RecordRemoteDataSource.kt index 95cee608..b6fe2266 100644 --- a/app/src/main/java/com/teampome/pome/repository/record/RecordRemoteDataSource.kt +++ b/app/src/main/java/com/teampome/pome/repository/record/RecordRemoteDataSource.kt @@ -1,11 +1,15 @@ package com.teampome.pome.repository.record +import androidx.paging.Pager +import androidx.paging.PagingConfig +import androidx.paging.PagingData import com.teampome.pome.model.* import com.teampome.pome.model.base.BaseAllData import com.teampome.pome.model.base.BasePomeResponse import com.teampome.pome.model.request.ConsumeRecordDataBody import com.teampome.pome.model.request.EmotionDataBody import com.teampome.pome.network.RecordService +import com.teampome.pome.repository.record.paging.RecordPagingSource import com.teampome.pome.util.base.ApiResponse import com.teampome.pome.util.base.apiRequestFlow import kotlinx.coroutines.flow.Flow @@ -15,7 +19,7 @@ class RecordRemoteDataSource @Inject constructor( private val service: RecordService ): RecordDataSource { override fun getRecordDataByUserId(userId: String): Flow>>> = apiRequestFlow { - service.getRecordDataByUserId(userId, null, null) + service.getRecordDataByUserId(userId) } override fun writeConsumeRecord(consumeRecordDataBody: ConsumeRecordDataBody): Flow>> = apiRequestFlow { @@ -37,10 +41,24 @@ class RecordRemoteDataSource @Inject constructor( } override fun getRecordByGoalId(goalId: Int): Flow>>> = apiRequestFlow { - service.getRecordByGoalId(goalId) + service.getRecordByGoalId(goalId, null, null) } override fun getOneWeekGoalByGoalId(goalId: Int): Flow>>> = apiRequestFlow { service.getOneWeekGoalByGoalId(goalId) } + + override fun getRecordPagingData(goalId: Int): Flow> { + return Pager( + config = PagingConfig( + pageSize = 15, + enablePlaceholders = false, + prefetchDistance = 3, + initialLoadSize = 20 + ), + pagingSourceFactory = { + RecordPagingSource(service = service, goalId = goalId) + } + ).flow + } } \ No newline at end of file diff --git a/app/src/main/java/com/teampome/pome/repository/record/RecordRepository.kt b/app/src/main/java/com/teampome/pome/repository/record/RecordRepository.kt index 0429cf97..f8bf0c42 100644 --- a/app/src/main/java/com/teampome/pome/repository/record/RecordRepository.kt +++ b/app/src/main/java/com/teampome/pome/repository/record/RecordRepository.kt @@ -1,5 +1,6 @@ package com.teampome.pome.repository.record +import androidx.paging.PagingData import com.teampome.pome.model.RecordData import com.teampome.pome.model.base.BasePomeResponse import com.teampome.pome.model.request.ConsumeRecordDataBody @@ -15,6 +16,11 @@ class RecordRepository @Inject constructor( private val recordDataSource: RecordDataSource, private val userManager: UserManager ) { + + fun getRecordPagingData(goalId: Int): Flow> { + return recordDataSource.getRecordPagingData(goalId) + } + fun getRecordDataByUserId(): Flow>>> { val userId = runBlocking { userManager.getUserId().first() diff --git a/app/src/main/java/com/teampome/pome/repository/record/paging/RecordPagingSource.kt b/app/src/main/java/com/teampome/pome/repository/record/paging/RecordPagingSource.kt index 520f9a30..f1774673 100644 --- a/app/src/main/java/com/teampome/pome/repository/record/paging/RecordPagingSource.kt +++ b/app/src/main/java/com/teampome/pome/repository/record/paging/RecordPagingSource.kt @@ -1,19 +1,20 @@ package com.teampome.pome.repository.record.paging +import android.util.Log import androidx.paging.PagingSource import androidx.paging.PagingState import com.teampome.pome.model.RecordData import com.teampome.pome.network.RecordService -import dagger.assisted.Assisted -import dagger.assisted.AssistedInject import retrofit2.HttpException import java.io.IOException -class RecordPagingSource @AssistedInject constructor( +class RecordPagingSource constructor( private val service: RecordService, - @Assisted("goalId") private val goalId: Int // Assisted는 Hilt를 통해 주입되지 않는다는 Annotation + private val goalId: Int ) : PagingSource() { override suspend fun load(params: LoadParams): LoadResult { + Log.d("test", "is in load?") + return try { val pageNumber = params.key ?: 0 val pageSize = params.loadSize @@ -42,18 +43,4 @@ class RecordPagingSource @AssistedInject constructor( anchorPage?.prevKey?.plus(1) ?: anchorPage?.nextKey?.minus(1) } } - - @com.squareup.inject.assisted.AssistedInject.Factory - interface Factory { - fun create(goalId: Int): RecordPagingSource - } - - companion object { - fun provideFactory( - assistedFactory: Factory, - goalId: Int - ): () -> RecordPagingSource = { - assistedFactory.create(goalId) - } - } } \ No newline at end of file diff --git a/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt b/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt index ef7473e8..950f79b1 100644 --- a/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt +++ b/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt @@ -4,6 +4,10 @@ import android.util.Log import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations +import androidx.lifecycle.viewModelScope +import androidx.paging.PagingData +import androidx.paging.cachedIn +import androidx.paging.map import com.teampome.pome.model.RecordData import com.teampome.pome.model.base.BaseAllData import com.teampome.pome.model.base.BasePomeResponse @@ -17,6 +21,9 @@ import com.teampome.pome.util.base.ApiResponse import com.teampome.pome.util.base.BaseViewModel import com.teampome.pome.util.base.CoroutineErrorHandler import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.collect +import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.launch import javax.inject.Inject @@ -37,6 +44,10 @@ class RecordViewModel @Inject constructor( private val _deleteGoalResponse = MutableLiveData>>() val deleteGoalResponse: LiveData>> = _deleteGoalResponse +// fun setPagingRecordByGoalId(goalId: Int): Flow> { +// return recordRepository.getPagingRecordByGoalId(goalId).cachedIn(viewModelScope) +// } + val goalCategory: LiveData> = Transformations.map(_findAllGoalByUserResponse) { when(it) { is ApiResponse.Success -> { @@ -138,4 +149,20 @@ class RecordViewModel @Inject constructor( fun setRecordData(list: List) { _recordData.value = list } + + private val _records = MutableLiveData>() + val records: LiveData> + get() = _records + + fun getRecordPagingData(goalId: Int) { + viewModelScope.launch { + recordRepository.getRecordPagingData(goalId).cachedIn(viewModelScope).collectLatest { + _records.value = it + + it.map { it2 -> + Log.d("test", "records_value? $it2") + } + } + } + } } \ No newline at end of file From 4e38183f0796244a8adb59c8ffa46678002bd0c0 Mon Sep 17 00:00:00 2001 From: hanseuk-Choi Date: Tue, 7 Mar 2023 01:08:46 +0900 Subject: [PATCH 09/40] =?UTF-8?q?feat=20:=20RecordPagingData=20=EC=9E=84?= =?UTF-8?q?=EC=8B=9C=20=EA=B5=AC=ED=98=84=20(=ED=98=84=EC=9E=AC=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=EA=B0=80=20=EC=A0=84=EB=B6=80=20?= =?UTF-8?q?=EB=B6=88=EB=A6=AC=EB=8A=94=20=EB=AC=B8=EC=A0=9C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../record/RecordContentsCardAdapter.kt | 15 ++++++--------- .../pome/presentation/record/RecordFragment.kt | 17 ++++++++--------- .../record/leave/RecordLeaveEmotionFragment.kt | 10 +++++----- .../repository/record/RecordRemoteDataSource.kt | 4 +--- .../record/paging/RecordPagingSource.kt | 2 +- .../pome/viewmodel/record/RecordViewModel.kt | 4 ---- 6 files changed, 21 insertions(+), 31 deletions(-) diff --git a/app/src/main/java/com/teampome/pome/presentation/record/RecordContentsCardAdapter.kt b/app/src/main/java/com/teampome/pome/presentation/record/RecordContentsCardAdapter.kt index c1eb6002..7df73ac3 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/RecordContentsCardAdapter.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/RecordContentsCardAdapter.kt @@ -3,6 +3,7 @@ package com.teampome.pome.presentation.record import android.util.Log import android.view.LayoutInflater import android.view.ViewGroup +import androidx.paging.PagingDataAdapter import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView @@ -10,7 +11,7 @@ import com.teampome.pome.databinding.ItemRecordEmotionCardBinding import com.teampome.pome.model.RecordData import com.teampome.pome.util.OnItemClickListener -class RecordContentsCardAdapter : ListAdapter( +class RecordContentsCardAdapter : PagingDataAdapter( RecordContentsCardDiffCallback() ) { private lateinit var binding: ItemRecordEmotionCardBinding @@ -41,19 +42,15 @@ class RecordContentsCardAdapter : ListAdapter(R.layout.fragment_rec } }) - viewModel.getRecordPagingData(275) - - viewModel.records.observe(viewLifecycleOwner) { pagingData -> - // Update the data in the RecyclerView adapter -// adapter.submitData(viewLifecycleOwner.lifecycle, pagingData) - pagingData.map { recordData -> - Log.d("PagingData", "recordData: $recordData") + viewModel.records.observe(viewLifecycleOwner) { + lifecycleScope.launch { + (binding.recordEmotionRv.adapter as RecordContentsCardAdapter).submitData( + it + ) } } - - makeBottomSheetDialog() makeRecordDialog() makeGoalRemoveDialog() @@ -163,6 +159,8 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec } + viewModel.getRecordPagingData(item.goalId) + viewModel.getOneWeekRecordByGoalId(item.goalId, object : CoroutineErrorHandler { override fun onError(message: String) { Log.e("record", "record error $message") @@ -225,6 +223,7 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec currentCategory = it[0]!!.name currentCategoryPosition = 0 + viewModel.getRecordPagingData(it[0]!!.goalId) // // 카테고리 데이터 받은 후 목표 가져오는 작업 진행 // viewModel.getRecordByGoalId(it[0]!!.goalId, object : CoroutineErrorHandler { // override fun onError(message: String) { diff --git a/app/src/main/java/com/teampome/pome/presentation/record/leave/RecordLeaveEmotionFragment.kt b/app/src/main/java/com/teampome/pome/presentation/record/leave/RecordLeaveEmotionFragment.kt index c6183758..f6bf24ab 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/leave/RecordLeaveEmotionFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/leave/RecordLeaveEmotionFragment.kt @@ -67,11 +67,11 @@ class RecordLeaveEmotionFragment : BaseFragment - Log.d("test", "records_value? $it2") - } } } } From b5839156b5ccd64a70832af5db49cb64c5272f8e Mon Sep 17 00:00:00 2001 From: hanseulchoi Date: Tue, 7 Mar 2023 17:34:37 +0900 Subject: [PATCH 10/40] =?UTF-8?q?feat=20:=20backup=20Paging3=20=EC=97=90?= =?UTF-8?q?=EB=9F=AC=20=ED=99=95=EC=9D=B8=20=ED=9B=84=20=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=20(=EB=B7=B0=20=EA=B5=AC=EC=A1=B0=20=EB=B0=B0=EC=B9=98=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20=ED=95=84=EC=9A=94)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../record/RecordContentsCardAdapter.kt | 7 +- .../presentation/record/RecordFragment.kt | 107 +++--------------- .../record/RecordRemoteDataSource.kt | 4 +- .../record/paging/RecordPagingSource.kt | 5 +- .../pome/viewmodel/record/RecordViewModel.kt | 36 +++--- app/src/main/res/layout/fragment_record.xml | 29 ++--- 6 files changed, 53 insertions(+), 135 deletions(-) diff --git a/app/src/main/java/com/teampome/pome/presentation/record/RecordContentsCardAdapter.kt b/app/src/main/java/com/teampome/pome/presentation/record/RecordContentsCardAdapter.kt index 7df73ac3..85850fd9 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/RecordContentsCardAdapter.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/RecordContentsCardAdapter.kt @@ -14,7 +14,6 @@ import com.teampome.pome.util.OnItemClickListener class RecordContentsCardAdapter : PagingDataAdapter( RecordContentsCardDiffCallback() ) { - private lateinit var binding: ItemRecordEmotionCardBinding // 절대 Adapter 내부에 lateinit var을 넣지 말자. // bind를 lateinit하고 onCreateViewHolder에서 재사용하고 있어 메모리 누수가 발생됨 // ex) RecyclerView에서 아이템이 추가될 때 마다 Binding 인스턴스가 할당되고 이전에 할당된 인스턴스가 GC로 회수되지 않을 가능성이 매우 큼 @@ -34,9 +33,7 @@ class RecordContentsCardAdapter : PagingDataAdapter(R.layout.fragment_record) { @@ -104,14 +97,6 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec } }) - viewModel.records.observe(viewLifecycleOwner) { - lifecycleScope.launch { - (binding.recordEmotionRv.adapter as RecordContentsCardAdapter).submitData( - it - ) - } - } - makeBottomSheetDialog() makeRecordDialog() makeGoalRemoveDialog() @@ -126,38 +111,6 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec override fun onCategoryItemClick(item: GoalCategory, position: Int) { currentCategory = item.name currentCategoryPosition = position -// viewModel.getRecordByGoalId(item.goalId, object : CoroutineErrorHandler { -// override fun onError(message: String) { -// Log.e("record", "record error $message") -// } -// }) - - lifecycleScope.launch { -// val pagingConfig = PagingConfig( -// pageSize = 15, -// enablePlaceholders = false -// ) -// -// val recordPagingSourceFactory = RecordPagingSource.provideFactory(recordPagingSourceFactory, item.goalId) -// -// val recordPager = Pager( -// config = pagingConfig, -// pagingSourceFactory = recordPagingSourceFactory).liveData -// -// Log.d("test", "pager : ${recordPager.value}") - -// pagingData.let { contents -> -// binding.recordData = contents.content -// viewModel.setRecordData(contents.content) -// -// binding.executePendingBindings() -// } -// -// (binding.recordEmotionRv.adapter as RecordContentsCardAdapter).submitList( -// it.data.data?.content?.toMutableList() ?: mutableListOf() -// ) - - } viewModel.getRecordPagingData(item.goalId) @@ -213,9 +166,6 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec // goal Details Observe 등록 viewModel.goalDetails.observe(viewLifecycleOwner) {} - // recordData 등록 - viewModel.recordData.observe(viewLifecycleOwner) {} - // category listener - category를 주입 viewModel.goalCategory.observe(viewLifecycleOwner) { if(!it.isNullOrEmpty()) { @@ -223,13 +173,8 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec currentCategory = it[0]!!.name currentCategoryPosition = 0 + // 카테고리 데이터 받은 후 목표 가져오는 작업 진행 viewModel.getRecordPagingData(it[0]!!.goalId) -// // 카테고리 데이터 받은 후 목표 가져오는 작업 진행 -// viewModel.getRecordByGoalId(it[0]!!.goalId, object : CoroutineErrorHandler { -// override fun onError(message: String) { -// Log.e("record", "record error $message") -// } -// }) viewModel.getOneWeekRecordByGoalId(it[0]!!.goalId, object : CoroutineErrorHandler { override fun onError(message: String) { @@ -243,31 +188,17 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec } } -// viewModel.getRecordByGoalIdResponse.observe(viewLifecycleOwner) { it -> -// when(it) { -// is ApiResponse.Success -> { -// it.data.data?.let { contents -> -// binding.recordData = contents.content -// viewModel.setRecordData(contents.content) -// -// binding.executePendingBindings() -// } -// -// (binding.recordEmotionRv.adapter as RecordContentsCardAdapter).submitList( -// it.data.data?.content?.toMutableList() ?: mutableListOf() -// ) -// -// hideLoading() -// } -// is ApiResponse.Failure -> { -// Toast.makeText(requireContext(), it.errorMessage, Toast.LENGTH_SHORT).show() -// Log.d("recordData", "failure RecordData : $it") -// -// hideLoading() -// } -// is ApiResponse.Loading -> { showLoading() } -// } -// } + // 목표에 따른 recordPagingData 처리 + viewModel.pagingRecordData.observe(viewLifecycleOwner) { pagingData -> + lifecycleScope.launch { + (binding.recordEmotionRv.adapter as RecordContentsCardAdapter).apply { + submitData(pagingData) + binding.recordData = snapshot().items + + binding.executePendingBindings() + } + } + } viewModel.getOneWeekRecordByGoalIdResponse.observe(viewLifecycleOwner) { when(it) { @@ -353,19 +284,13 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec } binding.recordWriteEmotionContainerCl.setOnClickListener { - moveToRecordLeaveEmotion( - - ) + moveToRecordLeaveEmotion() } binding.recordGoalCompleteCl.setOnClickListener { - viewModel.recordData.value?.let { - if(it.isEmpty()) { - moveToRecordGoalFinish() - } else { - finishGoalAlertDialog.show() - } - } ?: run { + if((binding.recordEmotionRv.adapter as RecordContentsCardAdapter).snapshot().items.isEmpty()) { + moveToRecordGoalFinish() + } else { finishGoalAlertDialog.show() } } diff --git a/app/src/main/java/com/teampome/pome/repository/record/RecordRemoteDataSource.kt b/app/src/main/java/com/teampome/pome/repository/record/RecordRemoteDataSource.kt index 9a7204e9..e783a0b9 100644 --- a/app/src/main/java/com/teampome/pome/repository/record/RecordRemoteDataSource.kt +++ b/app/src/main/java/com/teampome/pome/repository/record/RecordRemoteDataSource.kt @@ -52,7 +52,9 @@ class RecordRemoteDataSource @Inject constructor( return Pager( config = PagingConfig( pageSize = 15, - initialLoadSize = 15 + initialLoadSize = 15, + prefetchDistance = 10, + enablePlaceholders = false ), pagingSourceFactory = { RecordPagingSource(service = service, goalId = goalId) diff --git a/app/src/main/java/com/teampome/pome/repository/record/paging/RecordPagingSource.kt b/app/src/main/java/com/teampome/pome/repository/record/paging/RecordPagingSource.kt index fecf7e6f..683eefbf 100644 --- a/app/src/main/java/com/teampome/pome/repository/record/paging/RecordPagingSource.kt +++ b/app/src/main/java/com/teampome/pome/repository/record/paging/RecordPagingSource.kt @@ -5,6 +5,7 @@ import androidx.paging.PagingSource import androidx.paging.PagingState import com.teampome.pome.model.RecordData import com.teampome.pome.network.RecordService +import kotlinx.coroutines.delay import retrofit2.HttpException import java.io.IOException @@ -16,7 +17,7 @@ class RecordPagingSource constructor( Log.d("test", "is in load?") return try { - val pageNumber = params.key ?: 1 + val pageNumber = params.key ?: 0 val pageSize = params.loadSize val response = service.getRecordByGoalId(goalId, pageNumber, pageSize) @@ -26,6 +27,8 @@ class RecordPagingSource constructor( val prevKey = if (pageNumber == 0) null else pageNumber - 1 val nextKey = if (items.isEmpty() || response.body()?.data?.empty == true) null else pageNumber + 1 + Log.d("key", "test key $prevKey -> $pageNumber -> $nextKey") + LoadResult.Page(items, prevKey, nextKey) } else { LoadResult.Error(Exception("Error loading data")) diff --git a/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt b/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt index f0fb55de..f372e0a9 100644 --- a/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt +++ b/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt @@ -1,6 +1,5 @@ package com.teampome.pome.viewmodel.record -import android.util.Log import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations @@ -21,7 +20,6 @@ import com.teampome.pome.util.base.ApiResponse import com.teampome.pome.util.base.BaseViewModel import com.teampome.pome.util.base.CoroutineErrorHandler import dagger.hilt.android.lifecycle.HiltViewModel -import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.launch @@ -113,15 +111,15 @@ class RecordViewModel @Inject constructor( goalRepository.deleteGoal(goalId) } - private val _getRecordByGoalIdResponse = SingleLiveEvent>>>() - val getRecordByGoalIdResponse: LiveData>>> = _getRecordByGoalIdResponse - - fun getRecordByGoalId(goalId: Int, coroutineErrorHandler: CoroutineErrorHandler) = baseRequest( - _getRecordByGoalIdResponse, - coroutineErrorHandler - ) { - recordRepository.getRecordByGoalId(goalId) - } +// private val _getRecordByGoalIdResponse = SingleLiveEvent>>>() +// val getRecordByGoalIdResponse: LiveData>>> = _getRecordByGoalIdResponse +// +// fun getRecordByGoalId(goalId: Int, coroutineErrorHandler: CoroutineErrorHandler) = baseRequest( +// _getRecordByGoalIdResponse, +// coroutineErrorHandler +// ) { +// recordRepository.getRecordByGoalId(goalId) +// } private val _getOneWeekRecordByGoalIdResponse = SingleLiveEvent>>>() val getOneWeekRecordByGoalIdResponse: LiveData>>> = _getOneWeekRecordByGoalIdResponse @@ -143,21 +141,13 @@ class RecordViewModel @Inject constructor( recordRepository.getOneWeekGoalByGoalId(goalId) } - private val _recordData = MutableLiveData>(listOf()) - val recordData: LiveData> = _recordData - - fun setRecordData(list: List) { - _recordData.value = list - } - - private val _records = MutableLiveData>() - val records: LiveData> - get() = _records + private val _pagingRecordData = MutableLiveData>() + val pagingRecordData: LiveData> = _pagingRecordData fun getRecordPagingData(goalId: Int) { viewModelScope.launch { - recordRepository.getRecordPagingData(goalId).cachedIn(viewModelScope).collectLatest { - _records.value = it + recordRepository.getRecordPagingData(goalId).cachedIn(viewModelScope).collect { + _pagingRecordData.value = it } } } diff --git a/app/src/main/res/layout/fragment_record.xml b/app/src/main/res/layout/fragment_record.xml index 60dfd66b..dd172a04 100644 --- a/app/src/main/res/layout/fragment_record.xml +++ b/app/src/main/res/layout/fragment_record.xml @@ -82,6 +82,7 @@ tools:listitem="@layout/item_record_category_chip" /> - - + + Date: Wed, 8 Mar 2023 14:19:47 +0900 Subject: [PATCH 11/40] =?UTF-8?q?feat=20:=20RecordFragment=20api=20?= =?UTF-8?q?=EC=9A=94=EC=B2=AD=20=EA=B4=80=EB=A0=A8=20=EB=A6=AC=ED=8C=A9?= =?UTF-8?q?=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/teampome/pome/model/RecordData.kt | 19 +-- .../teampome/pome/model/goal/GoalCategory.kt | 1 + .../record/ModifyRecordCardFragment.kt | 55 +++++---- .../record/RecordContentsCardAdapter.kt | 5 + .../presentation/record/RecordFragment.kt | 109 ++++++++---------- .../leave/RecordLeaveEmotionFragment.kt | 4 +- .../com/teampome/pome/util/BindingAdapter.kt | 6 +- .../pome/viewmodel/record/RecordViewModel.kt | 13 ++- 8 files changed, 116 insertions(+), 96 deletions(-) diff --git a/app/src/main/java/com/teampome/pome/model/RecordData.kt b/app/src/main/java/com/teampome/pome/model/RecordData.kt index 8b9d48dc..a6bf045d 100644 --- a/app/src/main/java/com/teampome/pome/model/RecordData.kt +++ b/app/src/main/java/com/teampome/pome/model/RecordData.kt @@ -1,18 +1,21 @@ package com.teampome.pome.model import android.os.Parcelable +import com.teampome.pome.presentation.record.RecordViewType import kotlinx.parcelize.Parcelize +import kotlinx.parcelize.RawValue @Parcelize data class RecordData( - val createdAt: String, - val emotionResponse: EmotionResponse, - val id: Int, - val nickname: String, - val oneLineMind: String, - val useComment: String, - val useDate: String, - val usePrice: Long + val createdAt: String?, + val emotionResponse: EmotionResponse?, + val id: Int?, + val nickname: String?, + val oneLineMind: String?, + val useComment: String?, + val useDate: String?, + val usePrice: Long?, + val viewType: @RawValue RecordViewType? = RecordViewType.Contents ) : Parcelable @Parcelize diff --git a/app/src/main/java/com/teampome/pome/model/goal/GoalCategory.kt b/app/src/main/java/com/teampome/pome/model/goal/GoalCategory.kt index d6ab773a..e7150575 100644 --- a/app/src/main/java/com/teampome/pome/model/goal/GoalCategory.kt +++ b/app/src/main/java/com/teampome/pome/model/goal/GoalCategory.kt @@ -10,4 +10,5 @@ data class GoalCategory( var isSelected: Boolean? = false, val goalId: Int, var isEnd: Boolean? = false, + var pos: Int = 0 ) : Parcelable \ No newline at end of file diff --git a/app/src/main/java/com/teampome/pome/presentation/record/ModifyRecordCardFragment.kt b/app/src/main/java/com/teampome/pome/presentation/record/ModifyRecordCardFragment.kt index 7a2f52a2..a0483c44 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/ModifyRecordCardFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/ModifyRecordCardFragment.kt @@ -46,19 +46,29 @@ class ModifyRecordCardFragment : BaseFragment(R override fun initView() { binding.modifyRecordGoalAet.setText(args.currentCategory) - binding.modifyRecordDateAet.setText(args.recordData.useDate) - viewModel.setDate(args.recordData.useDate) - binding.modifyRecordPriceAet.setText(args.recordData.usePrice.toString()) - viewModel.setPrice(args.recordData.usePrice.toString()) - binding.modifyRecordContentAet.setText(args.recordData.useComment) - viewModel.setUseComment(args.recordData.useComment) + + args.recordData.useDate?.let { useDate -> + binding.modifyRecordDateAet.setText(useDate) + viewModel.setDate(useDate) + + makeCalendarBottomSheetDialog(useDate) + } + + args.recordData.usePrice?.let { usePrice -> + binding.modifyRecordPriceAet.setText(usePrice.toString()) + viewModel.setPrice(usePrice.toString()) + } + + args.recordData.useComment?.let {useComment -> + binding.modifyRecordContentAet.setText(useComment) + viewModel.setUseComment(useComment) + } + binding.content = args.recordData.useComment binding.price = args.recordData.usePrice.toString() binding.executePendingBindings() - - makeCalendarBottomSheetDialog() } override fun initListener() { @@ -78,19 +88,20 @@ class ModifyRecordCardFragment : BaseFragment(R // 수정했어요 클릭 binding.modifyRecordCheckAcb.setOnClickListener { Log.d("click", "click 수정") - - viewModel.updateRecord( - args.recordData.id, - args.goalId, - viewModel.useComment.value ?: "", - viewModel.date.value ?: "23.01.01", - (viewModel.price.value?.toLong() ?: "0") as Long, - object : CoroutineErrorHandler { - override fun onError(message: String) { - Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show() + args.recordData.id?.let { recordId -> + viewModel.updateRecord( + recordId, + args.goalId, + viewModel.useComment.value ?: "", + viewModel.date.value ?: "23.01.01", + (viewModel.price.value?.toLong() ?: "0") as Long, + object : CoroutineErrorHandler { + override fun onError(message: String) { + Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show() + } } - } - ) + ) + } } // 금액 EditTextListener @@ -149,7 +160,7 @@ class ModifyRecordCardFragment : BaseFragment(R } } - private fun makeCalendarBottomSheetDialog() { + private fun makeCalendarBottomSheetDialog(useDate: String) { calendarBottomSheetDialog = BottomSheetDialog(requireContext()).apply { behavior.state = BottomSheetBehavior.STATE_EXPANDED } @@ -161,7 +172,7 @@ class ModifyRecordCardFragment : BaseFragment(R requireContext(), calendarBottomSheetDialogBinding.calendarMcv, calendarBottomSheetDialogBinding.calendarSelectAtb, - CommonUtil.stringToLocalDate(args.recordData.useDate), + CommonUtil.stringToLocalDate(useDate), { date, str -> curDate = date viewModel.setDate(str) diff --git a/app/src/main/java/com/teampome/pome/presentation/record/RecordContentsCardAdapter.kt b/app/src/main/java/com/teampome/pome/presentation/record/RecordContentsCardAdapter.kt index 85850fd9..9b91fb30 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/RecordContentsCardAdapter.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/RecordContentsCardAdapter.kt @@ -11,6 +11,11 @@ import com.teampome.pome.databinding.ItemRecordEmotionCardBinding import com.teampome.pome.model.RecordData import com.teampome.pome.util.OnItemClickListener +sealed class RecordViewType { + object OneWeek: RecordViewType() + object Contents: RecordViewType() +} + class RecordContentsCardAdapter : PagingDataAdapter( RecordContentsCardDiffCallback() ) { diff --git a/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt b/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt index ec611890..50b47731 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt @@ -61,10 +61,9 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec private lateinit var finishGoalAlertDialogBinding: PomeAlertDialogBinding private lateinit var finishGoalAlertDialog: Dialog - // Todo: send item 저장, data를 여기에 저장하는 것이 맞나? -> 임시 데이터면 생명주기와 연관 x? - private lateinit var recordData: RecordData - private var currentCategory: String? = null - private var currentCategoryPosition: Int? = null + // 선택한 RecordData + private lateinit var selectRecordData: RecordData + // 임시 클릭 리스너 private val itemClickListener = object: OnRecordItemClickListener { @@ -79,7 +78,7 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec private val moreItemClickListener = object : OnMoreItemClickListener { override fun onMoreIconClick(item: RecordData) { - recordData = item + selectRecordData = item recordDialog.show() } } @@ -90,6 +89,7 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec override fun initView() { // 초기 목표 데이터 요청 (같이 요청을 하긴 하는데 showLoading은 언제까지?) + // 초기 목표 데이터 요청 -> 일주일 감정 조회 요청 -> 기록 뷰 요청 viewModel.findAllGoalByUser(object : CoroutineErrorHandler { override fun onError(message: String) { Log.e("error", "findAllGoalByUser error $message") @@ -109,20 +109,7 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec RecordCategoryAdapter().apply { setOnItemClickListener(object : OnCategoryItemClickListener { override fun onCategoryItemClick(item: GoalCategory, position: Int) { - currentCategory = item.name - currentCategoryPosition = position - - viewModel.getRecordPagingData(item.goalId) - - viewModel.getOneWeekRecordByGoalId(item.goalId, object : CoroutineErrorHandler { - override fun onError(message: String) { - Log.e("record", "record error $message") - } - }) - - binding.goalDetails = viewModel.goalDetails.value?.get(position) - binding.currentGoalState = setGoalState(viewModel.goalDetails.value?.get(position)) - binding.executePendingBindings() + viewModel.setCurrentGoal(item, position) } }) } @@ -140,12 +127,7 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec when(it) { is ApiResponse.Success -> { it.data.data?.content?.let { list -> - if(list.isNotEmpty()) currentCategoryPosition = 0 - currentCategoryPosition?.let { pos -> - binding.goalDetails = list[pos] - binding.currentGoalState = setGoalState(list[pos]) - binding.executePendingBindings() - } + } ?: run { binding.goalDetails = null binding.currentGoalState = GoalState.Empty @@ -163,24 +145,27 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec } } + viewModel.curGoal.observe(viewLifecycleOwner) { cateogry -> + // 현재 목표에 따라 일주일 감정 기록 확인 + viewModel.getOneWeekRecordByGoalId(cateogry.goalId, object : CoroutineErrorHandler { + override fun onError(message: String) { + Log.e("record", "record error $message") + } + }) + + binding.goalDetails = viewModel.goalDetails.value?.get(cateogry.pos) + binding.currentGoalState = setGoalState(viewModel.goalDetails.value?.get(cateogry.pos)) + binding.executePendingBindings() + } + // goal Details Observe 등록 viewModel.goalDetails.observe(viewLifecycleOwner) {} // category listener - category를 주입 - viewModel.goalCategory.observe(viewLifecycleOwner) { + viewModel.goalCategorys.observe(viewLifecycleOwner) { if(!it.isNullOrEmpty()) { // 초기에 category를 받으면 0번을 기반으로 데이터 초기화 - currentCategory = it[0]!!.name - currentCategoryPosition = 0 - - // 카테고리 데이터 받은 후 목표 가져오는 작업 진행 - viewModel.getRecordPagingData(it[0]!!.goalId) - - viewModel.getOneWeekRecordByGoalId(it[0]!!.goalId, object : CoroutineErrorHandler { - override fun onError(message: String) { - Log.e("record", "record error $message") - } - }) + viewModel.setCurrentGoal(it[0]!!, 0) (binding.recordCategoryChipsRv.adapter as RecordCategoryAdapter).submitList( it @@ -192,6 +177,9 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec viewModel.pagingRecordData.observe(viewLifecycleOwner) { pagingData -> lifecycleScope.launch { (binding.recordEmotionRv.adapter as RecordContentsCardAdapter).apply { + +// val items = pagingData.insertHeaderItem() + submitData(pagingData) binding.recordData = snapshot().items @@ -207,6 +195,11 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec binding.executePendingBindings() hideLoading() + + // 기록 페이징 요청 + viewModel.curGoal.value?.let { category -> + viewModel.getRecordPagingData(category.goalId) + } } is ApiResponse.Failure -> { Toast.makeText(requireContext(), it.errorMessage, Toast.LENGTH_SHORT).show() @@ -250,7 +243,7 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec // 목표 + 클릭 binding.recordCategoryPlusTv.setOnClickListener { - viewModel.goalCategory.value?.let { + viewModel.goalCategorys.value?.let { if(it.size > 10) { alertWarningDialog( R.drawable.number_10, @@ -326,8 +319,8 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec // 삭제하기 버튼 클릭 removeGoalDialogBinding.removeYesTextAtv.setOnClickListener { viewModel.goalDetails.value?.let { list -> - currentCategoryPosition?.let { pos -> - list[pos]?.let { goalData -> + viewModel.curGoal.value?.let { goal -> + list[goal.pos]?.let { goalData -> viewModel.deleteGoal( goalData.id, object : CoroutineErrorHandler { @@ -372,7 +365,7 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec recordDialogBinding.pomeBottomSheetDialogPencilTv.setOnClickListener { recordDialog.dismiss() - moveToModifyRecordCard(recordData) + moveToModifyRecordCard(selectRecordData) } // 삭제 클릭 @@ -482,18 +475,16 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec } private fun moveToModifyRecordCard(recordData: RecordData) { - viewModel.goalCategory.value?.let { list -> - currentCategoryPosition?.let { pos -> - currentCategory?.let { category -> - list[pos]?.let { goalCategory -> - val action = RecordFragmentDirections.actionRecordFragmentToModifyRecordCardFragment( - recordData, - goalCategory.goalId, - category - ) + viewModel.goalCategorys.value?.let { list -> + viewModel.curGoal.value?.let { goal -> + list[goal.pos]?.let { goalCategory -> + val action = RecordFragmentDirections.actionRecordFragmentToModifyRecordCardFragment( + recordData, + goalCategory.goalId, + goal.name + ) - findNavController().navigate(action) - } + findNavController().navigate(action) } } } @@ -512,9 +503,9 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec } private fun moveToConsume() { - viewModel.goalCategory.value?.let { list -> - currentCategoryPosition?.let { pos -> - list[pos]?.let { goalCategory -> + viewModel.goalCategorys.value?.let { list -> + viewModel.curGoal.value?.let { goal -> + list[goal.pos]?.let { goalCategory -> val changeList : List = list.map { it?.let { gc -> GoalCategory( @@ -542,8 +533,8 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec private fun moveToRecordLeaveEmotion() { viewModel.goalDetails.value?.let { list -> - currentCategoryPosition?.let { pos -> - list[pos]?.let { goalData -> + viewModel.curGoal.value?.let { goal -> + list[goal.pos]?.let { goalData -> val action = RecordFragmentDirections.actionRecordFragmentToRecordLeaveEmotionFragment( goalData ) @@ -556,8 +547,8 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec private fun moveToRecordGoalFinish() { viewModel.goalDetails.value?.let { list -> - currentCategoryPosition?.let { pos -> - list[pos]?.let { goalData -> + viewModel.curGoal.value?.let { goal -> + list[goal.pos]?.let { goalData -> val action = RecordFragmentDirections.actionRecordFragmentToRecordGoalFinishFragment(goalData) findNavController().navigate(action) diff --git a/app/src/main/java/com/teampome/pome/presentation/record/leave/RecordLeaveEmotionFragment.kt b/app/src/main/java/com/teampome/pome/presentation/record/leave/RecordLeaveEmotionFragment.kt index f6bf24ab..154db09c 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/leave/RecordLeaveEmotionFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/leave/RecordLeaveEmotionFragment.kt @@ -43,7 +43,9 @@ class RecordLeaveEmotionFragment : BaseFragment + moveToLeaveEmotion(itemId) + } } }) } diff --git a/app/src/main/java/com/teampome/pome/util/BindingAdapter.kt b/app/src/main/java/com/teampome/pome/util/BindingAdapter.kt index 8b6a8da1..e2188154 100644 --- a/app/src/main/java/com/teampome/pome/util/BindingAdapter.kt +++ b/app/src/main/java/com/teampome/pome/util/BindingAdapter.kt @@ -215,7 +215,9 @@ fun bindingCategoryColor(textView: TextView, isSelected: Boolean?, isEnd: Boolea */ @BindingAdapter("goalConnectTime") fun bindingGoalConnectTime(textView: TextView, recordData: RecordData?) { - recordData?.let { - textView.text = textView.context.getString(R.string.connect_dot_text, recordData.oneLineMind, CommonUtil.changeAfterTime(recordData.createdAt)) + recordData?.let {record -> + record.createdAt?.let { createdAt -> + textView.text = textView.context.getString(R.string.connect_dot_text, recordData.oneLineMind, CommonUtil.changeAfterTime(createdAt)) + } } } diff --git a/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt b/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt index f372e0a9..7e1cc3e9 100644 --- a/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt +++ b/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt @@ -6,7 +6,6 @@ import androidx.lifecycle.Transformations import androidx.lifecycle.viewModelScope import androidx.paging.PagingData import androidx.paging.cachedIn -import androidx.paging.map import com.teampome.pome.model.RecordData import com.teampome.pome.model.base.BaseAllData import com.teampome.pome.model.base.BasePomeResponse @@ -20,8 +19,6 @@ import com.teampome.pome.util.base.ApiResponse import com.teampome.pome.util.base.BaseViewModel import com.teampome.pome.util.base.CoroutineErrorHandler import dagger.hilt.android.lifecycle.HiltViewModel -import kotlinx.coroutines.flow.collect -import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.launch import javax.inject.Inject @@ -30,6 +27,14 @@ class RecordViewModel @Inject constructor( private val recordRepository: RecordRepository, private val goalRepository: GoalRepository ) : BaseViewModel() { + private val _curGoal = MutableLiveData() + val curGoal: LiveData = _curGoal + + fun setCurrentGoal(goal: GoalCategory, pos: Int) { + goal.pos = pos + _curGoal.value = goal + } + private val _recordDataByUserIdResponse = MutableLiveData>>>() val recordDataByUserIdResponse: LiveData>>> = _recordDataByUserIdResponse @@ -46,7 +51,7 @@ class RecordViewModel @Inject constructor( // return recordRepository.getPagingRecordByGoalId(goalId).cachedIn(viewModelScope) // } - val goalCategory: LiveData> = Transformations.map(_findAllGoalByUserResponse) { + val goalCategorys: LiveData> = Transformations.map(_findAllGoalByUserResponse) { when(it) { is ApiResponse.Success -> { it.data.data?.let { allGoalData -> From 81c33fb3a947eecb99bbee08ccef0fbd52dec484 Mon Sep 17 00:00:00 2001 From: hanseuk-Choi Date: Thu, 9 Mar 2023 00:45:41 +0900 Subject: [PATCH 12/40] =?UTF-8?q?refact=20:=20RecordView=20=EB=B3=80?= =?UTF-8?q?=ED=99=98=20->=20NestedScrollView=20=EB=AC=B8=EC=A0=9C=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0(Paging=20=EB=AC=B8=EC=A0=9C=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/teampome/pome/model/RecordData.kt | 7 +- .../presentation/record/GoalCardViewHolder.kt | 32 ++ .../record/LeaveEmotionCardViewHolder.kt | 20 ++ .../record/RecordCardViewHolder.kt | 25 ++ .../record/RecordContentsCardAdapter.kt | 123 +++++-- .../presentation/record/RecordFragment.kt | 217 ++++++------ .../leave/RecordLeaveEmotionFragment.kt | 3 +- app/src/main/res/layout/fragment_record.xml | 318 ++---------------- app/src/main/res/layout/item_goal_card.xml | 190 +++++++++++ .../res/layout/item_leave_emotion_card.xml | 89 +++++ 10 files changed, 593 insertions(+), 431 deletions(-) create mode 100644 app/src/main/java/com/teampome/pome/presentation/record/GoalCardViewHolder.kt create mode 100644 app/src/main/java/com/teampome/pome/presentation/record/LeaveEmotionCardViewHolder.kt create mode 100644 app/src/main/java/com/teampome/pome/presentation/record/RecordCardViewHolder.kt create mode 100644 app/src/main/res/layout/item_goal_card.xml create mode 100644 app/src/main/res/layout/item_leave_emotion_card.xml diff --git a/app/src/main/java/com/teampome/pome/model/RecordData.kt b/app/src/main/java/com/teampome/pome/model/RecordData.kt index a6bf045d..d495116a 100644 --- a/app/src/main/java/com/teampome/pome/model/RecordData.kt +++ b/app/src/main/java/com/teampome/pome/model/RecordData.kt @@ -1,6 +1,8 @@ package com.teampome.pome.model import android.os.Parcelable +import com.teampome.pome.model.goal.GoalData +import com.teampome.pome.presentation.record.GoalState import com.teampome.pome.presentation.record.RecordViewType import kotlinx.parcelize.Parcelize import kotlinx.parcelize.RawValue @@ -15,7 +17,10 @@ data class RecordData( val useComment: String?, val useDate: String?, val usePrice: Long?, - val viewType: @RawValue RecordViewType? = RecordViewType.Contents + var viewType: @RawValue RecordViewType? = RecordViewType.Contents, + var oneWeekCount: Int? = 0, + var goalDetail: GoalData?, + var goalState: @RawValue GoalState? = GoalState.Empty ) : Parcelable @Parcelize diff --git a/app/src/main/java/com/teampome/pome/presentation/record/GoalCardViewHolder.kt b/app/src/main/java/com/teampome/pome/presentation/record/GoalCardViewHolder.kt new file mode 100644 index 00000000..a0413abc --- /dev/null +++ b/app/src/main/java/com/teampome/pome/presentation/record/GoalCardViewHolder.kt @@ -0,0 +1,32 @@ +package com.teampome.pome.presentation.record + +import androidx.recyclerview.widget.RecyclerView +import com.teampome.pome.databinding.ItemGoalCardBinding +import com.teampome.pome.model.goal.GoalData +import com.teampome.pome.util.OnItemClickListener + +class GoalCardViewHolder( + private val binding: ItemGoalCardBinding, + private val moreItemClickListener: OnItemClickListener?, + private val noGoalCardClickListener: OnItemClickListener?, + private val goalCompleteClickListener: OnItemClickListener? +) : RecyclerView.ViewHolder(binding.root) { + fun bind(goalData: GoalData?, goalState: GoalState?) { + binding.recordGoalMoreAiv.setOnClickListener { + moreItemClickListener?.itemClick() + } + + binding.recordNoGoalSubtitleContainerCl.setOnClickListener { + noGoalCardClickListener?.itemClick() + } + + binding.recordGoalCompleteCl.setOnClickListener { + goalCompleteClickListener?.itemClick() + } + + binding.goalDetails = goalData + binding.currentGoalState = goalState ?: GoalState.Empty + + binding.executePendingBindings() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/teampome/pome/presentation/record/LeaveEmotionCardViewHolder.kt b/app/src/main/java/com/teampome/pome/presentation/record/LeaveEmotionCardViewHolder.kt new file mode 100644 index 00000000..5a7b6248 --- /dev/null +++ b/app/src/main/java/com/teampome/pome/presentation/record/LeaveEmotionCardViewHolder.kt @@ -0,0 +1,20 @@ +package com.teampome.pome.presentation.record + +import androidx.recyclerview.widget.RecyclerView +import com.teampome.pome.databinding.ItemLeaveEmotionCardBinding +import com.teampome.pome.util.OnItemClickListener + +class LeaveEmotionCardViewHolder( + private val binding: ItemLeaveEmotionCardBinding, + private val onItemClickListener: OnItemClickListener? +) : RecyclerView.ViewHolder(binding.root) { + fun bind(count: Int) { + binding.countOneWeekRecord = count + + binding.executePendingBindings() + + binding.recordWriteEmotionContainerCl.setOnClickListener { + onItemClickListener?.itemClick() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/teampome/pome/presentation/record/RecordCardViewHolder.kt b/app/src/main/java/com/teampome/pome/presentation/record/RecordCardViewHolder.kt new file mode 100644 index 00000000..463899aa --- /dev/null +++ b/app/src/main/java/com/teampome/pome/presentation/record/RecordCardViewHolder.kt @@ -0,0 +1,25 @@ +package com.teampome.pome.presentation.record + +import androidx.recyclerview.widget.RecyclerView +import com.teampome.pome.databinding.ItemRecordEmotionCardBinding +import com.teampome.pome.model.RecordData + +class RecordCardViewHolder( + private val binding : ItemRecordEmotionCardBinding, + private val moreItemClickListener: OnMoreItemClickListener?, + private val bodyClickListener: OnRecordItemClickListener? +) : RecyclerView.ViewHolder(binding.root) { + fun bind(item: RecordData) { + binding.recordData = item + + binding.recordContentsCardMoreAiv.setOnClickListener { + moreItemClickListener?.onMoreIconClick(item) + } + + binding.recordContentsCardContainerCv.setOnClickListener { + bodyClickListener?.onRecordItemClick(item) + } + + binding.executePendingBindings() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/teampome/pome/presentation/record/RecordContentsCardAdapter.kt b/app/src/main/java/com/teampome/pome/presentation/record/RecordContentsCardAdapter.kt index 9b91fb30..3354bdc2 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/RecordContentsCardAdapter.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/RecordContentsCardAdapter.kt @@ -1,77 +1,136 @@ package com.teampome.pome.presentation.record -import android.util.Log import android.view.LayoutInflater import android.view.ViewGroup import androidx.paging.PagingDataAdapter import androidx.recyclerview.widget.DiffUtil -import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView +import com.teampome.pome.databinding.ItemGoalCardBinding +import com.teampome.pome.databinding.ItemLeaveEmotionCardBinding import com.teampome.pome.databinding.ItemRecordEmotionCardBinding import com.teampome.pome.model.RecordData import com.teampome.pome.util.OnItemClickListener -sealed class RecordViewType { - object OneWeek: RecordViewType() - object Contents: RecordViewType() +sealed class RecordViewType(val type: Int) { + object Goal: RecordViewType(0) + object OneWeek: RecordViewType(1) + object Contents: RecordViewType(2) +// OneWeek(0), Contents(1) } -class RecordContentsCardAdapter : PagingDataAdapter( +class RecordContentsCardAdapter : PagingDataAdapter( RecordContentsCardDiffCallback() ) { // 절대 Adapter 내부에 lateinit var을 넣지 말자. // bind를 lateinit하고 onCreateViewHolder에서 재사용하고 있어 메모리 누수가 발생됨 // ex) RecyclerView에서 아이템이 추가될 때 마다 Binding 인스턴스가 할당되고 이전에 할당된 인스턴스가 GC로 회수되지 않을 가능성이 매우 큼 - private var moreItemClickListener: OnMoreItemClickListener? = null + private var moreRecordItemClickListener: OnMoreItemClickListener? = null + private var recordBodyClickListener: OnRecordItemClickListener? = null + private var leaveEmotionCardClickListener: OnItemClickListener? = null + private var moreGoalItemClickListener: OnItemClickListener? = null + private var noGoalCardClickListener: OnItemClickListener? = null + private var goalCompleteClickListener: OnItemClickListener? = null - private var bodyClickListener: OnRecordItemClickListener? = null + fun setOnMoreRecordItemClickListener(listener: OnMoreItemClickListener) { + moreRecordItemClickListener = listener + } + + fun setOnRecordBodyClickListener(listener: OnRecordItemClickListener) { + recordBodyClickListener = listener + } + + fun setOnLeaveEmotionCardClickListener(listener: OnItemClickListener) { + leaveEmotionCardClickListener = listener + } + + fun setOnMoreGoalItemClickListener(listener: OnItemClickListener) { + moreGoalItemClickListener = listener + } - fun setOnMoreItemClickListener(listener: OnMoreItemClickListener) { - moreItemClickListener = listener + fun setOnNoGoalCardClickListener(listener: OnItemClickListener) { + noGoalCardClickListener = listener } - fun setOnBodyClickListener(listener: OnRecordItemClickListener) { - bodyClickListener = listener + fun setOnGoalCompleteClickListener(listener: OnItemClickListener) { + goalCompleteClickListener = listener + } + + override fun getItemViewType(position: Int): Int { + val data = getItem(position) + + data?.let { recordData -> + recordData.viewType?.let { viewType -> + return viewType.type + } ?: run { + return RecordViewType.Contents.type + } + } ?: run { + return RecordViewType.Contents.type + } } override fun onCreateViewHolder( parent: ViewGroup, viewType: Int - ): RecordContentsCardViewHolder { - val binding = ItemRecordEmotionCardBinding.inflate(LayoutInflater.from(parent.context), parent, false) + ): RecyclerView.ViewHolder { + when(viewType) { + RecordViewType.Goal.type -> { + val binding = ItemGoalCardBinding.inflate(LayoutInflater.from(parent.context), parent, false) - return RecordContentsCardViewHolder(binding) - } + return GoalCardViewHolder(binding, moreGoalItemClickListener, noGoalCardClickListener, goalCompleteClickListener) + } + + RecordViewType.OneWeek.type -> { + val binding = ItemLeaveEmotionCardBinding.inflate(LayoutInflater.from(parent.context), parent, false) + + return LeaveEmotionCardViewHolder(binding, leaveEmotionCardClickListener) + } + + RecordViewType.Contents.type -> { + val binding = ItemRecordEmotionCardBinding.inflate(LayoutInflater.from(parent.context), parent, false) + + return RecordCardViewHolder(binding, moreRecordItemClickListener, recordBodyClickListener) + } + + else -> { + assert(false) // 여기로 떨어지면 안됨 -> 따로 처리 필요 + val binding = ItemRecordEmotionCardBinding.inflate(LayoutInflater.from(parent.context), parent, false) - override fun onBindViewHolder(holder: RecordContentsCardViewHolder, position: Int) { - getItem(position)?.let { - Log.d("test", "data is $it") - holder.bind(it) + return RecordCardViewHolder(binding, moreRecordItemClickListener, recordBodyClickListener) + } } } - inner class RecordContentsCardViewHolder( - private val binding : ItemRecordEmotionCardBinding - ) : RecyclerView.ViewHolder(binding.root) { - fun bind(item: RecordData) { - binding.recordData = item - - binding.recordContentsCardMoreAiv.setOnClickListener { - moreItemClickListener?.onMoreIconClick(item) + override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { + when(holder) { + is GoalCardViewHolder -> { + getItem(position)?.let { + holder.bind(it.goalDetail, it.goalState) + } } - binding.recordContentsCardContainerCv.setOnClickListener { - bodyClickListener?.onRecordItemClick(item) + is LeaveEmotionCardViewHolder -> { + getItem(position)?.let { + holder.bind(it.oneWeekCount ?: 0) + } } - binding.executePendingBindings() + is RecordCardViewHolder -> { + getItem(position)?.let { + holder.bind(it) + } + } } } } class RecordContentsCardDiffCallback : DiffUtil.ItemCallback() { override fun areItemsTheSame(oldItem: RecordData, newItem: RecordData): Boolean { - return oldItem.id == newItem.id + return if(oldItem.id != null && newItem.id != null) { + oldItem.id == newItem.id + } else { + oldItem == newItem + } } override fun areContentsTheSame(oldItem: RecordData, newItem: RecordData): Boolean { diff --git a/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt b/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt index 50b47731..7bded5d5 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt @@ -2,15 +2,15 @@ package com.teampome.pome.presentation.record import android.annotation.SuppressLint import android.app.Dialog -import android.os.Bundle import android.util.Log -import android.view.View import android.widget.Toast import androidx.annotation.DrawableRes import androidx.annotation.RawRes import androidx.fragment.app.viewModels import androidx.lifecycle.lifecycleScope import androidx.navigation.fragment.findNavController +import androidx.paging.TerminalSeparatorType +import androidx.paging.insertHeaderItem import com.bumptech.glide.Glide import com.google.android.material.bottomsheet.BottomSheetDialog import com.teampome.pome.R @@ -26,6 +26,7 @@ import com.teampome.pome.model.goal.GoalCategory import com.teampome.pome.model.goal.GoalData import com.teampome.pome.presentation.remind.OnCategoryItemClickListener import com.teampome.pome.util.CommonUtil +import com.teampome.pome.util.OnItemClickListener import com.teampome.pome.util.base.ApiResponse import com.teampome.pome.util.base.CoroutineErrorHandler import com.teampome.pome.viewmodel.record.RecordViewModel @@ -64,29 +65,6 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec // 선택한 RecordData private lateinit var selectRecordData: RecordData - - // 임시 클릭 리스너 - private val itemClickListener = object: OnRecordItemClickListener { - override fun onRecordItemClick(item: RecordData) { - alertWarningDialog( - R.drawable.pen_pink, - "아직은 감정을 기록할 수 없어요", - "일주일이 지나야 감정을 남길 수 있어요\n나중에 다시 봐요!" - ) - } - } - - private val moreItemClickListener = object : OnMoreItemClickListener { - override fun onMoreIconClick(item: RecordData) { - selectRecordData = item - recordDialog.show() - } - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - } - override fun initView() { // 초기 목표 데이터 요청 (같이 요청을 하긴 하는데 showLoading은 언제까지?) // 초기 목표 데이터 요청 -> 일주일 감정 조회 요청 -> 기록 뷰 요청 @@ -104,6 +82,48 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec makeWarningDialog() makeFinishGoalAlertDialog() + setInitAdapter() + } + + override fun initListener() { + setInitViewModelDataListener() + + binding.recordNoticeBellAiv.setOnClickListener { + moveToRecordAlarms() + } + + // 목표 + 클릭 + binding.recordCategoryPlusTv.setOnClickListener { + viewModel.goalCategorys.value?.let { + if(it.size > 10) { + alertWarningDialog( + R.drawable.number_10, + "목표는 10개를 넘을 수 없어요", + "포미는 사용자가 무리하지 않고 즐겁게 목표를 달성할 수 있도록 응원하고 있어요!" + ) + } else { + moveToAddGoal() + } + } ?: run { + moveToAddGoal() + } + } + + // float button 클릭 + binding.recordWriteButtonCl.setOnClickListener { + viewModel.goalDetails.value?.get(viewModel.curGoal.value?.pos ?: 0)?.let { + moveToConsume() + } ?: run { + alertWarningDialog( + R.drawable.writing_warning_alert_3d_component, + "지금은 씀씀이를 기록할 수 없어요", + "나만의 소비 목표를 설정하고\n기록을 시작해보세요!" + ) + } + } + } + + private fun setInitAdapter() { // 카테고리 어댑터 설정 binding.recordCategoryChipsRv.adapter = RecordCategoryAdapter().apply { @@ -116,23 +136,59 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec // Record Contents 어댑터 설정 binding.recordEmotionRv.adapter = RecordContentsCardAdapter().apply { - setOnBodyClickListener(itemClickListener) - setOnMoreItemClickListener(moreItemClickListener) + // 기록 클릭 + setOnRecordBodyClickListener(object: OnRecordItemClickListener { + override fun onRecordItemClick(item: RecordData) { + alertWarningDialog( + R.drawable.pen_pink, + "아직은 감정을 기록할 수 없어요", + "일주일이 지나야 감정을 남길 수 있어요\n나중에 다시 봐요!" + ) + } + }) + // 기록 더보기 클릭 + setOnMoreRecordItemClickListener(object : OnMoreItemClickListener { + override fun onMoreIconClick(item: RecordData) { + selectRecordData = item + recordDialog.show() + } + }) + // 감정 남기기 클릭 + setOnLeaveEmotionCardClickListener(object : OnItemClickListener { + override fun itemClick() { + moveToRecordLeaveEmotion() + } + }) + // 목표 더보기 클릭 + setOnMoreGoalItemClickListener(object : OnItemClickListener { + override fun itemClick() { + goalMoreBottomSheetDialog.show() + } + }) + // 목표 없을 때 클릭 + setOnNoGoalCardClickListener(object : OnItemClickListener { + override fun itemClick() { + moveToAddGoal() + } + }) + // 목표 완료 시 클릭 + setOnGoalCompleteClickListener(object : OnItemClickListener { + override fun itemClick() { + if((binding.recordEmotionRv.adapter as RecordContentsCardAdapter).snapshot().items.isEmpty()) { + moveToRecordGoalFinish() + } else { + finishGoalAlertDialog.show() + } + } + }) } } - override fun initListener() { + private fun setInitViewModelDataListener() { // 모든 목표 Response observe viewModel.findAllGoalByUserResponse.observe(viewLifecycleOwner) { when(it) { is ApiResponse.Success -> { - it.data.data?.content?.let { list -> - - } ?: run { - binding.goalDetails = null - binding.currentGoalState = GoalState.Empty - binding.executePendingBindings() - } hideLoading() } @@ -145,17 +201,13 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec } } - viewModel.curGoal.observe(viewLifecycleOwner) { cateogry -> + viewModel.curGoal.observe(viewLifecycleOwner) { category -> // 현재 목표에 따라 일주일 감정 기록 확인 - viewModel.getOneWeekRecordByGoalId(cateogry.goalId, object : CoroutineErrorHandler { + viewModel.getOneWeekRecordByGoalId(category.goalId, object : CoroutineErrorHandler { override fun onError(message: String) { Log.e("record", "record error $message") } }) - - binding.goalDetails = viewModel.goalDetails.value?.get(cateogry.pos) - binding.currentGoalState = setGoalState(viewModel.goalDetails.value?.get(cateogry.pos)) - binding.executePendingBindings() } // goal Details Observe 등록 @@ -178,10 +230,29 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec lifecycleScope.launch { (binding.recordEmotionRv.adapter as RecordContentsCardAdapter).apply { -// val items = pagingData.insertHeaderItem() + var item = pagingData.insertHeaderItem( + terminalSeparatorType = TerminalSeparatorType.FULLY_COMPLETE, + RecordData( + null, null, null, null, null, null, null, null, + viewType = RecordViewType.OneWeek, + oneWeekCount = viewModel.oneWeekRecords.value?.size, + null, + null + ) + ) + + item = item.insertHeaderItem( + terminalSeparatorType = TerminalSeparatorType.FULLY_COMPLETE, + RecordData( + null, null, null, null, null, null, null, null, + viewType = RecordViewType.Goal, + null, + viewModel.goalDetails.value?.get(viewModel.curGoal.value?.pos ?: 0), + setGoalState(viewModel.goalDetails.value?.get(viewModel.curGoal.value?.pos ?: 0)) + ) + ) - submitData(pagingData) - binding.recordData = snapshot().items + submitData(item) binding.executePendingBindings() } @@ -191,7 +262,7 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec viewModel.getOneWeekRecordByGoalIdResponse.observe(viewLifecycleOwner) { when(it) { is ApiResponse.Success -> { - binding.countOneWeekRecord = it.data.data?.content?.size ?: 0 +// binding.countOneWeekRecord = it.data.data?.content?.size ?: 0 binding.executePendingBindings() hideLoading() @@ -231,62 +302,6 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec is ApiResponse.Loading -> { showLoading() } } } - - binding.recordNoticeBellAiv.setOnClickListener { - moveToRecordAlarms() - } - - // 목표의 더보기 클릭 - binding.recordGoalMoreAiv.setOnClickListener { - goalMoreBottomSheetDialog.show() - } - - // 목표 + 클릭 - binding.recordCategoryPlusTv.setOnClickListener { - viewModel.goalCategorys.value?.let { - if(it.size > 10) { - alertWarningDialog( - R.drawable.number_10, - "목표는 10개를 넘을 수 없어요", - "포미는 사용자가 무리하지 않고 즐겁게 목표를 달성할 수 있도록 응원하고 있어요!" - ) - } else { - moveToAddGoal() - } - } ?: run { - moveToAddGoal() - } - } - - // 목표 없을 때 목표 만들기 클릭 - binding.recordNoGoalSubtitleContainerCl.setOnClickListener { - moveToAddGoal() - } - - // float button 클릭 - binding.recordWriteButtonCl.setOnClickListener { - if(binding.currentGoalState is GoalState.Empty) { - alertWarningDialog( - R.drawable.writing_warning_alert_3d_component, - "지금은 씀씀이를 기록할 수 없어요", - "나만의 소비 목표를 설정하고\n기록을 시작해보세요!" - ) - } else { - moveToConsume() - } - } - - binding.recordWriteEmotionContainerCl.setOnClickListener { - moveToRecordLeaveEmotion() - } - - binding.recordGoalCompleteCl.setOnClickListener { - if((binding.recordEmotionRv.adapter as RecordContentsCardAdapter).snapshot().items.isEmpty()) { - moveToRecordGoalFinish() - } else { - finishGoalAlertDialog.show() - } - } } // 목표 카드 더보기 클릭 diff --git a/app/src/main/java/com/teampome/pome/presentation/record/leave/RecordLeaveEmotionFragment.kt b/app/src/main/java/com/teampome/pome/presentation/record/leave/RecordLeaveEmotionFragment.kt index 154db09c..25928b2d 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/leave/RecordLeaveEmotionFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/leave/RecordLeaveEmotionFragment.kt @@ -12,7 +12,6 @@ import com.teampome.pome.databinding.FragmentRecordLeaveEmotionBinding import com.teampome.pome.model.RecordData import com.teampome.pome.presentation.record.OnRecordItemClickListener import com.teampome.pome.presentation.record.RecordContentsCardAdapter -import com.teampome.pome.util.OnItemClickListener import com.teampome.pome.util.base.ApiResponse import com.teampome.pome.util.base.BaseFragment import com.teampome.pome.util.base.CoroutineErrorHandler @@ -41,7 +40,7 @@ class RecordLeaveEmotionFragment : BaseFragment moveToLeaveEmotion(itemId) diff --git a/app/src/main/res/layout/fragment_record.xml b/app/src/main/res/layout/fragment_record.xml index dd172a04..26c6dc6e 100644 --- a/app/src/main/res/layout/fragment_record.xml +++ b/app/src/main/res/layout/fragment_record.xml @@ -5,26 +5,7 @@ xmlns:tools="http://schemas.android.com/tools"> - - - - - - - - - - - - + + android:foregroundGravity="center" + app:layout_constraintTop_toBottomOf="@id/record_category_chips_rv" + app:layout_constraintBottom_toBottomOf="parent"> + android:layout_height="wrap_content" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintTop_toTopOf="parent"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + app:layout_constraintTop_toTopOf="parent" /> - - - - - - - - - - - - - - - - - - - - - - - - + android:layout_marginTop="12dp" + android:text="@string/record_no_write_emotion_text" + app:layout_constraintEnd_toEndOf="@id/record_no_write_emotion_aiv" + app:layout_constraintStart_toStartOf="@id/record_no_write_emotion_aiv" + app:layout_constraintTop_toBottomOf="@id/record_no_write_emotion_aiv" /> - + diff --git a/app/src/main/res/layout/item_goal_card.xml b/app/src/main/res/layout/item_goal_card.xml new file mode 100644 index 00000000..6421a44e --- /dev/null +++ b/app/src/main/res/layout/item_goal_card.xml @@ -0,0 +1,190 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_leave_emotion_card.xml b/app/src/main/res/layout/item_leave_emotion_card.xml new file mode 100644 index 00000000..03b61d11 --- /dev/null +++ b/app/src/main/res/layout/item_leave_emotion_card.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 7097d9b43cebd56857d01a303a260746626325b6 Mon Sep 17 00:00:00 2001 From: hanseuk-Choi Date: Thu, 9 Mar 2023 07:10:21 +0900 Subject: [PATCH 13/40] =?UTF-8?q?fix=20:=20Record=20View=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/layout/fragment_record.xml | 6 +++++- app/src/main/res/layout/item_goal_card.xml | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/res/layout/fragment_record.xml b/app/src/main/res/layout/fragment_record.xml index 26c6dc6e..5b0ff882 100644 --- a/app/src/main/res/layout/fragment_record.xml +++ b/app/src/main/res/layout/fragment_record.xml @@ -1,11 +1,14 @@ + + diff --git a/app/src/main/res/layout/item_goal_card.xml b/app/src/main/res/layout/item_goal_card.xml index 6421a44e..531b29e2 100644 --- a/app/src/main/res/layout/item_goal_card.xml +++ b/app/src/main/res/layout/item_goal_card.xml @@ -14,14 +14,14 @@ type="com.teampome.pome.presentation.record.GoalState" /> - + android:layout_height="wrap_content" + android:layout_marginTop="7dp"> Date: Thu, 9 Mar 2023 17:30:23 +0900 Subject: [PATCH 14/40] =?UTF-8?q?fix=20:=20=EA=B0=90=EC=A0=95=20=EB=82=A8?= =?UTF-8?q?=EA=B8=B0=EA=B8=B0=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 7 ----- .../presentation/record/RecordFragment.kt | 15 ++++++----- .../main/java/com/teampome/pome/util/Event.kt | 27 +++++++++++++++++++ .../teampome/pome/util/base/BaseFragment.kt | 6 ++--- .../teampome/pome/util/base/BaseViewModel.kt | 16 +++++++++++ .../pome/viewmodel/record/RecordViewModel.kt | 16 ++++++----- 6 files changed, 64 insertions(+), 23 deletions(-) create mode 100644 app/src/main/java/com/teampome/pome/util/Event.kt diff --git a/app/build.gradle b/app/build.gradle index 0fce4db4..55d9a0e6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -107,11 +107,4 @@ dependencies { // Paging def paging_version = '3.1.1' implementation "androidx.paging:paging-runtime:$paging_version" - - implementation 'com.squareup.inject:assisted-inject-annotations-dagger2:0.6.0' - kapt 'com.squareup.inject:assisted-inject-processor-dagger2:0.6.0' - kapt "com.google.dagger:dagger-compiler:2.44" - kapt "com.google.dagger:dagger-android-processor:2.44" - kapt "com.squareup.inject:assisted-inject-processor-dagger2:0.6.0" - kapt 'com.google.dagger:hilt-android-compiler:2.44' } \ No newline at end of file diff --git a/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt b/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt index 7bded5d5..bcc6d368 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt @@ -229,13 +229,12 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec viewModel.pagingRecordData.observe(viewLifecycleOwner) { pagingData -> lifecycleScope.launch { (binding.recordEmotionRv.adapter as RecordContentsCardAdapter).apply { - var item = pagingData.insertHeaderItem( terminalSeparatorType = TerminalSeparatorType.FULLY_COMPLETE, RecordData( null, null, null, null, null, null, null, null, viewType = RecordViewType.OneWeek, - oneWeekCount = viewModel.oneWeekRecords.value?.size, + oneWeekCount = viewModel.oneWeekCount.value, null, null ) @@ -253,8 +252,6 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec ) submitData(item) - - binding.executePendingBindings() } } } @@ -262,8 +259,10 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec viewModel.getOneWeekRecordByGoalIdResponse.observe(viewLifecycleOwner) { when(it) { is ApiResponse.Success -> { -// binding.countOneWeekRecord = it.data.data?.content?.size ?: 0 - binding.executePendingBindings() + + Log.d("test", "data is ${it.data.data}") + viewModel.setOneWeekCount(it.data.data?.content?.size ?: 0) +// binding.executePendingBindings() hideLoading() @@ -283,7 +282,9 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec } // UI용으로 짜여진 oneWeekRecords observe - viewModel.oneWeekRecords.observe(viewLifecycleOwner) {} + viewModel.oneWeekRecords.observe(viewLifecycleOwner) { + Log.d("data", "data is $it") + } // 삭제하기 response viewModel.deleteGoalResponse.observe(viewLifecycleOwner) { diff --git a/app/src/main/java/com/teampome/pome/util/Event.kt b/app/src/main/java/com/teampome/pome/util/Event.kt new file mode 100644 index 00000000..d1692a6d --- /dev/null +++ b/app/src/main/java/com/teampome/pome/util/Event.kt @@ -0,0 +1,27 @@ +package com.teampome.pome.util + +/** + * Used as a wrapper for data that is exposed via a LiveData that represents an event. + */ +open class Event(private val content: T) { + + var hasBeenHandled = false + private set // Allow external read but not write + + /** + * Returns the content and prevents its use again. + */ + fun getContentIfNotHandled(): T? { + return if (hasBeenHandled) { + null + } else { + hasBeenHandled = true + content + } + } + + /** + * Returns the content, even if it's already been handled. + */ + fun peekContent(): T = content +} \ No newline at end of file diff --git a/app/src/main/java/com/teampome/pome/util/base/BaseFragment.kt b/app/src/main/java/com/teampome/pome/util/base/BaseFragment.kt index 4dcd0014..0e349f25 100644 --- a/app/src/main/java/com/teampome/pome/util/base/BaseFragment.kt +++ b/app/src/main/java/com/teampome/pome/util/base/BaseFragment.kt @@ -27,12 +27,12 @@ abstract class BaseFragment(@LayoutRes private val layoutId: } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - - binding.lifecycleOwner = viewLifecycleOwner + binding.lifecycleOwner = this@BaseFragment initView() initListener() + + super.onViewCreated(view, savedInstanceState) } override fun onAttach(context: Context) { diff --git a/app/src/main/java/com/teampome/pome/util/base/BaseViewModel.kt b/app/src/main/java/com/teampome/pome/util/base/BaseViewModel.kt index 64f1fe7f..792200c8 100644 --- a/app/src/main/java/com/teampome/pome/util/base/BaseViewModel.kt +++ b/app/src/main/java/com/teampome/pome/util/base/BaseViewModel.kt @@ -3,6 +3,7 @@ package com.teampome.pome.util.base import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import com.teampome.pome.util.Event import kotlinx.coroutines.* import kotlinx.coroutines.flow.Flow @@ -32,6 +33,21 @@ open class BaseViewModel : ViewModel() { } } + protected fun baseEventRequest(liveData: MutableLiveData>, errorHandler: CoroutineErrorHandler, request: () -> Flow) { + job = viewModelScope.launch(Dispatchers.IO + CoroutineExceptionHandler {_, error -> + viewModelScope.launch(Dispatchers.Main) { + error.printStackTrace() + errorHandler.onError(error.message ?: "API Request 도중 Error 발생 $error") + } + }) { + request().collect { + withContext(Dispatchers.Main) { + liveData.value = Event(it) + } + } + } + } + override fun onCleared() { super.onCleared() job?.let { diff --git a/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt b/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt index 7e1cc3e9..764874b8 100644 --- a/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt +++ b/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt @@ -1,9 +1,6 @@ package com.teampome.pome.viewmodel.record -import androidx.lifecycle.LiveData -import androidx.lifecycle.MutableLiveData -import androidx.lifecycle.Transformations -import androidx.lifecycle.viewModelScope +import androidx.lifecycle.* import androidx.paging.PagingData import androidx.paging.cachedIn import com.teampome.pome.model.RecordData @@ -129,7 +126,7 @@ class RecordViewModel @Inject constructor( private val _getOneWeekRecordByGoalIdResponse = SingleLiveEvent>>>() val getOneWeekRecordByGoalIdResponse: LiveData>>> = _getOneWeekRecordByGoalIdResponse - val oneWeekRecords : LiveData> = Transformations.map(_getOneWeekRecordByGoalIdResponse) { + val oneWeekRecords: LiveData> = Transformations.map(_getOneWeekRecordByGoalIdResponse) { when(it) { is ApiResponse.Success -> { it.data.data?.content ?: run { null } @@ -139,6 +136,13 @@ class RecordViewModel @Inject constructor( } } + private val _oneWeekCount = MutableLiveData() + val oneWeekCount: LiveData = _oneWeekCount + + fun setOneWeekCount(count: Int) { + _oneWeekCount.value = count + } + fun getOneWeekRecordByGoalId(goalId: Int, coroutineErrorHandler: CoroutineErrorHandler) = baseRequest( _getOneWeekRecordByGoalIdResponse, coroutineErrorHandler @@ -146,7 +150,7 @@ class RecordViewModel @Inject constructor( recordRepository.getOneWeekGoalByGoalId(goalId) } - private val _pagingRecordData = MutableLiveData>() + private val _pagingRecordData = SingleLiveEvent>() val pagingRecordData: LiveData> = _pagingRecordData fun getRecordPagingData(goalId: Int) { From 43dc0a87348f1c7b2d53e0f293c2d8a8ba565ca3 Mon Sep 17 00:00:00 2001 From: hanseuk-Choi Date: Thu, 9 Mar 2023 23:05:17 +0900 Subject: [PATCH 15/40] =?UTF-8?q?refact=20:=20package=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/teampome/pome/model/RecordData.kt | 4 ++-- .../presentation/addfriends/AddFriendsFragment.kt | 3 +-- .../presentation/record/ModifyRecordCardFragment.kt | 2 +- .../pome/presentation/record/RecordAlarmsFragment.kt | 1 + .../pome/presentation/record/RecordFragment.kt | 9 +++++++-- .../record/add/AddGoalCalendarFragment.kt | 4 +--- .../record/add/AddGoalContentsFragment.kt | 4 +--- .../record/consume/ConsumeEmotionFragment.kt | 4 ++-- .../record/consume/ConsumeRecordFragment.kt | 12 ++++++------ .../record/finish/RecordGoalFinishCommentFragment.kt | 3 +-- .../record/leave/LeaveEmotionFragment.kt | 4 ++-- .../record/leave/RecordLeaveEmotionFragment.kt | 4 ++-- .../OnGoalCategoryClickListener.kt | 2 +- .../{ => recyclerview}/OnMoreItemClickListener.kt | 2 +- .../{ => recyclerview}/OnRecordItemClickListener.kt | 2 +- .../adapter}/RecordAlarmsAdapter.kt | 6 ++++-- .../adapter}/RecordCategoryAdapter.kt | 6 ++++-- .../adapter}/RecordContentsCardAdapter.kt | 9 +++++++-- .../{ => recyclerview/adapter}/TextListAdapter.kt | 3 ++- .../viewholder}/GoalCardViewHolder.kt | 5 +++-- .../viewholder}/LeaveEmotionCardViewHolder.kt | 4 ++-- .../viewholder}/RecordCardViewHolder.kt | 4 +++- .../pome/presentation/register/RegisterFragment.kt | 4 ++-- .../presentation/register/RegisterProfileFragment.kt | 2 +- .../presentation/register/RegisterTermsFragment.kt | 2 +- .../pome/presentation/remind/RemindDetailFragment.kt | 4 ---- .../pome/presentation/remind/RemindFragment.kt | 11 +++++------ .../pome/presentation/splash/SplashFragment.kt | 2 +- .../java/com/teampome/pome/util/BindingAdapter.kt | 4 +++- .../com/teampome/pome/util/base/BaseViewModel.kt | 2 +- .../teampome/pome/util/{ => common}/CommonUtil.kt | 3 +-- .../com/teampome/pome/util/{ => common}/Constants.kt | 2 +- .../com/teampome/pome/util/{ => common}/Emotion.kt | 4 +++- .../com/teampome/pome/util/{ => common}/Event.kt | 2 +- .../record => util/common}/GoalState.kt | 2 +- .../pome/util/{ => common}/OnItemClickListener.kt | 2 +- .../pome/util/{ => common}/SingleLiveEvent.kt | 2 +- .../pome/util/customview/PomeBigGoalCardView.kt | 2 +- .../com/teampome/pome/viewmodel/RemindViewModel.kt | 4 ++-- .../pome/viewmodel/record/ConsumeEmotionViewModel.kt | 2 +- .../pome/viewmodel/record/LeaveEmotionViewModel.kt | 2 +- .../viewmodel/record/RecordGoalFinishViewModel.kt | 3 +-- .../pome/viewmodel/record/RecordViewModel.kt | 4 ++-- .../viewmodel/register/RegisterProfileViewModel.kt | 2 +- .../main/res/layout/fragment_add_goal_contents.xml | 2 +- .../main/res/layout/fragment_record_goal_finish.xml | 2 +- .../res/layout/fragment_record_leave_emotion.xml | 2 +- app/src/main/res/layout/fragment_remind.xml | 8 ++++---- app/src/main/res/layout/item_goal_card.xml | 6 +++--- app/src/main/res/layout/item_record_emotion_card.xml | 2 +- .../main/res/layout/item_remind_contents_card.xml | 2 +- 51 files changed, 99 insertions(+), 89 deletions(-) rename app/src/main/java/com/teampome/pome/presentation/record/{ => recyclerview}/OnGoalCategoryClickListener.kt (58%) rename app/src/main/java/com/teampome/pome/presentation/record/{ => recyclerview}/OnMoreItemClickListener.kt (67%) rename app/src/main/java/com/teampome/pome/presentation/record/{ => recyclerview}/OnRecordItemClickListener.kt (68%) rename app/src/main/java/com/teampome/pome/presentation/record/{ => recyclerview/adapter}/RecordAlarmsAdapter.kt (91%) rename app/src/main/java/com/teampome/pome/presentation/record/{ => recyclerview/adapter}/RecordCategoryAdapter.kt (94%) rename app/src/main/java/com/teampome/pome/presentation/record/{ => recyclerview/adapter}/RecordContentsCardAdapter.kt (90%) rename app/src/main/java/com/teampome/pome/presentation/record/{ => recyclerview/adapter}/TextListAdapter.kt (91%) rename app/src/main/java/com/teampome/pome/presentation/record/{ => recyclerview/viewholder}/GoalCardViewHolder.kt (85%) rename app/src/main/java/com/teampome/pome/presentation/record/{ => recyclerview/viewholder}/LeaveEmotionCardViewHolder.kt (81%) rename app/src/main/java/com/teampome/pome/presentation/record/{ => recyclerview/viewholder}/RecordCardViewHolder.kt (77%) rename app/src/main/java/com/teampome/pome/util/{ => common}/CommonUtil.kt (99%) rename app/src/main/java/com/teampome/pome/util/{ => common}/Constants.kt (89%) rename app/src/main/java/com/teampome/pome/util/{ => common}/Emotion.kt (71%) rename app/src/main/java/com/teampome/pome/util/{ => common}/Event.kt (94%) rename app/src/main/java/com/teampome/pome/{presentation/record => util/common}/GoalState.kt (72%) rename app/src/main/java/com/teampome/pome/util/{ => common}/OnItemClickListener.kt (58%) rename app/src/main/java/com/teampome/pome/util/{ => common}/SingleLiveEvent.kt (96%) diff --git a/app/src/main/java/com/teampome/pome/model/RecordData.kt b/app/src/main/java/com/teampome/pome/model/RecordData.kt index d495116a..b09973b3 100644 --- a/app/src/main/java/com/teampome/pome/model/RecordData.kt +++ b/app/src/main/java/com/teampome/pome/model/RecordData.kt @@ -2,8 +2,8 @@ package com.teampome.pome.model import android.os.Parcelable import com.teampome.pome.model.goal.GoalData -import com.teampome.pome.presentation.record.GoalState -import com.teampome.pome.presentation.record.RecordViewType +import com.teampome.pome.util.common.GoalState +import com.teampome.pome.presentation.record.recyclerview.adapter.RecordViewType import kotlinx.parcelize.Parcelize import kotlinx.parcelize.RawValue diff --git a/app/src/main/java/com/teampome/pome/presentation/addfriends/AddFriendsFragment.kt b/app/src/main/java/com/teampome/pome/presentation/addfriends/AddFriendsFragment.kt index 146a0d70..418603f5 100644 --- a/app/src/main/java/com/teampome/pome/presentation/addfriends/AddFriendsFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/addfriends/AddFriendsFragment.kt @@ -1,6 +1,5 @@ package com.teampome.pome.presentation.addfriends -import android.annotation.SuppressLint import android.os.Bundle import android.text.Editable import android.text.TextWatcher @@ -15,7 +14,7 @@ import com.teampome.pome.R import com.teampome.pome.databinding.FragmentAddFriendsBinding import com.teampome.pome.presentation.addfriends.recyclerview.AddFriendsListAdapter import com.teampome.pome.presentation.addfriends.recyclerview.OnAddFriendClickListener -import com.teampome.pome.util.CommonUtil +import com.teampome.pome.util.common.CommonUtil import com.teampome.pome.util.base.ApiResponse import com.teampome.pome.util.base.BaseFragment import com.teampome.pome.util.base.CoroutineErrorHandler diff --git a/app/src/main/java/com/teampome/pome/presentation/record/ModifyRecordCardFragment.kt b/app/src/main/java/com/teampome/pome/presentation/record/ModifyRecordCardFragment.kt index a0483c44..e0a3b0b7 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/ModifyRecordCardFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/ModifyRecordCardFragment.kt @@ -18,7 +18,7 @@ import com.prolificinteractive.materialcalendarview.* import com.teampome.pome.R import com.teampome.pome.databinding.FragmentModifyRecordCardBinding import com.teampome.pome.databinding.PomeCalendarBottomSheetDialogBinding -import com.teampome.pome.util.CommonUtil +import com.teampome.pome.util.common.CommonUtil import com.teampome.pome.util.base.ApiResponse import com.teampome.pome.util.base.BaseFragment import com.teampome.pome.util.base.CoroutineErrorHandler diff --git a/app/src/main/java/com/teampome/pome/presentation/record/RecordAlarmsFragment.kt b/app/src/main/java/com/teampome/pome/presentation/record/RecordAlarmsFragment.kt index f927d17b..6ebdd568 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/RecordAlarmsFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/RecordAlarmsFragment.kt @@ -6,6 +6,7 @@ import androidx.fragment.app.viewModels import androidx.navigation.fragment.findNavController import com.teampome.pome.R import com.teampome.pome.databinding.FragmentRecordAlarmsBinding +import com.teampome.pome.presentation.record.recyclerview.adapter.RecordAlarmsAdapter import com.teampome.pome.util.base.BaseFragment import com.teampome.pome.viewmodel.record.RecordAlarmsViewModel import dagger.hilt.android.AndroidEntryPoint diff --git a/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt b/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt index bcc6d368..f982adbd 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt @@ -24,9 +24,14 @@ import com.teampome.pome.databinding.TopImgNoticeDialogBinding import com.teampome.pome.model.RecordData import com.teampome.pome.model.goal.GoalCategory import com.teampome.pome.model.goal.GoalData +import com.teampome.pome.presentation.record.recyclerview.* +import com.teampome.pome.presentation.record.recyclerview.adapter.RecordCategoryAdapter +import com.teampome.pome.presentation.record.recyclerview.adapter.RecordContentsCardAdapter +import com.teampome.pome.presentation.record.recyclerview.adapter.RecordViewType import com.teampome.pome.presentation.remind.OnCategoryItemClickListener -import com.teampome.pome.util.CommonUtil -import com.teampome.pome.util.OnItemClickListener +import com.teampome.pome.util.common.CommonUtil +import com.teampome.pome.util.common.GoalState +import com.teampome.pome.util.common.OnItemClickListener import com.teampome.pome.util.base.ApiResponse import com.teampome.pome.util.base.CoroutineErrorHandler import com.teampome.pome.viewmodel.record.RecordViewModel diff --git a/app/src/main/java/com/teampome/pome/presentation/record/add/AddGoalCalendarFragment.kt b/app/src/main/java/com/teampome/pome/presentation/record/add/AddGoalCalendarFragment.kt index 05e89e6e..a2cb4fb1 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/add/AddGoalCalendarFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/add/AddGoalCalendarFragment.kt @@ -1,8 +1,6 @@ package com.teampome.pome.presentation.record.add import android.os.Bundle -import android.text.Editable -import android.text.TextWatcher import android.view.View import androidx.activity.OnBackPressedCallback import androidx.fragment.app.viewModels @@ -12,7 +10,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialog import com.teampome.pome.R import com.teampome.pome.databinding.FragmentAddGoalCalendarBinding import com.teampome.pome.databinding.PomeCalendarBottomSheetDialogBinding -import com.teampome.pome.util.CommonUtil +import com.teampome.pome.util.common.CommonUtil import com.teampome.pome.util.base.BaseFragment import com.teampome.pome.viewmodel.record.AddGoalCalendarViewModel import dagger.hilt.android.AndroidEntryPoint diff --git a/app/src/main/java/com/teampome/pome/presentation/record/add/AddGoalContentsFragment.kt b/app/src/main/java/com/teampome/pome/presentation/record/add/AddGoalContentsFragment.kt index cbbeecb6..6504315b 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/add/AddGoalContentsFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/add/AddGoalContentsFragment.kt @@ -13,15 +13,13 @@ import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.navArgs import com.teampome.pome.R import com.teampome.pome.databinding.FragmentAddGoalContentsBinding -import com.teampome.pome.util.CommonUtil +import com.teampome.pome.util.common.CommonUtil import com.teampome.pome.util.base.ApiResponse import com.teampome.pome.util.base.BaseFragment import com.teampome.pome.util.base.CoroutineErrorHandler import com.teampome.pome.util.token.UserManager import com.teampome.pome.viewmodel.record.AddGoalContentsViewModel import dagger.hilt.android.AndroidEntryPoint -import kotlinx.coroutines.flow.first -import kotlinx.coroutines.runBlocking import java.text.DecimalFormat import javax.inject.Inject diff --git a/app/src/main/java/com/teampome/pome/presentation/record/consume/ConsumeEmotionFragment.kt b/app/src/main/java/com/teampome/pome/presentation/record/consume/ConsumeEmotionFragment.kt index 64d87b78..d0be48d0 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/consume/ConsumeEmotionFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/consume/ConsumeEmotionFragment.kt @@ -13,8 +13,8 @@ import androidx.navigation.fragment.navArgs import com.teampome.pome.R import com.teampome.pome.databinding.FragmentConsumeEmotionBinding import com.teampome.pome.model.goal.GoalCategory -import com.teampome.pome.util.CommonUtil -import com.teampome.pome.util.Emotion +import com.teampome.pome.util.common.CommonUtil +import com.teampome.pome.util.common.Emotion import com.teampome.pome.util.base.ApiResponse import com.teampome.pome.util.base.BaseFragment import com.teampome.pome.util.base.CoroutineErrorHandler diff --git a/app/src/main/java/com/teampome/pome/presentation/record/consume/ConsumeRecordFragment.kt b/app/src/main/java/com/teampome/pome/presentation/record/consume/ConsumeRecordFragment.kt index 3af86838..9c7e653d 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/consume/ConsumeRecordFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/consume/ConsumeRecordFragment.kt @@ -14,12 +14,12 @@ import com.teampome.pome.databinding.PomeCalendarBottomSheetDialogBinding import com.teampome.pome.databinding.PomeTextListBottomSheetDialogBinding import com.teampome.pome.model.consume.ConsumeRecord import com.teampome.pome.model.goal.GoalCategory -import com.teampome.pome.presentation.record.OnGoalCategoryClickListener -import com.teampome.pome.presentation.record.TextListAdapter -import com.teampome.pome.util.CommonUtil -import com.teampome.pome.util.CommonUtil.dateToLocalDate -import com.teampome.pome.util.CommonUtil.getCurrentDate -import com.teampome.pome.util.CommonUtil.getCurrentDateString +import com.teampome.pome.presentation.record.recyclerview.OnGoalCategoryClickListener +import com.teampome.pome.presentation.record.recyclerview.adapter.TextListAdapter +import com.teampome.pome.util.common.CommonUtil +import com.teampome.pome.util.common.CommonUtil.dateToLocalDate +import com.teampome.pome.util.common.CommonUtil.getCurrentDate +import com.teampome.pome.util.common.CommonUtil.getCurrentDateString import com.teampome.pome.util.base.BaseFragment import com.teampome.pome.viewmodel.record.ConsumeRecordViewModel import dagger.hilt.android.AndroidEntryPoint diff --git a/app/src/main/java/com/teampome/pome/presentation/record/finish/RecordGoalFinishCommentFragment.kt b/app/src/main/java/com/teampome/pome/presentation/record/finish/RecordGoalFinishCommentFragment.kt index 3cec8991..d2e0c774 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/finish/RecordGoalFinishCommentFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/finish/RecordGoalFinishCommentFragment.kt @@ -13,13 +13,12 @@ import androidx.navigation.fragment.navArgs import com.teampome.pome.R import com.teampome.pome.databinding.FragmentRecordGoalFinishCommentBinding import com.teampome.pome.databinding.PomeRemoveDialogBinding -import com.teampome.pome.util.CommonUtil +import com.teampome.pome.util.common.CommonUtil import com.teampome.pome.util.base.ApiResponse import com.teampome.pome.util.base.BaseFragment import com.teampome.pome.util.base.CoroutineErrorHandler import com.teampome.pome.viewmodel.record.RecordGoalFinishCommentViewModel import dagger.hilt.android.AndroidEntryPoint -import javax.inject.Inject @AndroidEntryPoint class RecordGoalFinishCommentFragment : BaseFragment(R.layout.fragment_record_goal_finish_comment) { diff --git a/app/src/main/java/com/teampome/pome/presentation/record/leave/LeaveEmotionFragment.kt b/app/src/main/java/com/teampome/pome/presentation/record/leave/LeaveEmotionFragment.kt index 10bf5738..de9e7ad8 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/leave/LeaveEmotionFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/leave/LeaveEmotionFragment.kt @@ -13,8 +13,8 @@ import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.navArgs import com.teampome.pome.R import com.teampome.pome.databinding.FragmentLeaveEmotionBinding -import com.teampome.pome.util.CommonUtil -import com.teampome.pome.util.Emotion +import com.teampome.pome.util.common.CommonUtil +import com.teampome.pome.util.common.Emotion import com.teampome.pome.util.base.ApiResponse import com.teampome.pome.util.base.BaseFragment import com.teampome.pome.util.base.CoroutineErrorHandler diff --git a/app/src/main/java/com/teampome/pome/presentation/record/leave/RecordLeaveEmotionFragment.kt b/app/src/main/java/com/teampome/pome/presentation/record/leave/RecordLeaveEmotionFragment.kt index 25928b2d..680be032 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/leave/RecordLeaveEmotionFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/leave/RecordLeaveEmotionFragment.kt @@ -10,8 +10,8 @@ import androidx.navigation.fragment.navArgs import com.teampome.pome.R import com.teampome.pome.databinding.FragmentRecordLeaveEmotionBinding import com.teampome.pome.model.RecordData -import com.teampome.pome.presentation.record.OnRecordItemClickListener -import com.teampome.pome.presentation.record.RecordContentsCardAdapter +import com.teampome.pome.presentation.record.recyclerview.OnRecordItemClickListener +import com.teampome.pome.presentation.record.recyclerview.adapter.RecordContentsCardAdapter import com.teampome.pome.util.base.ApiResponse import com.teampome.pome.util.base.BaseFragment import com.teampome.pome.util.base.CoroutineErrorHandler diff --git a/app/src/main/java/com/teampome/pome/presentation/record/OnGoalCategoryClickListener.kt b/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/OnGoalCategoryClickListener.kt similarity index 58% rename from app/src/main/java/com/teampome/pome/presentation/record/OnGoalCategoryClickListener.kt rename to app/src/main/java/com/teampome/pome/presentation/record/recyclerview/OnGoalCategoryClickListener.kt index afec9b86..99e60a58 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/OnGoalCategoryClickListener.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/OnGoalCategoryClickListener.kt @@ -1,4 +1,4 @@ -package com.teampome.pome.presentation.record +package com.teampome.pome.presentation.record.recyclerview interface OnGoalCategoryClickListener { fun categoryClick(category: String) diff --git a/app/src/main/java/com/teampome/pome/presentation/record/OnMoreItemClickListener.kt b/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/OnMoreItemClickListener.kt similarity index 67% rename from app/src/main/java/com/teampome/pome/presentation/record/OnMoreItemClickListener.kt rename to app/src/main/java/com/teampome/pome/presentation/record/recyclerview/OnMoreItemClickListener.kt index 16d45f28..93fedeb9 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/OnMoreItemClickListener.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/OnMoreItemClickListener.kt @@ -1,4 +1,4 @@ -package com.teampome.pome.presentation.record +package com.teampome.pome.presentation.record.recyclerview import com.teampome.pome.model.RecordData diff --git a/app/src/main/java/com/teampome/pome/presentation/record/OnRecordItemClickListener.kt b/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/OnRecordItemClickListener.kt similarity index 68% rename from app/src/main/java/com/teampome/pome/presentation/record/OnRecordItemClickListener.kt rename to app/src/main/java/com/teampome/pome/presentation/record/recyclerview/OnRecordItemClickListener.kt index 5662cb61..e1dfe1ba 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/OnRecordItemClickListener.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/OnRecordItemClickListener.kt @@ -1,4 +1,4 @@ -package com.teampome.pome.presentation.record +package com.teampome.pome.presentation.record.recyclerview import com.teampome.pome.model.RecordData diff --git a/app/src/main/java/com/teampome/pome/presentation/record/RecordAlarmsAdapter.kt b/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/adapter/RecordAlarmsAdapter.kt similarity index 91% rename from app/src/main/java/com/teampome/pome/presentation/record/RecordAlarmsAdapter.kt rename to app/src/main/java/com/teampome/pome/presentation/record/recyclerview/adapter/RecordAlarmsAdapter.kt index 5084c3a3..66080169 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/RecordAlarmsAdapter.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/adapter/RecordAlarmsAdapter.kt @@ -1,4 +1,4 @@ -package com.teampome.pome.presentation.record +package com.teampome.pome.presentation.record.recyclerview.adapter import android.view.LayoutInflater import android.view.ViewGroup @@ -8,7 +8,9 @@ import androidx.recyclerview.widget.RecyclerView import com.teampome.pome.databinding.ItemRecordAlarmsBinding import com.teampome.pome.model.TestAlarmsData -class RecordAlarmsAdapter : ListAdapter(RecordAlarmsDiffCallback()) { +class RecordAlarmsAdapter : ListAdapter( + RecordAlarmsDiffCallback() +) { private lateinit var binding: ItemRecordAlarmsBinding override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecordAlarmsViewHolder { diff --git a/app/src/main/java/com/teampome/pome/presentation/record/RecordCategoryAdapter.kt b/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/adapter/RecordCategoryAdapter.kt similarity index 94% rename from app/src/main/java/com/teampome/pome/presentation/record/RecordCategoryAdapter.kt rename to app/src/main/java/com/teampome/pome/presentation/record/recyclerview/adapter/RecordCategoryAdapter.kt index bff658bd..0fca3350 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/RecordCategoryAdapter.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/adapter/RecordCategoryAdapter.kt @@ -1,4 +1,4 @@ -package com.teampome.pome.presentation.record +package com.teampome.pome.presentation.record.recyclerview.adapter import android.view.LayoutInflater import android.view.ViewGroup @@ -9,7 +9,9 @@ import com.teampome.pome.databinding.ItemRecordCategoryChipBinding import com.teampome.pome.model.goal.GoalCategory import com.teampome.pome.presentation.remind.OnCategoryItemClickListener -class RecordCategoryAdapter : ListAdapter(RecordCategoryDiffCallback()) { +class RecordCategoryAdapter : ListAdapter( + RecordCategoryDiffCallback() +) { // category click 관리 변수 private var onCategoryItemClickListener: OnCategoryItemClickListener? = null private var selectedPosition = 0 diff --git a/app/src/main/java/com/teampome/pome/presentation/record/RecordContentsCardAdapter.kt b/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/adapter/RecordContentsCardAdapter.kt similarity index 90% rename from app/src/main/java/com/teampome/pome/presentation/record/RecordContentsCardAdapter.kt rename to app/src/main/java/com/teampome/pome/presentation/record/recyclerview/adapter/RecordContentsCardAdapter.kt index 3354bdc2..0bbf33a1 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/RecordContentsCardAdapter.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/adapter/RecordContentsCardAdapter.kt @@ -1,4 +1,4 @@ -package com.teampome.pome.presentation.record +package com.teampome.pome.presentation.record.recyclerview.adapter import android.view.LayoutInflater import android.view.ViewGroup @@ -9,7 +9,12 @@ import com.teampome.pome.databinding.ItemGoalCardBinding import com.teampome.pome.databinding.ItemLeaveEmotionCardBinding import com.teampome.pome.databinding.ItemRecordEmotionCardBinding import com.teampome.pome.model.RecordData -import com.teampome.pome.util.OnItemClickListener +import com.teampome.pome.presentation.record.recyclerview.OnMoreItemClickListener +import com.teampome.pome.presentation.record.recyclerview.OnRecordItemClickListener +import com.teampome.pome.presentation.record.recyclerview.viewholder.GoalCardViewHolder +import com.teampome.pome.presentation.record.recyclerview.viewholder.LeaveEmotionCardViewHolder +import com.teampome.pome.presentation.record.recyclerview.viewholder.RecordCardViewHolder +import com.teampome.pome.util.common.OnItemClickListener sealed class RecordViewType(val type: Int) { object Goal: RecordViewType(0) diff --git a/app/src/main/java/com/teampome/pome/presentation/record/TextListAdapter.kt b/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/adapter/TextListAdapter.kt similarity index 91% rename from app/src/main/java/com/teampome/pome/presentation/record/TextListAdapter.kt rename to app/src/main/java/com/teampome/pome/presentation/record/recyclerview/adapter/TextListAdapter.kt index 5f66388b..abacf244 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/TextListAdapter.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/adapter/TextListAdapter.kt @@ -1,4 +1,4 @@ -package com.teampome.pome.presentation.record +package com.teampome.pome.presentation.record.recyclerview.adapter import android.view.LayoutInflater import android.view.ViewGroup @@ -6,6 +6,7 @@ import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView import com.teampome.pome.databinding.ItemTextListBinding +import com.teampome.pome.presentation.record.recyclerview.OnGoalCategoryClickListener class TextListAdapter : ListAdapter( TextListDiffCallback() diff --git a/app/src/main/java/com/teampome/pome/presentation/record/GoalCardViewHolder.kt b/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/viewholder/GoalCardViewHolder.kt similarity index 85% rename from app/src/main/java/com/teampome/pome/presentation/record/GoalCardViewHolder.kt rename to app/src/main/java/com/teampome/pome/presentation/record/recyclerview/viewholder/GoalCardViewHolder.kt index a0413abc..62edbdba 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/GoalCardViewHolder.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/viewholder/GoalCardViewHolder.kt @@ -1,9 +1,10 @@ -package com.teampome.pome.presentation.record +package com.teampome.pome.presentation.record.recyclerview.viewholder import androidx.recyclerview.widget.RecyclerView import com.teampome.pome.databinding.ItemGoalCardBinding import com.teampome.pome.model.goal.GoalData -import com.teampome.pome.util.OnItemClickListener +import com.teampome.pome.util.common.GoalState +import com.teampome.pome.util.common.OnItemClickListener class GoalCardViewHolder( private val binding: ItemGoalCardBinding, diff --git a/app/src/main/java/com/teampome/pome/presentation/record/LeaveEmotionCardViewHolder.kt b/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/viewholder/LeaveEmotionCardViewHolder.kt similarity index 81% rename from app/src/main/java/com/teampome/pome/presentation/record/LeaveEmotionCardViewHolder.kt rename to app/src/main/java/com/teampome/pome/presentation/record/recyclerview/viewholder/LeaveEmotionCardViewHolder.kt index 5a7b6248..47731e2c 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/LeaveEmotionCardViewHolder.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/viewholder/LeaveEmotionCardViewHolder.kt @@ -1,8 +1,8 @@ -package com.teampome.pome.presentation.record +package com.teampome.pome.presentation.record.recyclerview.viewholder import androidx.recyclerview.widget.RecyclerView import com.teampome.pome.databinding.ItemLeaveEmotionCardBinding -import com.teampome.pome.util.OnItemClickListener +import com.teampome.pome.util.common.OnItemClickListener class LeaveEmotionCardViewHolder( private val binding: ItemLeaveEmotionCardBinding, diff --git a/app/src/main/java/com/teampome/pome/presentation/record/RecordCardViewHolder.kt b/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/viewholder/RecordCardViewHolder.kt similarity index 77% rename from app/src/main/java/com/teampome/pome/presentation/record/RecordCardViewHolder.kt rename to app/src/main/java/com/teampome/pome/presentation/record/recyclerview/viewholder/RecordCardViewHolder.kt index 463899aa..93cdb929 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/RecordCardViewHolder.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/viewholder/RecordCardViewHolder.kt @@ -1,8 +1,10 @@ -package com.teampome.pome.presentation.record +package com.teampome.pome.presentation.record.recyclerview.viewholder import androidx.recyclerview.widget.RecyclerView import com.teampome.pome.databinding.ItemRecordEmotionCardBinding import com.teampome.pome.model.RecordData +import com.teampome.pome.presentation.record.recyclerview.OnMoreItemClickListener +import com.teampome.pome.presentation.record.recyclerview.OnRecordItemClickListener class RecordCardViewHolder( private val binding : ItemRecordEmotionCardBinding, diff --git a/app/src/main/java/com/teampome/pome/presentation/register/RegisterFragment.kt b/app/src/main/java/com/teampome/pome/presentation/register/RegisterFragment.kt index 0d44ece9..8de4280f 100644 --- a/app/src/main/java/com/teampome/pome/presentation/register/RegisterFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/register/RegisterFragment.kt @@ -14,9 +14,9 @@ import androidx.navigation.fragment.findNavController import com.google.android.material.bottomsheet.BottomSheetDialog import com.teampome.pome.R import com.teampome.pome.databinding.FragmentRegisterBinding -import com.teampome.pome.util.CommonUtil +import com.teampome.pome.util.common.CommonUtil import com.teampome.pome.databinding.PomeRegisterBottomSheetDialogBinding -import com.teampome.pome.util.CommonUtil.getPixelToDp +import com.teampome.pome.util.common.CommonUtil.getPixelToDp import com.teampome.pome.util.base.ApiResponse import com.teampome.pome.util.base.BaseFragment import com.teampome.pome.util.base.CoroutineErrorHandler diff --git a/app/src/main/java/com/teampome/pome/presentation/register/RegisterProfileFragment.kt b/app/src/main/java/com/teampome/pome/presentation/register/RegisterProfileFragment.kt index ea10afb6..e96420c8 100644 --- a/app/src/main/java/com/teampome/pome/presentation/register/RegisterProfileFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/register/RegisterProfileFragment.kt @@ -24,7 +24,7 @@ import com.teampome.pome.R import com.teampome.pome.databinding.FragmentRegisterProfileBinding import com.teampome.pome.databinding.PomeRegisterBottomSheetDialogBinding import com.teampome.pome.util.base.BaseFragment -import com.teampome.pome.util.CommonUtil +import com.teampome.pome.util.common.CommonUtil import com.teampome.pome.util.base.ApiResponse import com.teampome.pome.util.base.CoroutineErrorHandler import com.teampome.pome.util.token.TokenManager diff --git a/app/src/main/java/com/teampome/pome/presentation/register/RegisterTermsFragment.kt b/app/src/main/java/com/teampome/pome/presentation/register/RegisterTermsFragment.kt index ecc8e382..d886b75f 100644 --- a/app/src/main/java/com/teampome/pome/presentation/register/RegisterTermsFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/register/RegisterTermsFragment.kt @@ -7,7 +7,7 @@ import androidx.fragment.app.viewModels import androidx.navigation.fragment.findNavController import com.teampome.pome.R import com.teampome.pome.databinding.FragmentRegisterTermsBinding -import com.teampome.pome.util.CommonUtil +import com.teampome.pome.util.common.CommonUtil import com.teampome.pome.util.base.BaseFragment import com.teampome.pome.viewmodel.register.RegisterTermsViewModel import dagger.hilt.android.AndroidEntryPoint diff --git a/app/src/main/java/com/teampome/pome/presentation/remind/RemindDetailFragment.kt b/app/src/main/java/com/teampome/pome/presentation/remind/RemindDetailFragment.kt index e28ef6ff..73bfedff 100644 --- a/app/src/main/java/com/teampome/pome/presentation/remind/RemindDetailFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/remind/RemindDetailFragment.kt @@ -1,12 +1,8 @@ package com.teampome.pome.presentation.remind -import android.os.Bundle -import android.view.View import androidx.navigation.fragment.findNavController -import androidx.navigation.fragment.navArgs import com.teampome.pome.R import com.teampome.pome.databinding.FragmentRemindItemDetailBinding -import com.teampome.pome.util.CommonUtil import com.teampome.pome.util.base.BaseFragment class RemindDetailFragment : diff --git a/app/src/main/java/com/teampome/pome/presentation/remind/RemindFragment.kt b/app/src/main/java/com/teampome/pome/presentation/remind/RemindFragment.kt index 175d47e4..e1463150 100644 --- a/app/src/main/java/com/teampome/pome/presentation/remind/RemindFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/remind/RemindFragment.kt @@ -13,12 +13,11 @@ import com.teampome.pome.databinding.FragmentRemindBinding import com.teampome.pome.databinding.PomeRemindBottomSheetDialogBinding import com.teampome.pome.model.RecordData import com.teampome.pome.model.goal.GoalCategory -import com.teampome.pome.presentation.record.GoalState -import com.teampome.pome.presentation.record.RecordCategoryAdapter -import com.teampome.pome.util.CommonUtil -import com.teampome.pome.util.Constants.FIRST_EMOTION -import com.teampome.pome.util.Constants.LAST_EMOTION -import com.teampome.pome.util.Emotion +import com.teampome.pome.presentation.record.recyclerview.adapter.RecordCategoryAdapter +import com.teampome.pome.util.common.CommonUtil +import com.teampome.pome.util.common.Constants.FIRST_EMOTION +import com.teampome.pome.util.common.Constants.LAST_EMOTION +import com.teampome.pome.util.common.Emotion import com.teampome.pome.util.base.ApiResponse import com.teampome.pome.util.base.CoroutineErrorHandler import com.teampome.pome.viewmodel.RemindViewModel diff --git a/app/src/main/java/com/teampome/pome/presentation/splash/SplashFragment.kt b/app/src/main/java/com/teampome/pome/presentation/splash/SplashFragment.kt index de911c38..8d0791f5 100644 --- a/app/src/main/java/com/teampome/pome/presentation/splash/SplashFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/splash/SplashFragment.kt @@ -9,7 +9,7 @@ import androidx.navigation.fragment.findNavController import com.teampome.pome.R import com.teampome.pome.util.base.BaseFragment import com.teampome.pome.databinding.FragmentSplashBinding -import com.teampome.pome.util.CommonUtil +import com.teampome.pome.util.common.CommonUtil import com.teampome.pome.util.base.ApiResponse import com.teampome.pome.util.base.CoroutineErrorHandler import com.teampome.pome.util.safeNavigate diff --git a/app/src/main/java/com/teampome/pome/util/BindingAdapter.kt b/app/src/main/java/com/teampome/pome/util/BindingAdapter.kt index e2188154..cc0a0f72 100644 --- a/app/src/main/java/com/teampome/pome/util/BindingAdapter.kt +++ b/app/src/main/java/com/teampome/pome/util/BindingAdapter.kt @@ -1,6 +1,5 @@ package com.teampome.pome.util -import android.util.Log import android.widget.ImageView import android.widget.TextView import androidx.appcompat.widget.AppCompatTextView @@ -11,6 +10,9 @@ import com.bumptech.glide.load.resource.bitmap.CenterCrop import com.bumptech.glide.request.RequestOptions import com.teampome.pome.R import com.teampome.pome.model.RecordData +import com.teampome.pome.util.common.CommonUtil +import com.teampome.pome.util.common.Constants +import com.teampome.pome.util.common.Emotion import com.teampome.pome.util.customview.PomeBigGoalCardView import com.teampome.pome.util.customview.PomeSmallGoalCardView import jp.wasabeef.glide.transformations.MaskTransformation diff --git a/app/src/main/java/com/teampome/pome/util/base/BaseViewModel.kt b/app/src/main/java/com/teampome/pome/util/base/BaseViewModel.kt index 792200c8..03365f28 100644 --- a/app/src/main/java/com/teampome/pome/util/base/BaseViewModel.kt +++ b/app/src/main/java/com/teampome/pome/util/base/BaseViewModel.kt @@ -3,7 +3,7 @@ package com.teampome.pome.util.base import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.teampome.pome.util.Event +import com.teampome.pome.util.common.Event import kotlinx.coroutines.* import kotlinx.coroutines.flow.Flow diff --git a/app/src/main/java/com/teampome/pome/util/CommonUtil.kt b/app/src/main/java/com/teampome/pome/util/common/CommonUtil.kt similarity index 99% rename from app/src/main/java/com/teampome/pome/util/CommonUtil.kt rename to app/src/main/java/com/teampome/pome/util/common/CommonUtil.kt index 7850f690..2cce35ae 100644 --- a/app/src/main/java/com/teampome/pome/util/CommonUtil.kt +++ b/app/src/main/java/com/teampome/pome/util/common/CommonUtil.kt @@ -1,4 +1,4 @@ -package com.teampome.pome.util +package com.teampome.pome.util.common import android.annotation.SuppressLint import android.app.Activity @@ -11,7 +11,6 @@ import android.net.ConnectivityManager import android.net.NetworkCapabilities import android.net.Uri import android.os.Build -import android.util.Log import android.view.LayoutInflater import android.view.WindowInsets import android.view.WindowManager diff --git a/app/src/main/java/com/teampome/pome/util/Constants.kt b/app/src/main/java/com/teampome/pome/util/common/Constants.kt similarity index 89% rename from app/src/main/java/com/teampome/pome/util/Constants.kt rename to app/src/main/java/com/teampome/pome/util/common/Constants.kt index 9fd60cbf..01131faf 100644 --- a/app/src/main/java/com/teampome/pome/util/Constants.kt +++ b/app/src/main/java/com/teampome/pome/util/common/Constants.kt @@ -1,4 +1,4 @@ -package com.teampome.pome.util +package com.teampome.pome.util.common object Constants { const val FIRST_EMOTION = "처음 감정" diff --git a/app/src/main/java/com/teampome/pome/util/Emotion.kt b/app/src/main/java/com/teampome/pome/util/common/Emotion.kt similarity index 71% rename from app/src/main/java/com/teampome/pome/util/Emotion.kt rename to app/src/main/java/com/teampome/pome/util/common/Emotion.kt index df5d0988..78a3aab0 100644 --- a/app/src/main/java/com/teampome/pome/util/Emotion.kt +++ b/app/src/main/java/com/teampome/pome/util/common/Emotion.kt @@ -1,4 +1,6 @@ -package com.teampome.pome.util +package com.teampome.pome.util.common + +import com.teampome.pome.util.common.Constants enum class Emotion(val emotion: String) { HAPPY_EMOTION(Constants.HAPPY_EMOTION), diff --git a/app/src/main/java/com/teampome/pome/util/Event.kt b/app/src/main/java/com/teampome/pome/util/common/Event.kt similarity index 94% rename from app/src/main/java/com/teampome/pome/util/Event.kt rename to app/src/main/java/com/teampome/pome/util/common/Event.kt index d1692a6d..7a74c4b7 100644 --- a/app/src/main/java/com/teampome/pome/util/Event.kt +++ b/app/src/main/java/com/teampome/pome/util/common/Event.kt @@ -1,4 +1,4 @@ -package com.teampome.pome.util +package com.teampome.pome.util.common /** * Used as a wrapper for data that is exposed via a LiveData that represents an event. diff --git a/app/src/main/java/com/teampome/pome/presentation/record/GoalState.kt b/app/src/main/java/com/teampome/pome/util/common/GoalState.kt similarity index 72% rename from app/src/main/java/com/teampome/pome/presentation/record/GoalState.kt rename to app/src/main/java/com/teampome/pome/util/common/GoalState.kt index 37d2173d..c0ab3a19 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/GoalState.kt +++ b/app/src/main/java/com/teampome/pome/util/common/GoalState.kt @@ -1,4 +1,4 @@ -package com.teampome.pome.presentation.record +package com.teampome.pome.util.common sealed class GoalState { object Empty: GoalState() diff --git a/app/src/main/java/com/teampome/pome/util/OnItemClickListener.kt b/app/src/main/java/com/teampome/pome/util/common/OnItemClickListener.kt similarity index 58% rename from app/src/main/java/com/teampome/pome/util/OnItemClickListener.kt rename to app/src/main/java/com/teampome/pome/util/common/OnItemClickListener.kt index 076f7884..249267c0 100644 --- a/app/src/main/java/com/teampome/pome/util/OnItemClickListener.kt +++ b/app/src/main/java/com/teampome/pome/util/common/OnItemClickListener.kt @@ -1,4 +1,4 @@ -package com.teampome.pome.util +package com.teampome.pome.util.common interface OnItemClickListener { fun itemClick() diff --git a/app/src/main/java/com/teampome/pome/util/SingleLiveEvent.kt b/app/src/main/java/com/teampome/pome/util/common/SingleLiveEvent.kt similarity index 96% rename from app/src/main/java/com/teampome/pome/util/SingleLiveEvent.kt rename to app/src/main/java/com/teampome/pome/util/common/SingleLiveEvent.kt index c4dfbb1a..12a0b9e8 100644 --- a/app/src/main/java/com/teampome/pome/util/SingleLiveEvent.kt +++ b/app/src/main/java/com/teampome/pome/util/common/SingleLiveEvent.kt @@ -1,4 +1,4 @@ -package com.teampome.pome.util +package com.teampome.pome.util.common import android.util.Log import androidx.annotation.MainThread diff --git a/app/src/main/java/com/teampome/pome/util/customview/PomeBigGoalCardView.kt b/app/src/main/java/com/teampome/pome/util/customview/PomeBigGoalCardView.kt index 89ab3fa8..fdb6c0e3 100644 --- a/app/src/main/java/com/teampome/pome/util/customview/PomeBigGoalCardView.kt +++ b/app/src/main/java/com/teampome/pome/util/customview/PomeBigGoalCardView.kt @@ -5,7 +5,7 @@ import android.util.AttributeSet import android.util.Log import android.view.ViewTreeObserver import com.teampome.pome.R -import com.teampome.pome.util.CommonUtil +import com.teampome.pome.util.common.CommonUtil class PomeBigGoalCardView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : PomeSmallGoalCardView(context, attrs) { var useAmount: String? = "" diff --git a/app/src/main/java/com/teampome/pome/viewmodel/RemindViewModel.kt b/app/src/main/java/com/teampome/pome/viewmodel/RemindViewModel.kt index c47dbe49..74efc03e 100644 --- a/app/src/main/java/com/teampome/pome/viewmodel/RemindViewModel.kt +++ b/app/src/main/java/com/teampome/pome/viewmodel/RemindViewModel.kt @@ -9,8 +9,8 @@ import com.teampome.pome.model.goal.GoalCategory import com.teampome.pome.model.goal.GoalData import com.teampome.pome.repository.goal.GoalRepository import com.teampome.pome.repository.remind.RemindRepository -import com.teampome.pome.util.CommonUtil -import com.teampome.pome.util.SingleLiveEvent +import com.teampome.pome.util.common.CommonUtil +import com.teampome.pome.util.common.SingleLiveEvent import com.teampome.pome.util.base.ApiResponse import com.teampome.pome.util.base.BaseViewModel import com.teampome.pome.util.base.CoroutineErrorHandler diff --git a/app/src/main/java/com/teampome/pome/viewmodel/record/ConsumeEmotionViewModel.kt b/app/src/main/java/com/teampome/pome/viewmodel/record/ConsumeEmotionViewModel.kt index 7cee1370..50223aa9 100644 --- a/app/src/main/java/com/teampome/pome/viewmodel/record/ConsumeEmotionViewModel.kt +++ b/app/src/main/java/com/teampome/pome/viewmodel/record/ConsumeEmotionViewModel.kt @@ -5,7 +5,7 @@ import androidx.lifecycle.MutableLiveData import com.teampome.pome.model.RecordData import com.teampome.pome.model.base.BasePomeResponse import com.teampome.pome.repository.record.RecordRepository -import com.teampome.pome.util.Emotion +import com.teampome.pome.util.common.Emotion import com.teampome.pome.util.base.ApiResponse import com.teampome.pome.util.base.BaseViewModel import com.teampome.pome.util.base.CoroutineErrorHandler diff --git a/app/src/main/java/com/teampome/pome/viewmodel/record/LeaveEmotionViewModel.kt b/app/src/main/java/com/teampome/pome/viewmodel/record/LeaveEmotionViewModel.kt index ded48537..2073e8d0 100644 --- a/app/src/main/java/com/teampome/pome/viewmodel/record/LeaveEmotionViewModel.kt +++ b/app/src/main/java/com/teampome/pome/viewmodel/record/LeaveEmotionViewModel.kt @@ -5,7 +5,7 @@ import androidx.lifecycle.MutableLiveData import com.teampome.pome.model.RecordData import com.teampome.pome.model.base.BasePomeResponse import com.teampome.pome.repository.record.RecordRepository -import com.teampome.pome.util.Emotion +import com.teampome.pome.util.common.Emotion import com.teampome.pome.util.base.ApiResponse import com.teampome.pome.util.base.BaseViewModel import com.teampome.pome.util.base.CoroutineErrorHandler diff --git a/app/src/main/java/com/teampome/pome/viewmodel/record/RecordGoalFinishViewModel.kt b/app/src/main/java/com/teampome/pome/viewmodel/record/RecordGoalFinishViewModel.kt index b8ba22d3..cbee5e35 100644 --- a/app/src/main/java/com/teampome/pome/viewmodel/record/RecordGoalFinishViewModel.kt +++ b/app/src/main/java/com/teampome/pome/viewmodel/record/RecordGoalFinishViewModel.kt @@ -6,9 +6,8 @@ import com.teampome.pome.model.RecordData import com.teampome.pome.model.base.BaseAllData import com.teampome.pome.model.base.BasePomeResponse import com.teampome.pome.model.goal.GoalData -import com.teampome.pome.repository.record.RecordRepository import com.teampome.pome.repository.remind.RemindRepository -import com.teampome.pome.util.SingleLiveEvent +import com.teampome.pome.util.common.SingleLiveEvent import com.teampome.pome.util.base.ApiResponse import com.teampome.pome.util.base.BaseViewModel import com.teampome.pome.util.base.CoroutineErrorHandler diff --git a/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt b/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt index 764874b8..b52e09cc 100644 --- a/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt +++ b/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt @@ -10,8 +10,8 @@ import com.teampome.pome.model.goal.GoalCategory import com.teampome.pome.model.goal.GoalData import com.teampome.pome.repository.goal.GoalRepository import com.teampome.pome.repository.record.RecordRepository -import com.teampome.pome.util.CommonUtil -import com.teampome.pome.util.SingleLiveEvent +import com.teampome.pome.util.common.CommonUtil +import com.teampome.pome.util.common.SingleLiveEvent import com.teampome.pome.util.base.ApiResponse import com.teampome.pome.util.base.BaseViewModel import com.teampome.pome.util.base.CoroutineErrorHandler diff --git a/app/src/main/java/com/teampome/pome/viewmodel/register/RegisterProfileViewModel.kt b/app/src/main/java/com/teampome/pome/viewmodel/register/RegisterProfileViewModel.kt index 835093b5..6e777fc5 100644 --- a/app/src/main/java/com/teampome/pome/viewmodel/register/RegisterProfileViewModel.kt +++ b/app/src/main/java/com/teampome/pome/viewmodel/register/RegisterProfileViewModel.kt @@ -8,7 +8,7 @@ import com.teampome.pome.model.user.UserInfoData import com.teampome.pome.repository.register.PresignedUrlRepository import com.teampome.pome.repository.register.RegisterRepository import com.teampome.pome.repository.register.SendPreSignedImageRepository -import com.teampome.pome.util.CommonUtil +import com.teampome.pome.util.common.CommonUtil import com.teampome.pome.util.base.ApiResponse import com.teampome.pome.util.base.BaseViewModel import com.teampome.pome.util.base.CoroutineErrorHandler diff --git a/app/src/main/res/layout/fragment_add_goal_contents.xml b/app/src/main/res/layout/fragment_add_goal_contents.xml index a72d93cb..53f6b9f8 100644 --- a/app/src/main/res/layout/fragment_add_goal_contents.xml +++ b/app/src/main/res/layout/fragment_add_goal_contents.xml @@ -16,7 +16,7 @@ name="price" type="String" /> - + - + - + diff --git a/app/src/main/res/layout/fragment_remind.xml b/app/src/main/res/layout/fragment_remind.xml index 6abad4e4..014887f5 100644 --- a/app/src/main/res/layout/fragment_remind.xml +++ b/app/src/main/res/layout/fragment_remind.xml @@ -20,16 +20,16 @@ + type="com.teampome.pome.util.common.Emotion" /> + type="com.teampome.pome.util.common.Emotion" /> - - + + + type="com.teampome.pome.util.common.GoalState" /> - - + + - + - + From ea3b8f11545918b3d530ed3bb5a0a92326e2b654 Mon Sep 17 00:00:00 2001 From: hanseuk-Choi Date: Thu, 9 Mar 2023 23:45:50 +0900 Subject: [PATCH 16/40] =?UTF-8?q?feat=20:=20=EA=B8=B0=EB=A1=9D=ED=95=9C=20?= =?UTF-8?q?=EC=94=80=EC=94=80=EC=9D=B4=20=EB=B7=B0=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pome/presentation/record/RecordFragment.kt | 10 ++++++++++ .../teampome/pome/viewmodel/record/RecordViewModel.kt | 4 ---- app/src/main/res/layout/fragment_record.xml | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt b/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt index f982adbd..1a5e107f 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt @@ -10,7 +10,10 @@ import androidx.fragment.app.viewModels import androidx.lifecycle.lifecycleScope import androidx.navigation.fragment.findNavController import androidx.paging.TerminalSeparatorType +import androidx.paging.filter import androidx.paging.insertHeaderItem +import androidx.paging.map +import androidx.recyclerview.widget.RecyclerView import com.bumptech.glide.Glide import com.google.android.material.bottomsheet.BottomSheetDialog import com.teampome.pome.R @@ -186,6 +189,13 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec } } }) + + addOnPagesUpdatedListener { + if(binding.recordSize != itemCount - 2) { + binding.recordSize = itemCount - 2 + binding.executePendingBindings() + } + } } } diff --git a/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt b/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt index b52e09cc..c7a0e6c7 100644 --- a/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt +++ b/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt @@ -44,10 +44,6 @@ class RecordViewModel @Inject constructor( private val _deleteGoalResponse = MutableLiveData>>() val deleteGoalResponse: LiveData>> = _deleteGoalResponse -// fun setPagingRecordByGoalId(goalId: Int): Flow> { -// return recordRepository.getPagingRecordByGoalId(goalId).cachedIn(viewModelScope) -// } - val goalCategorys: LiveData> = Transformations.map(_findAllGoalByUserResponse) { when(it) { is ApiResponse.Success -> { diff --git a/app/src/main/res/layout/fragment_record.xml b/app/src/main/res/layout/fragment_record.xml index 5b0ff882..113417e4 100644 --- a/app/src/main/res/layout/fragment_record.xml +++ b/app/src/main/res/layout/fragment_record.xml @@ -78,6 +78,7 @@ From 716a6d16e878af38a26c941b625fbab3e6eca964 Mon Sep 17 00:00:00 2001 From: hanseuk-Choi Date: Thu, 9 Mar 2023 23:58:02 +0900 Subject: [PATCH 17/40] =?UTF-8?q?fix=20:=20snapshot=20=EB=8C=80=EC=8B=A0?= =?UTF-8?q?=20itemCount=EB=A1=9C=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/teampome/pome/presentation/record/RecordFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt b/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt index 1a5e107f..5763d456 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt @@ -182,7 +182,7 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec // 목표 완료 시 클릭 setOnGoalCompleteClickListener(object : OnItemClickListener { override fun itemClick() { - if((binding.recordEmotionRv.adapter as RecordContentsCardAdapter).snapshot().items.isEmpty()) { + if((binding.recordEmotionRv.adapter as RecordContentsCardAdapter).itemCount-2 <= 0) { moveToRecordGoalFinish() } else { finishGoalAlertDialog.show() From d24214bde84c39a0b47341cd73a5c54922530a53 Mon Sep 17 00:00:00 2001 From: hanseuk-Choi Date: Fri, 10 Mar 2023 00:33:34 +0900 Subject: [PATCH 18/40] =?UTF-8?q?feat=20:=20=EA=B0=90=EC=A0=95=20=EB=82=A8?= =?UTF-8?q?=EA=B8=B0=EA=B8=B0=20adpater=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../leave/RecordLeaveEmotionFragment.kt | 13 +++---- .../adapter/RecordOneWeekAdapter.kt | 35 +++++++++++++++++++ 2 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 app/src/main/java/com/teampome/pome/presentation/record/recyclerview/adapter/RecordOneWeekAdapter.kt diff --git a/app/src/main/java/com/teampome/pome/presentation/record/leave/RecordLeaveEmotionFragment.kt b/app/src/main/java/com/teampome/pome/presentation/record/leave/RecordLeaveEmotionFragment.kt index 680be032..1f1522c7 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/leave/RecordLeaveEmotionFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/leave/RecordLeaveEmotionFragment.kt @@ -12,6 +12,7 @@ import com.teampome.pome.databinding.FragmentRecordLeaveEmotionBinding import com.teampome.pome.model.RecordData import com.teampome.pome.presentation.record.recyclerview.OnRecordItemClickListener import com.teampome.pome.presentation.record.recyclerview.adapter.RecordContentsCardAdapter +import com.teampome.pome.presentation.record.recyclerview.adapter.RecordOneWeekAdapter import com.teampome.pome.util.base.ApiResponse import com.teampome.pome.util.base.BaseFragment import com.teampome.pome.util.base.CoroutineErrorHandler @@ -39,7 +40,7 @@ class RecordLeaveEmotionFragment : BaseFragment @@ -68,11 +69,11 @@ class RecordLeaveEmotionFragment : BaseFragment( + RecordContentsCardDiffCallback() +) { + + private var recordBodyClickListener: OnRecordItemClickListener? = null + + fun setOnRecordBodyClickListener(listener: OnRecordItemClickListener) { + recordBodyClickListener = listener + } + + override fun onCreateViewHolder( + parent: ViewGroup, + viewType: Int + ): RecordCardViewHolder { + val binding = ItemRecordEmotionCardBinding.inflate(LayoutInflater.from(parent.context), parent, false) + + return RecordCardViewHolder(binding, null, recordBodyClickListener) + } + + override fun onBindViewHolder(holder: RecordCardViewHolder, position: Int) { + getItem(position)?.let { + holder.bind(it) + } + } +} \ No newline at end of file From 9b2ea89df85e6b02caf36f03eee133d432078b04 Mon Sep 17 00:00:00 2001 From: hanseuk-Choi Date: Fri, 10 Mar 2023 00:45:04 +0900 Subject: [PATCH 19/40] =?UTF-8?q?fix=20:=20=EC=97=B0=EB=8F=84=EA=B0=80=204?= =?UTF-8?q?=EC=9E=90=EB=A6=AC=EC=9D=B8=20=EA=B2=BD=EC=9A=B0,=202=EC=9E=90?= =?UTF-8?q?=EB=A6=AC=EB=A1=9C=20=EB=B3=80=ED=99=98=ED=95=98=EC=97=AC=20?= =?UTF-8?q?=EB=82=A0=EC=A7=9C=20=EA=B3=84=EC=82=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/teampome/pome/util/common/CommonUtil.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/teampome/pome/util/common/CommonUtil.kt b/app/src/main/java/com/teampome/pome/util/common/CommonUtil.kt index 2cce35ae..d048b127 100644 --- a/app/src/main/java/com/teampome/pome/util/common/CommonUtil.kt +++ b/app/src/main/java/com/teampome/pome/util/common/CommonUtil.kt @@ -498,7 +498,11 @@ object CommonUtil { val nowYear = sdf.format(Date(System.currentTimeMillis())) - val dateArr = date.split(".") + val dateArr = date.split(".").toMutableList() + val useYearLen = dateArr[0].length + if(useYearLen > 2) { + dateArr[0] = dateArr[0].substring(useYearLen-2, useYearLen) + } // Log.d("year", "now : $nowYear , date : ${dateArr[0]}") From 62866c518df5677dcb29b5a1679f1c5aa6361631 Mon Sep 17 00:00:00 2001 From: hanseulchoi Date: Fri, 10 Mar 2023 10:04:12 +0900 Subject: [PATCH 20/40] =?UTF-8?q?fix=20:=20PagingConfig=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EC=B1=85=EC=9E=84=20viewModel=20=EC=9C=84=EC=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pome/repository/record/RecordDataSource.kt | 3 ++- .../pome/repository/record/RecordRemoteDataSource.kt | 9 ++------- .../pome/repository/record/RecordRepository.kt | 5 +++-- .../teampome/pome/viewmodel/record/RecordViewModel.kt | 10 +++++++++- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/teampome/pome/repository/record/RecordDataSource.kt b/app/src/main/java/com/teampome/pome/repository/record/RecordDataSource.kt index 16c2df99..933b52eb 100644 --- a/app/src/main/java/com/teampome/pome/repository/record/RecordDataSource.kt +++ b/app/src/main/java/com/teampome/pome/repository/record/RecordDataSource.kt @@ -1,5 +1,6 @@ package com.teampome.pome.repository.record +import androidx.paging.PagingConfig import androidx.paging.PagingData import com.teampome.pome.model.RecordData import com.teampome.pome.model.base.BaseAllData @@ -16,5 +17,5 @@ interface RecordDataSource { fun updateRecord(recordId: Int, recordDataBody: ConsumeRecordDataBody): Flow>> fun getRecordByGoalId(goalId: Int): Flow>>> fun getOneWeekGoalByGoalId(goalId: Int): Flow>>> - fun getRecordPagingData(goalId: Int): Flow> + fun getRecordPagingData(goalId: Int, pagingConfig: PagingConfig): Flow> } \ No newline at end of file diff --git a/app/src/main/java/com/teampome/pome/repository/record/RecordRemoteDataSource.kt b/app/src/main/java/com/teampome/pome/repository/record/RecordRemoteDataSource.kt index e783a0b9..496cf0dd 100644 --- a/app/src/main/java/com/teampome/pome/repository/record/RecordRemoteDataSource.kt +++ b/app/src/main/java/com/teampome/pome/repository/record/RecordRemoteDataSource.kt @@ -48,14 +48,9 @@ class RecordRemoteDataSource @Inject constructor( service.getOneWeekGoalByGoalId(goalId) } - override fun getRecordPagingData(goalId: Int): Flow> { + override fun getRecordPagingData(goalId: Int, pagingConfig: PagingConfig): Flow> { return Pager( - config = PagingConfig( - pageSize = 15, - initialLoadSize = 15, - prefetchDistance = 10, - enablePlaceholders = false - ), + config = pagingConfig, pagingSourceFactory = { RecordPagingSource(service = service, goalId = goalId) } diff --git a/app/src/main/java/com/teampome/pome/repository/record/RecordRepository.kt b/app/src/main/java/com/teampome/pome/repository/record/RecordRepository.kt index f8bf0c42..e01b080a 100644 --- a/app/src/main/java/com/teampome/pome/repository/record/RecordRepository.kt +++ b/app/src/main/java/com/teampome/pome/repository/record/RecordRepository.kt @@ -1,5 +1,6 @@ package com.teampome.pome.repository.record +import androidx.paging.PagingConfig import androidx.paging.PagingData import com.teampome.pome.model.RecordData import com.teampome.pome.model.base.BasePomeResponse @@ -17,8 +18,8 @@ class RecordRepository @Inject constructor( private val userManager: UserManager ) { - fun getRecordPagingData(goalId: Int): Flow> { - return recordDataSource.getRecordPagingData(goalId) + fun getRecordPagingData(goalId: Int, pagingConfig: PagingConfig): Flow> { + return recordDataSource.getRecordPagingData(goalId, pagingConfig) } fun getRecordDataByUserId(): Flow>>> { diff --git a/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt b/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt index c7a0e6c7..77dab332 100644 --- a/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt +++ b/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt @@ -1,6 +1,7 @@ package com.teampome.pome.viewmodel.record import androidx.lifecycle.* +import androidx.paging.PagingConfig import androidx.paging.PagingData import androidx.paging.cachedIn import com.teampome.pome.model.RecordData @@ -149,9 +150,16 @@ class RecordViewModel @Inject constructor( private val _pagingRecordData = SingleLiveEvent>() val pagingRecordData: LiveData> = _pagingRecordData + private val recordPagingConfig = + PagingConfig( + pageSize = 15, + initialLoadSize = 15, + prefetchDistance = 10, + enablePlaceholders = false + ) fun getRecordPagingData(goalId: Int) { viewModelScope.launch { - recordRepository.getRecordPagingData(goalId).cachedIn(viewModelScope).collect { + recordRepository.getRecordPagingData(goalId, recordPagingConfig).cachedIn(viewModelScope).collect { _pagingRecordData.value = it } } From 2ffcf201fe8934792e5716547c15346beb9fc93c Mon Sep 17 00:00:00 2001 From: hanseulchoi Date: Fri, 10 Mar 2023 14:03:44 +0900 Subject: [PATCH 21/40] =?UTF-8?q?feat=20:=20=EC=9D=B8=EC=A6=9D=EB=B2=88?= =?UTF-8?q?=ED=98=B8=20=EB=AC=B8=EA=B5=AC=20=EC=B6=94=EA=B0=80=20=EB=B0=8F?= =?UTF-8?q?=20=ED=86=A0=EC=8A=A4=ED=8A=B8=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pome/presentation/register/RegisterFragment.kt | 8 ++++++-- app/src/main/res/layout/fragment_register.xml | 13 +++++++++++++ app/src/main/res/values/strings.xml | 1 + 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/teampome/pome/presentation/register/RegisterFragment.kt b/app/src/main/java/com/teampome/pome/presentation/register/RegisterFragment.kt index 8de4280f..fb3454b5 100644 --- a/app/src/main/java/com/teampome/pome/presentation/register/RegisterFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/register/RegisterFragment.kt @@ -161,6 +161,12 @@ class RegisterFragment : BaseFragment(R.layout.fragment override fun afterTextChanged(p0: Editable?) { p0?.let { viewModel.registerCertNum.value = it.toString() + + if(it.toString() == viewModel.smsValidate) { + binding.registerCertNumCheckTv.visibility = View.GONE + } else { + binding.registerCertNumCheckTv.visibility = View.VISIBLE + } } settingAgreeButton() @@ -169,8 +175,6 @@ class RegisterFragment : BaseFragment(R.layout.fragment // 번호 인증 요청 binding.registerCertPhoneAcb.setOnClickListener { - Toast.makeText(requireContext(), "번호 인증 요청", Toast.LENGTH_SHORT).show() - binding.registerCertPhoneAcb.text = "재요청" binding.registerCertPhoneAcb.setPadding( diff --git a/app/src/main/res/layout/fragment_register.xml b/app/src/main/res/layout/fragment_register.xml index 0d72f399..b443120b 100644 --- a/app/src/main/res/layout/fragment_register.xml +++ b/app/src/main/res/layout/fragment_register.xml @@ -108,6 +108,19 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/register_cert_num_title_tv" /> + + ··· 목표가 있어야 씀씀이를\n기록하고 돌아볼 수 있어요 목표 만들기 + 인증번호가 일치하지 않아요 \ No newline at end of file From 1f158d766300460580527dd51c95ac99921d1f18 Mon Sep 17 00:00:00 2001 From: hanseulchoi Date: Fri, 10 Mar 2023 17:01:27 +0900 Subject: [PATCH 22/40] =?UTF-8?q?feat=20:=20=EC=9B=B9=20=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=20=EC=9D=B4=EB=8F=99=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/register/RegisterTermsFragment.kt | 10 +++------- .../com/teampome/pome/util/common/CommonUtil.kt | 9 +++++++++ app/src/main/res/layout/fragment_register_terms.xml | 13 ++++++++----- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/teampome/pome/presentation/register/RegisterTermsFragment.kt b/app/src/main/java/com/teampome/pome/presentation/register/RegisterTermsFragment.kt index d886b75f..e91238c3 100644 --- a/app/src/main/java/com/teampome/pome/presentation/register/RegisterTermsFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/register/RegisterTermsFragment.kt @@ -24,10 +24,6 @@ class RegisterTermsFragment : BaseFragment(R.layou resources.getColor(R.color.grey_3, null) } - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - } - override fun initView() { Log.d("test", "terms fragment in") @@ -57,7 +53,7 @@ class RegisterTermsFragment : BaseFragment(R.layou // 이용약관 동의 텍스트 클릭 binding.registerAgreeUsingTermsAtv.setOnClickListener { - moveToTermsDetail() + CommonUtil.goToWebPage(requireContext(), "https://few-horse-2aa.notion.site/6a2e6f6241e94a479a3e2c2a3cdb909e") } // 개인정보 수집 동의 체크 클릭 @@ -67,7 +63,7 @@ class RegisterTermsFragment : BaseFragment(R.layou // 개인정보 수집 동의 텍스트 클릭 binding.registerAgreePrivacyAtv.setOnClickListener { - moveToTermsDetail() + CommonUtil.goToWebPage(requireContext(), "https://few-horse-2aa.notion.site/b396b02d8bd3460f945cf3f90935667b") } // 마케팅 정보 수집 동의 체크 클릭 @@ -77,7 +73,7 @@ class RegisterTermsFragment : BaseFragment(R.layou // 마케팅 정보 수집 동의 텍스트 클릭 binding.registerAgreeMarketingAtv.setOnClickListener { - moveToTermsDetail() + CommonUtil.goToWebPage(requireContext(), "https://few-horse-2aa.notion.site/8cc486236d77473f84fa53a3b0ede726") } // 전체동의 체크시 뷰 diff --git a/app/src/main/java/com/teampome/pome/util/common/CommonUtil.kt b/app/src/main/java/com/teampome/pome/util/common/CommonUtil.kt index d048b127..a8b1bbd3 100644 --- a/app/src/main/java/com/teampome/pome/util/common/CommonUtil.kt +++ b/app/src/main/java/com/teampome/pome/util/common/CommonUtil.kt @@ -4,6 +4,7 @@ import android.annotation.SuppressLint import android.app.Activity import android.app.Dialog import android.content.Context +import android.content.Intent import android.graphics.Color import android.graphics.Point import android.graphics.drawable.ColorDrawable @@ -521,4 +522,12 @@ object CommonUtil { fun stringToLocalDate(date: String) : LocalDate { return LocalDate.parse("20${date.replace(".", "-")}", DateTimeFormatter.ISO_DATE) } + + /** + * webPage 이동 메소드 + */ + fun goToWebPage(context: Context, page: String) { + val intent = Intent(Intent.ACTION_VIEW, Uri.parse(page)) + context.startActivity(intent) + } } \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_register_terms.xml b/app/src/main/res/layout/fragment_register_terms.xml index 9c8a01a7..9ea6968e 100644 --- a/app/src/main/res/layout/fragment_register_terms.xml +++ b/app/src/main/res/layout/fragment_register_terms.xml @@ -57,8 +57,9 @@ style="@style/Pome.Medium.16" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginStart="21dp" - android:layout_marginTop="28dp" + android:layout_marginStart="14dp" + android:layout_marginTop="21dp" + android:padding="7dp" android:text="@string/register_agree_using_terms_text" android:textColor="@color/grey_8" app:layout_constraintStart_toStartOf="@id/register_terms_all_agree_atv" @@ -80,8 +81,9 @@ style="@style/Pome.Medium.16" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="16dp" + android:layout_marginTop="9dp" android:text="@string/register_agree_privacy_text" + android:padding="7dp" android:textColor="@color/grey_8" app:layout_constraintStart_toStartOf="@id/register_agree_using_terms_atv" app:layout_constraintTop_toBottomOf="@id/register_agree_using_terms_atv" /> @@ -102,8 +104,9 @@ style="@style/Pome.Medium.16" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginStart="21dp" - android:layout_marginTop="16dp" + android:layout_marginStart="14dp" + android:layout_marginTop="9dp" + android:padding="7dp" android:text="@string/register_agree_marketing_text" android:textColor="@color/grey_8" app:layout_constraintStart_toStartOf="@id/register_terms_all_agree_atv" From 0bfbd36cca7c711f78c5bc7c117a2c00ee5f078b Mon Sep 17 00:00:00 2001 From: hanseulchoi Date: Mon, 13 Mar 2023 10:05:19 +0900 Subject: [PATCH 23/40] =?UTF-8?q?fix=20:=20MANAGE=5FEXTERNAL=5FSTORAGE=20?= =?UTF-8?q?=EA=B6=8C=ED=95=9C=20=EC=A0=9C=EA=B1=B0(Playstore=20=EB=B0=B0?= =?UTF-8?q?=ED=8F=AC=20=EB=AC=B8=EC=A0=9C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index dc7a75ad..bde7c12a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -9,8 +9,6 @@ - Date: Mon, 13 Mar 2023 11:31:29 +0900 Subject: [PATCH 24/40] =?UTF-8?q?fix=20:=20Fragment=20Memory=20Leak=20?= =?UTF-8?q?=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/teampome/pome/util/base/BaseFragment.kt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/teampome/pome/util/base/BaseFragment.kt b/app/src/main/java/com/teampome/pome/util/base/BaseFragment.kt index 0e349f25..2a3a2f64 100644 --- a/app/src/main/java/com/teampome/pome/util/base/BaseFragment.kt +++ b/app/src/main/java/com/teampome/pome/util/base/BaseFragment.kt @@ -14,20 +14,23 @@ import com.teampome.pome.MainActivity abstract class BaseFragment(@LayoutRes private val layoutId: Int): Fragment() { private var backPressedCallback: OnBackPressedCallback? = null - protected lateinit var binding: T + + // dataBinding Memory Leak 개선 + private var _binding: T? = null + protected val binding get() = _binding!! override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { - binding = DataBindingUtil.inflate(inflater, layoutId, container, false) + _binding = DataBindingUtil.inflate(inflater, layoutId, container, false) return binding.root } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - binding.lifecycleOwner = this@BaseFragment + binding.lifecycleOwner = this@BaseFragment.viewLifecycleOwner // 생명주기는 View의 lifeCycleOwner로 적용 initView() initListener() @@ -48,6 +51,12 @@ abstract class BaseFragment(@LayoutRes private val layoutId: backPressedCallback?.remove() } + override fun onDestroyView() { + super.onDestroyView() + + _binding = null + } + // View 초기화 작업 protected abstract fun initView() From f3df16e90e31210cf8321d975061b3decb0d7cab Mon Sep 17 00:00:00 2001 From: hanseulchoi Date: Mon, 13 Mar 2023 14:09:21 +0900 Subject: [PATCH 25/40] =?UTF-8?q?fix=20:=20Category=20chip=20=EA=B0=80?= =?UTF-8?q?=EB=A0=A4=EC=A7=90=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/layout/fragment_record.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/layout/fragment_record.xml b/app/src/main/res/layout/fragment_record.xml index 113417e4..8880e5e0 100644 --- a/app/src/main/res/layout/fragment_record.xml +++ b/app/src/main/res/layout/fragment_record.xml @@ -113,7 +113,7 @@ app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@id/record_category_chips_rv" + app:layout_constraintTop_toBottomOf="@id/record_category_plus_tv" tools:listitem="@layout/item_record_emotion_card" /> From f961b13ed2cf5ecfaa62c648f05af62a318308e0 Mon Sep 17 00:00:00 2001 From: hanseulchoi Date: Mon, 13 Mar 2023 14:09:45 +0900 Subject: [PATCH 26/40] =?UTF-8?q?fix=20:=20PagingData=20Empty=EC=9D=BC=20?= =?UTF-8?q?=EB=95=8C=EB=8F=84=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/record/RecordFragment.kt | 74 ++++++++++++++----- 1 file changed, 55 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt b/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt index 5763d456..42720b84 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt @@ -9,11 +9,7 @@ import androidx.annotation.RawRes import androidx.fragment.app.viewModels import androidx.lifecycle.lifecycleScope import androidx.navigation.fragment.findNavController -import androidx.paging.TerminalSeparatorType -import androidx.paging.filter -import androidx.paging.insertHeaderItem -import androidx.paging.map -import androidx.recyclerview.widget.RecyclerView +import androidx.paging.* import com.bumptech.glide.Glide import com.google.android.material.bottomsheet.BottomSheetDialog import com.teampome.pome.R @@ -205,6 +201,32 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec when(it) { is ApiResponse.Success -> { + if(it.data.data?.content.isNullOrEmpty()) { + lifecycleScope.launch { + (binding.recordEmotionRv.adapter as RecordContentsCardAdapter).apply { + val item = makeRecordPagingData( + null, + RecordData( + null, null, null, null, null, null, null, null, + viewType = RecordViewType.Goal, + oneWeekCount = null, + null, + null + ), + RecordData( + null, null, null, null, null, null, null, null, + viewType = RecordViewType.OneWeek, + null, + null, + null + ) + ) + + submitData(item) + } + } + } + hideLoading() } is ApiResponse.Failure -> { @@ -244,25 +266,21 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec viewModel.pagingRecordData.observe(viewLifecycleOwner) { pagingData -> lifecycleScope.launch { (binding.recordEmotionRv.adapter as RecordContentsCardAdapter).apply { - var item = pagingData.insertHeaderItem( - terminalSeparatorType = TerminalSeparatorType.FULLY_COMPLETE, - RecordData( - null, null, null, null, null, null, null, null, - viewType = RecordViewType.OneWeek, - oneWeekCount = viewModel.oneWeekCount.value, - null, - null - ) - ) - - item = item.insertHeaderItem( - terminalSeparatorType = TerminalSeparatorType.FULLY_COMPLETE, + val item = makeRecordPagingData( + pagingData, RecordData( null, null, null, null, null, null, null, null, viewType = RecordViewType.Goal, null, viewModel.goalDetails.value?.get(viewModel.curGoal.value?.pos ?: 0), setGoalState(viewModel.goalDetails.value?.get(viewModel.curGoal.value?.pos ?: 0)) + ), + RecordData( + null, null, null, null, null, null, null, null, + viewType = RecordViewType.OneWeek, + oneWeekCount = viewModel.oneWeekCount.value, + null, + null ) ) @@ -277,7 +295,6 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec Log.d("test", "data is ${it.data.data}") viewModel.setOneWeekCount(it.data.data?.content?.size ?: 0) -// binding.executePendingBindings() hideLoading() @@ -320,6 +337,25 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec } } + // RecordData용 pagingData 만드는 메소드 + private suspend fun makeRecordPagingData( + pagingData: PagingData?, + goalCardHeader: RecordData, + oneWeekCardHeader: RecordData + ): PagingData { + val pageData = pagingData ?: PagingData.empty() + + val item = pageData.insertHeaderItem( + terminalSeparatorType = TerminalSeparatorType.FULLY_COMPLETE, + oneWeekCardHeader + ) + + return item.insertHeaderItem( + terminalSeparatorType = TerminalSeparatorType.FULLY_COMPLETE, + goalCardHeader + ) + } + // 목표 카드 더보기 클릭 private fun makeBottomSheetDialog() { goalMoreBottomSheetDialog = BottomSheetDialog(requireContext()) From 89e2a53977027edf4e26422291e1ed9c90813a10 Mon Sep 17 00:00:00 2001 From: hanseulchoi Date: Mon, 13 Mar 2023 17:16:01 +0900 Subject: [PATCH 27/40] =?UTF-8?q?feat=20:=20=EB=AA=A9=ED=91=9C=20=EB=82=A0?= =?UTF-8?q?=EC=A7=9C=20=EC=84=A0=ED=83=9D=20(=ED=95=9C=EB=8B=AC=20?= =?UTF-8?q?=EC=A0=84=EB=A7=8C=20=EA=B0=80=EB=8A=A5)=20=ED=91=9C=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../record/add/AddGoalCalendarFragment.kt | 19 ++++++++++++ .../teampome/pome/util/common/CommonUtil.kt | 31 +++++++++++++++++-- .../res/layout/fragment_add_goal_calendar.xml | 24 ++++++++++++-- app/src/main/res/values/strings.xml | 1 + 4 files changed, 70 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/teampome/pome/presentation/record/add/AddGoalCalendarFragment.kt b/app/src/main/java/com/teampome/pome/presentation/record/add/AddGoalCalendarFragment.kt index a2cb4fb1..d708d0d3 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/add/AddGoalCalendarFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/add/AddGoalCalendarFragment.kt @@ -1,6 +1,7 @@ package com.teampome.pome.presentation.record.add import android.os.Bundle +import android.util.Log import android.view.View import androidx.activity.OnBackPressedCallback import androidx.fragment.app.viewModels @@ -76,11 +77,29 @@ class AddGoalCalendarFragment: BaseFragment(R.la viewModel.startDate.observe(viewLifecycleOwner) { binding.startDate = it + + if(CommonUtil.isDiffLowerThanOneMonth(viewModel.startDate.value, viewModel.endDate.value)) { + binding.addGoalDateCheckTv.visibility = View.GONE + binding.isLowerThanOneMonth = true + } else { + binding.addGoalDateCheckTv.visibility = View.VISIBLE + binding.isLowerThanOneMonth = false + } + binding.executePendingBindings() } viewModel.endDate.observe(viewLifecycleOwner) { binding.endDate = it + + if(CommonUtil.isDiffLowerThanOneMonth(viewModel.startDate.value, viewModel.endDate.value)) { + binding.addGoalDateCheckTv.visibility = View.GONE + binding.isLowerThanOneMonth = true + } else { + binding.addGoalDateCheckTv.visibility = View.VISIBLE + binding.isLowerThanOneMonth = false + } + binding.executePendingBindings() } } diff --git a/app/src/main/java/com/teampome/pome/util/common/CommonUtil.kt b/app/src/main/java/com/teampome/pome/util/common/CommonUtil.kt index a8b1bbd3..d5731ef2 100644 --- a/app/src/main/java/com/teampome/pome/util/common/CommonUtil.kt +++ b/app/src/main/java/com/teampome/pome/util/common/CommonUtil.kt @@ -368,9 +368,9 @@ object CommonUtil { endDate?.let { val sdf = SimpleDateFormat("yyyy.MM.dd") val ed = sdf.parse(endDate) - val today = Calendar.getInstance() + val today = Calendar.getInstance().time.time - val challengeDay = (ed.time - today.time.time) / (60 * 60 * 24 * 1000) + val challengeDay = (ed.time - today) / (60 * 60 * 24 * 1000) return if(challengeDay >= 0) { challengeDay.toInt() @@ -380,6 +380,33 @@ object CommonUtil { } ?: return 0 } + /** + * 들어온 매개변수들이 한달 차이인지 확인하는 메소드 + * + * format = "yyyy.MM.dd" + */ + fun isDiffLowerThanOneMonth(curDateStr: String?, endDateStr: String?): Boolean { + val sdf = SimpleDateFormat("yyyy.MM.dd") + + curDateStr?.let { + endDateStr?.let { + val curDate = sdf.parse(curDateStr) + val endDate = sdf.parse(endDateStr) + + val afterOneMonthDay = Calendar.getInstance() + afterOneMonthDay.time = curDate + + afterOneMonthDay.add(Calendar.MONTH, 1) + + return (afterOneMonthDay.time >= endDate && curDate <= endDate) + } ?: run { + return false + } + } ?: run { + return false + } + } + /** * 서버 상호작용을 위한 num -> Emotion 변경 */ diff --git a/app/src/main/res/layout/fragment_add_goal_calendar.xml b/app/src/main/res/layout/fragment_add_goal_calendar.xml index cb8bac84..7d348d8e 100644 --- a/app/src/main/res/layout/fragment_add_goal_calendar.xml +++ b/app/src/main/res/layout/fragment_add_goal_calendar.xml @@ -11,6 +11,10 @@ + + + + 목표가 있어야 씀씀이를\n기록하고 돌아볼 수 있어요 목표 만들기 인증번호가 일치하지 않아요 + 목표 기간은 한 달 이내로 설정할 수 있어요! \ No newline at end of file From f0d558c8ab31b7d71b89b99c7892189eb4d763e4 Mon Sep 17 00:00:00 2001 From: hanseulchoi Date: Mon, 13 Mar 2023 17:29:46 +0900 Subject: [PATCH 28/40] =?UTF-8?q?fix:=20inputType=20=EB=B0=8F=20=EB=8B=A4?= =?UTF-8?q?=EC=9D=8C=20editFocus=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/layout/fragment_add_goal_contents.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/res/layout/fragment_add_goal_contents.xml b/app/src/main/res/layout/fragment_add_goal_contents.xml index 53f6b9f8..0f622256 100644 --- a/app/src/main/res/layout/fragment_add_goal_contents.xml +++ b/app/src/main/res/layout/fragment_add_goal_contents.xml @@ -83,10 +83,12 @@ android:hint="@string/add_goal_contents_category_hint_text" android:maxLength="8" android:maxLines="1" + android:inputType="text" android:paddingHorizontal="16dp" android:textColor="@color/black" android:textColorHint="@color/grey_5" android:textCursorDrawable="@drawable/register_profile_name_cursor" + android:nextFocusDown="@id/add_goal_contents_promise_aet" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/add_goal_contents_category_title_tv" /> @@ -113,10 +115,12 @@ android:hint="@string/add_goal_contents_promise_hint_text" android:maxLength="18" android:maxLines="1" + android:inputType="text" android:paddingHorizontal="16dp" android:textColor="@color/black" android:textColorHint="@color/grey_5" android:textCursorDrawable="@drawable/register_profile_name_cursor" + android:nextFocusDown="@id/add_goal_contents_amount_aet" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/add_goal_contents_promise_title_tv" /> From 7ddf83cd98e7afa50b9ebc42946419acb588e3de Mon Sep 17 00:00:00 2001 From: hanseulchoi Date: Tue, 14 Mar 2023 10:03:26 +0900 Subject: [PATCH 29/40] =?UTF-8?q?feat=20:=20Register=20EditText=20?= =?UTF-8?q?=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pome/presentation/register/RegisterFragment.kt | 11 +++++++++++ app/src/main/res/layout/fragment_register.xml | 1 + 2 files changed, 12 insertions(+) diff --git a/app/src/main/java/com/teampome/pome/presentation/register/RegisterFragment.kt b/app/src/main/java/com/teampome/pome/presentation/register/RegisterFragment.kt index fb3454b5..9fcf005b 100644 --- a/app/src/main/java/com/teampome/pome/presentation/register/RegisterFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/register/RegisterFragment.kt @@ -7,6 +7,7 @@ import android.text.TextWatcher import android.util.Log import android.view.LayoutInflater import android.view.View +import android.view.View.OnFocusChangeListener import android.view.ViewGroup import android.widget.Toast import androidx.fragment.app.viewModels @@ -173,6 +174,14 @@ class RegisterFragment : BaseFragment(R.layout.fragment } }) + // focus 감지 + binding.registerPhoneAet.onFocusChangeListener = + OnFocusChangeListener { _, hasFocus -> + if(!hasFocus) { + binding.registerCertPhoneAcb.performClick() + } + } + // 번호 인증 요청 binding.registerCertPhoneAcb.setOnClickListener { binding.registerCertPhoneAcb.text = "재요청" @@ -189,6 +198,8 @@ class RegisterFragment : BaseFragment(R.layout.fragment Toast.makeText(requireContext(), "error : $message", Toast.LENGTH_SHORT).show() } }) + + binding.registerCertNumAet.requestFocus() } // 동의하고 시작하기 버튼 diff --git a/app/src/main/res/layout/fragment_register.xml b/app/src/main/res/layout/fragment_register.xml index b443120b..c02266a8 100644 --- a/app/src/main/res/layout/fragment_register.xml +++ b/app/src/main/res/layout/fragment_register.xml @@ -52,6 +52,7 @@ android:textColor="@color/black" android:textColorHint="@color/grey_5" android:textCursorDrawable="@drawable/register_profile_name_cursor" + android:nextFocusRight="@id/register_cert_phone_acb" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/register_phone_title_tv" /> From 7c49adfea8ffd144c746f595c44cdc2d28f0ec85 Mon Sep 17 00:00:00 2001 From: hanseulchoi Date: Tue, 14 Mar 2023 11:41:17 +0900 Subject: [PATCH 30/40] =?UTF-8?q?fix=20:=20CalendarView=20MinDate=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../record/add/AddGoalCalendarFragment.kt | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/teampome/pome/presentation/record/add/AddGoalCalendarFragment.kt b/app/src/main/java/com/teampome/pome/presentation/record/add/AddGoalCalendarFragment.kt index d708d0d3..ad44d30d 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/add/AddGoalCalendarFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/add/AddGoalCalendarFragment.kt @@ -1,13 +1,14 @@ package com.teampome.pome.presentation.record.add +import android.os.Build import android.os.Bundle -import android.util.Log import android.view.View import androidx.activity.OnBackPressedCallback import androidx.fragment.app.viewModels import androidx.navigation.fragment.findNavController import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetDialog +import com.prolificinteractive.materialcalendarview.MaterialCalendarView import com.teampome.pome.R import com.teampome.pome.databinding.FragmentAddGoalCalendarBinding import com.teampome.pome.databinding.PomeCalendarBottomSheetDialogBinding @@ -15,6 +16,8 @@ import com.teampome.pome.util.common.CommonUtil import com.teampome.pome.util.base.BaseFragment import com.teampome.pome.viewmodel.record.AddGoalCalendarViewModel import dagger.hilt.android.AndroidEntryPoint +import org.threeten.bp.LocalDate +import org.threeten.bp.format.DateTimeFormatter @AndroidEntryPoint class AddGoalCalendarFragment: BaseFragment(R.layout.fragment_add_goal_calendar) { @@ -118,6 +121,7 @@ class AddGoalCalendarFragment: BaseFragment(R.la startCalendarBinding.calendarSelectAtb, { _, str -> viewModel.setStartDate(str) + setMinDate(endCalendarBinding.calendarMcv, viewModel.startDate.value) } ) { startCalendarDialog.dismiss() @@ -144,6 +148,20 @@ class AddGoalCalendarFragment: BaseFragment(R.la } } + /** + * date format pattern : yyyy.MM.dd + */ + private fun setMinDate(calendar: MaterialCalendarView, date: String?) { + date?.let { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + val formatter = DateTimeFormatter.ofPattern("yyyy.MM.dd") + val minDate = LocalDate.parse(date, formatter) + + calendar.state().edit().setMinimumDate(minDate).commit() + } + } + } + private fun moveToAddGoalContents() { val action = AddGoalCalendarFragmentDirections.actionAddGoalCalendarFragmentToAddGoalContentsFragment( viewModel.startDate.value ?: "2023.01.01", From 98015faae5dd0a1ab975b42ae8abf32e98ea7f29 Mon Sep 17 00:00:00 2001 From: hanseulchoi Date: Tue, 14 Mar 2023 15:50:14 +0900 Subject: [PATCH 31/40] =?UTF-8?q?feat=20:=20=EC=B2=AB=20register=20image?= =?UTF-8?q?=20=EC=84=A0=ED=83=9D=EC=8B=9C=20Camera=20=EB=B0=8F=20=EA=B0=A4?= =?UTF-8?q?=EB=9F=AC=EB=A6=AC=20=ED=98=B8=EC=B6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 11 ++ .../register/RegisterProfileFragment.kt | 168 ++++++++++++++++-- .../register/RegisterProfileViewModel.kt | 14 +- app/src/main/res/xml/file_paths.xml | 4 + 4 files changed, 184 insertions(+), 13 deletions(-) create mode 100644 app/src/main/res/xml/file_paths.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index bde7c12a..752e70f1 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -34,6 +34,17 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/teampome/pome/presentation/register/RegisterProfileFragment.kt b/app/src/main/java/com/teampome/pome/presentation/register/RegisterProfileFragment.kt index e96420c8..b6aa7464 100644 --- a/app/src/main/java/com/teampome/pome/presentation/register/RegisterProfileFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/register/RegisterProfileFragment.kt @@ -3,8 +3,12 @@ package com.teampome.pome.presentation.register import android.annotation.SuppressLint import android.app.Activity import android.content.Intent +import android.graphics.BitmapFactory +import android.graphics.drawable.Drawable +import android.net.Uri import android.os.Build import android.os.Bundle +import android.os.Environment import android.provider.MediaStore import android.text.Editable import android.text.TextWatcher @@ -12,6 +16,8 @@ import android.util.Log import android.view.View import android.widget.Toast import androidx.activity.result.contract.ActivityResultContracts +import androidx.core.content.FileProvider +import androidx.core.net.toUri import androidx.fragment.app.activityViewModels import androidx.fragment.app.viewModels import androidx.navigation.fragment.findNavController @@ -35,6 +41,11 @@ import dagger.hilt.android.AndroidEntryPoint import jp.wasabeef.glide.transformations.MaskTransformation import kotlinx.coroutines.* import kotlinx.coroutines.flow.first +import java.io.File +import java.io.IOException +import java.text.SimpleDateFormat +import java.util.* +import java.util.concurrent.Executors import javax.inject.Inject @AndroidEntryPoint @@ -50,8 +61,12 @@ class RegisterProfileFragment : BaseFragment(R.l private val viewModel: RegisterProfileViewModel by viewModels() private val tokenViewModel: TokenViewModel by activityViewModels() - private lateinit var pomeBottomSheetDialog: BottomSheetDialog - private lateinit var pomeBottomSheetDialogBinding: PomeRegisterBottomSheetDialogBinding + private lateinit var pomeNewBottomSheetDialog: BottomSheetDialog + private lateinit var pomeNewBottomSheetDialogBinding: PomeRegisterBottomSheetDialogBinding + + // 수정하기 bottomsheet + private lateinit var pomeModifyBottomSheetDialog: BottomSheetDialog + private lateinit var pomeModifyBottomSheetDialogBinding: PomeRegisterBottomSheetDialogBinding @Inject lateinit var userManger: UserManager @@ -59,16 +74,37 @@ class RegisterProfileFragment : BaseFragment(R.l @Inject lateinit var tokenManager: TokenManager + private val photoFile: File? by lazy { + try { + createImageFile() + } catch (ex: IOException) { + null + } + } + @SuppressLint("InflateParams") override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) } override fun initView() { - // pomeBottomSheetDialog 뷰 인플레이션 과정 - pomeBottomSheetDialog = BottomSheetDialog(requireContext()) - pomeBottomSheetDialogBinding = PomeRegisterBottomSheetDialogBinding.inflate(layoutInflater, null, false) - pomeBottomSheetDialog.setContentView(pomeBottomSheetDialogBinding.root) + // pomeNewBottomSheetDialog 뷰 인플레이션 과정 + pomeNewBottomSheetDialog = BottomSheetDialog(requireContext()) + pomeNewBottomSheetDialogBinding = PomeRegisterBottomSheetDialogBinding.inflate(layoutInflater, null, false) + pomeNewBottomSheetDialog.setContentView(pomeNewBottomSheetDialogBinding.root) + + pomeNewBottomSheetDialogBinding.apply { + pomeBottomSheetDialogPencilAiv.visibility = View.INVISIBLE + pomeBottomSheetDialogTrashAiv.visibility = View.INVISIBLE + + pomeBottomSheetDialogPencilTv.text = "사진앨범" + pomeBottomSheetDialogTrashTv.text = "카메라" + } + + // pomeModifyBottomSheetDialog 뷰 인플레이션 과정 + pomeModifyBottomSheetDialog = BottomSheetDialog(requireContext()) + pomeModifyBottomSheetDialogBinding = PomeRegisterBottomSheetDialogBinding.inflate(layoutInflater, null, false) + pomeModifyBottomSheetDialog.setContentView(pomeModifyBottomSheetDialogBinding.root) CommonUtil.disabledPomeBtn(binding.registerProfileCheckBtn) } @@ -201,7 +237,12 @@ class RegisterProfileFragment : BaseFragment(R.l } binding.registerProfileAiv.setOnClickListener { - pomeBottomSheetDialog.show() + // 사진이 등록되어 있지 않으면? + if(viewModel.showFirstBottomSheet.value == true) { + pomeNewBottomSheetDialog.show() + } else { + pomeModifyBottomSheetDialog.show() + } } // 닉네임 변경 글자 감지 @@ -223,7 +264,7 @@ class RegisterProfileFragment : BaseFragment(R.l disableName() CommonUtil.disabledPomeBtn(binding.registerProfileCheckBtn) } else { - viewModel.userName.value = name.toString() + viewModel.setUserName(name.toString()) viewModel.checkNickname(object : CoroutineErrorHandler { override fun onError(message: String) { @@ -267,13 +308,27 @@ class RegisterProfileFragment : BaseFragment(R.l } } + pomeNewBottomSheetDialogBinding.pomeBottomSheetDialogPencilTv.setOnClickListener { + openGallery() + + pomeNewBottomSheetDialog.dismiss() + } + + pomeNewBottomSheetDialogBinding.pomeBottomSheetDialogTrashTv.setOnClickListener { + // 카메라 기능 + showCamera() + + pomeNewBottomSheetDialog.dismiss() + } + + // Modify // dialog 수정 click - pomeBottomSheetDialogBinding.pomeBottomSheetDialogPencilTv.setOnClickListener { + pomeModifyBottomSheetDialogBinding.pomeBottomSheetDialogPencilTv.setOnClickListener { openGallery() } // dialog 삭제 click - pomeBottomSheetDialogBinding.pomeBottomSheetDialogTrashTv.setOnClickListener { + pomeModifyBottomSheetDialogBinding.pomeBottomSheetDialogTrashTv.setOnClickListener { binding.registerProfileAiv.setImageDrawable(resources.getDrawable(R.drawable.user_profile_empty_150, null)) binding.registerProfilePlusAiv.visibility = View.VISIBLE @@ -285,7 +340,8 @@ class RegisterProfileFragment : BaseFragment(R.l userManger.saveUserProfileUrl("default") } - pomeBottomSheetDialog.dismiss() + viewModel.setShowFirstBottomSheet(true) + pomeModifyBottomSheetDialog.dismiss() } // close Button 처리 @@ -354,18 +410,106 @@ class RegisterProfileFragment : BaseFragment(R.l ).into(binding.registerProfileAiv) } } + + viewModel.setShowFirstBottomSheet(false) } catch (e: Exception) { e.printStackTrace() } // 다 끝나면 바텀시트 닫고 플러스 버튼 가리기 binding.registerProfilePlusAiv.visibility = View.INVISIBLE - pomeBottomSheetDialog.dismiss() + pomeModifyBottomSheetDialog.dismiss() } else { hideLoading() } } + private val cameraLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result -> + if (result.resultCode == Activity.RESULT_OK) { + val imageUri = photoFile?.toUri() + + // 이미지 url 요청 + viewModel.getPresignedImageUrl(object : CoroutineErrorHandler { + override fun onError(message: String) { + Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show() + Log.d("test", "getPresignedImageError : $message") + } + }) + + // 이미지 byteArray 세팅 + imageUri?.let { + viewModel.settingProfileImageByteArray(CommonUtil.getImageByteArray(requireContext(), it)) + } + + try { + if(Build.VERSION.SDK_INT < 28) { + val bitmap = MediaStore.Images.Media.getBitmap( + activity?.contentResolver, + imageUri + ) + binding.registerProfileAiv.setImageBitmap(bitmap) + } else { + imageUri?.let { + Glide.with(requireContext()) + .load(it) + .apply( + bitmapTransform(MultiTransformation(CenterCrop(), + MaskTransformation(R.drawable.user_profile_empty_150))) + ).into(binding.registerProfileAiv) + } + } + + viewModel.setShowFirstBottomSheet(false) + } catch (e: Exception) { + e.printStackTrace() + } + + // 다 끝나면 바텀시트 닫고 플러스 버튼 가리기 + binding.registerProfilePlusAiv.visibility = View.INVISIBLE + pomeModifyBottomSheetDialog.dismiss() + } else { + hideLoading() + } + } + + private fun showCamera() { + val intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE) + + photoFile?.let{ + intent.apply { + val photoUri: Uri = FileProvider.getUriForFile( + requireContext(), + "com.teampome.pome.fileprovider", + it + ) + + putExtra(MediaStore.EXTRA_OUTPUT, photoUri) + } + + cameraLauncher.launch(intent) + } + } + + private fun createImageFile(): File? { + // 이미지 파일 이름 생성 + val timeStamp = SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(Date()) + val imageFileName = "JPEG_${timeStamp}_" + + // 이미지 파일이 저장될 폴더 경로 생성 + val storageDir = requireActivity().getExternalFilesDir(Environment.DIRECTORY_PICTURES) + if (storageDir?.exists() == false) storageDir.mkdirs() + + // 이미지 파일 생성 + val imageFile = File.createTempFile( + imageFileName, /* prefix */ + ".jpg", /* suffix */ + storageDir /* directory */ + ) + + // 생성된 이미지 파일 객체 반환 + return imageFile + } + private fun openGallery() { val intent = Intent() intent.apply { diff --git a/app/src/main/java/com/teampome/pome/viewmodel/register/RegisterProfileViewModel.kt b/app/src/main/java/com/teampome/pome/viewmodel/register/RegisterProfileViewModel.kt index 6e777fc5..37629f36 100644 --- a/app/src/main/java/com/teampome/pome/viewmodel/register/RegisterProfileViewModel.kt +++ b/app/src/main/java/com/teampome/pome/viewmodel/register/RegisterProfileViewModel.kt @@ -21,7 +21,19 @@ class RegisterProfileViewModel @Inject constructor( private val imageRepository : PresignedUrlRepository, private val sendImageRepository : SendPreSignedImageRepository ) : BaseViewModel() { - val userName = MutableLiveData() + private val _userName = MutableLiveData() + val userName: LiveData = _userName + + private val _showFirstBottomSheet = MutableLiveData(true) + val showFirstBottomSheet: LiveData = _showFirstBottomSheet + + fun setUserName(userName: String) { + _userName.value = userName + } + + fun setShowFirstBottomSheet(isFirst: Boolean) { + _showFirstBottomSheet.value = isFirst + } private val _nicknameResponse = MutableLiveData>>() val nicknameResponse: LiveData>> = _nicknameResponse diff --git a/app/src/main/res/xml/file_paths.xml b/app/src/main/res/xml/file_paths.xml new file mode 100644 index 00000000..3d985443 --- /dev/null +++ b/app/src/main/res/xml/file_paths.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file From cf24dc2ecc32686deb9e5f9882f01ea79a44f863 Mon Sep 17 00:00:00 2001 From: hanseuk-Choi Date: Tue, 14 Mar 2023 20:34:26 +0900 Subject: [PATCH 32/40] =?UTF-8?q?feat=20:=20Record=20Contents=20=EC=B9=9C?= =?UTF-8?q?=EA=B5=AC=20=EA=B0=90=EC=A0=95=EA=B9=8C=EC=A7=80=20=EB=82=98?= =?UTF-8?q?=EC=98=A4=EB=8A=94=20Card=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adapter/RecordContentsCardAdapter.kt | 6 +- .../adapter/RecordOneWeekAdapter.kt | 20 +- .../viewholder/RecordCardViewHolder.kt | 7 +- .../res/layout/item_record_contents_card.xml | 223 ++++++++++++++++++ .../res/layout/item_remind_contents_card.xml | 2 + 5 files changed, 247 insertions(+), 11 deletions(-) create mode 100644 app/src/main/res/layout/item_record_contents_card.xml diff --git a/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/adapter/RecordContentsCardAdapter.kt b/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/adapter/RecordContentsCardAdapter.kt index 0bbf33a1..6116a33e 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/adapter/RecordContentsCardAdapter.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/adapter/RecordContentsCardAdapter.kt @@ -7,7 +7,7 @@ import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.RecyclerView import com.teampome.pome.databinding.ItemGoalCardBinding import com.teampome.pome.databinding.ItemLeaveEmotionCardBinding -import com.teampome.pome.databinding.ItemRecordEmotionCardBinding +import com.teampome.pome.databinding.ItemRecordContentsCardBinding import com.teampome.pome.model.RecordData import com.teampome.pome.presentation.record.recyclerview.OnMoreItemClickListener import com.teampome.pome.presentation.record.recyclerview.OnRecordItemClickListener @@ -92,14 +92,14 @@ class RecordContentsCardAdapter : PagingDataAdapter { - val binding = ItemRecordEmotionCardBinding.inflate(LayoutInflater.from(parent.context), parent, false) + val binding = ItemRecordContentsCardBinding.inflate(LayoutInflater.from(parent.context), parent, false) return RecordCardViewHolder(binding, moreRecordItemClickListener, recordBodyClickListener) } else -> { assert(false) // 여기로 떨어지면 안됨 -> 따로 처리 필요 - val binding = ItemRecordEmotionCardBinding.inflate(LayoutInflater.from(parent.context), parent, false) + val binding = ItemRecordContentsCardBinding.inflate(LayoutInflater.from(parent.context), parent, false) return RecordCardViewHolder(binding, moreRecordItemClickListener, recordBodyClickListener) } diff --git a/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/adapter/RecordOneWeekAdapter.kt b/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/adapter/RecordOneWeekAdapter.kt index b424fbfa..af94510d 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/adapter/RecordOneWeekAdapter.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/adapter/RecordOneWeekAdapter.kt @@ -3,12 +3,12 @@ package com.teampome.pome.presentation.record.recyclerview.adapter import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.ListAdapter +import androidx.recyclerview.widget.RecyclerView import com.teampome.pome.databinding.ItemRecordEmotionCardBinding import com.teampome.pome.model.RecordData import com.teampome.pome.presentation.record.recyclerview.OnRecordItemClickListener -import com.teampome.pome.presentation.record.recyclerview.viewholder.RecordCardViewHolder -class RecordOneWeekAdapter : ListAdapter( +class RecordOneWeekAdapter : ListAdapter( RecordContentsCardDiffCallback() ) { @@ -21,15 +21,25 @@ class RecordOneWeekAdapter : ListAdapter( override fun onCreateViewHolder( parent: ViewGroup, viewType: Int - ): RecordCardViewHolder { + ): RecordOneWeekCardViewHolder { val binding = ItemRecordEmotionCardBinding.inflate(LayoutInflater.from(parent.context), parent, false) - return RecordCardViewHolder(binding, null, recordBodyClickListener) + return RecordOneWeekCardViewHolder(binding) } - override fun onBindViewHolder(holder: RecordCardViewHolder, position: Int) { + override fun onBindViewHolder(holder: RecordOneWeekCardViewHolder, position: Int) { getItem(position)?.let { holder.bind(it) } } + + inner class RecordOneWeekCardViewHolder( + private val binding : ItemRecordEmotionCardBinding + ) : RecyclerView.ViewHolder(binding.root) { + fun bind(item: RecordData) { + binding.recordData = item + + binding.executePendingBindings() + } + } } \ No newline at end of file diff --git a/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/viewholder/RecordCardViewHolder.kt b/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/viewholder/RecordCardViewHolder.kt index 93cdb929..11081c07 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/viewholder/RecordCardViewHolder.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/recyclerview/viewholder/RecordCardViewHolder.kt @@ -1,24 +1,25 @@ package com.teampome.pome.presentation.record.recyclerview.viewholder import androidx.recyclerview.widget.RecyclerView +import com.teampome.pome.databinding.ItemRecordContentsCardBinding import com.teampome.pome.databinding.ItemRecordEmotionCardBinding import com.teampome.pome.model.RecordData import com.teampome.pome.presentation.record.recyclerview.OnMoreItemClickListener import com.teampome.pome.presentation.record.recyclerview.OnRecordItemClickListener class RecordCardViewHolder( - private val binding : ItemRecordEmotionCardBinding, + private val binding : ItemRecordContentsCardBinding, private val moreItemClickListener: OnMoreItemClickListener?, private val bodyClickListener: OnRecordItemClickListener? ) : RecyclerView.ViewHolder(binding.root) { fun bind(item: RecordData) { binding.recordData = item - binding.recordContentsCardMoreAiv.setOnClickListener { + binding.recordContentsMoreAiv.setOnClickListener { moreItemClickListener?.onMoreIconClick(item) } - binding.recordContentsCardContainerCv.setOnClickListener { + binding.recordContentsContainerCl.setOnClickListener { bodyClickListener?.onRecordItemClick(item) } diff --git a/app/src/main/res/layout/item_record_contents_card.xml b/app/src/main/res/layout/item_record_contents_card.xml new file mode 100644 index 00000000..96109251 --- /dev/null +++ b/app/src/main/res/layout/item_record_contents_card.xml @@ -0,0 +1,223 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_remind_contents_card.xml b/app/src/main/res/layout/item_remind_contents_card.xml index f4981109..6871a5c1 100644 --- a/app/src/main/res/layout/item_remind_contents_card.xml +++ b/app/src/main/res/layout/item_remind_contents_card.xml @@ -24,6 +24,7 @@ app:cardPreventCornerOverlap="true"> @@ -207,6 +208,7 @@ Date: Tue, 14 Mar 2023 20:48:12 +0900 Subject: [PATCH 33/40] =?UTF-8?q?feat=20:=20Record=20Progress=20=EC=B4=88?= =?UTF-8?q?=EA=B3=BC=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pome_seekbar_custom_over_thumb.xml | 8 ++++++++ .../res/drawable/pome_seekbar_over_custom.xml | 20 +++++++++++++++++++ .../util/customview/PomeBigGoalCardView.kt | 16 +++++++++++++-- app/src/main/res/values/colors.xml | 1 + app/src/main/res/values/strings.xml | 1 + 5 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 app/src/debug/res/drawable/pome_seekbar_custom_over_thumb.xml create mode 100644 app/src/debug/res/drawable/pome_seekbar_over_custom.xml diff --git a/app/src/debug/res/drawable/pome_seekbar_custom_over_thumb.xml b/app/src/debug/res/drawable/pome_seekbar_custom_over_thumb.xml new file mode 100644 index 00000000..22711ecc --- /dev/null +++ b/app/src/debug/res/drawable/pome_seekbar_custom_over_thumb.xml @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/app/src/debug/res/drawable/pome_seekbar_over_custom.xml b/app/src/debug/res/drawable/pome_seekbar_over_custom.xml new file mode 100644 index 00000000..9a8c746e --- /dev/null +++ b/app/src/debug/res/drawable/pome_seekbar_over_custom.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/teampome/pome/util/customview/PomeBigGoalCardView.kt b/app/src/main/java/com/teampome/pome/util/customview/PomeBigGoalCardView.kt index fdb6c0e3..74de4c5e 100644 --- a/app/src/main/java/com/teampome/pome/util/customview/PomeBigGoalCardView.kt +++ b/app/src/main/java/com/teampome/pome/util/customview/PomeBigGoalCardView.kt @@ -4,6 +4,7 @@ import android.content.Context import android.util.AttributeSet import android.util.Log import android.view.ViewTreeObserver +import androidx.appcompat.content.res.AppCompatResources import com.teampome.pome.R import com.teampome.pome.util.common.CommonUtil @@ -30,8 +31,19 @@ class PomeBigGoalCardView @JvmOverloads constructor(context: Context, attrs: Att set(value) { field = value - binding.goalCardAmountProgressAsb.progress = value - binding.goalCardProgressTextTv.text = context.getString(R.string.record_progress_percent, value) + if(value > 100) { + binding.goalCardAmountProgressAsb.progress = 100 + binding.goalCardProgressTextTv.text = context.getString(R.string.record_progress_over) + + binding.goalCardAmountProgressAsb.progressDrawable = AppCompatResources.getDrawable(context, R.drawable.pome_seekbar_over_custom) + binding.goalCardAmountProgressAsb.thumb = AppCompatResources.getDrawable(context, R.drawable.pome_seekbar_custom_over_thumb) + } else { + binding.goalCardAmountProgressAsb.progress = value + binding.goalCardProgressTextTv.text = context.getString(R.string.record_progress_percent, value) + + binding.goalCardAmountProgressAsb.progressDrawable = AppCompatResources.getDrawable(context, R.drawable.pome_seekbar_custom) + binding.goalCardAmountProgressAsb.thumb = AppCompatResources.getDrawable(context, R.drawable.pome_seekbar_custom_thumb) + } binding.goalCardAmountProgressAsb.apply { isEnabled = false diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 4cfe6b25..2201785f 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -37,4 +37,5 @@ #FFDEDC #E5FAE9 #ADB8CD + #E96962 \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cb459560..0aec940b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -141,6 +141,7 @@ 로그아웃 하시겠어요? %d%% + 초과 일주일 씀씀이 감정을 남겨주세요 기록한 씀씀이가 없어요 From 12adb11e354ed5f7febda5d9966c20b5cda42cf9 Mon Sep 17 00:00:00 2001 From: hanseuk-Choi Date: Tue, 14 Mar 2023 21:20:53 +0900 Subject: [PATCH 34/40] =?UTF-8?q?feat=20:=20=EA=B8=B0=EB=A1=9D=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=ED=95=98=EA=B8=B0=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../teampome/pome/network/RecordService.kt | 8 +++++ .../presentation/record/RecordFragment.kt | 30 ++++++++++++++----- .../repository/record/RecordDataSource.kt | 1 + .../record/RecordRemoteDataSource.kt | 4 +++ .../repository/record/RecordRepository.kt | 2 ++ .../pome/viewmodel/record/RecordViewModel.kt | 10 +++++++ 6 files changed, 48 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/teampome/pome/network/RecordService.kt b/app/src/main/java/com/teampome/pome/network/RecordService.kt index e85c048d..530d594e 100644 --- a/app/src/main/java/com/teampome/pome/network/RecordService.kt +++ b/app/src/main/java/com/teampome/pome/network/RecordService.kt @@ -61,4 +61,12 @@ interface RecordService { suspend fun getOneWeekGoalByGoalId( @Path("goalId") goalId: Int ) : Response>> + + /** + * 기록 삭제 api + */ + @DELETE("api/v1/records/{recordId}") + suspend fun deleteRecordByRecordId( + @Path("recordId") recordId: Int + ) : Response> } \ No newline at end of file diff --git a/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt b/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt index 42720b84..5c881c22 100644 --- a/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/record/RecordFragment.kt @@ -54,7 +54,7 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec private lateinit var removeCardDialogBinding: PomeRemoveDialogBinding private lateinit var removeCardDialog: Dialog - // Todo : 공통 다이얼로그로 변경 + // 수정 삭제하기 다이얼로그 private lateinit var recordDialogBinding: PomeRegisterBottomSheetDialogBinding private lateinit var recordDialog: BottomSheetDialog @@ -335,10 +335,23 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec is ApiResponse.Loading -> { showLoading() } } } + + viewModel.deleteRecordResponse.observe(viewLifecycleOwner) { + when(it) { + is ApiResponse.Success -> { + // refresh + refresh() + } + is ApiResponse.Failure -> { + Log.e("error", "deleteRecord failure by ${it.errorMessage}") + } + is ApiResponse.Loading -> { showLoading() } + } + } } // RecordData용 pagingData 만드는 메소드 - private suspend fun makeRecordPagingData( + private fun makeRecordPagingData( pagingData: PagingData?, goalCardHeader: RecordData, oneWeekCardHeader: RecordData @@ -437,8 +450,6 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec // 삭제 클릭 recordDialogBinding.pomeBottomSheetDialogTrashTv.setOnClickListener { - Toast.makeText(requireContext(), "기록 카드 삭제하기", Toast.LENGTH_SHORT).show() - recordDialog.dismiss() removeCardDialog.show() @@ -459,15 +470,20 @@ class RecordFragment : BaseFragment(R.layout.fragment_rec // 삭제하기 버튼 클릭 removeCardDialogBinding.removeYesTextAtv.setOnClickListener { - Toast.makeText(requireContext(), "카드 삭제 Yes", Toast.LENGTH_SHORT).show() + // 삭제 api + selectRecordData.id?.let { recordId -> + viewModel.deleteRecordByRecordId(recordId, object : CoroutineErrorHandler { + override fun onError(message: String) { + Log.d("error", "deleteRecord error by $message") + } + }) + } removeCardDialog.dismiss() } // 아니요 버튼 클릭 removeCardDialogBinding.removeNoTextAtv.setOnClickListener { - Toast.makeText(requireContext(), "카드 삭제 No", Toast.LENGTH_SHORT).show() - removeCardDialog.dismiss() } } diff --git a/app/src/main/java/com/teampome/pome/repository/record/RecordDataSource.kt b/app/src/main/java/com/teampome/pome/repository/record/RecordDataSource.kt index 933b52eb..78829b21 100644 --- a/app/src/main/java/com/teampome/pome/repository/record/RecordDataSource.kt +++ b/app/src/main/java/com/teampome/pome/repository/record/RecordDataSource.kt @@ -18,4 +18,5 @@ interface RecordDataSource { fun getRecordByGoalId(goalId: Int): Flow>>> fun getOneWeekGoalByGoalId(goalId: Int): Flow>>> fun getRecordPagingData(goalId: Int, pagingConfig: PagingConfig): Flow> + fun deleteRecordByRecordId(recordId: Int): Flow>> } \ No newline at end of file diff --git a/app/src/main/java/com/teampome/pome/repository/record/RecordRemoteDataSource.kt b/app/src/main/java/com/teampome/pome/repository/record/RecordRemoteDataSource.kt index 496cf0dd..b1cca622 100644 --- a/app/src/main/java/com/teampome/pome/repository/record/RecordRemoteDataSource.kt +++ b/app/src/main/java/com/teampome/pome/repository/record/RecordRemoteDataSource.kt @@ -56,4 +56,8 @@ class RecordRemoteDataSource @Inject constructor( } ).flow } + + override fun deleteRecordByRecordId(recordId: Int): Flow>> = apiRequestFlow { + service.deleteRecordByRecordId(recordId) + } } \ No newline at end of file diff --git a/app/src/main/java/com/teampome/pome/repository/record/RecordRepository.kt b/app/src/main/java/com/teampome/pome/repository/record/RecordRepository.kt index e01b080a..fb0ae1fd 100644 --- a/app/src/main/java/com/teampome/pome/repository/record/RecordRepository.kt +++ b/app/src/main/java/com/teampome/pome/repository/record/RecordRepository.kt @@ -76,4 +76,6 @@ class RecordRepository @Inject constructor( fun getRecordByGoalId(goalId: Int) = recordDataSource.getRecordByGoalId(goalId) fun getOneWeekGoalByGoalId(goalId: Int) = recordDataSource.getOneWeekGoalByGoalId(goalId) + + fun deleteRecordByRecordId(recordId: Int) = recordDataSource.deleteRecordByRecordId(recordId) } \ No newline at end of file diff --git a/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt b/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt index 77dab332..7f9e5344 100644 --- a/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt +++ b/app/src/main/java/com/teampome/pome/viewmodel/record/RecordViewModel.kt @@ -164,4 +164,14 @@ class RecordViewModel @Inject constructor( } } } + + private val _deleteRecordResponse = MutableLiveData>>() + val deleteRecordResponse: LiveData>> = _deleteRecordResponse + + fun deleteRecordByRecordId(recordId: Int, coroutineErrorHandler: CoroutineErrorHandler) = baseRequest( + _deleteRecordResponse, + coroutineErrorHandler + ) { + recordRepository.deleteRecordByRecordId(recordId) + } } \ No newline at end of file From 3ed1d24f2f338c8caa84aa382942984de58ea30c Mon Sep 17 00:00:00 2001 From: hanseulchoi Date: Wed, 15 Mar 2023 13:00:50 +0900 Subject: [PATCH 35/40] =?UTF-8?q?feat=20:=20Network=20=EC=97=B0=EA=B2=B0?= =?UTF-8?q?=20=EC=83=81=ED=83=9C=20=ED=99=95=EC=9D=B8=20=ED=9B=84=20Alert?= =?UTF-8?q?=20=ED=91=9C=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/teampome/pome/MainActivity.kt | 71 ++++++++++++++++++- .../teampome/pome/PomeConnectivityReceiver.kt | 56 +++++++++++++++ .../main/res/drawable/ic_exclamation_24.xml | 10 +++ 3 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/com/teampome/pome/PomeConnectivityReceiver.kt create mode 100644 app/src/main/res/drawable/ic_exclamation_24.xml diff --git a/app/src/main/java/com/teampome/pome/MainActivity.kt b/app/src/main/java/com/teampome/pome/MainActivity.kt index e37e69fe..2989e8a0 100644 --- a/app/src/main/java/com/teampome/pome/MainActivity.kt +++ b/app/src/main/java/com/teampome/pome/MainActivity.kt @@ -1,19 +1,24 @@ package com.teampome.pome +import android.app.Dialog +import android.content.IntentFilter import android.graphics.drawable.ColorDrawable -import androidx.appcompat.app.AppCompatActivity +import android.net.ConnectivityManager import android.os.Bundle import android.view.View import android.view.WindowManager import androidx.annotation.ColorRes +import androidx.appcompat.app.AppCompatActivity import androidx.databinding.DataBindingUtil import androidx.navigation.fragment.NavHostFragment import androidx.navigation.ui.setupWithNavController -import com.bumptech.glide.Glide import com.teampome.pome.databinding.ActivityMainBinding +import com.teampome.pome.databinding.PomeRemoveDialogBinding +import com.teampome.pome.util.common.CommonUtil import com.teampome.pome.util.customview.PomeLoadingDialog import dagger.hilt.android.AndroidEntryPoint + @AndroidEntryPoint class MainActivity : AppCompatActivity() { private lateinit var binding: ActivityMainBinding @@ -21,9 +26,23 @@ class MainActivity : AppCompatActivity() { // loading 관련 dialog private lateinit var loadingDialog: PomeLoadingDialog + // 목표 삭제 클릭 다이얼로그 + private lateinit var removeGoalDialogBinding: PomeRemoveDialogBinding + private lateinit var removeGoalDialog: Dialog + + private val connectivityReceiver by lazy { + PomeConnectivityReceiver() + } + + private val connectivityReceiverIntentFilter by lazy { + IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION) + } + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + registerReceiver(connectivityReceiver, connectivityReceiverIntentFilter) + binding = DataBindingUtil.setContentView(this, R.layout.activity_main) // nav controller 찾고 @@ -55,6 +74,7 @@ class MainActivity : AppCompatActivity() { changeStatusBarColor(R.color.main) } R.id.splashLoginFragment -> { + binding.activityMainBnv.visibility = View.GONE changeStatusBarColor(R.color.white) } R.id.register_profile_fragment -> { @@ -69,6 +89,14 @@ class MainActivity : AppCompatActivity() { loadingDialog = PomeLoadingDialog(this) loadingDialog.window?.setBackgroundDrawable(ColorDrawable(android.graphics.Color.TRANSPARENT)) loadingDialog.setCancelable(false) + + makeGoalRemoveDialog() + + PomeConnectivityReceiver.ConnectivityUtils.getLiveConnectivityState().observe(this) { + if(!it.isConnected) { + removeGoalDialog.show() + } + } } // status bar color 바꾸기 @@ -86,4 +114,43 @@ class MainActivity : AppCompatActivity() { fun hideLoadingProgress() { loadingDialog.dismiss() } + + override fun onDestroy() { + super.onDestroy() + + unregisterReceiver(connectivityReceiver) + } + + private fun makeGoalRemoveDialog() { + removeGoalDialog = Dialog(this) + removeGoalDialogBinding = PomeRemoveDialogBinding.inflate(layoutInflater, null, false) + + removeGoalDialog.setContentView(removeGoalDialogBinding.root) + removeGoalDialog.setCancelable(false) + + removeGoalDialogBinding.removeDialogTitleAtv.text = "인터넷에 연결할 수 없어요" + removeGoalDialogBinding.removeDialogSubtitleAtv.text = "다시 시도하거나 네트워크 설정을 확인해주세요" + removeGoalDialogBinding.removeTrashAiv.setImageResource(R.drawable.ic_exclamation_24) + + CommonUtil.makePomeDialog(removeGoalDialog) + + // 삭제하기 버튼 클릭 + removeGoalDialogBinding.removeYesTextAtv.apply { + text = "다시시도" + + setOnClickListener { + removeGoalDialog.dismiss() + recreate() + } + } + // 아니요 버튼 클릭 + removeGoalDialogBinding.removeNoTextAtv.apply { + text = "취소" + + setOnClickListener { + removeGoalDialog.dismiss() + finish() + } + } + } } \ No newline at end of file diff --git a/app/src/main/java/com/teampome/pome/PomeConnectivityReceiver.kt b/app/src/main/java/com/teampome/pome/PomeConnectivityReceiver.kt new file mode 100644 index 00000000..8fca7885 --- /dev/null +++ b/app/src/main/java/com/teampome/pome/PomeConnectivityReceiver.kt @@ -0,0 +1,56 @@ +package com.teampome.pome + +import android.app.Dialog +import android.content.BroadcastReceiver +import android.content.Context +import android.content.Intent +import android.net.ConnectivityManager +import android.net.NetworkInfo +import android.widget.Toast +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData +import com.teampome.pome.databinding.PomeRemoveDialogBinding + +class PomeConnectivityReceiver: BroadcastReceiver() { + override fun onReceive(context: Context?, intent: Intent?) { + context?.let { + ConnectivityUtils.notifyNetworkStatus(it) + } + } + + enum class NetworkState(val isConnected: Boolean) { + CONNECTED(true), + DISCONNECTED(false) + } + + object ConnectivityUtils { + private val liveConnectivityState = MutableLiveData() + + fun notifyNetworkStatus(context: Context) { + val newState = getLatestConnectivityStatusWithContext(context) + + liveConnectivityState.value = newState + } + + private fun getLatestConnectivityStatusWithContext(context: Context): NetworkState { + val isConnect = isConnected(context) + + return if(isConnect) { + NetworkState.CONNECTED + } else { + NetworkState.DISCONNECTED + } + } + + fun getLiveConnectivityState() : LiveData { + return liveConnectivityState + } + + private fun isConnected(context: Context): Boolean { + val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager + val networkInfo: NetworkInfo? = connectivityManager.activeNetworkInfo + + return networkInfo != null && networkInfo.isConnected + } + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_exclamation_24.xml b/app/src/main/res/drawable/ic_exclamation_24.xml new file mode 100644 index 00000000..dcd4ce43 --- /dev/null +++ b/app/src/main/res/drawable/ic_exclamation_24.xml @@ -0,0 +1,10 @@ + + + From d6db54f375e452cefcb759b3d412b9a6695d1feb Mon Sep 17 00:00:00 2001 From: hanseulchoi Date: Wed, 15 Mar 2023 14:50:09 +0900 Subject: [PATCH 36/40] =?UTF-8?q?fix=20:=20=EB=8B=89=EB=84=A4=EC=9E=84=20?= =?UTF-8?q?=EA=B2=80=EC=A6=9D=20=EB=B6=80=EB=B6=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../register/RegisterProfileFragment.kt | 14 +++++++------- app/src/main/res/values/strings.xml | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/teampome/pome/presentation/register/RegisterProfileFragment.kt b/app/src/main/java/com/teampome/pome/presentation/register/RegisterProfileFragment.kt index b6aa7464..0718e576 100644 --- a/app/src/main/java/com/teampome/pome/presentation/register/RegisterProfileFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/register/RegisterProfileFragment.kt @@ -258,12 +258,12 @@ class RegisterProfileFragment : BaseFragment(R.l editable?.let { name -> binding.registerProfileNameCheckTv.visibility = View.VISIBLE - if(name.length < 6 || name.length > 18) { // 일단 테스트용으로 텍스트가 6이하일 때, 불가능 처리 - binding.registerProfileNameCheckTv.text = getString(R.string.register_profile_name_chek_hint_text) - - disableName() - CommonUtil.disabledPomeBtn(binding.registerProfileCheckBtn) - } else { +// if(name.length < 6 || name.length > 18) { // 일단 테스트용으로 텍스트가 6이하일 때, 불가능 처리 +// binding.registerProfileNameCheckTv.text = getString(R.string.register_profile_name_chek_hint_text) +// +// disableName() +// CommonUtil.disabledPomeBtn(binding.registerProfileCheckBtn) +// } else { viewModel.setUserName(name.toString()) viewModel.checkNickname(object : CoroutineErrorHandler { @@ -271,7 +271,7 @@ class RegisterProfileFragment : BaseFragment(R.l Toast.makeText(requireContext(), "error : $message", Toast.LENGTH_SHORT).show() } }) - } +// } } ?: kotlin.run { // 만약 값이 비어있다면, 밑에 desc를 표기하면 안됨 // GONE이 아니고 INVISIBLE 처리 => 공간을 차지해야 constraintLayout 알맞게 동작 binding.registerProfileNameCheckTv.visibility = View.INVISIBLE diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0aec940b..30053627 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -42,7 +42,7 @@ 나만의 프로필을\n만들어 볼까요? - 영어, 한국어 최소 6자, 최대 18자 이내 입력 + 영어, 한국어 최대 10자 이내 입력 만들었어요 입력한 정보는 회원을 식별하고 친구간 커뮤니케이션을 위한 동의 목적으로만 사용되며 포미 이용기간 동안 보관돼요 삭제하기 From 68903a89575f55b21ab816ffc9cc62ae59ef6353 Mon Sep 17 00:00:00 2001 From: hanseulchoi Date: Wed, 15 Mar 2023 16:36:10 +0900 Subject: [PATCH 37/40] =?UTF-8?q?feat=20:=20Camera=20BottomSheetDialog=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/teampome/pome/MainActivity.kt | 3 +- .../register/RegisterProfileFragment.kt | 33 +++++++++---------- .../main/res/drawable/icon_camera_mono.xml | 14 ++++++++ .../main/res/drawable/icon_picture_mono.xml | 10 ++++++ 4 files changed, 41 insertions(+), 19 deletions(-) create mode 100644 app/src/main/res/drawable/icon_camera_mono.xml create mode 100644 app/src/main/res/drawable/icon_picture_mono.xml diff --git a/app/src/main/java/com/teampome/pome/MainActivity.kt b/app/src/main/java/com/teampome/pome/MainActivity.kt index 2989e8a0..ee658859 100644 --- a/app/src/main/java/com/teampome/pome/MainActivity.kt +++ b/app/src/main/java/com/teampome/pome/MainActivity.kt @@ -9,6 +9,7 @@ import android.view.View import android.view.WindowManager import androidx.annotation.ColorRes import androidx.appcompat.app.AppCompatActivity +import androidx.appcompat.content.res.AppCompatResources import androidx.databinding.DataBindingUtil import androidx.navigation.fragment.NavHostFragment import androidx.navigation.ui.setupWithNavController @@ -130,7 +131,7 @@ class MainActivity : AppCompatActivity() { removeGoalDialogBinding.removeDialogTitleAtv.text = "인터넷에 연결할 수 없어요" removeGoalDialogBinding.removeDialogSubtitleAtv.text = "다시 시도하거나 네트워크 설정을 확인해주세요" - removeGoalDialogBinding.removeTrashAiv.setImageResource(R.drawable.ic_exclamation_24) + removeGoalDialogBinding.removeTrashAiv.setImageDrawable(AppCompatResources.getDrawable(this, R.drawable.ic_exclamation_24)) CommonUtil.makePomeDialog(removeGoalDialog) diff --git a/app/src/main/java/com/teampome/pome/presentation/register/RegisterProfileFragment.kt b/app/src/main/java/com/teampome/pome/presentation/register/RegisterProfileFragment.kt index 0718e576..bc6f1162 100644 --- a/app/src/main/java/com/teampome/pome/presentation/register/RegisterProfileFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/register/RegisterProfileFragment.kt @@ -17,6 +17,7 @@ import android.view.View import android.widget.Toast import androidx.activity.result.contract.ActivityResultContracts import androidx.core.content.FileProvider +import androidx.core.content.res.ResourcesCompat import androidx.core.net.toUri import androidx.fragment.app.activityViewModels import androidx.fragment.app.viewModels @@ -97,8 +98,11 @@ class RegisterProfileFragment : BaseFragment(R.l pomeBottomSheetDialogPencilAiv.visibility = View.INVISIBLE pomeBottomSheetDialogTrashAiv.visibility = View.INVISIBLE - pomeBottomSheetDialogPencilTv.text = "사진앨범" - pomeBottomSheetDialogTrashTv.text = "카메라" + pomeBottomSheetDialogPencilAiv.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.icon_camera_mono, null)) + pomeBottomSheetDialogTrashAiv.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.icon_picture_mono, null)) + + pomeBottomSheetDialogPencilTv.text = "카메라" + pomeBottomSheetDialogTrashTv.text = "사진 앨범" } // pomeModifyBottomSheetDialog 뷰 인플레이션 과정 @@ -258,20 +262,13 @@ class RegisterProfileFragment : BaseFragment(R.l editable?.let { name -> binding.registerProfileNameCheckTv.visibility = View.VISIBLE -// if(name.length < 6 || name.length > 18) { // 일단 테스트용으로 텍스트가 6이하일 때, 불가능 처리 -// binding.registerProfileNameCheckTv.text = getString(R.string.register_profile_name_chek_hint_text) -// -// disableName() -// CommonUtil.disabledPomeBtn(binding.registerProfileCheckBtn) -// } else { - viewModel.setUserName(name.toString()) + viewModel.setUserName(name.toString()) - viewModel.checkNickname(object : CoroutineErrorHandler { - override fun onError(message: String) { - Toast.makeText(requireContext(), "error : $message", Toast.LENGTH_SHORT).show() - } - }) -// } + viewModel.checkNickname(object : CoroutineErrorHandler { + override fun onError(message: String) { + Toast.makeText(requireContext(), "error : $message", Toast.LENGTH_SHORT).show() + } + }) } ?: kotlin.run { // 만약 값이 비어있다면, 밑에 desc를 표기하면 안됨 // GONE이 아니고 INVISIBLE 처리 => 공간을 차지해야 constraintLayout 알맞게 동작 binding.registerProfileNameCheckTv.visibility = View.INVISIBLE @@ -309,14 +306,14 @@ class RegisterProfileFragment : BaseFragment(R.l } pomeNewBottomSheetDialogBinding.pomeBottomSheetDialogPencilTv.setOnClickListener { - openGallery() + // 카메라 기능 + showCamera() pomeNewBottomSheetDialog.dismiss() } pomeNewBottomSheetDialogBinding.pomeBottomSheetDialogTrashTv.setOnClickListener { - // 카메라 기능 - showCamera() + openGallery() pomeNewBottomSheetDialog.dismiss() } diff --git a/app/src/main/res/drawable/icon_camera_mono.xml b/app/src/main/res/drawable/icon_camera_mono.xml new file mode 100644 index 00000000..5513e3e7 --- /dev/null +++ b/app/src/main/res/drawable/icon_camera_mono.xml @@ -0,0 +1,14 @@ + + + + diff --git a/app/src/main/res/drawable/icon_picture_mono.xml b/app/src/main/res/drawable/icon_picture_mono.xml new file mode 100644 index 00000000..5af531cb --- /dev/null +++ b/app/src/main/res/drawable/icon_picture_mono.xml @@ -0,0 +1,10 @@ + + + From 3292048b2261ee5c7c923d27a6bf4c8736fb8c88 Mon Sep 17 00:00:00 2001 From: hanseulchoi Date: Wed, 15 Mar 2023 16:44:44 +0900 Subject: [PATCH 38/40] =?UTF-8?q?feat=20:=20Single=20Click=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/register/RegisterFragment.kt | 3 ++- .../java/com/teampome/pome/util/Extension.kt | 11 ++++++++++ .../pome/util/base/OnSingleClickListener.kt | 20 +++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/com/teampome/pome/util/Extension.kt create mode 100644 app/src/main/java/com/teampome/pome/util/base/OnSingleClickListener.kt diff --git a/app/src/main/java/com/teampome/pome/presentation/register/RegisterFragment.kt b/app/src/main/java/com/teampome/pome/presentation/register/RegisterFragment.kt index 9fcf005b..b6158a61 100644 --- a/app/src/main/java/com/teampome/pome/presentation/register/RegisterFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/register/RegisterFragment.kt @@ -21,6 +21,7 @@ import com.teampome.pome.util.common.CommonUtil.getPixelToDp import com.teampome.pome.util.base.ApiResponse import com.teampome.pome.util.base.BaseFragment import com.teampome.pome.util.base.CoroutineErrorHandler +import com.teampome.pome.util.setOnSingleClickListener import com.teampome.pome.util.token.TokenManager import com.teampome.pome.util.token.UserManager import com.teampome.pome.viewmodel.register.RegisterViewModel @@ -183,7 +184,7 @@ class RegisterFragment : BaseFragment(R.layout.fragment } // 번호 인증 요청 - binding.registerCertPhoneAcb.setOnClickListener { + binding.registerCertPhoneAcb.setOnSingleClickListener { binding.registerCertPhoneAcb.text = "재요청" binding.registerCertPhoneAcb.setPadding( diff --git a/app/src/main/java/com/teampome/pome/util/Extension.kt b/app/src/main/java/com/teampome/pome/util/Extension.kt new file mode 100644 index 00000000..b919f88a --- /dev/null +++ b/app/src/main/java/com/teampome/pome/util/Extension.kt @@ -0,0 +1,11 @@ +package com.teampome.pome.util + +import android.view.View +import com.teampome.pome.util.base.OnSingleClickListener + +fun View.setOnSingleClickListener(onSingleClick: (View) -> Unit) { + val oneClick = OnSingleClickListener { + onSingleClick(it) + } + setOnClickListener(oneClick) +} \ No newline at end of file diff --git a/app/src/main/java/com/teampome/pome/util/base/OnSingleClickListener.kt b/app/src/main/java/com/teampome/pome/util/base/OnSingleClickListener.kt new file mode 100644 index 00000000..108d66cb --- /dev/null +++ b/app/src/main/java/com/teampome/pome/util/base/OnSingleClickListener.kt @@ -0,0 +1,20 @@ +package com.teampome.pome.util.base + +import android.os.SystemClock +import android.view.View + +class OnSingleClickListener( + private var interval: Int = 600, + private var onSingleClick: (View) -> Unit +) : View.OnClickListener { + private var lastClickTime: Long = 0 + + override fun onClick(v: View) { + val elapsedRealtime = SystemClock.elapsedRealtime() + if((elapsedRealtime - lastClickTime) < interval) { + return + } + lastClickTime = elapsedRealtime + onSingleClick(v) + } +} \ No newline at end of file From 48d2b553c15f826f3eb7c8bffafcd9049a91eadd Mon Sep 17 00:00:00 2001 From: hanseulchoi Date: Wed, 15 Mar 2023 16:51:05 +0900 Subject: [PATCH 39/40] =?UTF-8?q?fix=20:=20networkErrorDialog=20=EB=B3=80?= =?UTF-8?q?=EC=88=98=EB=AA=85=20=EC=88=98=EC=A0=95=20=EB=B0=8F=20plus=20?= =?UTF-8?q?=EB=B2=84=ED=8A=BC=20=EC=83=81=EC=8B=9C=20=ED=99=9C=EC=84=B1?= =?UTF-8?q?=ED=99=94,=20=EC=B9=B4=EB=A9=94=EB=9D=BC=20icon=20Visible=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/teampome/pome/MainActivity.kt | 30 +++++++++---------- .../register/RegisterProfileFragment.kt | 13 ++++---- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/com/teampome/pome/MainActivity.kt b/app/src/main/java/com/teampome/pome/MainActivity.kt index ee658859..24dcb07e 100644 --- a/app/src/main/java/com/teampome/pome/MainActivity.kt +++ b/app/src/main/java/com/teampome/pome/MainActivity.kt @@ -28,8 +28,8 @@ class MainActivity : AppCompatActivity() { private lateinit var loadingDialog: PomeLoadingDialog // 목표 삭제 클릭 다이얼로그 - private lateinit var removeGoalDialogBinding: PomeRemoveDialogBinding - private lateinit var removeGoalDialog: Dialog + private lateinit var networkErrorDialogBinding: PomeRemoveDialogBinding + private lateinit var networkErrorDialog: Dialog private val connectivityReceiver by lazy { PomeConnectivityReceiver() @@ -95,7 +95,7 @@ class MainActivity : AppCompatActivity() { PomeConnectivityReceiver.ConnectivityUtils.getLiveConnectivityState().observe(this) { if(!it.isConnected) { - removeGoalDialog.show() + networkErrorDialog.show() } } } @@ -123,33 +123,33 @@ class MainActivity : AppCompatActivity() { } private fun makeGoalRemoveDialog() { - removeGoalDialog = Dialog(this) - removeGoalDialogBinding = PomeRemoveDialogBinding.inflate(layoutInflater, null, false) + networkErrorDialog = Dialog(this) + networkErrorDialogBinding = PomeRemoveDialogBinding.inflate(layoutInflater, null, false) - removeGoalDialog.setContentView(removeGoalDialogBinding.root) - removeGoalDialog.setCancelable(false) + networkErrorDialog.setContentView(networkErrorDialogBinding.root) + networkErrorDialog.setCancelable(false) - removeGoalDialogBinding.removeDialogTitleAtv.text = "인터넷에 연결할 수 없어요" - removeGoalDialogBinding.removeDialogSubtitleAtv.text = "다시 시도하거나 네트워크 설정을 확인해주세요" - removeGoalDialogBinding.removeTrashAiv.setImageDrawable(AppCompatResources.getDrawable(this, R.drawable.ic_exclamation_24)) + networkErrorDialogBinding.removeDialogTitleAtv.text = "인터넷에 연결할 수 없어요" + networkErrorDialogBinding.removeDialogSubtitleAtv.text = "다시 시도하거나 네트워크 설정을 확인해주세요" + networkErrorDialogBinding.removeTrashAiv.setImageDrawable(AppCompatResources.getDrawable(this, R.drawable.ic_exclamation_24)) - CommonUtil.makePomeDialog(removeGoalDialog) + CommonUtil.makePomeDialog(networkErrorDialog) // 삭제하기 버튼 클릭 - removeGoalDialogBinding.removeYesTextAtv.apply { + networkErrorDialogBinding.removeYesTextAtv.apply { text = "다시시도" setOnClickListener { - removeGoalDialog.dismiss() + networkErrorDialog.dismiss() recreate() } } // 아니요 버튼 클릭 - removeGoalDialogBinding.removeNoTextAtv.apply { + networkErrorDialogBinding.removeNoTextAtv.apply { text = "취소" setOnClickListener { - removeGoalDialog.dismiss() + networkErrorDialog.dismiss() finish() } } diff --git a/app/src/main/java/com/teampome/pome/presentation/register/RegisterProfileFragment.kt b/app/src/main/java/com/teampome/pome/presentation/register/RegisterProfileFragment.kt index bc6f1162..700d5e7d 100644 --- a/app/src/main/java/com/teampome/pome/presentation/register/RegisterProfileFragment.kt +++ b/app/src/main/java/com/teampome/pome/presentation/register/RegisterProfileFragment.kt @@ -95,9 +95,6 @@ class RegisterProfileFragment : BaseFragment(R.l pomeNewBottomSheetDialog.setContentView(pomeNewBottomSheetDialogBinding.root) pomeNewBottomSheetDialogBinding.apply { - pomeBottomSheetDialogPencilAiv.visibility = View.INVISIBLE - pomeBottomSheetDialogTrashAiv.visibility = View.INVISIBLE - pomeBottomSheetDialogPencilAiv.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.icon_camera_mono, null)) pomeBottomSheetDialogTrashAiv.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.icon_picture_mono, null)) @@ -327,7 +324,7 @@ class RegisterProfileFragment : BaseFragment(R.l // dialog 삭제 click pomeModifyBottomSheetDialogBinding.pomeBottomSheetDialogTrashTv.setOnClickListener { binding.registerProfileAiv.setImageDrawable(resources.getDrawable(R.drawable.user_profile_empty_150, null)) - binding.registerProfilePlusAiv.visibility = View.VISIBLE +// binding.registerProfilePlusAiv.visibility = View.VISIBLE runBlocking { if(userManger.getUserProfileUrl().first() != null) { @@ -413,8 +410,8 @@ class RegisterProfileFragment : BaseFragment(R.l e.printStackTrace() } - // 다 끝나면 바텀시트 닫고 플러스 버튼 가리기 - binding.registerProfilePlusAiv.visibility = View.INVISIBLE +// // 다 끝나면 바텀시트 닫고 플러스 버튼 가리기 +// binding.registerProfilePlusAiv.visibility = View.INVISIBLE pomeModifyBottomSheetDialog.dismiss() } else { hideLoading() @@ -461,8 +458,8 @@ class RegisterProfileFragment : BaseFragment(R.l e.printStackTrace() } - // 다 끝나면 바텀시트 닫고 플러스 버튼 가리기 - binding.registerProfilePlusAiv.visibility = View.INVISIBLE +// // 다 끝나면 바텀시트 닫고 플러스 버튼 가리기 +// binding.registerProfilePlusAiv.visibility = View.INVISIBLE pomeModifyBottomSheetDialog.dismiss() } else { hideLoading() From 87c3c50eb56d7bd33043450f2c1744e931f5bb74 Mon Sep 17 00:00:00 2001 From: hanseulchoi Date: Fri, 17 Mar 2023 16:41:30 +0900 Subject: [PATCH 40/40] =?UTF-8?q?refact=20:=20kts=EB=A1=9C=20=EB=A7=88?= =?UTF-8?q?=EC=9D=B4=EA=B7=B8=EB=A0=88=EC=9D=B4=EC=85=98=20=EC=9E=91?= =?UTF-8?q?=EC=97=85=20=EC=A7=84=ED=96=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 110 ----------------------- app/build.gradle.kts | 116 +++++++++++++++++++++++++ app/proguard-rules.pro | 2 +- build.gradle | 12 --- build.gradle.kts | 11 +++ settings.gradle => settings.gradle.kts | 4 +- 6 files changed, 130 insertions(+), 125 deletions(-) delete mode 100644 app/build.gradle create mode 100644 app/build.gradle.kts delete mode 100644 build.gradle create mode 100644 build.gradle.kts rename settings.gradle => settings.gradle.kts (84%) diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index 55d9a0e6..00000000 --- a/app/build.gradle +++ /dev/null @@ -1,110 +0,0 @@ -plugins { - id 'com.android.application' - id 'org.jetbrains.kotlin.android' - id 'kotlin-parcelize' - id 'androidx.navigation.safeargs.kotlin' - id 'dagger.hilt.android.plugin' - id 'kotlin-kapt' -} - -android { - compileSdk 33 - - defaultConfig { - applicationId "com.teampome.pome" - minSdk 23 - targetSdk 33 - versionCode 1 - versionName "1.0" - - multiDexEnabled true - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - debug { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - buildConfigField "String", "BASE_URL", "\"http://13.125.237.136:8085/\"" - buildConfigField "String", "IMAGE_BASE_URL", "\"http://image-main-server.ap-northeast-2.elasticbeanstalk.com/\"" - } - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - buildConfigField "String", "BASE_URL", "\"http://52.79.89.129/\"" - buildConfigField "String", "IMAGE_BASE_URL", "\"http://image-main-server.ap-northeast-2.elasticbeanstalk.com/\"" - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 - } - kotlinOptions { - jvmTarget = '1.8' - } - dataBinding { - enabled = true - } -} - -dependencies { - implementation 'androidx.core:core-ktx:1.9.0' - implementation 'androidx.appcompat:appcompat:1.5.1' - implementation 'com.google.android.material:material:1.7.0' - implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.3' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' - - // Fragment ViewModel - def fragment_ktx_version = '1.5.3' - implementation "androidx.fragment:fragment-ktx:$fragment_ktx_version" - - // Retrofit - def retrofit_version = '2.9.0' - implementation "com.squareup.retrofit2:retrofit:$retrofit_version" - implementation "com.google.code.gson:gson:$retrofit_version" - implementation "com.squareup.retrofit2:converter-gson:$retrofit_version" - - def okhttp_version = "4.10.0" - implementation "com.squareup.okhttp3:okhttp:$okhttp_version" - implementation "com.squareup.okhttp3:logging-interceptor:$okhttp_version" - - // Glide - def glide_version = '4.13.2' - implementation "com.github.bumptech.glide:glide:$glide_version" - kapt "com.github.bumptech.glide:compiler:$glide_version" - implementation ("com.github.bumptech.glide:okhttp3-integration:$glide_version"){ - exclude group: 'glide-parent' - } - implementation "com.github.bumptech.glide:annotations:$glide_version" - annotationProcessor "com.github.bumptech.glide:compiler:$glide_version" - implementation 'com.caverock:androidsvg-aar:1.4' - - // Glide Tranform - implementation 'jp.wasabeef:glide-transformations:4.3.0' - - // Navigation - def nav_version = '2.5.2' - implementation "androidx.navigation:navigation-fragment-ktx:$nav_version" - implementation "androidx.navigation:navigation-ui-ktx:$nav_version" - - // Hilt - def hilt_version = '2.44' - implementation "com.google.dagger:hilt-android:$hilt_version" - kapt "com.google.dagger:hilt-android-compiler:$hilt_version" - - def kotlinx_metadata_jvm_version = '0.5.0' - implementation "org.jetbrains.kotlinx:kotlinx-metadata-jvm:$kotlinx_metadata_jvm_version" - - // Calendar - implementation 'com.github.prolificinteractive:material-calendarview:2.0.1' - implementation 'com.jakewharton.threetenabp:threetenabp:1.1.1' - - // DataStore - implementation "androidx.datastore:datastore-preferences:1.0.0" - - // Paging - def paging_version = '3.1.1' - implementation "androidx.paging:paging-runtime:$paging_version" -} \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 00000000..0a63f189 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,116 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") + id("kotlin-parcelize") + id("androidx.navigation.safeargs.kotlin") + id("dagger.hilt.android.plugin") + id("kotlin-kapt") +} + +android { + compileSdk = 33 + + defaultConfig { + applicationId = "com.teampome.pome" + minSdk = 23 + targetSdk = 33 + versionCode = 1 + versionName = "1.0" + + multiDexEnabled = true + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + debug { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + buildConfigField("String", "BASE_URL", "\"http://13.125.237.136:8085/\"") + buildConfigField("String", "IMAGE_BASE_URL", "\"http://image-main-server.ap-northeast-2.elasticbeanstalk.com/\"") + } + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + buildConfigField("String", "BASE_URL", "\"http://52.79.89.129/\"") + buildConfigField("String", "IMAGE_BASE_URL", "\"http://image-main-server.ap-northeast-2.elasticbeanstalk.com/\"") + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + kotlinOptions { + jvmTarget = "1.8" + } + dataBinding { + enable = true + } +} + +dependencies { + implementation("androidx.core:core-ktx:1.9.0") + implementation("androidx.appcompat:appcompat:1.5.1") + implementation("com.google.android.material:material:1.7.0") + implementation("androidx.constraintlayout:constraintlayout:2.1.4") + testImplementation("junit:junit:4.13.2") + androidTestImplementation("androidx.test.ext:junit:1.1.3") + androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0") + + // Fragment ViewModel + val fragmentKtxVersion = "1.5.3" + implementation("androidx.fragment:fragment-ktx:$fragmentKtxVersion") + + // Retrofit + val retrofitVersion = "2.9.0" + implementation("com.squareup.retrofit2:retrofit:$retrofitVersion") + implementation("com.google.code.gson:gson:$retrofitVersion") + implementation("com.squareup.retrofit2:converter-gson:$retrofitVersion") + + val okhttp_version = "4.10.0" + implementation("com.squareup.okhttp3:okhttp:$okhttp_version") + implementation("com.squareup.okhttp3:logging-interceptor:$okhttp_version") + + // Glide + val glide_version = "4.13.2" + implementation("com.github.bumptech.glide:glide:$glide_version") + kapt("com.github.bumptech.glide:compiler:$glide_version") + implementation("com.github.bumptech.glide:okhttp3-integration:$glide_version"){ + exclude(group = "glide-parent") + } + implementation("com.github.bumptech.glide:annotations:$glide_version") + annotationProcessor("com.github.bumptech.glide:compiler:$glide_version") + implementation("com.caverock:androidsvg-aar:1.4") + + // Glide Tranform + implementation("jp.wasabeef:glide-transformations:4.3.0") + + // Navigation + val navVersion = "2.5.2" + implementation("androidx.navigation:navigation-fragment-ktx:$navVersion") + implementation("androidx.navigation:navigation-ui-ktx:$navVersion") + + // Hilt + val hiltVersion = "2.44" + implementation("com.google.dagger:hilt-android:$hiltVersion") + kapt("com.google.dagger:hilt-android-compiler:$hiltVersion") + + val kotlinxMetadataJvmVersion = "0.5.0" + implementation("org.jetbrains.kotlinx:kotlinx-metadata-jvm:$kotlinxMetadataJvmVersion") + + // Calendar + implementation("com.github.prolificinteractive:material-calendarview:2.0.1") + implementation("com.jakewharton.threetenabp:threetenabp:1.1.1") + + // DataStore + implementation("androidx.datastore:datastore-preferences:1.0.0") + + // Paging + val pagingVersion = "3.1.1" + implementation("androidx.paging:paging-runtime:$pagingVersion") +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 481bb434..ff59496d 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 390b7711..00000000 --- a/build.gradle +++ /dev/null @@ -1,12 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. -plugins { - id 'com.android.application' version '7.3.1' apply false - id 'com.android.library' version '7.3.1' apply false - id 'org.jetbrains.kotlin.android' version '1.7.20' apply false - id 'androidx.navigation.safeargs' version '2.4.2' apply false - id 'com.google.dagger.hilt.android' version '2.42' apply false -} - -task clean(type: Delete) { - delete rootProject.buildDir -} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..29738a60 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,11 @@ +plugins { + id("com.android.application") version "7.3.1" apply false + id("com.android.library") version "7.3.1" apply false + id("org.jetbrains.kotlin.android") version "1.7.20" apply false + id("androidx.navigation.safeargs") version "2.4.2" apply false + id("com.google.dagger.hilt.android") version "2.42" apply false +} + +tasks.register("clean", Delete::class) { + delete(rootProject.buildDir) +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle.kts similarity index 84% rename from settings.gradle rename to settings.gradle.kts index b513a25a..5158c002 100644 --- a/settings.gradle +++ b/settings.gradle.kts @@ -10,8 +10,8 @@ dependencyResolutionManagement { repositories { google() mavenCentral() - maven { url 'https://jitpack.io' } + maven(url = "https://jitpack.io") } } rootProject.name = "Pome" -include ':app' +include(":app")