refresh items after sorting/filtering/grouping only if something changed
This commit is contained in:
parent
f38612de5f
commit
80390c67f2
4 changed files with 33 additions and 21 deletions
|
@ -12,26 +12,26 @@ import com.simplemobiletools.gallery.pro.helpers.*
|
|||
import kotlinx.android.synthetic.main.dialog_change_grouping.view.*
|
||||
|
||||
class ChangeGroupingDialog(val activity: BaseSimpleActivity, val path: String = "", val callback: () -> Unit) :
|
||||
DialogInterface.OnClickListener {
|
||||
DialogInterface.OnClickListener {
|
||||
private var currGrouping = 0
|
||||
private var config = activity.config
|
||||
private val pathToUse = if (path.isEmpty()) SHOW_ALL else path
|
||||
private var view: View
|
||||
|
||||
init {
|
||||
currGrouping = config.getFolderGrouping(pathToUse)
|
||||
view = activity.layoutInflater.inflate(R.layout.dialog_change_grouping, null).apply {
|
||||
grouping_dialog_use_for_this_folder.isChecked = config.hasCustomGrouping(pathToUse)
|
||||
grouping_dialog_radio_folder.beVisibleIf(path.isEmpty())
|
||||
}
|
||||
|
||||
AlertDialog.Builder(activity)
|
||||
.setPositiveButton(R.string.ok, this)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.group_by)
|
||||
}
|
||||
.setPositiveButton(R.string.ok, this)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.group_by)
|
||||
}
|
||||
|
||||
currGrouping = config.getFolderGrouping(pathToUse)
|
||||
setupGroupRadio()
|
||||
setupOrderRadio()
|
||||
view.grouping_dialog_show_file_count.isChecked = currGrouping and GROUP_SHOW_FILE_COUNT != 0
|
||||
|
@ -90,6 +90,7 @@ class ChangeGroupingDialog(val activity: BaseSimpleActivity, val path: String =
|
|||
config.removeFolderGrouping(pathToUse)
|
||||
config.groupBy = grouping
|
||||
}
|
||||
|
||||
callback()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,6 +113,9 @@ class ChangeSortingDialog(
|
|||
config.sorting = sorting
|
||||
}
|
||||
}
|
||||
callback()
|
||||
|
||||
if (currSorting != sorting) {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,15 +47,20 @@ class ChangeViewTypeDialog(val activity: BaseSimpleActivity, val fromFoldersView
|
|||
}
|
||||
|
||||
AlertDialog.Builder(activity)
|
||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this)
|
||||
}
|
||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this)
|
||||
}
|
||||
}
|
||||
|
||||
private fun dialogConfirmed() {
|
||||
val viewType = if (view.change_view_type_dialog_radio.checkedRadioButtonId == view.change_view_type_dialog_radio_grid.id) VIEW_TYPE_GRID else VIEW_TYPE_LIST
|
||||
val viewType = if (view.change_view_type_dialog_radio.checkedRadioButtonId == view.change_view_type_dialog_radio_grid.id) {
|
||||
VIEW_TYPE_GRID
|
||||
} else {
|
||||
VIEW_TYPE_LIST
|
||||
}
|
||||
|
||||
if (fromFoldersView) {
|
||||
config.viewTypeFolders = viewType
|
||||
config.groupDirectSubfolders = view.change_view_type_dialog_group_direct_subfolders.isChecked
|
||||
|
@ -68,6 +73,7 @@ class ChangeViewTypeDialog(val activity: BaseSimpleActivity, val fromFoldersView
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
callback()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,11 +23,11 @@ class FilterMediaDialog(val activity: BaseSimpleActivity, val callback: (result:
|
|||
}
|
||||
|
||||
AlertDialog.Builder(activity)
|
||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.filter_media)
|
||||
}
|
||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.filter_media)
|
||||
}
|
||||
}
|
||||
|
||||
private fun dialogConfirmed() {
|
||||
|
@ -49,7 +49,9 @@ class FilterMediaDialog(val activity: BaseSimpleActivity, val callback: (result:
|
|||
result = getDefaultFileFilter()
|
||||
}
|
||||
|
||||
activity.config.filterMedia = result
|
||||
callback(result)
|
||||
if (activity.config.filterMedia != result) {
|
||||
activity.config.filterMedia = result
|
||||
callback(result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue