Example usage for android.content.res Resources getColor

List of usage examples for android.content.res Resources getColor

Introduction

In this page you can find the example usage for android.content.res Resources getColor.

Prototype

@ColorInt
@Deprecated
public int getColor(@ColorRes int id) throws NotFoundException 

Source Link

Document

Returns a color integer associated with a particular resource ID.

Usage

From source file:com.sckftr.android.app.view.InsetFrameLayout.java

public void setBackgroundDrawableWithAnimation(int startColorResID, int endColorResID) {

    Resources resources = getResources();

    if (mInsetBackground == null)
        mInsetBackground = new ColorDrawable(resources.getColor(startColorResID));

    mStartColor = resources.getColor(startColorResID);
    mEndColor = resources.getColor(endColorResID);

    if (objectAnimator.isRunning())
        objectAnimator.cancel();// w  ww.  j av  a2  s.co m

    objectAnimator.start();
}

From source file:com.polatic.pantaudki.home.ShoppingFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View v = inflater.inflate(R.layout.home_fragment_shopping, container, false);
    final Resources resources = getResources();
    ArrayList<Bar> aBars = new ArrayList<Bar>();

    Bar bar = new Bar();
    bar.setColor(resources.getColor(R.color.green_light));
    bar.setSelectedColor(resources.getColor(R.color.transparent_orange));
    bar.setName("PEGAWAI");
    bar.setValue(11919);/*from  w ww .j  a v  a  2s.  c  o m*/
    bar.setValueString("11,919  Milyar");
    aBars.add(bar);

    bar = new Bar();
    bar.setColor(resources.getColor(R.color.purple));
    bar.setName("BUNGA");
    bar.setValue(4);
    bar.setValueString("4 Milyar");
    aBars.add(bar);

    bar = new Bar();
    bar.setColor(resources.getColor(R.color.red));
    bar.setName("HIBAH");
    bar.setValue(2617);
    bar.setValueString("2,617 Milyar");
    aBars.add(bar);

    bar = new Bar();
    bar.setColor(resources.getColor(R.color.main_blue_light));
    bar.setName("SOSIAL");
    bar.setValue(1220);
    bar.setValueString("1,220 Milyar");
    aBars.add(bar);

    BarGraph barGraph = (BarGraph) v.findViewById(R.id.first_bargraph);
    barGraph.setBars(aBars);

    barGraph.setOnBarClickedListener(new OnBarClickedListener() {

        @Override
        public void onClick(int index) {
            Toast.makeText(getActivity(), "Bar " + index + " clicked", Toast.LENGTH_SHORT).show();
        }
    });

    aBars = new ArrayList<Bar>();

    bar = new Bar();
    bar.setColor(resources.getColor(R.color.green_light));
    bar.setSelectedColor(resources.getColor(R.color.transparent_orange));
    bar.setName("BANTUAN KEUANGAN");
    bar.setValue(36);
    bar.setValueString("36 Milyar");
    aBars.add(bar);

    bar = new Bar();
    bar.setColor(resources.getColor(R.color.purple));
    bar.setName("TIDAK TERDUGA");
    bar.setValue(78);
    bar.setValueString("78 Milyar");
    aBars.add(bar);

    barGraph = (BarGraph) v.findViewById(R.id.second_bargraph);
    barGraph.setBars(aBars);

    aBars = new ArrayList<Bar>();

    bar = new Bar();
    bar.setColor(resources.getColor(R.color.green_light));
    bar.setSelectedColor(resources.getColor(R.color.transparent_orange));
    bar.setName("PEGAWAI");
    bar.setValue(2865);
    bar.setValueString("2,865 Milyar");
    aBars.add(bar);

    bar = new Bar();
    bar.setColor(resources.getColor(R.color.purple));
    bar.setName("BARANG & JASA");
    bar.setValue(17104);
    bar.setValueString("17,104 Milyar");
    aBars.add(bar);

    bar = new Bar();
    bar.setColor(resources.getColor(R.color.purple));
    bar.setName("MODAL");
    bar.setValue(2386);
    bar.setValueString("2,386 Milyar");
    aBars.add(bar);

    barGraph = (BarGraph) v.findViewById(R.id.third_bargraph);
    barGraph.setBars(aBars);

    return v;
}

