Java Code Examples for com.gianlu.commonutils.CommonUtils#resolveAttrAsColor()

The following examples show how to use com.gianlu.commonutils.CommonUtils#resolveAttrAsColor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MenuItemsAdapter.java    From CommonUtils with Apache License 2.0 5 votes vote down vote up
MenuItemsAdapter(@NonNull Context context, List<BaseDrawerItem<E>> items, Listener<E> listener) {
    this.inflater = LayoutInflater.from(context);
    this.items = items;
    this.listener = listener;
    this.colorTextPrimary = CommonUtils.resolveAttrAsColor(context, android.R.attr.textColorPrimary);
    this.colorAccent = ContextCompat.getColor(context, R.color.colorSecondary);
}
 
Example 2
Source File: BaseTester.java    From Aria2App with GNU General Public License v3.0 4 votes vote down vote up
@ColorInt
public int getColor(@NonNull Context context) {
    if (resolve) return CommonUtils.resolveAttrAsColor(context, res);
    else return ContextCompat.getColor(context, res);
}
 
Example 3
Source File: Utils.java    From Aria2App with GNU General Public License v3.0 4 votes vote down vote up
public static void setupChart(@NonNull LineChart chart, boolean small, @ColorRes @Nullable Integer fgColorRes) {
    chart.clear();

    int fgColor;
    Context context = chart.getContext();
    if (fgColorRes == null)
        fgColor = CommonUtils.resolveAttrAsColor(context, R.attr.colorOnSurface);
    else
        fgColor = ContextCompat.getColor(context, fgColorRes);

    chart.setDescription(null);
    chart.setDrawGridBackground(false);
    chart.setBackgroundColor(Color.alpha(0));
    chart.setTouchEnabled(false);

    Legend legend = chart.getLegend();
    legend.setTextColor(fgColor);
    legend.setEnabled(true);

    LineData data = new LineData();
    data.setValueTextColor(fgColor);
    chart.setData(data);

    YAxis ya = chart.getAxisLeft();
    ya.setAxisLineColor(fgColor);
    ya.setTextColor(fgColor);
    ya.setTextSize(small ? 8 : 9);
    ya.setAxisMinimum(0);
    ya.setDrawAxisLine(false);
    ya.setLabelCount(small ? 4 : 8, true);
    ya.setEnabled(true);
    ya.setDrawGridLines(true);
    ya.setGridColor(fgColor);
    ya.setValueFormatter(new CustomYAxisValueFormatter());

    chart.getAxisRight().setEnabled(false);
    chart.getXAxis().setEnabled(false);

    data.addDataSet(initUploadSet(context));
    data.addDataSet(initDownloadSet(context));

    chart.invalidate();
}