Skip to content

Instantly share code, notes, and snippets.

View andhikayuana's full-sized avatar
🌏
bertapa

Andhika Yuana andhikayuana

🌏
bertapa
View GitHub Profile
@andhikayuana
andhikayuana / Doze_Mode_Behavior.md
Created September 3, 2018 07:02 — forked from christophermark/Doze_Mode_Behavior.md
Android Marshmallow Idle Mode Behavior

What is "idle mode"?

Idle mode is a state where the phone has no network connectivity and apps are temporarily suspended. Idle mode gets triggered by one of two ways: an asleep, still, unplugged phone (Doze mode), and when an app has not been opened in a significant amount of time (App Standby Mode). During idle mode via Doze, the phone will wake up periodically for a short amount of time, allowing apps to run and use network connectivity. Using several different methods outlined below, it is possible to wake apps up during idle mode outside of these maintenance windows.

Time to enter Doze mode

1 hour of being still after the screen turns off.

Time to enter App Standby mode

TBD

Idle maintenance windows

@andhikayuana
andhikayuana / Main.java
Created August 1, 2018 08:49
Proxy Pattern
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
public class Main
{
public static void main(String[] args) {
Original original = new Original();
Handler handler = new Handler(original);
@andhikayuana
andhikayuana / BaseAdapter.java
Last active August 23, 2020 00:50
BaseRecyclerViewAdapter Android
/**
* @author Yuana [email protected]
* @since Jun, Sun 10 2018 13.44
**/
public abstract class BaseAdapter<T, V extends BaseViewHolder> extends RecyclerView.Adapter<V> {
protected List<T> data = new ArrayList<T>();
protected Context context;
protected OnItemClickListener itemClickListener;
protected OnLongItemClickListener longItemClickListener;
@andhikayuana
andhikayuana / PermissionDef.java
Created June 30, 2018 22:37 — forked from jmarkovic/PermissionDef.java
Android annotation defining all permissions in a StringDef annotation.
/**
* Typedef annotation listing all permissions
* available in the latest SDK.
* Using this on a method parameter
* or on a method with {@link String} return value
* will trigger value lookup in Android Studio.
*
* @version SDK23
* @author jmarkovic
*/
@andhikayuana
andhikayuana / gitlab-ci.yml
Last active June 10, 2018 05:24
build android using gitlab ci
# author Yuana
# since june, 20 2018
image: azabost/android-sdk-27:latest
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
cache:
paths:
@andhikayuana
andhikayuana / dependencies.gradle
Created May 30, 2018 06:45
Dependencies Management for Android
ext {
versions = [
support : "27.0.2",
firebase : '11.8.0',
okHttp : "3.9.1",
retrofit : '2.3.0',
dagger : '2.14.1',
butterKnife : '8.8.1',
rxJava : '2.1.5',
rxJavaAndroid : '2.0.1',
@andhikayuana
andhikayuana / .travis.yml
Created May 29, 2018 02:24 — forked from willprice/.travis.yml
How to set up TravisCI for projects that push back to github
# Ruby is our language as asciidoctor is a ruby gem.
lang: ruby
before_install:
- sudo apt-get install pandoc
- gem install asciidoctor
script:
- make
after_success:
- .travis/push.sh
env:
@andhikayuana
andhikayuana / KeyboardObserver.java
Created May 14, 2018 04:15
KeyboardObserve Util for Android
public class KeyboardObserver implements ViewTreeObserver.OnGlobalLayoutListener {
private final static int MAGIC_NUMBER = 200;
private SoftKeyboardToggleListener mCallback;
private View mRootView;
private float mScreenDensity = 1;
private static HashMap<SoftKeyboardToggleListener, KeyboardObserver> sListenerMap = new HashMap<>();
public interface SoftKeyboardToggleListener {
void onToggleSoftKeyboard(boolean isVisible);
@andhikayuana
andhikayuana / README.md
Created April 27, 2018 04:31 — forked from lopspower/README.md
Configuration of proguard-rules.pro

Proguard Configuration

Twitter

1) Enable Proguard in your build.gradle module :

android {
    //...
 buildTypes {