Skip to content

Instantly share code, notes, and snippets.

View victorydst3's full-sized avatar

victorydst3 victorydst3

  • Đà Nẵng - Việt Nam
View GitHub Profile

Keybase proof

I hereby claim:

  • I am vinhhuynh93 on github.
  • I am victorydst3 (https://keybase.io/victorydst3) on keybase.
  • I have a public key ASAzOVGFiR5maVwxeQ_FD8aUItzKCGaXiq_KUaz5_4jnxgo

To claim this, I am signing this object:

@victorydst3
victorydst3 / AppLifeCycle.java
Created January 4, 2016 10:11
Android application foreground or bakcground
/**
* Check if the application is in the foreground or background.
* *
* Register this callbacks for an application
* Application application = (Application) context.getApplicationContext();
* application.registerActivityLifecycleCallbacks(new BaseLifeCycleCallbacks());
* *
* Note: These callbacks can be registered at any level of the application lifecycle.
* Previous methods to get the application lifecycle forced the lifecycle callbacks to be registered
@victorydst3
victorydst3 / EndlessRecyclerOnScrollListener.java
Created January 4, 2016 10:11 — forked from imran0101/EndlessRecyclerOnScrollListener.java
RecyclerView position helper to get first and last visible positions
/**
* Custom Scroll listener for RecyclerView.
* Based on implementation https://gist.github.com/ssinss/e06f12ef66c51252563e
*/
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = "EndlessScrollListener";
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
@victorydst3
victorydst3 / KeyboardObserver.java
Last active January 4, 2016 10:11 — forked from imran0101/KeyboardObserver.java
Observe Keyboard open or hidden
public class KeyboardObserver implements ViewTreeObserver.OnGlobalLayoutListener {
public interface Callback {
void onKeyboardVisible();
void onKeyboardHidden();
}
WeakReference<View> view;