Fix tab name update
This commit is contained in:
parent
9d46baef90
commit
2a80d7548d
|
@ -120,7 +120,7 @@ class ArrangeTabsFragment: DialogFragment() {
|
||||||
fun callbackOnClickListener(tabNew: Tab, isCheckedNew: Boolean, hashtag: String? = null) {
|
fun callbackOnClickListener(tabNew: Tab, isCheckedNew: Boolean, hashtag: String? = null) {
|
||||||
tabNew.filter = hashtag?.split("#")?.filter { it.isNotBlank() }?.get(0)?.trim()
|
tabNew.filter = hashtag?.split("#")?.filter { it.isNotBlank() }?.get(0)?.trim()
|
||||||
model.tabsCheckReplace(position, Pair(tabNew, isCheckedNew))
|
model.tabsCheckReplace(position, Pair(tabNew, isCheckedNew))
|
||||||
checkBox.isChecked = isCheckedNew
|
checkBox.isChecked = model.uiState.value.tabsChecked[position].second
|
||||||
|
|
||||||
val hashtagWithHashtag = tabNew.filter?.let {
|
val hashtagWithHashtag = tabNew.filter?.let {
|
||||||
StringBuilder("#").append(it).toString()
|
StringBuilder("#").append(it).toString()
|
||||||
|
@ -176,6 +176,7 @@ class ArrangeTabsFragment: DialogFragment() {
|
||||||
fun onItemMove(from: Int, to: Int) {
|
fun onItemMove(from: Int, to: Int) {
|
||||||
val previous = model.tabsCheckedRemove(from)
|
val previous = model.tabsCheckedRemove(from)
|
||||||
model.tabsCheckedAdd(to, previous)
|
model.tabsCheckedAdd(to, previous)
|
||||||
|
model.swapTabsButtons(from, to)
|
||||||
notifyItemMoved(from, to)
|
notifyItemMoved(from, to)
|
||||||
notifyItemChanged(to) // necessary to avoid checkBox issues
|
notifyItemChanged(to) // necessary to avoid checkBox issues
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,6 +118,18 @@ class ArrangeTabsViewModel @Inject constructor(
|
||||||
fun getTabsButtons(position: Int): String? {
|
fun getTabsButtons(position: Int): String? {
|
||||||
return _uiState.value.tabsButtons[position]
|
return _uiState.value.tabsButtons[position]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun swapTabsButtons(from: Int, to: Int) {
|
||||||
|
oldTabsButtons = _uiState.value.tabsButtons.toMutableList()
|
||||||
|
val fromText = oldTabsButtons[from]
|
||||||
|
oldTabsButtons[from] = oldTabsButtons[to]
|
||||||
|
oldTabsButtons[to] = fromText
|
||||||
|
_uiState.update { currentUiState ->
|
||||||
|
currentUiState.copy(
|
||||||
|
tabsButtons = oldTabsButtons.toList()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data class ArrangeTabsUiState(
|
data class ArrangeTabsUiState(
|
||||||
|
|
Loading…
Reference in New Issue