Skip to content

Instantly share code, notes, and snippets.

If the app has the ability to switch between different app color themes, every view must use a style or refer to a custom ?attr/ for all colors.

attrs.xml has:

<attr name="subtitle_1_color" format="color"/>

Which is mapped in styles.xml:

@alunsford3
alunsford3 / ThemeUtils.java
Created February 18, 2016 23:40
Manually resolve color attributes and set for each state
public static int DEFAULT_STATE = -1;
public static int[][] createStatesArray(int... args) {
int length = args.length;
int[][] states = new int[length][];
for (int i = 0; i < length; i++) {
int state = args[i];
if (state == DEFAULT_STATE) {
states[i] = new int[]{};
} else {
@alunsford3
alunsford3 / MapViewHolder.java
Last active November 29, 2020 12:44
RecyclerViews with MapViews
public class MapViewHolder extends RecyclerView.ViewHolder {
private MapViewListItemView mMapViewListItemView;
public MapViewHolder(MapViewListItemView mapViewListItemView) {
super(mapViewListItemView);
mMapViewListItemView = mapViewListItemView;
}
public void mapViewListItemViewOnCreate(Bundle savedInstanceState) {
@alunsford3
alunsford3 / dex-method-count-after-proguard.txt
Created July 22, 2015 15:25
Big Nerd Ranch - ProGuard blog post
Processing app-dev-debug-0.1-debug.apk
Read in 44413 method IDs.
<root>: 44413
: 3
android: 10379
accounts: 3
animation: 42
app: 235
bluetooth: 3
content: 273
@alunsford3
alunsford3 / gist:7272571
Created November 1, 2013 21:54
sharedpreferences aes broken
11-01 21:06:03.165: ERROR/AndroidRuntime(6386): FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.company.android.appname/com.company.android.appname.controller.login.LoginActivity}: java.lang.IllegalStateException: java.security.NoSuchAlgorithmException: KeyGenerator AES/CBC/PKCS5Padding implementation not found
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)