Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.util.TypedValue;

public class Main {
    public static ColorStateList colorStateListIcon(Context context) {
        int[][] states = new int[][] { new int[] { android.R.attr.state_enabled },
                new int[] { -android.R.attr.state_enabled }, new int[] { -android.R.attr.state_checked },
                new int[] { android.R.attr.state_pressed } };
        int[] colors = new int[] { getTextColorSecondary(context), getPrimaryColor(context),
                getPrimaryColor(context), getPrimaryColor(context) };
        return new ColorStateList(states, colors);
    }

    public static int getTextColorSecondary(Context context) {
        TypedValue typedValue = new TypedValue();
        TypedArray typedArray = context.obtainStyledAttributes(typedValue.data, new int[] { 16842808 });
        int accent = typedArray.getColor(0, 0);
        typedArray.recycle();
        return accent;
    }

    public static int getPrimaryColor(Context context) {
        TypedValue typedValue = new TypedValue();
        TypedArray typedArray = context.obtainStyledAttributes(typedValue.data, new int[] { 16843827 });
        int accent = typedArray.getColor(0, 0);
        typedArray.recycle();
        return accent;
    }
}