aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt7
1 files changed, 6 insertions, 1 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt
index ca88a23e..e8f9fee9 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt
@@ -3,11 +3,13 @@ package com.pitchedapps.frost.web
import com.pitchedapps.frost.activities.WebOverlayActivity
import com.pitchedapps.frost.activities.WebOverlayActivityBase
import com.pitchedapps.frost.activities.WebOverlayBasicActivity
+
import com.pitchedapps.frost.contracts.VideoViewHolder
import com.pitchedapps.frost.facebook.FbItem
import com.pitchedapps.frost.facebook.USER_AGENT_BASIC
import com.pitchedapps.frost.facebook.formattedFbUrl
import com.pitchedapps.frost.utils.*
+import org.jetbrains.anko.runOnUiThread
/**
* Created by Allan Wang on 2017-08-15.
@@ -18,6 +20,9 @@ import com.pitchedapps.frost.utils.*
* This helper method will collect all known cases and launch the overlay accordingly
* Returns {@code true} (default) if action is consumed, {@code false} otherwise
*
+ * Note that this is not always called on the main thread!
+ * UI related methods should always be posted or they may not be properly executed.
+ *
* If the request already comes from an instance of [WebOverlayActivity], we will then judge
* whether the user agent string should be changed. All propagated results will return false,
* as we have no need of sending a new intent to the same activity
@@ -26,7 +31,7 @@ fun FrostWebViewCore.requestWebOverlay(url: String): Boolean {
if (url == "#") return false
if (url.isVideoUrl && context is VideoViewHolder) {
L.i("Found video", url)
- (context as VideoViewHolder).showVideo(url)
+ context.runOnUiThread { (context as VideoViewHolder).showVideo(url) }
return true
}
if (!Prefs.overlayEnabled) return false