diff options
author | Allan Wang <me@allanwang.ca> | 2019-01-05 00:10:25 -0500 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2019-01-05 00:10:25 -0500 |
commit | 495df6c84bb7a0daf8cea789f03396b6dabcdf2d (patch) | |
tree | 022a83435995a8d467e6bd0a778a1a84a196393a /app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt | |
parent | 765c74196042430bb2c5b1a0d522da20a4485dc4 (diff) | |
download | frost-495df6c84bb7a0daf8cea789f03396b6dabcdf2d.tar.gz frost-495df6c84bb7a0daf8cea789f03396b6dabcdf2d.tar.bz2 frost-495df6c84bb7a0daf8cea789f03396b6dabcdf2d.zip |
Remove reactivex from debugger
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.kt | 13 |
1 files changed, 8 insertions, 5 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 22668309..d2b53ab5 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt @@ -23,7 +23,6 @@ import android.graphics.Color import android.util.AttributeSet import android.view.View import android.webkit.WebView -import androidx.annotation.WorkerThread import ca.allanwang.kau.utils.withAlpha import com.pitchedapps.frost.facebook.USER_AGENT_BASIC import com.pitchedapps.frost.injectors.CssAssets @@ -33,6 +32,8 @@ import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.Prefs import com.pitchedapps.frost.utils.createFreshFile import com.pitchedapps.frost.utils.isFacebookUrl +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext import java.io.File /** @@ -61,14 +62,16 @@ class DebugWebView @JvmOverloads constructor( isDrawingCacheEnabled = true } - @WorkerThread - fun getScreenshot(output: File): Boolean { + /** + * Fetches a screenshot of the current webview, returning true if successful, false otherwise. + */ + suspend fun getScreenshot(output: File): Boolean = withContext(Dispatchers.IO) { if (!output.createFreshFile()) { L.e { "Failed to create ${output.absolutePath} for debug screenshot" } - return false + return@withContext false } - return try { + try { output.outputStream().use { drawingCache.compress(Bitmap.CompressFormat.PNG, 100, it) } |