diff --git a/buildSrc/src/main/kotlin/Constants.kt b/buildSrc/src/main/kotlin/Constants.kt index c6955d43..d07d9e2f 100644 --- a/buildSrc/src/main/kotlin/Constants.kt +++ b/buildSrc/src/main/kotlin/Constants.kt @@ -3,6 +3,6 @@ object Constants { const val compileSdk = 34 const val minSdk = 28 const val targetSdk = 34 - const val versionCode = 6 + const val versionCode = 7 const val versionName = "1.0" } diff --git a/presentation/src/main/java/com/going/presentation/todo/mytodo/MyTodoFragment.kt b/presentation/src/main/java/com/going/presentation/todo/mytodo/MyTodoFragment.kt index 6385d65f..6764274e 100644 --- a/presentation/src/main/java/com/going/presentation/todo/mytodo/MyTodoFragment.kt +++ b/presentation/src/main/java/com/going/presentation/todo/mytodo/MyTodoFragment.kt @@ -8,7 +8,9 @@ import android.text.SpannableStringBuilder import android.text.Spanned import android.text.style.ForegroundColorSpan import android.view.View +import android.view.ViewTreeObserver import androidx.core.content.ContextCompat +import androidx.core.view.isVisible import androidx.fragment.app.activityViewModels import androidx.lifecycle.flowWithLifecycle import androidx.lifecycle.lifecycleScope @@ -57,6 +59,7 @@ class MyTodoFragment() : BaseFragment(R.layout.fragment_m setViewPagerDebounce() setTodoCountText() setToolbarColor() + initEmptyViewHeight() setEmptyViewHeight() observeMyTripInfoState() observeTotalUncompletedTodoCount() @@ -171,17 +174,36 @@ class MyTodoFragment() : BaseFragment(R.layout.fragment_m } } + private fun initEmptyViewHeight() { + binding.appbarMyTodo.viewTreeObserver.addOnGlobalLayoutListener(object : + ViewTreeObserver.OnGlobalLayoutListener { + override fun onGlobalLayout() { + binding.appbarMyTodo.viewTreeObserver.removeOnGlobalLayoutListener(this) + val displayHeight = activity?.getWindowHeight() ?: return + val toolbarHeight = binding.toolbarMyTodo.height + val appBarHeight = binding.appbarMyTodo.totalScrollRange + binding.layoutMyTodoEmpty.layoutParams = (binding.layoutMyTodoEmpty.layoutParams).also { + it.height = displayHeight - toolbarHeight - appBarHeight - 300 + } + } + }) + } + private fun setEmptyViewHeight() { binding.appbarMyTodo.addOnOffsetChangedListener { appBarLayout, verticalOffset -> val displayHeight = activity?.getWindowHeight() ?: return@addOnOffsetChangedListener val toolbarHeight = binding.toolbarMyTodo.height val appBarHeight = appBarLayout.totalScrollRange + verticalOffset - binding.vpMyTodo.layoutParams = (binding.vpMyTodo.layoutParams).also { + binding.layoutMyTodoEmpty.layoutParams = (binding.layoutMyTodoEmpty.layoutParams).also { it.height = displayHeight - toolbarHeight - appBarHeight - 300 } } } + fun showEmptyView(show: Boolean) { + binding.layoutMyTodoEmpty.isVisible = show + } + private fun observeMyTripInfoState() { viewModel.myTripInfoState.flowWithLifecycle(lifecycle).onEach { state -> when (state) { diff --git a/presentation/src/main/java/com/going/presentation/todo/mytodo/todolist/MyTodoCompleteFragment.kt b/presentation/src/main/java/com/going/presentation/todo/mytodo/todolist/MyTodoCompleteFragment.kt index 3ade99f8..c696d2ea 100644 --- a/presentation/src/main/java/com/going/presentation/todo/mytodo/todolist/MyTodoCompleteFragment.kt +++ b/presentation/src/main/java/com/going/presentation/todo/mytodo/todolist/MyTodoCompleteFragment.kt @@ -104,7 +104,7 @@ class MyTodoCompleteFragment() : private fun setLayoutEmpty(isEmpty: Boolean) { binding.rvMyTodoComplete.isVisible = !isEmpty - binding.layoutMyTodoCompleteEmpty.isVisible = isEmpty + (requireParentFragment() as MyTodoFragment).showEmptyView(isEmpty) } private fun observeTodoRedoState() { diff --git a/presentation/src/main/java/com/going/presentation/todo/mytodo/todolist/MyTodoUncompleteFragment.kt b/presentation/src/main/java/com/going/presentation/todo/mytodo/todolist/MyTodoUncompleteFragment.kt index ea328ae4..b4251ced 100644 --- a/presentation/src/main/java/com/going/presentation/todo/mytodo/todolist/MyTodoUncompleteFragment.kt +++ b/presentation/src/main/java/com/going/presentation/todo/mytodo/todolist/MyTodoUncompleteFragment.kt @@ -104,7 +104,7 @@ class MyTodoUncompleteFragment() : private fun setLayoutEmpty(isEmpty: Boolean) { binding.rvMyTodoUncomplete.isVisible = !isEmpty - binding.layoutMyTodoUncompleteEmpty.isVisible = isEmpty + (requireParentFragment() as MyTodoFragment).showEmptyView(isEmpty) } private fun observeTodoFinishState() { diff --git a/presentation/src/main/java/com/going/presentation/todo/ourtodo/OurTodoFragment.kt b/presentation/src/main/java/com/going/presentation/todo/ourtodo/OurTodoFragment.kt index 56dbc190..53ef09de 100644 --- a/presentation/src/main/java/com/going/presentation/todo/ourtodo/OurTodoFragment.kt +++ b/presentation/src/main/java/com/going/presentation/todo/ourtodo/OurTodoFragment.kt @@ -9,6 +9,7 @@ import android.text.Spanned import android.text.style.ForegroundColorSpan import android.view.View import androidx.core.content.ContextCompat +import androidx.core.view.isVisible import androidx.fragment.app.activityViewModels import androidx.lifecycle.flowWithLifecycle import androidx.lifecycle.lifecycleScope @@ -213,12 +214,16 @@ class OurTodoFragment() : BaseFragment(R.layout.fragment val displayHeight = activity?.getWindowHeight() ?: return@addOnOffsetChangedListener val toolbarHeight = binding.toolbarOurTodo.height val appBarHeight = appBarLayout.totalScrollRange + verticalOffset - binding.vpOurTodo.layoutParams = (binding.vpOurTodo.layoutParams).also { + binding.layoutOurTodoEmpty.layoutParams = (binding.layoutOurTodoEmpty.layoutParams).also { it.height = displayHeight - toolbarHeight - appBarHeight - 300 } } } + fun showEmptyView(show: Boolean) { + binding.layoutOurTodoEmpty.isVisible = show + } + private fun observeOurTripInfoState() { viewModel.ourTripInfoState.flowWithLifecycle(lifecycle).onEach { state -> when (state) { diff --git a/presentation/src/main/java/com/going/presentation/todo/ourtodo/OurTodoFriendAdapter.kt b/presentation/src/main/java/com/going/presentation/todo/ourtodo/OurTodoFriendAdapter.kt index 67a7aee3..b97e9605 100644 --- a/presentation/src/main/java/com/going/presentation/todo/ourtodo/OurTodoFriendAdapter.kt +++ b/presentation/src/main/java/com/going/presentation/todo/ourtodo/OurTodoFriendAdapter.kt @@ -2,12 +2,13 @@ package com.going.presentation.todo.ourtodo import android.view.LayoutInflater import android.view.ViewGroup -import androidx.recyclerview.widget.ListAdapter +import androidx.recyclerview.widget.RecyclerView import com.going.domain.entity.response.TripParticipantModel import com.going.presentation.databinding.ItemTodoFriendsBinding -import com.going.ui.extension.ItemDiffCallback -class OurTodoFriendAdapter : ListAdapter(diffUtil) { +class OurTodoFriendAdapter : RecyclerView.Adapter() { + + private var itemList = mutableListOf() override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): OurTodoFriendViewHolder { val binding: ItemTodoFriendsBinding = @@ -16,13 +17,14 @@ class OurTodoFriendAdapter : ListAdapter( - onItemsTheSame = { old, new -> old.participantId == new.participantId }, - onContentsTheSame = { old, new -> old == new }, - ) + override fun getItemCount(): Int = itemList.size + + fun submitList(newItems: List) { + this.itemList.clear() + this.itemList.addAll(newItems) + notifyDataSetChanged() } } \ No newline at end of file diff --git a/presentation/src/main/java/com/going/presentation/todo/ourtodo/todolist/OurTodoCompleteFragment.kt b/presentation/src/main/java/com/going/presentation/todo/ourtodo/todolist/OurTodoCompleteFragment.kt index ef56889b..7db212df 100644 --- a/presentation/src/main/java/com/going/presentation/todo/ourtodo/todolist/OurTodoCompleteFragment.kt +++ b/presentation/src/main/java/com/going/presentation/todo/ourtodo/todolist/OurTodoCompleteFragment.kt @@ -15,6 +15,7 @@ import com.going.presentation.todo.ourtodo.OurTodoViewModel.Companion.COMPLETE import com.going.presentation.todo.ourtodo.OurTodoViewModel.Companion.OUR_TODO import com.going.presentation.todo.detail.PublicDetailActivity import com.going.presentation.todo.detail.PublicDetailActivity.Companion.EXTRA_TODO_ID +import com.going.presentation.todo.mytodo.MyTodoFragment import com.going.presentation.todo.ourtodo.OurTodoFragment import com.going.ui.base.BaseFragment import com.going.ui.extension.UiState @@ -90,7 +91,7 @@ class OurTodoCompleteFragment() : private fun setLayoutEmpty(isEmpty: Boolean) { binding.rvOurTodoComplete.isVisible = !isEmpty - binding.layoutOurTodoCompleteEmpty.isVisible = isEmpty + (requireParentFragment() as OurTodoFragment).showEmptyView(isEmpty) } override fun onDestroyView() { diff --git a/presentation/src/main/java/com/going/presentation/todo/ourtodo/todolist/OurTodoUncompleteFragment.kt b/presentation/src/main/java/com/going/presentation/todo/ourtodo/todolist/OurTodoUncompleteFragment.kt index fbe310f3..b2d58ab0 100644 --- a/presentation/src/main/java/com/going/presentation/todo/ourtodo/todolist/OurTodoUncompleteFragment.kt +++ b/presentation/src/main/java/com/going/presentation/todo/ourtodo/todolist/OurTodoUncompleteFragment.kt @@ -90,7 +90,7 @@ class OurTodoUncompleteFragment() : private fun setLayoutEmpty(isEmpty: Boolean) { binding.rvOurTodoUncomplete.isVisible = !isEmpty - binding.layoutOurTodoUncompleteEmpty.isVisible = isEmpty + (requireParentFragment() as OurTodoFragment).showEmptyView(isEmpty) } override fun onDestroyView() { diff --git a/presentation/src/main/res/layout/fragment_my_todo.xml b/presentation/src/main/res/layout/fragment_my_todo.xml index a7a383c0..47d3a292 100644 --- a/presentation/src/main/res/layout/fragment_my_todo.xml +++ b/presentation/src/main/res/layout/fragment_my_todo.xml @@ -143,6 +143,39 @@ android:layout_height="wrap_content" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> + + + + + + + + - - - - - - - - \ No newline at end of file diff --git a/presentation/src/main/res/layout/fragment_my_todo_uncomplete.xml b/presentation/src/main/res/layout/fragment_my_todo_uncomplete.xml index c6bc5967..d5c655c1 100644 --- a/presentation/src/main/res/layout/fragment_my_todo_uncomplete.xml +++ b/presentation/src/main/res/layout/fragment_my_todo_uncomplete.xml @@ -18,7 +18,6 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginHorizontal="23dp" - android:nestedScrollingEnabled="true" android:orientation="vertical" android:overScrollMode="never" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" @@ -27,41 +26,6 @@ app:layout_constraintTop_toTopOf="parent" tools:listitem="@layout/item_my_todo" /> - - - - - - - - \ No newline at end of file diff --git a/presentation/src/main/res/layout/fragment_our_todo.xml b/presentation/src/main/res/layout/fragment_our_todo.xml index b654f977..ed3828a3 100644 --- a/presentation/src/main/res/layout/fragment_our_todo.xml +++ b/presentation/src/main/res/layout/fragment_our_todo.xml @@ -332,6 +332,39 @@ android:layout_height="wrap_content" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> + + + + + + + + - - - - - - - - \ No newline at end of file diff --git a/presentation/src/main/res/layout/fragment_our_todo_uncomplete.xml b/presentation/src/main/res/layout/fragment_our_todo_uncomplete.xml index b05bd602..ab11c35b 100644 --- a/presentation/src/main/res/layout/fragment_our_todo_uncomplete.xml +++ b/presentation/src/main/res/layout/fragment_our_todo_uncomplete.xml @@ -27,42 +27,6 @@ app:layout_constraintTop_toTopOf="parent" tools:listitem="@layout/item_our_todo" /> - - - - - - - - \ No newline at end of file