This file contains 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 java.io.BufferedReader; | |
import java.io.File; | |
import java.io.FileReader; | |
import java.io.FileWriter; | |
import java.nio.file.Files; | |
import java.nio.file.Path; | |
import java.nio.file.Paths; | |
import java.util.regex.*; | |
import java.util.Arrays; | |
import java.util.Collection; |
This file contains 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 enum MyPermission { | |
// declare runtime permissions specific to your app here (don't keep unused ones) | |
READ_PHONE_STATE(Manifest.permission.READ_PHONE_STATE), | |
FINE_LOCATION(Manifest.permission.ACCESS_FINE_LOCATION); | |
public static MyPermission fromAndroidPermission(String androidPermission) { | |
for (MyPermission permission : MyPermission.values()) { | |
if (permission.getAndroidPermission().equals(androidPermission)) { | |
return permission; | |
} |
This file contains 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 abstract class BaseBusyObservable<LISTENER_CLASS> extends BaseObservable<LISTENER_CLASS> { | |
private final AtomicBoolean mIsBusy = new AtomicBoolean(false); | |
public final boolean isBusy() { | |
return mIsBusy.get(); | |
} | |
/** | |
* Atomically assert not busy and become busy |
This file contains 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 abstract class BaseObservable<LISTENER_CLASS> { | |
private final Object MONITOR = new Object(); | |
private final Set<LISTENER_CLASS> mListeners = new HashSet<>(); | |
public void registerListener(LISTENER_CLASS listener) { | |
synchronized (MONITOR) { | |
boolean hadNoListeners = mListeners.size() == 0; | |
mListeners.add(listener); |