diff --git a/app/src/main/java/com/ismartcoding/plain/ui/extensions/TextView.kt b/app/src/main/java/com/ismartcoding/plain/ui/extensions/TextView.kt index c9951e63..6483987b 100644 --- a/app/src/main/java/com/ismartcoding/plain/ui/extensions/TextView.kt +++ b/app/src/main/java/com/ismartcoding/plain/ui/extensions/TextView.kt @@ -8,6 +8,7 @@ import android.view.MotionEvent import android.widget.TextView import androidx.core.view.GestureDetectorCompat import com.ismartcoding.lib.extensions.dp2px +import com.ismartcoding.lib.logcat.LogCat import com.ismartcoding.lib.markdown.AppImageSchemeHandler import com.ismartcoding.lib.markdown.FontTagHandler import com.ismartcoding.lib.markdown.NetworkSchemeHandler diff --git a/app/src/main/java/com/ismartcoding/plain/ui/preview/viewholders/SubsamplingViewHolder.kt b/app/src/main/java/com/ismartcoding/plain/ui/preview/viewholders/SubsamplingViewHolder.kt index bbfe1335..d5fb9625 100644 --- a/app/src/main/java/com/ismartcoding/plain/ui/preview/viewholders/SubsamplingViewHolder.kt +++ b/app/src/main/java/com/ismartcoding/plain/ui/preview/viewholders/SubsamplingViewHolder.kt @@ -11,6 +11,7 @@ import com.davemorrissey.labs.subscaleview.ImageSource import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView import com.ismartcoding.lib.helpers.CoroutinesHelper.coMain import com.ismartcoding.plain.databinding.ItemImageviewerSubsamplingBinding +import com.ismartcoding.plain.ui.helpers.DialogHelper import com.ismartcoding.plain.ui.preview.PreviewItem import com.ismartcoding.plain.ui.preview.utils.initTag import kotlinx.coroutines.delay @@ -26,31 +27,37 @@ class SubsamplingViewHolder( fun bind(item: PreviewItem) { val holder = this - binding.loading.isVisible = true binding.subsamplingView.run { initTag(item, holder) orientation = SubsamplingScaleImageView.ORIENTATION_USE_EXIF coMain { - delay(100) - binding.loading.isVisible = false - if (item.uri.startsWith("http://") || item.uri.startsWith("https://")) { + if (item.uri.startsWith("http://", true) || item.uri.startsWith("https://", true)) { val request = ImageRequest.Builder(context) .data(item.uri) .target( onStart = { _ -> + binding.loading.isVisible = true }, onSuccess = { result -> + binding.loading.isVisible = false val bitmap = (result as? BitmapDrawable)?.bitmap if (bitmap != null) { setImage(ImageSource.bitmap(bitmap)) } }, onError = { _ -> + binding.loading.isVisible = false } ) .build() context.imageLoader.enqueue(request) + } else if (item.uri.startsWith("app://", true)) { + val path = context.getExternalFilesDir(null)?.path?.removeSuffix("/") + "/" + item.uri.substring("app://".length) + setImage(ImageSource.uri(path)) } else { + binding.loading.isVisible = true + delay(100) + binding.loading.isVisible = false setImage(ImageSource.uri(item.uri)) } }