Skip to content

Instantly share code, notes, and snippets.

View tw-Frey's full-sized avatar

Frey tw-Frey

  • Taipei, Taiwan
View GitHub Profile
@tw-Frey
tw-Frey / Glide_Placeholders.md
Created June 17, 2022 15:08
Glide Placeholders (占位符)

Glide 允许用户指定三种不同的占位符用以适应不同的场景:

  • placeholder
  • error
  • fallback

占位符的显示流程可以参照下图: glide_placeholder_flow

@tw-Frey
tw-Frey / GPLv3.md
Created June 15, 2022 12:46 — forked from kn9ts/GPLv3.md
GPLv3 explained

GPL3 LICENSE SYNOPSIS

TL;DR* Here's what the license entails:

1. Anyone can copy, modify and distribute this software.
2. You have to include the license and copyright notice with each and every distribution.
3. You can use this software privately.
4. You can use this software for commercial purposes.
5. If you dare build your business solely from this code, you risk open-sourcing the whole code base.
@tw-Frey
tw-Frey / WebView.evaluateJavascript.md
Created June 6, 2022 13:34
透過 evaluateJavascript 取得 WebView 當前的連結

有時候用 WebView.url 得到的卻是 about:blank 或 沒有更新

例如 當使用 loadDataWithBaseURL 載頁面後, 變動 url fragment 時 WebView.url 沒有同步

有一些方式可以得到 WebView 當前連結 (含 url fragment)

下面是其中一種方式:

webView?.evaluateJavascript("location.href||''") { href ->
@tw-Frey
tw-Frey / gist:ba171f43ea16624a93d6adf8967076f1
Created May 20, 2022 12:48 — forked from minas1/gist:f920c037e511f71a1d06c9261f3307be
Exclude your own Activity from Activity.startActivity(Intent) chooser
/**
* Attempts to start an activity to handle the given intent, excluding activities of this app.
* <ul>
* <li>If the user has set a default activity (which does not belong in this app's package), it is opened without prompt.</li>
* <li>Otherwise, an intent chooser is displayed that excludes activities of this app's package.</li>
* </ul>
*
* @param context context
* @param intent intent to open
* @param chooserTitle the title that will be displayed for the intent chooser in case one needs to be displayed.
@tw-Frey
tw-Frey / ByteToHexTransform.md
Last active May 17, 2022 09:43
直接用 MD5 的 ByteArray 計算 SHA256 的 ByteArray 再串成 String

專案有一個需求

先對 某一組 String (全小寫且每次都不同) 算出 MD5

再將算出來的 MD5 轉成 Hex String 再與另一組 String(全小寫) 串成 新的 String

然後再算出 SHA256

在 Android 計算 MD5 是用

@tw-Frey
tw-Frey / Kotlin_SAM_Interface.md
Last active April 29, 2022 11:12
Kotlin SAM Interface

Kotlin SAM Interface

image

實體化時

image

A() 小括弧內的型態是已定

@tw-Frey
tw-Frey / Glide_v4.md
Created April 12, 2022 09:48
Glide v4 起 (App)GlideModule 不需要在 AndroidManifest.xml 註冊
@tw-Frey
tw-Frey / MainActivity.kt
Created April 1, 2022 12:56 — forked from pich4ya/MainActivity.kt
Android: Preventing Sensitive Information From Appearing In Background Screenshot (Recent App)
/*
@author longcat (Pichaya Morimoto)
This code snippet can be used to resolve BOT (Bank Of Thailand) mobile security requirement "insecure background"
without hurting user experience in mobile app.
Briefly, when the app is pushed into background mode (user presses the Home button)
Android phone will create screenshot of the current Activity for displaying it in recent apps menu
The recent's app screenshots will be stored at:
@tw-Frey
tw-Frey / usdc_to_glb.md
Last active May 20, 2025 19:25
USDZ convert Glb by Blender Command Line

使用 Blender 來轉換, 指令如下

Windows
blender -b -P usdz_to_glb.py -- %TIME%

Unix
blender -b -P usdz_to_glb.py -- "$(date)"