properly show/hide extended details after toggle

This commit is contained in:
tibbi 2017-10-18 22:00:27 +02:00
parent 2e339f08e4
commit 3fffe1eef1
2 changed files with 35 additions and 15 deletions

View file

@ -39,10 +39,12 @@ import java.io.FileOutputStream
import java.io.IOException import java.io.IOException
class PhotoFragment : ViewPagerFragment() { class PhotoFragment : ViewPagerFragment() {
lateinit var medium: Medium
lateinit var view: ViewGroup
private var isFragmentVisible = false private var isFragmentVisible = false
private var wasInit = false private var wasInit = false
private var storedShowExtendedDetails = false
lateinit var view: ViewGroup
lateinit var medium: Medium
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
view = inflater.inflate(R.layout.pager_photo_item, container, false) as ViewGroup view = inflater.inflate(R.layout.pager_photo_item, container, false) as ViewGroup
@ -104,6 +106,18 @@ class PhotoFragment : ViewPagerFragment() {
return view return view
} }
override fun onPause() {
super.onPause()
storedShowExtendedDetails = context.config.showExtendedDetails
}
override fun onResume() {
super.onResume()
if (wasInit && context.config.showExtendedDetails != storedShowExtendedDetails) {
checkExtendedDetails()
}
}
override fun setMenuVisibility(menuVisible: Boolean) { override fun setMenuVisibility(menuVisible: Boolean) {
super.setMenuVisibility(menuVisible) super.setMenuVisibility(menuVisible)
isFragmentVisible = menuVisible isFragmentVisible = menuVisible

View file

@ -43,6 +43,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
private var mIsFullscreen = false private var mIsFullscreen = false
private var mIsFragmentVisible = false private var mIsFragmentVisible = false
private var mPlayOnPrepare = false private var mPlayOnPrepare = false
private var mStoredShowExtendedDetails = false
private var mCurrTime = 0 private var mCurrTime = 0
private var mDuration = 0 private var mDuration = 0
@ -87,6 +88,24 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
activity.updateTextColors(mView.video_holder) activity.updateTextColors(mView.video_holder)
mView.video_volume_controller.beVisibleIf(context.config.allowVideoGestures) mView.video_volume_controller.beVisibleIf(context.config.allowVideoGestures)
mView.video_brightness_controller.beVisibleIf(context.config.allowVideoGestures) mView.video_brightness_controller.beVisibleIf(context.config.allowVideoGestures)
if (context.config.showExtendedDetails != mStoredShowExtendedDetails) {
checkExtendedDetails()
}
}
override fun onPause() {
super.onPause()
pauseVideo()
mIsFragmentVisible = false
mStoredShowExtendedDetails = context.config.showExtendedDetails
}
override fun onDestroy() {
super.onDestroy()
if (activity?.isChangingConfigurations == false) {
cleanup()
}
} }
private fun setupPlayer() { private fun setupPlayer() {
@ -396,19 +415,6 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
mMediaPlayer!!.pause() mMediaPlayer!!.pause()
} }
override fun onPause() {
super.onPause()
pauseVideo()
mIsFragmentVisible = false
}
override fun onDestroy() {
super.onDestroy()
if (activity?.isChangingConfigurations == false) {
cleanup()
}
}
private fun cleanup() { private fun cleanup() {
pauseVideo() pauseVideo()
mCurrTimeView?.text = 0.getFormattedDuration() mCurrTimeView?.text = 0.getFormattedDuration()