aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-03-11 19:24:32 -0400
committerGitHub <noreply@github.com>2018-03-11 19:24:32 -0400
commitfe51373f5a95323d64f6d966888a2c6c62a36deb (patch)
tree328bf7ab5bf00f01e070e9d84ff71cac59b0ecf1 /app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt
parent67988a25d83fc10b187fcc821c3ceacfad0195d5 (diff)
downloadfrost-fe51373f5a95323d64f6d966888a2c6c62a36deb.tar.gz
frost-fe51373f5a95323d64f6d966888a2c6c62a36deb.tar.bz2
frost-fe51373f5a95323d64f6d966888a2c6c62a36deb.zip
Enhancement/debug mode (#779)
* Update changelog * Improve debugger * Remove need for mapping urls * Remove excess logs * Clean up
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt30
1 files changed, 12 insertions, 18 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt
index 7fd2286c..4ac9e600 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt
@@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.content.Context
import android.graphics.Bitmap
import android.graphics.Color
+import android.support.annotation.WorkerThread
import android.util.AttributeSet
import android.view.View
import android.webkit.WebView
@@ -16,8 +17,6 @@ import com.pitchedapps.frost.utils.Prefs
import com.pitchedapps.frost.utils.createFreshFile
import com.pitchedapps.frost.utils.iab.IS_FROST_PRO
import com.pitchedapps.frost.utils.isFacebookUrl
-import org.jetbrains.anko.doAsync
-import org.jetbrains.anko.uiThread
import org.jetbrains.anko.withAlpha
import java.io.File
@@ -45,27 +44,22 @@ class DebugWebView @JvmOverloads constructor(
isDrawingCacheEnabled = true
}
- fun getScreenshot(output: File, callback: (Boolean) -> Unit) {
+ @WorkerThread
+ fun getScreenshot(output: File): Boolean {
if (!output.createFreshFile()) {
L.e { "Failed to create ${output.absolutePath} for debug screenshot" }
- return callback(false)
+ return false
}
- doAsync {
- var valid = true
- try {
- output.outputStream().use {
- drawingCache.compress(Bitmap.CompressFormat.PNG, 100, it)
- }
- L.d { "Created screenshot at ${output.absolutePath}" }
- } catch (e: Exception) {
- L.e { "An error occurred ${e.message}" }
- valid = false
- } finally {
- uiThread {
- callback(valid)
- }
+ return try {
+ output.outputStream().use {
+ drawingCache.compress(Bitmap.CompressFormat.PNG, 100, it)
}
+ L.d { "Created screenshot at ${output.absolutePath}" }
+ true
+ } catch (e: Exception) {
+ L.e { "An error occurred ${e.message}" }
+ false
}
}