-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
1,425 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
domain/src/main/kotlin/com/going/domain/entity/PreferenceData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.going.domain.entity | ||
|
||
data class PreferenceData( | ||
val number: Int, | ||
val leftPrefer: String, | ||
val rightPrefer: String, | ||
) |
16 changes: 16 additions & 0 deletions
16
domain/src/main/kotlin/com/going/domain/entity/response/TripParticipantsListModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.going.domain.entity.response | ||
|
||
data class TripParticipantsListModel( | ||
val participant: List<TripParticipantModel>, | ||
val styleA: Int, | ||
val styleB: Int, | ||
val styleC: Int, | ||
val styleD: Int, | ||
val styleE: Int, | ||
) { | ||
data class TripParticipantModel( | ||
val participantId: Long, | ||
val name: String, | ||
val result: Int | ||
) | ||
} |
40 changes: 40 additions & 0 deletions
40
presentation/src/main/java/com/going/presentation/preferencetag/PreferenceTagActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.going.presentation.preferencetag | ||
|
||
import android.os.Bundle | ||
import androidx.activity.viewModels | ||
import com.going.domain.entity.PreferenceData | ||
import com.going.presentation.R | ||
import com.going.presentation.databinding.ActivityPreferenceTagBinding | ||
import com.going.ui.base.BaseActivity | ||
import com.going.ui.extension.toast | ||
|
||
class PreferenceTagActivity : | ||
BaseActivity<ActivityPreferenceTagBinding>(R.layout.activity_preference_tag), | ||
PreferenceTagAdapter.OnPreferenceSelectedListener { | ||
|
||
private var _adapter: PreferenceTagAdapter? = null | ||
private val adapter get() = requireNotNull(_adapter) { getString(R.string.adapter_not_initialized_error_msg) } | ||
|
||
private val viewModel by viewModels<PreferenceTagViewModel>() | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
initAdapter() | ||
} | ||
|
||
private fun initAdapter() { | ||
_adapter = PreferenceTagAdapter(this, this) | ||
binding.rvPreferenceTag.adapter = adapter | ||
adapter.submitList(viewModel.preferenceTagList) | ||
} | ||
|
||
override fun onPreferenceSelected(preference: PreferenceData) { | ||
// 선택된 취향 태그 처리 | ||
} | ||
|
||
override fun onDestroy() { | ||
super.onDestroy() | ||
_adapter = null | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
presentation/src/main/java/com/going/presentation/preferencetag/PreferenceTagAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.going.presentation.preferencetag | ||
|
||
import android.content.Context | ||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import com.going.domain.entity.PreferenceData | ||
import androidx.recyclerview.widget.ListAdapter | ||
import com.going.presentation.databinding.ItemPreferenceTagBinding | ||
import com.going.ui.extension.ItemDiffCallback | ||
|
||
class PreferenceTagAdapter( | ||
context: Context, | ||
private val listener: OnPreferenceSelectedListener | ||
) : | ||
ListAdapter<PreferenceData, PreferenceTagViewHolder>(diffUtil) { | ||
|
||
private val inflater by lazy { LayoutInflater.from(context) } | ||
|
||
interface OnPreferenceSelectedListener { | ||
fun onPreferenceSelected(preference: PreferenceData) | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PreferenceTagViewHolder { | ||
val binding: ItemPreferenceTagBinding = | ||
ItemPreferenceTagBinding.inflate(inflater, parent, false) | ||
return PreferenceTagViewHolder(binding, listener) | ||
} | ||
|
||
override fun onBindViewHolder(holder: PreferenceTagViewHolder, position: Int) { | ||
holder.onBind(getItem(position)) | ||
} | ||
|
||
override fun getItemCount() = currentList.size | ||
|
||
companion object { | ||
private val diffUtil = ItemDiffCallback<PreferenceData>( | ||
onItemsTheSame = { old, new -> old.number == new.number }, | ||
onContentsTheSame = { old, new -> old == new }, | ||
) | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
presentation/src/main/java/com/going/presentation/preferencetag/PreferenceTagViewHolder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.going.presentation.preferencetag | ||
|
||
import androidx.appcompat.widget.AppCompatButton | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.going.domain.entity.PreferenceData | ||
import com.going.presentation.R | ||
import com.going.presentation.databinding.ItemPreferenceTagBinding | ||
|
||
class PreferenceTagViewHolder( | ||
val binding: ItemPreferenceTagBinding, | ||
private val listener: PreferenceTagAdapter.OnPreferenceSelectedListener | ||
) : RecyclerView.ViewHolder(binding.root) { | ||
|
||
fun onBind(item: PreferenceData) { | ||
binding.run { | ||
tvPreferenceNumber.text = item.number.toString() | ||
tvPreferenceLeft.text = item.leftPrefer | ||
tvPreferenceRight.text = item.rightPrefer | ||
|
||
rgPreferenceTag.setOnCheckedChangeListener { _, checkedId -> | ||
val selectedButtonIdList = listOf( | ||
R.id.rb_preference_1, | ||
R.id.rb_preference_2, | ||
R.id.rb_preference_3, | ||
R.id.rb_preference_4, | ||
R.id.rb_preference_5 | ||
) | ||
|
||
if (checkedId in selectedButtonIdList) { | ||
listener.onPreferenceSelected(item) | ||
} | ||
} | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
presentation/src/main/java/com/going/presentation/preferencetag/PreferenceTagViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.going.presentation.preferencetag | ||
|
||
import androidx.lifecycle.ViewModel | ||
import com.going.domain.entity.PreferenceData | ||
|
||
class PreferenceTagViewModel : ViewModel() { | ||
|
||
val preferenceTagList = listOf<PreferenceData>( | ||
PreferenceData( | ||
number = 1, | ||
leftPrefer = "휴식", | ||
rightPrefer = "관광" | ||
), | ||
PreferenceData( | ||
number = 2, | ||
leftPrefer = "관광지", | ||
rightPrefer = "로컬 플레이스" | ||
), | ||
PreferenceData( | ||
number = 3, | ||
leftPrefer = "철처한 계획", | ||
rightPrefer = "무계획" | ||
), | ||
PreferenceData( | ||
number = 4, | ||
leftPrefer = "찾아온 맛집", | ||
rightPrefer = "끌리는 곳" | ||
), | ||
PreferenceData( | ||
number = 5, | ||
leftPrefer = "느긋하게", | ||
rightPrefer = "효율적으로" | ||
), | ||
) | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
presentation/src/main/java/com/going/presentation/todo/TodoActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.going.presentation.todo | ||
|
||
import android.os.Bundle | ||
import androidx.fragment.app.Fragment | ||
import androidx.fragment.app.commit | ||
import androidx.fragment.app.replace | ||
import com.going.presentation.R | ||
import com.going.presentation.databinding.ActivityTodoBinding | ||
import com.going.presentation.todo.mytodo.MyTodoFragment | ||
import com.going.presentation.todo.ourtodo.OurTodoFragment | ||
import com.going.ui.base.BaseActivity | ||
import dagger.hilt.android.AndroidEntryPoint | ||
|
||
@AndroidEntryPoint | ||
class TodoActivity() : BaseActivity<ActivityTodoBinding>(R.layout.activity_todo) { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
initBnvItemIconTintList() | ||
initBnvItemSelectedListener() | ||
} | ||
|
||
private fun initBnvItemIconTintList() { | ||
binding.bnvTodo.itemIconTintList = null | ||
binding.bnvTodo.selectedItemId = R.id.menu_our_todo | ||
} | ||
|
||
private fun initBnvItemSelectedListener() { | ||
supportFragmentManager.findFragmentById(R.id.fcv_todo) ?: navigateTo<OurTodoFragment>() | ||
|
||
binding.bnvTodo.setOnItemSelectedListener { menu -> | ||
when (menu.itemId) { | ||
R.id.menu_our_todo -> navigateTo<OurTodoFragment>() | ||
|
||
R.id.menu_my_todo -> navigateTo<MyTodoFragment>() | ||
|
||
else -> return@setOnItemSelectedListener false | ||
} | ||
true | ||
} | ||
} | ||
|
||
private inline fun <reified T : Fragment> navigateTo() { | ||
supportFragmentManager.commit { | ||
replace<T>(R.id.fcv_todo, T::class.java.canonicalName) | ||
} | ||
} | ||
|
||
} |
2 changes: 2 additions & 0 deletions
2
presentation/src/main/java/com/going/presentation/todo/mytodo/MyTodoAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
package com.going.presentation.todo.mytodo | ||
|
18 changes: 18 additions & 0 deletions
18
presentation/src/main/java/com/going/presentation/todo/mytodo/MyTodoFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.going.presentation.todo.mytodo | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
import com.going.presentation.R | ||
import com.going.presentation.databinding.FragmentMyTodoBinding | ||
import com.going.ui.base.BaseFragment | ||
import dagger.hilt.android.AndroidEntryPoint | ||
|
||
@AndroidEntryPoint | ||
class MyTodoFragment() : BaseFragment<FragmentMyTodoBinding>(R.layout.fragment_my_todo) { | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
} | ||
|
||
} |
2 changes: 2 additions & 0 deletions
2
presentation/src/main/java/com/going/presentation/todo/mytodo/MyTodoViewHolder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
package com.going.presentation.todo.mytodo | ||
|
2 changes: 2 additions & 0 deletions
2
presentation/src/main/java/com/going/presentation/todo/mytodo/MyTodoViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
package com.going.presentation.todo.mytodo | ||
|
34 changes: 34 additions & 0 deletions
34
presentation/src/main/java/com/going/presentation/todo/ourtodo/OurTodoAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.going.presentation.todo.ourtodo | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.ListAdapter | ||
import com.going.domain.entity.response.TripParticipantsListModel.TripParticipantModel | ||
import com.going.presentation.databinding.ItemTodoFriendsBinding | ||
import com.going.ui.extension.ItemDiffCallback | ||
|
||
class OurTodoAdapter : ListAdapter<TripParticipantModel, OurTodoViewHolder>(diffUtil) { | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): OurTodoViewHolder { | ||
val binding: ItemTodoFriendsBinding = | ||
ItemTodoFriendsBinding.inflate(LayoutInflater.from(parent.context), parent, false) | ||
return OurTodoViewHolder(binding) | ||
} | ||
|
||
override fun onBindViewHolder(holder: OurTodoViewHolder, position: Int) { | ||
holder.onBind(getItem(position)) | ||
} | ||
|
||
fun addList(newItems: List<TripParticipantModel>) { | ||
val currentItems = currentList.toMutableList() | ||
currentItems.addAll(newItems) | ||
submitList(currentItems) | ||
} | ||
|
||
companion object { | ||
private val diffUtil = ItemDiffCallback<TripParticipantModel>( | ||
onItemsTheSame = { old, new -> old.participantId == new.participantId }, | ||
onContentsTheSame = { old, new -> old == new }, | ||
) | ||
} | ||
} |
Oops, something went wrong.