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 / 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 / Glide_Placeholders.md
Created June 17, 2022 15:08
Glide Placeholders (占位符)

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

  • placeholder
  • error
  • fallback

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

@tw-Frey
tw-Frey / applymapping_dontshrink.md
Created June 22, 2022 22:50
當開啟 Proguard/R8 時, 會發生 Android Instrumented Test 無法通過甚至無法執行

問題

當開啟 Proguard/R8 時, 會發生 Android Instrumented Test 無法通過甚至無法執行

解決方案之一

就是在 android buildType debug 裡, 新增以下 Proguard Rule:

-dontshrink
@tw-Frey
tw-Frey / ulmp.md
Created June 29, 2022 04:10
Unified layout margins and padding

Android 8.0 (API level 26) makes it easier for you to specify situations where opposite sides of a View element use the same margin or padding. Specifically, you can now use the following attributes in your layout XML files:

  • layout_marginVertical, which defines layout_marginTop and [layout_marginBottom] at the same time.
  • layout_marginHorizontal, which defines [layout_marginLeft] and [layout_marginRight] at the same time.
  • [paddingVertical], which defines [paddingTop] and [paddingBottom] at the same time.
  • [paddingHorizontal], which defines [paddingLeft] and [paddingRight] at the same time.
@tw-Frey
tw-Frey / Draw_Text_in_Deep.md
Created July 11, 2022 12:41
Draw Text in Deep (作者: xuyisheng)

文本测量

文本的测量是非常复杂,因为要适配全球几百种语言不同的排版,除了前面提到的FontMetrics,Android的渲染API还提供了很多测量文本的API。

getFontSpacing()

这个API用于获取推荐的行距。即两行文字间的baseline的距离。

这个值是系统根据文本的字体和字号自动计算的。当你使用drawText一行行绘制文字的时候,可以在换行的时候获取下一行的baseline坐标。

@tw-Frey
tw-Frey / git_show_echo_set_variable.md
Created July 11, 2022 14:22
Set output of a command as a variable (with pipes)

我想要

git show -s --format=%ci abcde12344

結果塞入 set variable

因為 command 裡有 %

@tw-Frey
tw-Frey / git-cherry-pick.md
Created July 11, 2022 14:43
git cherry-pick 保留 origin commit date

git cherry-pick 保留 origin commit date

@setlocal
@if not [%1]==[] (
	(git show -s --format=%%ci %1 & echo.)>cherry.log & (set /p GIT_COMMITTER_DATE=)<cherry.log
	git cherry-pick %1
)
@tw-Frey
tw-Frey / kotlin_same_name.md
Created July 14, 2022 08:58
Kotlin 同名接口 的真相
@tw-Frey
tw-Frey / Editable_to_Gson.md
Created July 21, 2022 23:05
Android TextView 的 Editable 輸出給 Gson 時,must do toString(),不然會以 SpannableString 轉 Json,這樣會有問題

Android TextView 的 Editable 輸出給 Gson 時,must do toString(),不然會以 SpannableString 轉 Json,這樣會有問題