From source file:com.sckftr.android.app.view.InsetFrameLayout.java

public void setBackgroundDrawableWithAnimation(int colorResId) {

    Resources resources = getResources();

    if (mInsetBackground == null)
        mInsetBackground = new ColorDrawable(resources.getColor(android.R.color.transparent));

    if (!(mInsetBackground instanceof ColorDrawable))
        throw new IllegalArgumentException("Can't animate background changing from non-ColorDrawable!");

    mStartColor = ((ColorDrawable) mInsetBackground).getColor();
    mEndColor = resources.getColor(colorResId);

    if (objectAnimator.isRunning())
        objectAnimator.cancel();//ww  w .j  a v  a  2s .com

    objectAnimator.start();
}

From source file:com.ichi2.anki.widgets.DeckAdapter.java

public DeckAdapter(LayoutInflater layoutInflater, Context context) {
    mLayoutInflater = layoutInflater;//from  w w w  . j  ava  2 s .  co  m
    mDeckList = new ArrayList<>();
    // Get the colors from the theme attributes
    int[] attrs = new int[] { R.attr.zeroCountColor, R.attr.newCountColor, R.attr.learnCountColor,
            R.attr.reviewCountColor, R.attr.currentDeckBackground, android.R.attr.textColor,
            R.attr.dynDeckColor, R.attr.expandRef, R.attr.collapseRef };
    TypedArray ta = context.obtainStyledAttributes(attrs);
    Resources res = context.getResources();
    mZeroCountColor = ta.getColor(0, res.getColor(R.color.zero_count));
    mNewCountColor = ta.getColor(1, res.getColor(R.color.new_count));
    mLearnCountColor = ta.getColor(2, res.getColor(R.color.learn_count));
    mReviewCountColor = ta.getColor(3, res.getColor(R.color.review_count));
    mRowCurrentDrawable = ta.getResourceId(4, 0);
    mDeckNameDefaultColor = ta.getColor(5, res.getColor(R.color.black));
    mDeckNameDynColor = ta.getColor(6, res.getColor(R.color.deckadapter_deck_name_dyn));
    mExpandImage = ta.getDrawable(7);
    mCollapseImage = ta.getDrawable(8);
    ta.recycle();
}

From source file:com.android.settings.sim.SimBootReceiver.java

private void createNotification(Context context) {
    final Resources resources = context.getResources();

    NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setSmallIcon(R.drawable.ic_sim_card_alert_white_48dp)
            .setColor(resources.getColor(R.color.sim_noitification))
            .setContentTitle(resources.getString(R.string.sim_notification_title))
            .setContentText(resources.getString(R.string.sim_notification_summary));
    Intent resultIntent = new Intent(context, SimSettingsActivity.class);
    resultIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent,
            PendingIntent.FLAG_CANCEL_CURRENT);
    builder.setContentIntent(resultPendingIntent);
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(NOTIFICATION_ID, builder.build());
}

From source file:com.androzic.waypoint.WaypointInfo.java

