mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 04:57:59 +01:00
reuse the same ChangeViewType dialog at media view too
This commit is contained in:
parent
702699e061
commit
c2178d467e
3 changed files with 28 additions and 18 deletions
|
@ -459,7 +459,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
}
|
||||
|
||||
private fun changeViewType() {
|
||||
ChangeViewTypeDialog(this) {
|
||||
ChangeViewTypeDialog(this, true) {
|
||||
invalidateOptionsMenu()
|
||||
setupLayoutManager()
|
||||
directories_grid.adapter = null
|
||||
|
|
|
@ -22,23 +22,18 @@ import com.bumptech.glide.request.RequestOptions
|
|||
import com.bumptech.glide.request.target.SimpleTarget
|
||||
import com.bumptech.glide.request.transition.Transition
|
||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.OTG_PATH
|
||||
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
|
||||
import com.simplemobiletools.commons.helpers.REQUEST_EDIT_IMAGE
|
||||
import com.simplemobiletools.commons.models.FileDirItem
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
import com.simplemobiletools.commons.views.MyGridLayoutManager
|
||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||
import com.simplemobiletools.gallery.pro.R
|
||||
import com.simplemobiletools.gallery.pro.adapters.MediaAdapter
|
||||
import com.simplemobiletools.gallery.pro.asynctasks.GetMediaAsynctask
|
||||
import com.simplemobiletools.gallery.pro.databases.GalleryDatabase
|
||||
import com.simplemobiletools.gallery.pro.dialogs.ChangeGroupingDialog
|
||||
import com.simplemobiletools.gallery.pro.dialogs.ChangeSortingDialog
|
||||
import com.simplemobiletools.gallery.pro.dialogs.ExcludeFolderDialog
|
||||
import com.simplemobiletools.gallery.pro.dialogs.FilterMediaDialog
|
||||
import com.simplemobiletools.gallery.pro.dialogs.*
|
||||
import com.simplemobiletools.gallery.pro.extensions.*
|
||||
import com.simplemobiletools.gallery.pro.helpers.*
|
||||
import com.simplemobiletools.gallery.pro.interfaces.DirectoryDao
|
||||
|
@ -493,12 +488,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
|||
}
|
||||
|
||||
private fun changeViewType() {
|
||||
val items = arrayListOf(
|
||||
RadioItem(VIEW_TYPE_GRID, getString(R.string.grid)),
|
||||
RadioItem(VIEW_TYPE_LIST, getString(R.string.list)))
|
||||
|
||||
RadioGroupDialog(this, items, config.viewTypeFiles) {
|
||||
config.viewTypeFiles = it as Int
|
||||
ChangeViewTypeDialog(this, false) {
|
||||
invalidateOptionsMenu()
|
||||
setupLayoutManager()
|
||||
media_grid.adapter = null
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.simplemobiletools.gallery.pro.dialogs
|
|||
import android.view.View
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.gallery.pro.R
|
||||
import com.simplemobiletools.gallery.pro.extensions.config
|
||||
|
@ -10,15 +11,29 @@ import com.simplemobiletools.gallery.pro.helpers.VIEW_TYPE_GRID
|
|||
import com.simplemobiletools.gallery.pro.helpers.VIEW_TYPE_LIST
|
||||
import kotlinx.android.synthetic.main.dialog_change_view_type.view.*
|
||||
|
||||
class ChangeViewTypeDialog(val activity: BaseSimpleActivity, val callback: () -> Unit) {
|
||||
class ChangeViewTypeDialog(val activity: BaseSimpleActivity, val fromFoldersView: Boolean, val callback: () -> Unit) {
|
||||
private var view: View
|
||||
private var config = activity.config
|
||||
|
||||
init {
|
||||
view = activity.layoutInflater.inflate(R.layout.dialog_change_view_type, null).apply {
|
||||
val viewToCheck = if (config.viewTypeFolders == VIEW_TYPE_GRID) change_view_type_dialog_radio_grid.id else change_view_type_dialog_radio_list.id
|
||||
val viewToCheck = if (fromFoldersView) {
|
||||
if (config.viewTypeFolders == VIEW_TYPE_GRID) {
|
||||
change_view_type_dialog_radio_grid.id
|
||||
} else {
|
||||
change_view_type_dialog_radio_list.id
|
||||
}
|
||||
} else if (config.viewTypeFiles == VIEW_TYPE_GRID) {
|
||||
change_view_type_dialog_radio_grid.id
|
||||
} else {
|
||||
change_view_type_dialog_radio_list.id
|
||||
}
|
||||
|
||||
change_view_type_dialog_radio.check(viewToCheck)
|
||||
change_view_type_dialog_group_direct_subfolders.isChecked = config.groupDirectSubfolders
|
||||
change_view_type_dialog_group_direct_subfolders.apply {
|
||||
beVisibleIf(fromFoldersView)
|
||||
isChecked = config.groupDirectSubfolders
|
||||
}
|
||||
}
|
||||
|
||||
AlertDialog.Builder(activity)
|
||||
|
@ -31,8 +46,13 @@ class ChangeViewTypeDialog(val activity: BaseSimpleActivity, val callback: () ->
|
|||
|
||||
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
|
||||
config.viewTypeFolders = viewType
|
||||
config.groupDirectSubfolders = view.change_view_type_dialog_group_direct_subfolders.isChecked
|
||||
if (fromFoldersView) {
|
||||
config.viewTypeFolders = viewType
|
||||
config.groupDirectSubfolders = view.change_view_type_dialog_group_direct_subfolders.isChecked
|
||||
} else {
|
||||
config.viewTypeFiles = viewType
|
||||
}
|
||||
|
||||
callback()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue