couple changes related to toggling fullscreen
This commit is contained in:
parent
bb81275b79
commit
d3d64865af
|
@ -98,6 +98,11 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
|
|||
} finally {
|
||||
cursor?.close()
|
||||
}
|
||||
|
||||
window.decorView.setOnSystemUiVisibilityChangeListener { visibility ->
|
||||
val isFullscreen = visibility and View.SYSTEM_UI_FLAG_FULLSCREEN != 0
|
||||
mFragment.fullscreenToggled(isFullscreen)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
@ -157,13 +162,4 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
|
|||
showSystemUI()
|
||||
}
|
||||
}
|
||||
|
||||
override fun systemUiVisibilityChanged(visibility: Int) {
|
||||
if (visibility and View.SYSTEM_UI_FLAG_FULLSCREEN == 0) {
|
||||
mIsFullScreen = false
|
||||
showSystemUI()
|
||||
} else {
|
||||
mIsFullScreen = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,6 +112,14 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
|
||||
if (config.hideSystemUI)
|
||||
fragmentClicked()
|
||||
|
||||
window.decorView.setOnSystemUiVisibilityChangeListener { visibility ->
|
||||
mIsFullScreen = visibility and View.SYSTEM_UI_FLAG_FULLSCREEN != 0
|
||||
view_pager.adapter?.let {
|
||||
(it as MyPagerAdapter).toggleFullscreen(mIsFullScreen)
|
||||
checkSystemUI()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
@ -445,6 +453,10 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
|
||||
override fun fragmentClicked() {
|
||||
mIsFullScreen = !mIsFullScreen
|
||||
checkSystemUI()
|
||||
}
|
||||
|
||||
private fun checkSystemUI() {
|
||||
if (mIsFullScreen) {
|
||||
hideSystemUI()
|
||||
} else {
|
||||
|
@ -452,15 +464,6 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
}
|
||||
}
|
||||
|
||||
override fun systemUiVisibilityChanged(visibility: Int) {
|
||||
if (visibility and View.SYSTEM_UI_FLAG_FULLSCREEN == 0) {
|
||||
mIsFullScreen = false
|
||||
showSystemUI()
|
||||
} else {
|
||||
mIsFullScreen = true
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateActionbarTitle() {
|
||||
runOnUiThread {
|
||||
if (mPos < mMedia.size) {
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.support.v4.app.Fragment
|
|||
import android.support.v4.app.FragmentManager
|
||||
import android.support.v4.app.FragmentStatePagerAdapter
|
||||
import android.support.v4.view.PagerAdapter
|
||||
import android.util.SparseArray
|
||||
import android.view.ViewGroup
|
||||
import com.simplemobiletools.gallery.activities.ViewPagerActivity
|
||||
import com.simplemobiletools.gallery.fragments.PhotoFragment
|
||||
|
@ -15,7 +14,7 @@ import com.simplemobiletools.gallery.helpers.MEDIUM
|
|||
import com.simplemobiletools.gallery.models.Medium
|
||||
|
||||
class MyPagerAdapter(val activity: ViewPagerActivity, fm: FragmentManager, val media: MutableList<Medium>) : FragmentStatePagerAdapter(fm) {
|
||||
private val mFragments = SparseArray<ViewPagerFragment>()
|
||||
private val mFragments = HashMap<Int, ViewPagerFragment>()
|
||||
override fun getCount() = media.size
|
||||
|
||||
override fun getItem(position: Int): Fragment {
|
||||
|
@ -49,4 +48,10 @@ class MyPagerAdapter(val activity: ViewPagerActivity, fm: FragmentManager, val m
|
|||
}
|
||||
|
||||
fun getCurrentFragment(position: Int) = mFragments.get(position)
|
||||
|
||||
fun toggleFullscreen(isFullscreen: Boolean) {
|
||||
for ((pos, fragment) in mFragments) {
|
||||
fragment.fullscreenToggled(isFullscreen)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,6 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
lateinit var view: ViewGroup
|
||||
private var isFragmentVisible = false
|
||||
private var wasInit = false
|
||||
private var RATIO_THRESHOLD = 0.1
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
view = inflater.inflate(R.layout.pager_photo_item, container, false) as ViewGroup
|
||||
|
@ -100,9 +99,6 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
}
|
||||
loadImage()
|
||||
|
||||
activity.window.decorView.setOnSystemUiVisibilityChangeListener { visibility ->
|
||||
listener?.systemUiVisibilityChanged(visibility)
|
||||
}
|
||||
wasInit = true
|
||||
|
||||
return view
|
||||
|
@ -256,4 +252,8 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
private fun photoClicked() {
|
||||
listener?.fragmentClicked()
|
||||
}
|
||||
|
||||
override fun fullscreenToggled(isFullscreen: Boolean) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,12 +60,6 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
}
|
||||
|
||||
mIsFullscreen = activity.window.decorView.systemUiVisibility and View.SYSTEM_UI_FLAG_FULLSCREEN == View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
|
||||
activity.window.decorView.setOnSystemUiVisibilityChangeListener { visibility ->
|
||||
mIsFullscreen = visibility and View.SYSTEM_UI_FLAG_FULLSCREEN != 0
|
||||
checkFullscreen()
|
||||
listener?.systemUiVisibilityChanged(visibility)
|
||||
}
|
||||
checkFullscreen()
|
||||
|
||||
return mView
|
||||
|
@ -114,8 +108,6 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
}
|
||||
|
||||
private fun toggleFullscreen() {
|
||||
mIsFullscreen = !mIsFullscreen
|
||||
checkFullscreen()
|
||||
listener?.fragmentClicked()
|
||||
}
|
||||
|
||||
|
@ -372,4 +364,9 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
|
||||
mIsDragged = false
|
||||
}
|
||||
|
||||
override fun fullscreenToggled(isFullscreen: Boolean) {
|
||||
mIsFullscreen = isFullscreen
|
||||
checkFullscreen()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@ import android.support.v4.app.Fragment
|
|||
abstract class ViewPagerFragment : Fragment() {
|
||||
var listener: FragmentListener? = null
|
||||
|
||||
abstract fun fullscreenToggled(isFullscreen: Boolean)
|
||||
|
||||
interface FragmentListener {
|
||||
fun fragmentClicked()
|
||||
|
||||
fun systemUiVisibilityChanged(visibility: Int)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue