some updates to starting slideshow from the thumbnails screen

This commit is contained in:
tibbi 2018-10-28 18:51:27 +01:00
parent 86a5501bf7
commit 2e097c59cb
3 changed files with 15 additions and 29 deletions

View file

@ -249,9 +249,9 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
R.id.stop_showing_hidden -> tryToggleTemporarilyShowHidden() R.id.stop_showing_hidden -> tryToggleTemporarilyShowHidden()
R.id.increase_column_count -> increaseColumnCount() R.id.increase_column_count -> increaseColumnCount()
R.id.reduce_column_count -> reduceColumnCount() R.id.reduce_column_count -> reduceColumnCount()
R.id.slideshow -> startSlideshow()
R.id.settings -> launchSettings() R.id.settings -> launchSettings()
R.id.about -> launchAbout() R.id.about -> launchAbout()
R.id.slideshow -> startSlideshow()
else -> return super.onOptionsItemSelected(item) else -> return super.onOptionsItemSelected(item)
} }
return true return true
@ -260,10 +260,8 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
private fun startSlideshow() { private fun startSlideshow() {
if (mMedia.isNotEmpty()) { if (mMedia.isNotEmpty()) {
Intent(this, ViewPagerActivity::class.java).apply { Intent(this, ViewPagerActivity::class.java).apply {
val item = mMedia[0] val item = mMedia.firstOrNull { it is Medium } as? Medium ?: return
if (item is Medium) { putExtra(PATH, item.path)
putExtra(PATH, item.path)
}
putExtra(SHOW_ALL, mShowAll) putExtra(SHOW_ALL, mShowAll)
putExtra(SLIDESHOW_START_ON_ENTER, true) putExtra(SLIDESHOW_START_ON_ENTER, true)
startActivity(this) startActivity(this)

View file

@ -53,8 +53,6 @@ import java.io.InputStream
import java.io.OutputStream import java.io.OutputStream
import java.util.* import java.util.*
private val SLIDESHOW_INITED_ON_START_KEY = "SLIDESHOW_INITED_ON_START"
class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, ViewPagerFragment.FragmentListener { class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, ViewPagerFragment.FragmentListener {
private var mPath = "" private var mPath = ""
private var mDirectory = "" private var mDirectory = ""
@ -70,7 +68,6 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
private var mSlideshowMoveBackwards = false private var mSlideshowMoveBackwards = false
private var mSlideshowMedia = mutableListOf<Medium>() private var mSlideshowMedia = mutableListOf<Medium>()
private var mAreSlideShowMediaVisible = false private var mAreSlideShowMediaVisible = false
private var mSlideshowInitedOnStart = false
private var mIsOrientationLocked = false private var mIsOrientationLocked = false
@ -104,23 +101,6 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
} }
initFavorites() initFavorites()
handleSlideshowRequest(savedInstanceState)
}
private fun handleSlideshowRequest(state: Bundle?) {
if (intent.getBooleanExtra(SLIDESHOW_START_ON_ENTER, false)) {
if (state == null || !state.getBoolean(SLIDESHOW_INITED_ON_START_KEY, false)) {
mSlideshowHandler.post {
initSlideshow()
}
}
mSlideshowInitedOnStart = true
}
}
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
outState.putBoolean(SLIDESHOW_INITED_ON_START_KEY, mSlideshowInitedOnStart)
} }
override fun onResume() { override fun onResume() {
@ -243,6 +223,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
if (!isDestroyed) { if (!isDestroyed) {
if (mMediaFiles.isNotEmpty()) { if (mMediaFiles.isNotEmpty()) {
gotMedia(mMediaFiles as ArrayList<ThumbnailItem>) gotMedia(mMediaFiles as ArrayList<ThumbnailItem>)
checkSlideshowOnEnter()
} }
} }
} }
@ -268,6 +249,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
} else { } else {
visibility and View.SYSTEM_UI_FLAG_FULLSCREEN != 0 visibility and View.SYSTEM_UI_FLAG_FULLSCREEN != 0
} }
view_pager.adapter?.let { view_pager.adapter?.let {
(it as MyPagerAdapter).toggleFullscreen(mIsFullScreen) (it as MyPagerAdapter).toggleFullscreen(mIsFullScreen)
checkSystemUI() checkSystemUI()
@ -389,6 +371,12 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
} }
} }
private fun checkSlideshowOnEnter() {
if (intent.getBooleanExtra(SLIDESHOW_START_ON_ENTER, false)) {
initSlideshow()
}
}
private fun initSlideshow() { private fun initSlideshow() {
SlideshowDialog(this) { SlideshowDialog(this) {
startSlideshow() startSlideshow()

View file

@ -79,6 +79,10 @@
android:id="@+id/reduce_column_count" android:id="@+id/reduce_column_count"
android:title="@string/reduce_column_count" android:title="@string/reduce_column_count"
app:showAsAction="never"/> app:showAsAction="never"/>
<item
android:id="@+id/slideshow"
android:title="@string/slideshow"
app:showAsAction="never"/>
<item <item
android:id="@+id/settings" android:id="@+id/settings"
android:title="@string/settings" android:title="@string/settings"
@ -87,8 +91,4 @@
android:id="@+id/about" android:id="@+id/about"
android:title="@string/about" android:title="@string/about"
app:showAsAction="never"/> app:showAsAction="never"/>
<item
android:id="@+id/slideshow"
android:title="@string/slideshow"
app:showAsAction="never"/>
</menu> </menu>