fixed media viewer background

This commit is contained in:
Mariotaku Lee 2017-02-08 12:12:25 +08:00
parent 2aec3a3c88
commit 7840478571
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
2 changed files with 36 additions and 35 deletions

View File

@ -280,7 +280,7 @@ open class BaseActivity : ChameleonActivity(), IExtendedActivity<BaseActivity>,
override val themeBackgroundOption: String
get() = ThemeUtils.getThemeBackgroundOption(this)
protected val shouldApplyWindowBackground: Boolean
protected open val shouldApplyWindowBackground: Boolean
get() {
return true
}

View File

@ -67,10 +67,10 @@ import android.Manifest.permission as AndroidPermissions
class MediaViewerActivity : BaseActivity(), IMediaViewerActivity, MediaSwipeCloseContainer.Listener {
@Inject
lateinit var mediaFileCache: FileCache
internal lateinit var mediaFileCache: FileCache
@Inject
lateinit var mediaDownloader: MediaDownloader
internal lateinit var mediaDownloader: MediaDownloader
private var saveToStoragePosition = -1
private var shareMediaPosition = -1
@ -89,6 +89,38 @@ class MediaViewerActivity : BaseActivity(), IMediaViewerActivity, MediaSwipeClos
intent.getParcelableArrayExtra(EXTRA_MEDIA).toTypedArray(ParcelableMedia.CREATOR)
}
override val shouldApplyWindowBackground: Boolean = false
override val controlBarHeight: Int
get() {
return supportActionBar?.height ?: 0
}
override var controlBarOffset: Float
get() {
val actionBar = supportActionBar
if (actionBar != null) {
return 1 - actionBar.hideOffset / controlBarHeight.toFloat()
}
return 0f
}
set(offset) {
val actionBar = supportActionBar
if (actionBar != null && !hideOffsetNotSupported) {
if (actionBar is WindowDecorActionBar) {
val toolbar = actionBar.containerView
toolbar.alpha = offset
}
try {
actionBar.hideOffset = Math.round(controlBarHeight * (1f - offset))
} catch (e: UnsupportedOperationException) {
// Some device will throw this exception
hideOffsetNotSupported = true
}
}
notifyControlBarOffsetChanged()
}
override fun onCreate(savedInstanceState: Bundle?) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION)
@ -337,37 +369,6 @@ class MediaViewerActivity : BaseActivity(), IMediaViewerActivity, MediaSwipeClos
}
}
override val controlBarHeight: Int
get() {
return supportActionBar?.height ?: 0
}
override var controlBarOffset: Float
get() {
val actionBar = supportActionBar
if (actionBar != null) {
return 1 - actionBar.hideOffset / controlBarHeight.toFloat()
}
return 0f
}
set(offset) {
val actionBar = supportActionBar
if (actionBar != null && !hideOffsetNotSupported) {
if (actionBar is WindowDecorActionBar) {
val toolbar = actionBar.containerView
toolbar.alpha = offset
}
try {
actionBar.hideOffset = Math.round(controlBarHeight * (1f - offset))
} catch (e: UnsupportedOperationException) {
// Some device will throw this exception
hideOffsetNotSupported = true
}
}
notifyControlBarOffsetChanged()
}
override fun setControlBarVisibleAnimate(visible: Boolean, listener: ControlBarShowHideHelper.ControlBarAnimationListener?) {
controlBarShowHideHelper.setControlBarVisibleAnimate(visible, listener)
}