Added change column count animation

This commit is contained in:
merkost
2023-07-20 11:41:39 +10:00
parent 1379c288e5
commit 7096cf5912
2 changed files with 11 additions and 5 deletions

View File

@@ -226,7 +226,7 @@ class MainActivity : SimpleActivity() {
val newColumnCount = it as Int
if (currentColumnCount != newColumnCount) {
config.contactsGridColumnCount = newColumnCount
favorites_fragment.updateListAdapter()
favorites_fragment?.columnCountChanged()
}
}
}
@@ -234,7 +234,7 @@ class MainActivity : SimpleActivity() {
private fun changeViewType() {
ChangeViewTypeDialog(this) {
refreshMenuItems()
favorites_fragment.updateListAdapter()
favorites_fragment?.refreshItems()
}
}

View File

@@ -87,7 +87,7 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
}
}
fun updateListAdapter() {
private fun updateListAdapter() {
val viewType = context.config.viewType
setViewType(viewType)
@@ -135,13 +135,19 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
fragment_list.scheduleLayoutAnimation()
}
} else {
currAdapter.updateItems(allContacts)
currAdapter.viewType = viewType
currAdapter.recyclerView.requestLayout()
currAdapter.updateItems(allContacts)
}
}
fun columnCountChanged() {
(fragment_list.layoutManager as MyGridLayoutManager).spanCount = context!!.config.contactsGridColumnCount
fragment_list?.adapter?.apply {
notifyItemRangeChanged(0, allContacts.size)
}
}
private fun sortByCustomOrder(favorites: List<Contact>): ArrayList<Contact> {
val favoritesOrder = activity!!.config.favoritesContactsOrder