Code snippets used in my conference talk: "Say Cheese! Elevate your camera flows with Jetpack Compose"
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 androidx.compose.runtime.Composable | |
import androidx.compose.runtime.Composer | |
import androidx.compose.runtime.CompositionTracer | |
import androidx.compose.runtime.DisposableEffect | |
import androidx.compose.runtime.InternalComposeApi | |
import androidx.compose.runtime.InternalComposeTracingApi | |
import androidx.compose.runtime.remember | |
import androidx.compose.runtime.snapshots.MutableSnapshot | |
import androidx.compose.runtime.snapshots.Snapshot | |
import java.util.WeakHashMap |
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
#!/bin/zsh | |
function get_devices() { | |
all_devices=$(command adb devices) | |
# Drop the title | |
all_devices=${all_devices#"List of devices attached"} | |
# Drop any unauthorised devices (i.e. USB debugging disabled or authorisations revoked) | |
valid_devices=$(echo $all_devices | grep -v "([[:alnum:]-]+[[:space:]]+unauthorized$)" | grep -oE "([[:alnum:]-]+[[:space:]]+device$)") |
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
/* | |
* Copyright 2023 The Android Open Source Project | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* https://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
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 | |
#NOTE: requires python3 and the pip package uiautomator2 | |
#These functions can be copied over to your own bash script | |
#and can be used by simply triggering tapIfExists... | |
function tapIfExists(){ | |
coords=$(getCoords "${1}") | |
if [[ "$coords" != "-" ]]; then | |
$fullAdb shell input tap "$coords" | |
fi |
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 android.graphics.Color | |
import androidx.annotation.ColorInt | |
import com.curiouscreature.kotlin.math.Float3 | |
import com.curiouscreature.kotlin.math.Mat3 | |
import com.curiouscreature.kotlin.math.saturate | |
import com.curiouscreature.kotlin.math.transpose | |
import kotlin.math.pow | |
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 java.io.BufferedReader; | |
import java.io.File; | |
import java.io.FileReader; | |
import java.io.FileWriter; | |
import java.nio.file.Files; | |
import java.nio.file.Path; | |
import java.nio.file.Paths; | |
import java.util.regex.*; | |
import java.util.Arrays; | |
import java.util.Collection; |
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 MainActivity : AppCompatActivity() { | |
private lateinit var swipeFragment: SwipeFragment | |
private lateinit var favoritesFragment: FavoritesFragment | |
private lateinit var newsFragment: NewsFragment | |
private val fragments: Array<out Fragment> get() = arrayOf(swipeFragment, favoritesFragment, newsFragment) | |
private fun selectFragment(selectedFragment: Fragment) { | |
var transaction = supportFragmentManager.beginTransaction() | |
fragments.forEachIndexed { index, fragment -> |
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
// https://github.com/Zhuinden/fragmentviewbindingdelegate-kt | |
import android.view.View | |
import androidx.fragment.app.Fragment | |
import androidx.lifecycle.DefaultLifecycleObserver | |
import androidx.lifecycle.Lifecycle | |
import androidx.lifecycle.LifecycleOwner | |
import androidx.lifecycle.Observer | |
import androidx.viewbinding.ViewBinding | |
import kotlin.properties.ReadOnlyProperty |
NewerOlder