diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeGroupingDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeGroupingDialog.kt index 4e21cfb9d..fb968708a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeGroupingDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeGroupingDialog.kt @@ -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() } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeSortingDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeSortingDialog.kt index b711e53cf..bcaddb1ed 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeSortingDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeSortingDialog.kt @@ -113,6 +113,9 @@ class ChangeSortingDialog( config.sorting = sorting } } - callback() + + if (currSorting != sorting) { + callback() + } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeViewTypeDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeViewTypeDialog.kt index c64fbde04..e2364be6f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeViewTypeDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeViewTypeDialog.kt @@ -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() } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/FilterMediaDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/FilterMediaDialog.kt index 5bcd1d09c..f694bfd4b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/FilterMediaDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/FilterMediaDialog.kt @@ -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) + } } }