Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX/#253] Todo / 어댑터 네이밍 전체 수정 #254

Merged
merged 2 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import com.going.domain.entity.response.TodoAllocatorModel
import com.going.presentation.databinding.ItemTodoCreateNameBinding
import com.going.ui.util.ItemDiffCallback

class TodoAllocatorAdapter(
class ChangeAllocatorAdapter(
private val itemClick: (Int) -> Unit
) : ListAdapter<TodoAllocatorModel, TodoAllocatorViewHolder>(diffUtil) {
) : ListAdapter<TodoAllocatorModel, ChangeAllocatorViewHolder>(diffUtil) {

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TodoAllocatorViewHolder {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ChangeAllocatorViewHolder {
val binding: ItemTodoCreateNameBinding =
ItemTodoCreateNameBinding.inflate(LayoutInflater.from(parent.context), parent, false)
return TodoAllocatorViewHolder(binding, itemClick)
return ChangeAllocatorViewHolder(binding, itemClick)
}

override fun onBindViewHolder(holder: TodoAllocatorViewHolder, position: Int) {
override fun onBindViewHolder(holder: ChangeAllocatorViewHolder, position: Int) {
holder.onBind(getItem(position), position)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.going.presentation.R
import com.going.presentation.databinding.ItemTodoCreateNameBinding
import com.going.ui.extension.colorOf

class TodoAllocatorViewHolder(
class ChangeAllocatorViewHolder(
val binding: ItemTodoCreateNameBinding,
private val itemClick: (Int) -> Unit
) : RecyclerView.ViewHolder(binding.root) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class TodoChangeActivity : BaseActivity<ActivityTodoChangeBinding>(R.layout.acti

private val viewModel by viewModels<TodoChangeViewModel>()

private var _adapter: TodoAllocatorAdapter? = null
private var _adapter: ChangeAllocatorAdapter? = null
private val adapter
get() = requireNotNull(_adapter) { getString(R.string.adapter_not_initialized_error_msg) }

Expand Down Expand Up @@ -115,7 +115,7 @@ class TodoChangeActivity : BaseActivity<ActivityTodoChangeBinding>(R.layout.acti
}

private fun initOurTodoNameListAdapter() {
_adapter = TodoAllocatorAdapter { position ->
_adapter = ChangeAllocatorAdapter { position ->
viewModel.allocatorModelList[position].also { it.isAllocated = !it.isAllocated }
viewModel.checkIsFinishAvailable()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ import com.going.domain.entity.response.TripParticipantModel
import com.going.presentation.databinding.ItemTodoCreateNameBinding
import com.going.ui.util.ItemDiffCallback

class TripParticipantAdapter(
class CreateParticipantAdapter(
private val isFixed: Boolean,
private val itemClick: (Int) -> Unit
) : ListAdapter<TripParticipantModel, TripParticipantViewHolder>(diffUtil) {
) : ListAdapter<TripParticipantModel, CreateParticipantViewHolder>(diffUtil) {

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TripParticipantViewHolder {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CreateParticipantViewHolder {
val binding: ItemTodoCreateNameBinding =
ItemTodoCreateNameBinding.inflate(LayoutInflater.from(parent.context), parent, false)
return TripParticipantViewHolder(binding, isFixed, itemClick)
return CreateParticipantViewHolder(binding, isFixed, itemClick)
}

override fun onBindViewHolder(holder: TripParticipantViewHolder, position: Int) {
override fun onBindViewHolder(holder: CreateParticipantViewHolder, position: Int) {
holder.onBind(getItem(position), position)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.going.presentation.R
import com.going.presentation.databinding.ItemTodoCreateNameBinding
import com.going.ui.extension.colorOf

class TripParticipantViewHolder(
class CreateParticipantViewHolder(
val binding: ItemTodoCreateNameBinding,
private val isFixed: Boolean,
private val itemClick: (Int) -> Unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class TodoCreateActivity : BaseActivity<ActivityTodoCreateBinding>(R.layout.acti

private val viewModel by viewModels<TodoCreateViewModel>()

private var _adapter: TripParticipantAdapter? = null
private var _adapter: CreateParticipantAdapter? = null
private val adapter
get() = requireNotNull(_adapter) { getString(R.string.adapter_not_initialized_error_msg) }

Expand Down Expand Up @@ -104,7 +104,7 @@ class TodoCreateActivity : BaseActivity<ActivityTodoCreateBinding>(R.layout.acti
}

private fun initOurTodoNameListAdapter() {
_adapter = TripParticipantAdapter(false) { position ->
_adapter = CreateParticipantAdapter(false) { position ->
viewModel.participantModelList[position].also { it.isSelected = !it.isSelected }
viewModel.checkIsFinishAvailable()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import com.going.domain.entity.response.TodoAllocatorModel
import com.going.presentation.databinding.ItemTodoCreateNameBinding
import com.going.ui.util.ItemDiffCallback

class TripAllocatorAdapter : ListAdapter<TodoAllocatorModel, TripAllocatorViewHolder>(diffUtil) {
class DetailAllocatorAdapter : ListAdapter<TodoAllocatorModel, DetailAllocatorViewHolder>(diffUtil) {

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TripAllocatorViewHolder {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DetailAllocatorViewHolder {
val inflater by lazy { LayoutInflater.from(parent.context) }
val binding: ItemTodoCreateNameBinding =
ItemTodoCreateNameBinding.inflate(inflater, parent, false)
return TripAllocatorViewHolder(binding)
return DetailAllocatorViewHolder(binding)
}

override fun onBindViewHolder(holder: TripAllocatorViewHolder, position: Int) {
override fun onBindViewHolder(holder: DetailAllocatorViewHolder, position: Int) {
holder.onBind(getItem(position))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.going.presentation.R
import com.going.presentation.databinding.ItemTodoCreateNameBinding
import com.going.ui.extension.colorOf

class TripAllocatorViewHolder(
class DetailAllocatorViewHolder(
val binding: ItemTodoCreateNameBinding
) : RecyclerView.ViewHolder(binding.root) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class TodoDetailActivity :

private val viewModel by viewModels<TodoDetailViewModel>()

private var _adapter: TripAllocatorAdapter? = null
private var _adapter: DetailAllocatorAdapter? = null
private val adapter
get() = requireNotNull(_adapter) { getString(R.string.adapter_not_initialized_error_msg) }

Expand Down Expand Up @@ -89,7 +89,7 @@ class TodoDetailActivity :

private fun initAllocatorListAdapter() {
if (viewModel.isPublic) {
_adapter = TripAllocatorAdapter()
_adapter = DetailAllocatorAdapter()
binding.rvOurTodoDetailPerson.adapter = adapter
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.going.presentation.todo.allocator
package com.going.presentation.todo.list

import android.view.LayoutInflater
import android.view.ViewGroup
Expand All @@ -7,18 +7,18 @@ import com.going.domain.entity.response.TodoListAllocatorModel
import com.going.presentation.databinding.ItemTodoNameBinding
import com.going.ui.util.ItemDiffCallback

class TodoAllocatorAdapter(
class ListAllocatorAdapter(
private val isCompleted: Boolean
) : ListAdapter<TodoListAllocatorModel, TodoAllocatorViewHolder>(diffUtil) {
) : ListAdapter<TodoListAllocatorModel, ListAllocatorViewHolder>(diffUtil) {

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TodoAllocatorViewHolder {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ListAllocatorViewHolder {
val inflater by lazy { LayoutInflater.from(parent.context) }
val binding: ItemTodoNameBinding =
ItemTodoNameBinding.inflate(inflater, parent, false)
return TodoAllocatorViewHolder(binding, isCompleted)
return ListAllocatorViewHolder(binding, isCompleted)
}

override fun onBindViewHolder(holder: TodoAllocatorViewHolder, position: Int) {
override fun onBindViewHolder(holder: ListAllocatorViewHolder, position: Int) {
holder.onBind(getItem(position))
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.going.presentation.todo.allocator
package com.going.presentation.todo.list

import androidx.recyclerview.widget.RecyclerView
import com.going.domain.entity.response.TodoListAllocatorModel
import com.going.presentation.R
import com.going.presentation.databinding.ItemTodoNameBinding
import com.going.ui.extension.colorOf

class TodoAllocatorViewHolder(
class ListAllocatorViewHolder(
val binding: ItemTodoNameBinding,
private val isCompleted: Boolean
) : RecyclerView.ViewHolder(binding.root) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import androidx.recyclerview.widget.RecyclerView
import com.going.domain.entity.response.TodoModel
import com.going.presentation.R
import com.going.presentation.databinding.ItemMyTodoBinding
import com.going.presentation.todo.allocator.TodoAllocatorAdapter
import com.going.presentation.todo.list.ListAllocatorAdapter
import com.going.ui.extension.colorOf
import com.going.ui.extension.setOnSingleClickListener

Expand All @@ -28,7 +28,7 @@ class MyTodoListViewHolder(
cbMyTodoSelected.isVisible = isCompleted
cbMyTodoUnselected.isVisible = !isCompleted

rvMyTodoName.adapter = TodoAllocatorAdapter(isCompleted).apply {
rvMyTodoName.adapter = ListAllocatorAdapter(isCompleted).apply {
submitList(item.allocators)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import androidx.recyclerview.widget.RecyclerView
import com.going.domain.entity.response.TodoModel
import com.going.presentation.R
import com.going.presentation.databinding.ItemOurTodoBinding
import com.going.presentation.todo.allocator.TodoAllocatorAdapter
import com.going.presentation.todo.list.ListAllocatorAdapter
import com.going.ui.extension.colorOf
import com.going.ui.extension.setOnSingleClickListener

Expand All @@ -25,7 +25,7 @@ class OurTodoListViewHolder(
} else {
rvOurTodoName.visibility = View.VISIBLE
layoutOurTodoEmptyAllocator.visibility = View.INVISIBLE
rvOurTodoName.adapter = TodoAllocatorAdapter(isCompleted).apply {
rvOurTodoName.adapter = ListAllocatorAdapter(isCompleted).apply {
submitList(item.allocators)
}
}
Expand Down
Loading