allow sorting Show All separately
This commit is contained in:
parent
8bb6c50075
commit
5db37d6c54
5 changed files with 17 additions and 12 deletions
|
@ -362,7 +362,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
media_horizontal_fastscroller.isHorizontal = true
|
||||
media_horizontal_fastscroller.beVisibleIf(allowHorizontalScroll)
|
||||
|
||||
val sorting = config.getFileSorting(mPath)
|
||||
val sorting = config.getFileSorting(if (mShowAll) SHOW_ALL else mPath)
|
||||
if (allowHorizontalScroll) {
|
||||
media_horizontal_fastscroller.allowBubbleDisplay = config.showInfoBubble
|
||||
media_horizontal_fastscroller.setViews(media_grid, media_refresh_layout) {
|
||||
|
@ -409,7 +409,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
}
|
||||
|
||||
private fun showSortingDialog() {
|
||||
ChangeSortingDialog(this, false, !config.showAll, mPath) {
|
||||
ChangeSortingDialog(this, false, true, mPath) {
|
||||
mLoadedInitialPhotos = false
|
||||
media_grid.adapter = null
|
||||
getMedia()
|
||||
|
|
|
@ -17,7 +17,8 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickImage
|
|||
private val mediaFetcher = MediaFetcher(context)
|
||||
|
||||
override fun doInBackground(vararg params: Void): ArrayList<ThumbnailItem> {
|
||||
val getProperDateTaken = context.config.getFileSorting(mPath) and SORT_BY_DATE_TAKEN != 0
|
||||
val pathToUse = if (showAll) SHOW_ALL else mPath
|
||||
val getProperDateTaken = context.config.getFileSorting(pathToUse) and SORT_BY_DATE_TAKEN != 0
|
||||
val favoritePaths = context.getFavoritePaths()
|
||||
val media = if (showAll) {
|
||||
val foldersToScan = mediaFetcher.getFoldersToScan()
|
||||
|
@ -27,12 +28,12 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickImage
|
|||
media.addAll(newMedia)
|
||||
}
|
||||
|
||||
mediaFetcher.sortMedia(media, context.config.getFileSorting(""))
|
||||
mediaFetcher.sortMedia(media, context.config.getFileSorting(SHOW_ALL))
|
||||
media
|
||||
} else {
|
||||
mediaFetcher.getFilesFrom(mPath, isPickImage, isPickVideo, getProperDateTaken, favoritePaths)
|
||||
}
|
||||
return mediaFetcher.groupMedia(media, if (showAll) SHOW_ALL else mPath)
|
||||
return mediaFetcher.groupMedia(media, pathToUse)
|
||||
}
|
||||
|
||||
override fun onPostExecute(media: ArrayList<ThumbnailItem>) {
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.simplemobiletools.commons.extensions.setupDialogStuff
|
|||
import com.simplemobiletools.commons.helpers.*
|
||||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.extensions.config
|
||||
import com.simplemobiletools.gallery.helpers.SHOW_ALL
|
||||
import kotlinx.android.synthetic.main.dialog_change_sorting.view.*
|
||||
|
||||
class ChangeSortingDialog(val activity: BaseSimpleActivity, val isDirectorySorting: Boolean, showFolderCheckbox: Boolean,
|
||||
|
@ -16,13 +17,14 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, val isDirectorySorti
|
|||
DialogInterface.OnClickListener {
|
||||
private var currSorting = 0
|
||||
private var config = activity.config
|
||||
private var pathToUse = if (!isDirectorySorting && path.isEmpty()) SHOW_ALL else path
|
||||
private var view: View
|
||||
|
||||
init {
|
||||
view = activity.layoutInflater.inflate(R.layout.dialog_change_sorting, null).apply {
|
||||
use_for_this_folder_divider.beVisibleIf(showFolderCheckbox)
|
||||
sorting_dialog_use_for_this_folder.beVisibleIf(showFolderCheckbox)
|
||||
sorting_dialog_use_for_this_folder.isChecked = config.hasCustomSorting(path)
|
||||
sorting_dialog_use_for_this_folder.isChecked = config.hasCustomSorting(pathToUse)
|
||||
}
|
||||
|
||||
AlertDialog.Builder(activity)
|
||||
|
@ -32,7 +34,7 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, val isDirectorySorti
|
|||
activity.setupDialogStuff(view, this, R.string.sort_by)
|
||||
}
|
||||
|
||||
currSorting = if (isDirectorySorting) config.directorySorting else config.getFileSorting(path)
|
||||
currSorting = if (isDirectorySorting) config.directorySorting else config.getFileSorting(pathToUse)
|
||||
setupSortRadio()
|
||||
setupOrderRadio()
|
||||
}
|
||||
|
@ -78,9 +80,9 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, val isDirectorySorti
|
|||
config.directorySorting = sorting
|
||||
} else {
|
||||
if (view.sorting_dialog_use_for_this_folder.isChecked) {
|
||||
config.saveFileSorting(path, sorting)
|
||||
config.saveFileSorting(pathToUse, sorting)
|
||||
} else {
|
||||
config.removeFileSorting(path)
|
||||
config.removeFileSorting(pathToUse)
|
||||
config.sorting = sorting
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.simplemobiletools.gallery.adapters.MediaAdapter
|
|||
import com.simplemobiletools.gallery.asynctasks.GetMediaAsynctask
|
||||
import com.simplemobiletools.gallery.extensions.config
|
||||
import com.simplemobiletools.gallery.extensions.getCachedMedia
|
||||
import com.simplemobiletools.gallery.helpers.SHOW_ALL
|
||||
import com.simplemobiletools.gallery.helpers.VIEW_TYPE_GRID
|
||||
import com.simplemobiletools.gallery.models.Medium
|
||||
import com.simplemobiletools.gallery.models.ThumbnailItem
|
||||
|
@ -71,7 +72,7 @@ class PickMediumDialog(val activity: BaseSimpleActivity, val path: String, val c
|
|||
}
|
||||
|
||||
val scrollHorizontally = activity.config.scrollHorizontally && isGridViewType
|
||||
val sorting = activity.config.getFileSorting(path)
|
||||
val sorting = activity.config.getFileSorting(if (path.isEmpty()) SHOW_ALL else path)
|
||||
view.apply {
|
||||
media_grid.adapter = adapter
|
||||
|
||||
|
|
|
@ -360,8 +360,9 @@ fun Context.getCachedMedia(path: String, getVideosOnly: Boolean = false, getImag
|
|||
}
|
||||
}) as ArrayList<Medium>
|
||||
|
||||
mediaFetcher.sortMedia(media, config.getFileSorting(path))
|
||||
val grouped = mediaFetcher.groupMedia(media, path)
|
||||
val pathToUse = if (path.isEmpty()) SHOW_ALL else path
|
||||
mediaFetcher.sortMedia(media, config.getFileSorting(pathToUse))
|
||||
val grouped = mediaFetcher.groupMedia(media, pathToUse)
|
||||
callback(grouped.clone() as ArrayList<ThumbnailItem>)
|
||||
|
||||
val recycleBinPath = filesDir.toString()
|
||||
|
|
Loading…
Reference in a new issue