Skip to content

Instantly share code, notes, and snippets.

View belinwu's full-sized avatar

吴上阿吉 belinwu

View GitHub Profile
@belinwu
belinwu / LazyLifecycleManager.kt
Created June 23, 2022 11:03 — forked from vishalratna-microsoft/LazyLifecycleManager.kt
Code for LazyLifecycleManager
import android.app.Activity
import android.util.Log
import android.view.ViewTreeObserver
import androidx.annotation.MainThread
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import com.******************.Barrier
import com.******************.Closure
import com.*******************.Once
./gradlew clean buildRelease publish
@belinwu
belinwu / build.gradle
Created March 23, 2020 14:08 — forked from wilik16/build.gradle
Archive/Copy debug or release APK / AAB (Android App Bundle) file and/or mapping.txt to a versioned folder
android {
applicationVariants.all { variant ->
variant.outputs.all {
def fileName = "app"
switch (variant.buildType.name) {
case "debug":
fileName = "${appNameDebug}-${variant.versionCode}"
break
case "release":
fileName = "${appNameRelease}-${variant.versionCode}"
@belinwu
belinwu / build.gradle
Created July 23, 2019 03:44 — forked from akperkins/build.gradle
Example of auto-generating the versionCode
apply plugin: 'com.android.application'
// version information
def versionMajor = 1
def versionMinor = 0
def versionPatch = 0
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
@belinwu
belinwu / AndroidBmpUtil.java
Last active October 25, 2018 09:03
Save Android Bitmap to .bmp file
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import android.graphics.Bitmap;
/**
@belinwu
belinwu / swap_arithmetic
Last active August 29, 2015 14:21
Swap Two Variables Without Using a Temp Variable (With Math!)
var a = 10, b = 20;
a = a + b;
b = a - b;
a = a - b;
console.log("a = " + a + ", b = " + b); // a = 20, b = 10