mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
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.*
|
import kotlinx.android.synthetic.main.dialog_change_grouping.view.*
|
||||||
|
|
||||||
class ChangeGroupingDialog(val activity: BaseSimpleActivity, val path: String = "", val callback: () -> Unit) :
|
class ChangeGroupingDialog(val activity: BaseSimpleActivity, val path: String = "", val callback: () -> Unit) :
|
||||||
DialogInterface.OnClickListener {
|
DialogInterface.OnClickListener {
|
||||||
private var currGrouping = 0
|
private var currGrouping = 0
|
||||||
private var config = activity.config
|
private var config = activity.config
|
||||||
private val pathToUse = if (path.isEmpty()) SHOW_ALL else path
|
private val pathToUse = if (path.isEmpty()) SHOW_ALL else path
|
||||||
private var view: View
|
private var view: View
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
currGrouping = config.getFolderGrouping(pathToUse)
|
||||||
view = activity.layoutInflater.inflate(R.layout.dialog_change_grouping, null).apply {
|
view = activity.layoutInflater.inflate(R.layout.dialog_change_grouping, null).apply {
|
||||||
grouping_dialog_use_for_this_folder.isChecked = config.hasCustomGrouping(pathToUse)
|
grouping_dialog_use_for_this_folder.isChecked = config.hasCustomGrouping(pathToUse)
|
||||||
grouping_dialog_radio_folder.beVisibleIf(path.isEmpty())
|
grouping_dialog_radio_folder.beVisibleIf(path.isEmpty())
|
||||||
}
|
}
|
||||||
|
|
||||||
AlertDialog.Builder(activity)
|
AlertDialog.Builder(activity)
|
||||||
.setPositiveButton(R.string.ok, this)
|
.setPositiveButton(R.string.ok, this)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.create().apply {
|
.create().apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.group_by)
|
activity.setupDialogStuff(view, this, R.string.group_by)
|
||||||
}
|
}
|
||||||
|
|
||||||
currGrouping = config.getFolderGrouping(pathToUse)
|
|
||||||
setupGroupRadio()
|
setupGroupRadio()
|
||||||
setupOrderRadio()
|
setupOrderRadio()
|
||||||
view.grouping_dialog_show_file_count.isChecked = currGrouping and GROUP_SHOW_FILE_COUNT != 0
|
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.removeFolderGrouping(pathToUse)
|
||||||
config.groupBy = grouping
|
config.groupBy = grouping
|
||||||
}
|
}
|
||||||
|
|
||||||
callback()
|
callback()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,6 +113,9 @@ class ChangeSortingDialog(
|
||||||
config.sorting = sorting
|
config.sorting = sorting
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
callback()
|
|
||||||
|
if (currSorting != sorting) {
|
||||||
|
callback()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,15 +47,20 @@ class ChangeViewTypeDialog(val activity: BaseSimpleActivity, val fromFoldersView
|
||||||
}
|
}
|
||||||
|
|
||||||
AlertDialog.Builder(activity)
|
AlertDialog.Builder(activity)
|
||||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.create().apply {
|
.create().apply {
|
||||||
activity.setupDialogStuff(view, this)
|
activity.setupDialogStuff(view, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun dialogConfirmed() {
|
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) {
|
if (fromFoldersView) {
|
||||||
config.viewTypeFolders = viewType
|
config.viewTypeFolders = viewType
|
||||||
config.groupDirectSubfolders = view.change_view_type_dialog_group_direct_subfolders.isChecked
|
config.groupDirectSubfolders = view.change_view_type_dialog_group_direct_subfolders.isChecked
|
||||||
|
@ -68,6 +73,7 @@ class ChangeViewTypeDialog(val activity: BaseSimpleActivity, val fromFoldersView
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
callback()
|
callback()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,11 +23,11 @@ class FilterMediaDialog(val activity: BaseSimpleActivity, val callback: (result:
|
||||||
}
|
}
|
||||||
|
|
||||||
AlertDialog.Builder(activity)
|
AlertDialog.Builder(activity)
|
||||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.create().apply {
|
.create().apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.filter_media)
|
activity.setupDialogStuff(view, this, R.string.filter_media)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun dialogConfirmed() {
|
private fun dialogConfirmed() {
|
||||||
|
@ -49,7 +49,9 @@ class FilterMediaDialog(val activity: BaseSimpleActivity, val callback: (result:
|
||||||
result = getDefaultFileFilter()
|
result = getDefaultFileFilter()
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.config.filterMedia = result
|
if (activity.config.filterMedia != result) {
|
||||||
callback(result)
|
activity.config.filterMedia = result
|
||||||
|
callback(result)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue