This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -o errexit | |
set -o pipefail | |
set -o nounset | |
OIFS="$IFS" | |
IFS=$'\n' | |
info () { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.graphics.Bitmap | |
import com.google.zxing.BarcodeFormat | |
import com.google.zxing.EncodeHintType | |
import com.google.zxing.MultiFormatWriter | |
import com.google.zxing.common.BitMatrix | |
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel | |
object BarcodeEncoder { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BooleanTypeAdapterTest { | |
@Test | |
fun testBooleanTypeAdapter() { | |
val gson = GsonBuilder() | |
.registerTypeAdapter(Boolean::class.javaObjectType, BooleanObjectTypeAdapter()) | |
.registerTypeAdapter(Boolean::class.javaPrimitiveType, BooleanPrimitiveTypeAdapter()) | |
.create() | |
assertEquals(null, gson.fromJson("""{"isBoolean"=null}""", Foo::class.java).isBoolean) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object RecyclerViewUtils { | |
fun <VH : RecyclerView.ViewHolder> scrollToHolderWithFallback( | |
recyclerViewMatcher: Matcher<View>, | |
viewHolderMatcher: Matcher<VH>, | |
failureViewAction: ViewAction, | |
maxRetryCount: Int | |
) { | |
var count = maxRetryCount |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Rule to be used in tests that display a Toast with class name and method name when each test starting. | |
* | |
* ``` | |
* @RunWith(AndroidJUnit4::class) | |
* class FooTest { | |
* | |
* @get:Rule | |
* val testNameToastRule = TestNameToastRule() | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @see <a href="https://medium.com/androiddevelopers/windows-insets-fragment-transitions-9024b239a436">Windows Insets + Fragment Transitions</a> | |
*/ | |
public class DispatchWindowInsetsToAllChildrenListener implements OnApplyWindowInsetsListener { | |
@Override | |
public WindowInsetsCompat onApplyWindowInsets(View view, WindowInsetsCompat windowInsetsCompat) { | |
boolean consumed = false; | |
if (view instanceof ViewGroup) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ToolbarOffsetChangedListener implements AppBarLayout.OnOffsetChangedListener { | |
private static final String TAG = "ToolbarOffsetChangedListener"; | |
private Toolbar toolbar; | |
private Drawable[] icons; | |
/** | |
* 觸發開始改變顏色的 offset [0, - AppBar's height] | |
*/ | |
private int verticalOffsetTrigger = -1; |
NewerOlder