@SuppressLint("NewApi")
private void updateWaypointInfo(double lat, double lon) {
    Androzic application = Androzic.getApplication();
    Activity activity = getActivity();//from   w w  w  .ja  va 2 s  . c  om
    Dialog dialog = getDialog();
    View view = getView();

    WebView description = (WebView) view.findViewById(R.id.description);

    if ("".equals(waypoint.description)) {
        description.setVisibility(View.GONE);
    } else {
        String descriptionHtml;
        try {
            TypedValue tv = new TypedValue();
            Theme theme = activity.getTheme();
            Resources resources = getResources();
            theme.resolveAttribute(android.R.attr.textColorSecondary, tv, true);
            int secondaryColor = resources.getColor(tv.resourceId);
            String css = String.format(
                    "<style type=\"text/css\">html,body{margin:0;background:transparent} *{color:#%06X}</style>\n",
                    (secondaryColor & 0x00FFFFFF));
            descriptionHtml = css + waypoint.description;
            description.setWebViewClient(new WebViewClient() {
                @Override
                public void onPageFinished(WebView view, String url) {
                    view.setBackgroundColor(Color.TRANSPARENT);
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
                        view.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);
                }
            });
            description.setBackgroundColor(Color.TRANSPARENT);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
                description.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);
        } catch (Resources.NotFoundException e) {
            description.setBackgroundColor(Color.LTGRAY);
            descriptionHtml = waypoint.description;
        }

        WebSettings settings = description.getSettings();
        settings.setDefaultTextEncodingName("utf-8");
        settings.setAllowFileAccess(true);
        Uri baseUrl = Uri.fromFile(new File(application.dataPath));
        description.loadDataWithBaseURL(baseUrl.toString() + "/", descriptionHtml, "text/html", "utf-8", null);
    }

    String coords = StringFormatter.coordinates(" ", waypoint.latitude, waypoint.longitude);
    ((TextView) view.findViewById(R.id.coordinates)).setText(coords);

    if (waypoint.altitude != Integer.MIN_VALUE) {
        ((TextView) view.findViewById(R.id.altitude)).setText(StringFormatter.elevationH(waypoint.altitude));
    }

    double dist = Geo.distance(lat, lon, waypoint.latitude, waypoint.longitude);
    double bearing = Geo.bearing(lat, lon, waypoint.latitude, waypoint.longitude);
    bearing = application.fixDeclination(bearing);
    String distance = StringFormatter.distanceH(dist) + " " + StringFormatter.angleH(bearing);
    ((TextView) view.findViewById(R.id.distance)).setText(distance);

    if (waypoint.date != null)
        ((TextView) view.findViewById(R.id.date))
                .setText(DateFormat.getDateFormat(activity).format(waypoint.date) + " "
                        + DateFormat.getTimeFormat(activity).format(waypoint.date));
    else
        ((TextView) view.findViewById(R.id.date)).setVisibility(View.GONE);

    dialog.setTitle(waypoint.name);
}

From source file:com.github.piasy.chatrecyclerview.example.InputDialogFragment.java

@Override
public void onStart() {
    super.onStart();
    Window window = getDialog().getWindow();
    window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    window.setBackgroundDrawableResource(android.R.color.transparent);

    final Resources res = getResources();
    final int titleDividerId = res.getIdentifier("titleDivider", "id", "android");
    if (titleDividerId > 0) {
        final View titleDivider = getDialog().findViewById(titleDividerId);
        if (titleDivider != null) {
            titleDivider.setBackgroundColor(res.getColor(android.R.color.transparent));
        }//from  ww w .j ava 2  s  .c  om
    }
}

From source file:com.hongshi.hongshiandroid.view.processbtn.ActionProcessButton.java

private void init(Context context) {
    Resources res = context.getResources();

    mMode = Mode.ENDLESS;/*w  w w  .  j a va  2s.c  o m*/

    mColor1 = res.getColor(android.R.color.holo_blue_bright);
    mColor2 = res.getColor(android.R.color.holo_green_light);
    mColor3 = res.getColor(android.R.color.holo_orange_light);
    mColor4 = res.getColor(android.R.color.holo_red_light);
}

From source file:com.runmit.sweedee.view.CirclePageIndicator.java

public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;//from ww  w  .j  a v  a2s .  c om

    final Resources res = getResources();
    defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color);
    defaultCommonColor = res.getColor(R.color.default_circle_indicator_stroke_color);
    final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, 0);
    mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius);
    a.recycle();
    mColorEvaluator = new ArgbEvaluator();
}

From source file:cn.qmz.tools.view.progressbtn.iml.ActionProcessButton.java

private void init(Context context) {
    Resources res = context.getResources();

    mMode = Mode.ENDLESS;// w w w.ja  va2  s. c  o m

    mColor1 = res.getColor(R.color.holo_blue_bright);
    mColor2 = res.getColor(R.color.holo_green_light);
    mColor3 = res.getColor(R.color.holo_orange_light);
    mColor4 = res.getColor(R.color.holo_red_light);
}