-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* ui: typography.body textSize 1sp 씩 증가 * feat: DeleteDialogFragment에 Handler 추가 * feat: 툴바의 수정, 삭제 버튼 제어를 위한 ToolbarHandler 추가 * feat: 방문 상세 화면을 위한 VisitDetailUiModel 추가 * ui: PlaceHolder를 위한 xml 파일 추가 * feat: 방문 기록 상세 화면을 위한 VisitAdapter 및 VisitViewHolder 구현 * feat: 임시 VisitViewModel와 VisitViewModelFactory 추가 * feat: VisitFragment 화면 구현 * feat: 방문 기록에 해당하는 여행 선택을 위한 TravelSelectionFragment 구현 * feat: 방문 기록에 해당하는 날짜 선택을 위한 VisitedAtSelectionFragment 구현 * feat: 방문 기록 생성을 위한 VisitCreationActivity 구현 * feat: 방문 기록 수정을 위한 VisitUpdateActivity 구현 * refactor: DialogHandler를 DeleteDialogFragment의 생성자에서 받도록 수정 * refactor: initVisitUpdateDoneButton 중복 로직 제거 * refactor: VisitViewHolderType 메서드 명 변경 of -> from * refactor: tv_place_name_title을 xml id convention에 맞게 수정
- Loading branch information
Showing
35 changed files
with
1,545 additions
and
70 deletions.
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
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
...oid/Staccato_AN/app/src/main/java/com/woowacourse/staccato/presentation/ToolbarHandler.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.woowacourse.staccato.presentation | ||
|
||
interface ToolbarHandler { | ||
fun onUpdateClicked() | ||
|
||
fun onDeleteClicked() | ||
} |
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
76 changes: 76 additions & 0 deletions
76
..._AN/app/src/main/java/com/woowacourse/staccato/presentation/visit/adapter/VisitAdapter.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,76 @@ | ||
package com.woowacourse.staccato.presentation.visit.adapter | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.woowacourse.staccato.databinding.ItemMyVisitLogBinding | ||
import com.woowacourse.staccato.databinding.ItemVisitDefaultBinding | ||
import com.woowacourse.staccato.presentation.visit.model.VisitDetailUiModel | ||
|
||
class VisitAdapter(private val items: MutableList<VisitDetailUiModel> = mutableListOf()) : | ||
RecyclerView.Adapter<VisitViewHolder>() { | ||
override fun getItemCount(): Int = items.size | ||
|
||
override fun getItemViewType(position: Int): Int { | ||
return if (position == VISIT_DEFAULT_POSITION) { | ||
VisitViewHolderType.VISIT_DEFAULT.value | ||
} else { | ||
VisitViewHolderType.MY_VISIT_LOG.value | ||
} | ||
} | ||
|
||
override fun onCreateViewHolder( | ||
parent: ViewGroup, | ||
viewType: Int, | ||
): VisitViewHolder { | ||
return when (VisitViewHolderType.from(viewType)) { | ||
VisitViewHolderType.VISIT_DEFAULT -> { | ||
val inflater = LayoutInflater.from(parent.context) | ||
val binding = ItemVisitDefaultBinding.inflate(inflater, parent, false) | ||
VisitViewHolder.VisitDefaultViewHolder(binding) | ||
} | ||
|
||
VisitViewHolderType.MY_VISIT_LOG -> { | ||
val inflater = LayoutInflater.from(parent.context) | ||
val binding = ItemMyVisitLogBinding.inflate(inflater, parent, false) | ||
VisitViewHolder.MyVisitLogViewHolder(binding) | ||
} | ||
} | ||
} | ||
|
||
override fun onBindViewHolder( | ||
holder: VisitViewHolder, | ||
position: Int, | ||
) { | ||
if (holder is VisitViewHolder.VisitDefaultViewHolder) { | ||
holder.bind(items[position] as VisitDetailUiModel.VisitDefaultUiModel) | ||
} | ||
if (holder is VisitViewHolder.MyVisitLogViewHolder) { | ||
holder.bind(items[position] as VisitDetailUiModel.VisitLogUiModel) | ||
} | ||
} | ||
|
||
fun updateVisitDefault(newVisitDefault: VisitDetailUiModel.VisitDefaultUiModel) { | ||
val result = mutableListOf<VisitDetailUiModel>(newVisitDefault) | ||
result.addAll(items.drop(VISIT_DEFAULT_ITEM_SIZE)) | ||
replaceAllItems(result) | ||
notifyItemChanged(VISIT_DEFAULT_POSITION) | ||
} | ||
|
||
fun updateVisitLogs(newVisitLogs: List<VisitDetailUiModel.VisitLogUiModel>) { | ||
val result = items.take(VISIT_DEFAULT_ITEM_SIZE).toMutableList() | ||
result.addAll(newVisitLogs) | ||
replaceAllItems(result) | ||
notifyItemRangeInserted(VISIT_DEFAULT_ITEM_SIZE, result.size) | ||
} | ||
|
||
private fun replaceAllItems(result: MutableList<VisitDetailUiModel>) { | ||
items.clear() | ||
items.addAll(result) | ||
} | ||
|
||
companion object { | ||
private const val VISIT_DEFAULT_POSITION = 0 | ||
private const val VISIT_DEFAULT_ITEM_SIZE = 1 | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
.../app/src/main/java/com/woowacourse/staccato/presentation/visit/adapter/VisitViewHolder.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,23 @@ | ||
package com.woowacourse.staccato.presentation.visit.adapter | ||
|
||
import androidx.databinding.ViewDataBinding | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.woowacourse.staccato.databinding.ItemMyVisitLogBinding | ||
import com.woowacourse.staccato.databinding.ItemVisitDefaultBinding | ||
import com.woowacourse.staccato.presentation.visit.model.VisitDetailUiModel | ||
|
||
sealed class VisitViewHolder(binding: ViewDataBinding) : RecyclerView.ViewHolder(binding.root) { | ||
class VisitDefaultViewHolder(private val binding: ItemVisitDefaultBinding) : | ||
VisitViewHolder(binding) { | ||
fun bind(item: VisitDetailUiModel.VisitDefaultUiModel) { | ||
binding.visitDefault = item | ||
} | ||
} | ||
|
||
class MyVisitLogViewHolder(private val binding: ItemMyVisitLogBinding) : | ||
VisitViewHolder(binding) { | ||
fun bind(item: VisitDetailUiModel.VisitLogUiModel) { | ||
binding.visitLog = item | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
.../src/main/java/com/woowacourse/staccato/presentation/visit/adapter/VisitViewHolderType.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,25 @@ | ||
package com.woowacourse.staccato.presentation.visit.adapter | ||
|
||
enum class VisitViewHolderType(val value: Int) { | ||
VISIT_DEFAULT(0), | ||
MY_VISIT_LOG(1), | ||
; | ||
|
||
companion object { | ||
fun from(value: Int): VisitViewHolderType { | ||
return when (value) { | ||
0 -> { | ||
VISIT_DEFAULT | ||
} | ||
|
||
1 -> { | ||
MY_VISIT_LOG | ||
} | ||
|
||
else -> { | ||
throw IllegalArgumentException("") | ||
} | ||
} | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...app/src/main/java/com/woowacourse/staccato/presentation/visit/model/VisitDetailUiModel.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,20 @@ | ||
package com.woowacourse.staccato.presentation.visit.model | ||
|
||
sealed class VisitDetailUiModel { | ||
data class VisitDefaultUiModel( | ||
val visitId: Long, | ||
val placeName: String, | ||
val visitImage: String, | ||
val address: String, | ||
val visitedAt: String, | ||
val visitedCount: Long, | ||
) : VisitDetailUiModel() | ||
|
||
data class VisitLogUiModel( | ||
val visitLogId: Long = 0, | ||
val memberId: Long = 0, | ||
val nickName: String, | ||
val memberImage: String, | ||
val content: String, | ||
) : VisitDetailUiModel() | ||
} |
Oops, something went wrong.