diff options
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt | 54 |
1 files changed, 42 insertions, 12 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt index b2796999..c2535940 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt @@ -1,3 +1,19 @@ +/* + * Copyright 2018 Allan Wang + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package com.pitchedapps.frost.views import android.content.Context @@ -8,11 +24,22 @@ import android.util.AttributeSet import android.view.MotionEvent import android.view.ViewTreeObserver import android.widget.FrameLayout -import ca.allanwang.kau.utils.* +import ca.allanwang.kau.utils.fadeIn +import ca.allanwang.kau.utils.fadeOut +import ca.allanwang.kau.utils.gone +import ca.allanwang.kau.utils.goneIf +import ca.allanwang.kau.utils.inflate +import ca.allanwang.kau.utils.isColorDark +import ca.allanwang.kau.utils.isGone +import ca.allanwang.kau.utils.isVisible +import ca.allanwang.kau.utils.setIcon +import ca.allanwang.kau.utils.setMenuIcons +import ca.allanwang.kau.utils.visible +import ca.allanwang.kau.utils.withMinAlpha import com.devbrackets.android.exomedia.listener.VideoControlsVisibilityListener import com.mikepenz.google_material_typeface_library.GoogleMaterial -import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.R +import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.Prefs import com.pitchedapps.frost.utils.frostDownload import kotlinx.android.synthetic.main.view_video.view.* @@ -21,7 +48,9 @@ import kotlinx.android.synthetic.main.view_video.view.* * Created by Allan Wang on 2017-10-13. */ class FrostVideoViewer @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 ) : FrameLayout(context, attrs, defStyleAttr), FrostVideoViewerContract { companion object { @@ -51,16 +80,18 @@ class FrostVideoViewer @JvmOverloads constructor( inflate(R.layout.view_video, true) alpha = 0f video_background.setBackgroundColor( - if (!Prefs.blackMediaBg && Prefs.bgColor.isColorDark) - Prefs.bgColor.withMinAlpha(200) - else - Color.BLACK) + if (!Prefs.blackMediaBg && Prefs.bgColor.isColorDark) + Prefs.bgColor.withMinAlpha(200) + else + Color.BLACK + ) video.setViewerContract(this) video.pause() video_toolbar.inflateMenu(R.menu.menu_video) - context.setMenuIcons(video_toolbar.menu, Prefs.iconColor, - R.id.action_pip to GoogleMaterial.Icon.gmd_picture_in_picture_alt, - R.id.action_download to GoogleMaterial.Icon.gmd_file_download + context.setMenuIcons( + video_toolbar.menu, Prefs.iconColor, + R.id.action_pip to GoogleMaterial.Icon.gmd_picture_in_picture_alt, + R.id.action_download to GoogleMaterial.Icon.gmd_file_download ) video_toolbar.setOnMenuItemClickListener { when (it.itemId) { @@ -141,7 +172,6 @@ class FrostVideoViewer @JvmOverloads constructor( if (!video_toolbar.isGone) video_toolbar.fadeOut(duration = CONTROL_ANIMATION_DURATION) { video_toolbar.gone() } } - } interface FrostVideoViewerContract : VideoControlsVisibilityListener { @@ -171,4 +201,4 @@ interface FrostVideoContainerContract { * Called once the video has stopped & should be removed */ fun onVideoFinished() -}
\ No newline at end of file +} |