Skip to content

Commit

Permalink
hide empty section
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammed-Alhams committed Apr 21, 2023
1 parent 6aeca05 commit 307eda5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(), HomeView {
override fun showPersonalTodos(getAllPersonalTodosResponse: GetAllPersonalTodosResponse) {
showHiddenSections()
requireActivity().runOnUiThread {
adapter.setTodoListVisibilty(
binding.recyclerViewHome,
getAllPersonalTodosResponse.value.isEmpty()
)
adapter.setPersonalCount(getAllPersonalTodosResponse.value.size)
personalTodos.data = getAllPersonalTodosResponse
adapter.notifyDataSetChanged()
Expand Down Expand Up @@ -141,6 +145,10 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(), HomeView {
override fun showTeamTodos(getAllTeamTodosResponse: GetAllTeamTodosResponse) {
showHiddenSections()
requireActivity().runOnUiThread {
adapter.setTodoListVisibilty(
binding.recyclerViewHome,
getAllTeamTodosResponse.value.isEmpty()
)
adapter.setTeamCount(getAllTeamTodosResponse.value.size)
teamTodos.data = getAllTeamTodosResponse
adapter.notifyDataSetChanged()
Expand Down Expand Up @@ -197,6 +205,7 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(), HomeView {
}

override fun showLoadStatus() {
binding.recyclerViewHome.visibility = View.GONE
binding.progressBarLoadState.visibility = View.VISIBLE
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,18 @@ class HomeAdapter(
private val onClickTeamTodoItem: (TeamTodo) -> Unit,
private val onClickPersonalTodoItem: (PersonalTodo) -> Unit,
private val onClickAllTeamTodos: () -> Unit,
private val onClickAllPersonalTodos: () -> Unit,
private var teamPendingTodosCount: Int = 0,
private var personalPendingTodosCount: Int = 0,
private var pendingTeamTodosCount: Int = 0,
private var pendingPersonalTodosCount: Int = 0,
private var completedTeamTodosCount: Int = 0,
private var completedPersonalTodosCount: Int = 0

private val onClickAllPersonalTodos: () -> Unit
) : RecyclerView.Adapter<HomeAdapter.BaseHomeHolder>() {

private var isTeamTodoVisible = false
private var isPersonalTodoVisible = false
private var teamPendingTodosCount: Int = 0
private var personalPendingTodosCount: Int = 0
private var pendingTeamTodosCount: Int = 0
private var pendingPersonalTodosCount: Int = 0
private var completedTeamTodosCount: Int = 0
private var completedPersonalTodosCount: Int = 0

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseHomeHolder {
return when (viewType) {
R.layout.item_statistics_tasks_person_has_done -> StaticsTasksPersonHasDoneHolder(
Expand Down Expand Up @@ -61,6 +63,13 @@ class HomeAdapter(
}
}

fun setTodoListVisibilty(itemView: View, isVisible: Boolean) {
if (!isVisible) {
itemView.visibility = View.GONE
}
itemView.visibility = View.VISIBLE
}

fun setTeamCount(newTeamPendingTodosCount: Int) {
teamPendingTodosCount = newTeamPendingTodosCount
notifyDataSetChanged()
Expand Down

0 comments on commit 307eda5

Please sign in to comment.