aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2021-11-19 21:31:35 -0800
committerAllan Wang <me@allanwang.ca>2021-11-19 21:31:35 -0800
commite6a45b29cae18161edd05337ae6ba3482ba3068c (patch)
treefcfa9c09b22b7ddcd5102826ac794373a535be79 /app/src/main/kotlin
parent2ee9bffe2a0a39f5fe1d44f82d9c5735b69803c6 (diff)
downloadfrost-e6a45b29cae18161edd05337ae6ba3482ba3068c.tar.gz
frost-e6a45b29cae18161edd05337ae6ba3482ba3068c.tar.bz2
frost-e6a45b29cae18161edd05337ae6ba3482ba3068c.zip
Delete unused code
Diffstat (limited to 'app/src/main/kotlin')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt57
1 files changed, 0 insertions, 57 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt
index da991236..0f1cf4a5 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt
@@ -113,8 +113,6 @@ class ImageActivity : KauBaseActivity() {
* Linked to the uri provider
*/
private const val IMAGE_FOLDER = "images"
- private const val TIME_FORMAT = "yyyyMMdd_HHmmss"
- private const val IMG_TAG = "Frost"
const val PURGE_TIME: Long = 10 * 60 * 1000 // 10 min block
private val L = KauLoggerExtension("Image", com.pitchedapps.frost.utils.L)
@@ -130,11 +128,6 @@ class ImageActivity : KauBaseActivity() {
private val imageText: String? by lazy { intent.getStringExtra(ARG_TEXT) }
- // a unique image identifier based on the id (if it exists), and its hash
- private val imageHash: String by lazy {
- "${abs(FB_IMAGE_ID_MATCHER.find(imageUrl)[1]?.hashCode() ?: 0)}_${abs(imageUrl.hashCode())}"
- }
-
lateinit var binding: ActivityImageBinding
private var bottomBehavior: BottomSheetBehavior<View>? = null
@@ -177,8 +170,6 @@ class ImageActivity : KauBaseActivity() {
setContentView(binding.root)
binding.init()
launch(CoroutineExceptionHandler { _, throwable -> loadError(throwable) }) {
-// val tempFile = downloadTempImage()
-// this@ImageActivity.tempFile = tempFile
binding.showImage(trueImageUrl.await())
}
}
@@ -328,54 +319,6 @@ class ImageActivity : KauBaseActivity() {
override fun clampViewPositionVertical(child: View, top: Int, dy: Int): Int = top
}
- private fun getImageExtension(type: String?): String? {
- if (type?.startsWith("image/") != true) {
- return null
- }
- return when (type.substring(6)) {
- "jpeg" -> "jpg"
- "png" -> "png"
- "gif" -> "gif"
- else -> null
- }
- }
-
- @Throws(IOException::class)
- private suspend fun downloadTempImage(): File = withContext(Dispatchers.IO) {
-
- // We assume all images are jpg
- // Activity launcher may be able to provide specifics, but this beats sending a request
- // just to get the content header
- val file = File(cacheDir(this@ImageActivity), "$imageHash.jpg")
-
- if (!file.isFile) {
- file.parentFile?.mkdirs()
- file.createNewFile()
- } else {
- file.setLastModified(System.currentTimeMillis())
- }
-
- // Forbid overwrites
- if (file.isFile && file.length() > 0) {
- L.i { "Forbid image overwrite" }
- return@withContext file
- }
-
- val response = cookie.requestBuilder()
- .url(trueImageUrl.await())
- .get()
- .call()
- .execute()
-
- if (!response.isSuccessful) {
- throw IOException("Unsuccessful response for image: ${response.peekBody(128).string()}")
- }
-
- val body = response.body ?: throw IOException("Failed to retrieve image body")
- file.copyFromInputStream(body.byteStream())
- file
- }
-
internal suspend fun saveImage() {
frostDownload(cookie = cookie, url = trueImageUrl.await())
}