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
/* | |
* Here we want to get the appbar offset changes paired with the direction it's moving and | |
* using RxBinding's great `offsetChanges` API to make an rx Observable of this. The first | |
* part buffers two while skipping one at a time and emits y delta pairs (cur and prev). Second | |
* part is just a simple map to pair the offset with the resolved scroll direction comparing | |
* to the previous offset. This gives us a nice stream of (offset, direction) emissions. | |
* | |
* Note that the filter() is important if you manipulate child views of the ABL. If any child | |
* view requests layout again, it will trigger an emission from the offset listener with the | |
* same value as before, potentially causing measure/layout/draw thrashing if your logic |
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
fun View.visible() { | |
visibility = View.VISIBLE | |
} | |
fun View.invisible() { | |
visibility = View.INVISIBLE | |
} | |
fun View.gone() { | |
visibility = View.GONE |
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
Message of Issue: "Screen overlay detected - To change this permission setting you first have to turn off the screen overlay from Settings > Apps" | |
Scope of issue: This only applies to Android M (6.0/API v23) Or Over | |
Explanation: Other apps installed on the users device may be utilizing a screen overlay on your phone (e.g. Twilight, Red Moon, etc...) | |
Screen overlays are virtual layers that cover part or all of screen while another app is in the foreground. | |
It may be dangerous for android to allow you to to change a sensitive setting while an overlay is active because you may prone to 'tap-jacking' | |
(i.e. a malicious application displays a fake user interface that seems like it can be interacted with, but actually passes interaction events such as finger taps to a hidden user interface behind it.). | |
Therefore to improve security, android doesn't allow you to change sensitive settings while an active overlay is detected, unless the user permits the app to do so. | |
Source: https://commonsware.com/blog/2016/03/24/ |
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
public class AndroidApplication extends MultiDexApplication { | |
public static final String TAG = AndroidApplication.class.getSimpleName(); | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
registerComponentCallbacks(new ComponentCallback()); | |
} | |
private class ComponentCallback implements ComponentCallbacks2 { |
Centralize the support libraries dependencies in gradle
Working with multi-modules project, it is very useful to centralize the dependencies, especially the support libraries.
A very good way is to separate gradle build files, defining something like:
root
--gradleScript
----dependencies.gradle
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.content.Context; | |
import android.os.Debug; | |
import java.io.File; | |
public class OomExceptionHandler implements Thread.UncaughtExceptionHandler { | |
private static final String FILENAME = "out-of-memory.hprof"; | |
public static void install(Context context) { | |
Thread.UncaughtExceptionHandler defaultHandler = Thread.getDefaultUncaughtExceptionHandler(); |
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
public static Observable<List<String>> paginatedThings(final Observable<Void> onNextObservable) { | |
return Observable.create(new Observable.OnSubscribe<List<String>>() { | |
@Override | |
public void call(final Subscriber<? super List<String>> subscriber) { | |
onNextObservable.subscribe(new Observer<Void>() { | |
int latestPage = -1; | |
@Override | |
public void onCompleted() { | |
subscriber.onCompleted(); |
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
package com.joshskeen.rxjava_example.model; | |
import java.util.ArrayList; | |
import java.util.List; | |
import de.greenrobot.event.EventBus; | |
import retrofit.Callback; | |
import retrofit.RetrofitError; | |
import retrofit.client.Response; | |
import rx.Observable; |
NewerOlder