Merge pull request #1031 from Austry/slideshow-on-media-list
Support slideshow option on media list
This commit is contained in:
commit
86a5501bf7
4 changed files with 41 additions and 1 deletions
|
@ -251,11 +251,26 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
R.id.reduce_column_count -> reduceColumnCount()
|
R.id.reduce_column_count -> reduceColumnCount()
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun startSlideshow() {
|
||||||
|
if (mMedia.isNotEmpty()) {
|
||||||
|
Intent(this, ViewPagerActivity::class.java).apply {
|
||||||
|
val item = mMedia[0]
|
||||||
|
if (item is Medium) {
|
||||||
|
putExtra(PATH, item.path)
|
||||||
|
}
|
||||||
|
putExtra(SHOW_ALL, mShowAll)
|
||||||
|
putExtra(SLIDESHOW_START_ON_ENTER, true)
|
||||||
|
startActivity(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun storeStateVariables() {
|
private fun storeStateVariables() {
|
||||||
config.apply {
|
config.apply {
|
||||||
mStoredAnimateGifs = animateGifs
|
mStoredAnimateGifs = animateGifs
|
||||||
|
|
|
@ -53,6 +53,8 @@ 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 = ""
|
||||||
|
@ -68,6 +70,8 @@ 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
|
||||||
|
|
||||||
private var mMediaFiles = ArrayList<Medium>()
|
private var mMediaFiles = ArrayList<Medium>()
|
||||||
|
@ -100,6 +104,23 @@ 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() {
|
||||||
|
@ -247,7 +268,6 @@ 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()
|
||||||
|
|
|
@ -76,6 +76,7 @@ const val SLIDESHOW_MOVE_BACKWARDS = "slideshow_move_backwards"
|
||||||
const val SLIDESHOW_LOOP = "loop_slideshow"
|
const val SLIDESHOW_LOOP = "loop_slideshow"
|
||||||
const val SLIDESHOW_DEFAULT_INTERVAL = 5
|
const val SLIDESHOW_DEFAULT_INTERVAL = 5
|
||||||
const val SLIDESHOW_SCROLL_DURATION = 500L
|
const val SLIDESHOW_SCROLL_DURATION = 500L
|
||||||
|
const val SLIDESHOW_START_ON_ENTER= "slideshow_start_on_enter"
|
||||||
|
|
||||||
const val NOMEDIA = ".nomedia"
|
const val NOMEDIA = ".nomedia"
|
||||||
const val FAVORITES = "favorites"
|
const val FAVORITES = "favorites"
|
||||||
|
|
|
@ -87,4 +87,8 @@
|
||||||
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>
|
||||||
|
|
Loading…
Reference in a new issue