Skip to content

Instantly share code, notes, and snippets.

@guness
guness / 00.install-android-sdk.sh
Last active May 10, 2022 13:19 — forked from nhtua/00.install-android-sdk.sh
Run a Headless Android Device on Ubuntu server (no GUI)
#!/bin/bash -i
#using shebang with -i to enable interactive mode (auto load .bashrc)
set -e #stop immediately if any error happens
# Install Open SDK
apt update
apt install openjdk-11-jre-headless -y
java -version
@guness
guness / etc_zprofile
Last active March 26, 2024 07:30
Global /etc/zprofile for user based dynamic ANDROID_HOME path.
# System-wide profile for interactive zsh(1) login shells.
# Setup user specific overrides for this in ~/.zprofile. See zshbuiltins(1)
# and zshoptions(1) for more details.
if [ -x /usr/libexec/path_helper ]; then
paths=`/usr/libexec/path_helper -s`
eval ${paths//'\$USER'/$'$USER'}
fi
@guness
guness / CombinedLiveData.java
Last active May 15, 2023 14:10
LiveData merger that takes two live data inputs and a merger function. Merges two results using merger function, and returning result allowing null inputs and outputs. Input and out types are parametric. However only supports two live data inputs for now.
import androidx.annotation.NonNull;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MediatorLiveData;
import androidx.lifecycle.Observer;
import java.util.function.BiFunction;
public class CombinedLiveData<T, K, S> extends MediatorLiveData<S> {
@guness
guness / CommentAdapter.kt
Created February 19, 2018 14:11
Custom PagedListAdapter with add support on top
/**
* Created by guness on 7.02.2018.
*/
class CommentAdapter(private val fragment: SGFragment) : RecyclerView.Adapter<CommentViewHolder>() {
private val mCustomList = ArrayList<Comment>()
private val mListener = object : ListUpdateCallback {
override fun onChanged(position: Int, count: Int, payload: Any?) {
notifyItemRangeChanged(paged(position), count, payload)