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 class App extends Application { | |
// Bunches of application code | |
public boolean isAppInForeground() { | |
ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); | |
List<RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses(); | |
if (appProcesses != null) { | |
final String packageName = getPackageName(); | |
for (RunningAppProcessInfo appProcess : appProcesses) { |
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
package com.twotoasters.util.anim; | |
import android.animation.Animator; | |
import android.animation.Animator.AnimatorListener; | |
import android.view.ViewPropertyAnimator; | |
import java.util.ArrayList; | |
/** | |
* A class which makes it really easy to implement sequencal animations with ViewPropertyAnimators. |
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
package com.example; | |
@JsonAdapter(JsonWrapperAdapter.class) | |
public class JsonWrapper { | |
private static final String classNameKey = "className"; | |
private static final String wrappedObjectKey = "wrappedObject"; | |
private final String className; | |
private final Object wrappedObject; |
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 class App extends Application { | |
// Bunches of application code | |
/** | |
* This will tell you if the give package currently has the URI permissions that you granted. | |
* It will fail it the app has been killed or uninstalled. | |
* This may not work for persistent permissions if the app is not running. | |
* @return PackageManager.PERMISSION_DENIED if it does not have permission and | |
* PackageManager.PERMISSION_GRANTED if it does have 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
private static HttpTransport httpTransport; | |
private static OkHttpClient client; | |
private static OkHttpClient getClient() { | |
if (client == null) { | |
client = new OkHttpClient(); | |
} | |
return client; | |
} |
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
apply plugin: 'com.android.library' | |
/** This closure will rename your output file with your outputName, versionName and git commit. */ | |
android.metaClass.renameVariants = { String moduleName, String outputName -> | |
def isApplication = binding.variables.containsKey('applicationVariants') | |
def variants = isApplication ? applicationVariants : libraryVariants | |
def gitCommit = "git rev-parse --short HEAD".execute().text.trim() | |
def ext = isApplication ? '.apk' : '.aar' | |
variants.all { -> outputs.each { |
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
package com.example; | |
import android.content.Context; | |
import android.support.v7.widget.RecyclerView; | |
import android.util.AttributeSet; | |
import com.exmaple.CenteringWidgetDelegate; | |
public class CenteringRecyclerView extends RecyclerView { | |
private CenteringWidgetDelegate centeringDelegate = new CenteringWidgetDelegate(); |
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 final class TintingColorFilter { | |
private TintingColorFilter() { } | |
/** | |
* @param color, The rgb color you would like to tint with. | |
* @param alpha, How strong you would like the color to tint. 0 is none, 1 is completely. | |
*/ | |
public static ColorFilter createFilter(@ColorInt int color, float alpha) { | |
int red = Color.red(color); | |
int green = Color.green(color); |
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
package com.bfreq.dice.widget | |
import android.content.Context | |
import android.util.AttributeSet | |
import android.view.View | |
import android.view.ViewGroup | |
import com.bfreq.dice.R | |
import com.bfreq.dice.util.forEachChild | |
import com.bfreq.dice.util.forEachChildIndexed |