Skip to content

Commit

Permalink
add internet gif and delay time
Browse files Browse the repository at this point in the history
  • Loading branch information
puutaro committed Aug 7, 2024
1 parent 68ccf70 commit 8bc9c28
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
Binary file added app/src/main/assets/res/gif/internet.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import com.puutaro.commandclick.util.file.ReadText
import com.puutaro.commandclick.util.image_tools.BitmapTool
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.io.File
Expand Down Expand Up @@ -65,6 +66,10 @@ class UrlHistoryAdapter(
context,
AssetsFileManager.urlHistoryGifPath
)
private val internetGifByteArray = AssetsFileManager.assetsByteArray(
context,
AssetsFileManager.internetGifPath
)

override fun onCreateViewHolder(
parent: ViewGroup,
Expand Down Expand Up @@ -139,6 +144,7 @@ class UrlHistoryAdapter(
setCaptureImage(
holder,
capturePngPathOrMacro,
urlStr
)
setSiteLogo(
holder,
Expand Down Expand Up @@ -189,6 +195,7 @@ class UrlHistoryAdapter(
private suspend fun setCaptureImage(
holder: UrlHistoryViewHolder,
capturePngPathOrMacro: String?,
url: String,
){
if (
context == null
Expand All @@ -198,8 +205,9 @@ class UrlHistoryAdapter(
val context = urlCaptureView.context
val isFile = !capturePngPathOrMacro.isNullOrEmpty()
&& File(capturePngPathOrMacro).isFile

val delayTime = (0..200L).random()
withContext(Dispatchers.Main) {
delay(delayTime)
when (isFile) {
true -> {
holder.urlCaptureView.imageTintList = null
Expand All @@ -217,9 +225,14 @@ class UrlHistoryAdapter(
}

else -> {
val byteArray =
if(
EnableUrlPrefix.isHttpPrefix(url)
) internetGifByteArray
else urlHistoryGifByteArray
Glide
.with(holder.urlCaptureView.context)
.load(urlHistoryGifByteArray)
.load(byteArray)
.into(holder.urlCaptureView)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ object AssetsFileManager {
const val pdfImagePingPath = "${resPngDirPath}/pdf_image.png"
const val resGifDirPath = "res/gif"
const val urlHistoryGifPath = "${resGifDirPath}/url_history.gif"
const val internetGifPath = "${resGifDirPath}/internet.gif"
private const val assetsBookmarkDirPath = "$assetsFannelsDirName/bookmark"
const val assetsClipToHistoryForBookmark = "$assetsBookmarkDirPath/clipToHistory.js"
private const val assetsDialogWebViewDirPath = "$assetsFannelsDirName/dialog_webview"
Expand Down

0 comments on commit 8bc9c28

Please sign in to comment.