aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-12-12 00:52:12 -0500
committerGitHub <noreply@github.com>2017-12-12 00:52:12 -0500
commit82f9aca96493316bc62008f2b3167d34a6029b38 (patch)
tree665f2a450b7b2d9ee8f9abc35d25007c1db81ef3 /app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt
parentb90dcc04376b48d2b91fea8a5de48acbd7f885c4 (diff)
downloadfrost-82f9aca96493316bc62008f2b3167d34a6029b38.tar.gz
frost-82f9aca96493316bc62008f2b3167d34a6029b38.tar.bz2
frost-82f9aca96493316bc62008f2b3167d34a6029b38.zip
Update/intro (#550)v1.7.0
* Add edit button to intro * Update readme * Fix video error and cancellation * Update changelog * Hide invalid tab options
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt15
1 files changed, 13 insertions, 2 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt
index 9d5e199a..4e3aa097 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt
@@ -8,11 +8,14 @@ import android.util.AttributeSet
import android.view.GestureDetector
import android.view.MotionEvent
import android.view.View
+import android.widget.Toast
import ca.allanwang.kau.ui.ProgressAnimator
import ca.allanwang.kau.utils.AnimHolder
import ca.allanwang.kau.utils.dpToPx
import ca.allanwang.kau.utils.scaleXY
+import ca.allanwang.kau.utils.toast
import com.devbrackets.android.exomedia.ui.widget.VideoView
+import com.pitchedapps.frost.R
import com.pitchedapps.frost.utils.L
/**
@@ -58,8 +61,6 @@ class FrostVideoView @JvmOverloads constructor(
var isExpanded: Boolean = true
set(value) {
if (field == value) return
- if (videoDimensions.x <= 0f || videoDimensions.y <= 0f)
- return L.d("Attempted to toggle video expansion when points have not been finalized")
field = value
val origX = translationX
val origY = translationY
@@ -96,6 +97,11 @@ class FrostVideoView @JvmOverloads constructor(
* and return the necessary transitions to get there
*/
private fun mapBounds(): Triple<Float, Float, Float> {
+ if (videoDimensions.x <= 0f || videoDimensions.y <= 0f) {
+ L.d("Attempted to toggle video expansion when points have not been finalized")
+ val dimen = Math.min(height, width).toFloat()
+ videoDimensions.set(dimen, dimen)
+ }
val portrait = height > width
val scale = Math.min(height / (if (portrait) 4f else 2.3f) / videoDimensions.y, width / (if (portrait) 2.3f else 4f) / videoDimensions.x)
val desiredHeight = scale * videoDimensions.y
@@ -124,6 +130,11 @@ class FrostVideoView @JvmOverloads constructor(
start()
if (isExpanded) showControls()
}
+ setOnErrorListener {
+ toast(R.string.video_load_failed, Toast.LENGTH_SHORT)
+ destroy()
+ true
+ }
setOnCompletionListener {
if (repeat) restart()
else viewerContract.onVideoComplete()