mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 04:57:59 +01:00
show an error toast earlier if every media is filtered out at slideshow
This commit is contained in:
parent
067798e5c2
commit
848c6c5667
1 changed files with 14 additions and 6 deletions
|
@ -6,6 +6,7 @@ import android.view.View
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import com.simplemobiletools.commons.extensions.hideKeyboard
|
import com.simplemobiletools.commons.extensions.hideKeyboard
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
|
import com.simplemobiletools.commons.extensions.toast
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.activities.SimpleActivity
|
import com.simplemobiletools.gallery.activities.SimpleActivity
|
||||||
import com.simplemobiletools.gallery.extensions.config
|
import com.simplemobiletools.gallery.extensions.config
|
||||||
|
@ -14,7 +15,6 @@ import kotlinx.android.synthetic.main.dialog_slideshow.view.*
|
||||||
|
|
||||||
|
|
||||||
class SlideshowDialog(val activity: SimpleActivity, val callback: () -> Unit) {
|
class SlideshowDialog(val activity: SimpleActivity, val callback: () -> Unit) {
|
||||||
val dialog: AlertDialog
|
|
||||||
val view: View
|
val view: View
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
@ -64,12 +64,22 @@ class SlideshowDialog(val activity: SimpleActivity, val callback: () -> Unit) {
|
||||||
}
|
}
|
||||||
setupValues()
|
setupValues()
|
||||||
|
|
||||||
dialog = AlertDialog.Builder(activity)
|
AlertDialog.Builder(activity)
|
||||||
.setPositiveButton(R.string.ok, { dialog, which -> dialogConfirmed() })
|
.setPositiveButton(R.string.ok, null)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.create().apply {
|
.create().apply {
|
||||||
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)
|
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)
|
||||||
activity.setupDialogStuff(view, this)
|
activity.setupDialogStuff(view, this)
|
||||||
|
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
|
||||||
|
if (!view.include_photos.isChecked && !view.include_videos.isChecked && !view.include_gifs.isChecked) {
|
||||||
|
activity.toast(R.string.no_media_for_slideshow)
|
||||||
|
return@setOnClickListener
|
||||||
|
}
|
||||||
|
|
||||||
|
storeValues()
|
||||||
|
callback()
|
||||||
|
dismiss()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +96,7 @@ class SlideshowDialog(val activity: SimpleActivity, val callback: () -> Unit) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun dialogConfirmed() {
|
private fun storeValues() {
|
||||||
var interval = view.interval_value.text.toString()
|
var interval = view.interval_value.text.toString()
|
||||||
if (interval.trim('0').isEmpty())
|
if (interval.trim('0').isEmpty())
|
||||||
interval = SLIDESHOW_DEFAULT_INTERVAL.toString()
|
interval = SLIDESHOW_DEFAULT_INTERVAL.toString()
|
||||||
|
@ -100,7 +110,5 @@ class SlideshowDialog(val activity: SimpleActivity, val callback: () -> Unit) {
|
||||||
slideshowUseFade = view.use_fade.isChecked
|
slideshowUseFade = view.use_fade.isChecked
|
||||||
slideshowMoveBackwards = view.move_backwards.isChecked
|
slideshowMoveBackwards = view.move_backwards.isChecked
|
||||||
}
|
}
|
||||||
dialog.dismiss()
|
|
||||||
callback()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue