diff --git a/app/src/main/java/org/pixeldroid/app/settings/ArrangeTabsFragment.kt b/app/src/main/java/org/pixeldroid/app/settings/ArrangeTabsFragment.kt index e6bbe5d9..41e3f90d 100644 --- a/app/src/main/java/org/pixeldroid/app/settings/ArrangeTabsFragment.kt +++ b/app/src/main/java/org/pixeldroid/app/settings/ArrangeTabsFragment.kt @@ -120,7 +120,7 @@ class ArrangeTabsFragment: DialogFragment() { fun callbackOnClickListener(tabNew: Tab, isCheckedNew: Boolean, hashtag: String? = null) { tabNew.filter = hashtag?.split("#")?.filter { it.isNotBlank() }?.get(0)?.trim() model.tabsCheckReplace(position, Pair(tabNew, isCheckedNew)) - checkBox.isChecked = isCheckedNew + checkBox.isChecked = model.uiState.value.tabsChecked[position].second val hashtagWithHashtag = tabNew.filter?.let { StringBuilder("#").append(it).toString() @@ -176,6 +176,7 @@ class ArrangeTabsFragment: DialogFragment() { fun onItemMove(from: Int, to: Int) { val previous = model.tabsCheckedRemove(from) model.tabsCheckedAdd(to, previous) + model.swapTabsButtons(from, to) notifyItemMoved(from, to) notifyItemChanged(to) // necessary to avoid checkBox issues } diff --git a/app/src/main/java/org/pixeldroid/app/settings/ArrangeTabsViewModel.kt b/app/src/main/java/org/pixeldroid/app/settings/ArrangeTabsViewModel.kt index 9d0347fb..2440f398 100644 --- a/app/src/main/java/org/pixeldroid/app/settings/ArrangeTabsViewModel.kt +++ b/app/src/main/java/org/pixeldroid/app/settings/ArrangeTabsViewModel.kt @@ -118,6 +118,18 @@ class ArrangeTabsViewModel @Inject constructor( fun getTabsButtons(position: Int): String? { 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(