From e69fed198115e3803bd6b6a552982fdd2ec4ee5e Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 12 Oct 2021 23:18:26 +0200 Subject: [PATCH] simplifying a check in the sorting dialog --- .../pro/dialogs/ChangeSortingDialog.kt | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) 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 10aa1a274..b711e53cf 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 @@ -4,6 +4,7 @@ import android.content.DialogInterface import android.view.View import androidx.appcompat.app.AlertDialog import com.simplemobiletools.commons.activities.BaseSimpleActivity +import com.simplemobiletools.commons.extensions.beGoneIf import com.simplemobiletools.commons.extensions.beVisibleIf import com.simplemobiletools.commons.extensions.isVisible import com.simplemobiletools.commons.extensions.setupDialogStuff @@ -13,9 +14,11 @@ import com.simplemobiletools.gallery.pro.extensions.config import com.simplemobiletools.gallery.pro.helpers.SHOW_ALL import kotlinx.android.synthetic.main.dialog_change_sorting.view.* -class ChangeSortingDialog(val activity: BaseSimpleActivity, val isDirectorySorting: Boolean, val showFolderCheckbox: Boolean, - val path: String = "", val callback: () -> Unit) : - DialogInterface.OnClickListener { +class ChangeSortingDialog( + val activity: BaseSimpleActivity, val isDirectorySorting: Boolean, val showFolderCheckbox: Boolean, + val path: String = "", val callback: () -> Unit +) : + DialogInterface.OnClickListener { private var currSorting = 0 private var config = activity.config private var pathToUse = if (!isDirectorySorting && path.isEmpty()) SHOW_ALL else path @@ -36,11 +39,11 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, val isDirectorySorti } AlertDialog.Builder(activity) - .setPositiveButton(R.string.ok, this) - .setNegativeButton(R.string.cancel, null) - .create().apply { - activity.setupDialogStuff(view, this, R.string.sort_by) - } + .setPositiveButton(R.string.ok, this) + .setNegativeButton(R.string.cancel, null) + .create().apply { + activity.setupDialogStuff(view, this, R.string.sort_by) + } setupSortRadio() setupOrderRadio() @@ -54,8 +57,8 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, val isDirectorySorti view.use_for_this_folder_divider.beVisibleIf(view.sorting_dialog_numeric_sorting.isVisible() || view.sorting_dialog_use_for_this_folder.isVisible()) val isCustomSorting = checkedId == sortingRadio.sorting_dialog_radio_custom.id - view.sorting_dialog_radio_order.beVisibleIf(!isCustomSorting) - view.sorting_dialog_order_divider.beVisibleIf(!isCustomSorting) + view.sorting_dialog_radio_order.beGoneIf(isCustomSorting) + view.sorting_dialog_order_divider.beGoneIf(isCustomSorting) } val sortBtn = when {