Search in sources :

Example 1 with ColorRes

use of android.support.annotation.ColorRes in project Robot-Scouter by SUPERCILEX.

the class TeamMenuHelper method updateToolbarColor.

private void updateToolbarColor(boolean visible) {
    FragmentActivity activity = mFragment.getActivity();
    @ColorRes int oldColorPrimary = visible ? R.color.selected_toolbar : R.color.colorPrimary;
    @ColorRes int newColorPrimary = visible ? R.color.colorPrimary : R.color.selected_toolbar;
    Toolbar toolbar = activity.findViewById(R.id.toolbar);
    animateColorChange(mFragment.getContext(), oldColorPrimary, newColorPrimary, animator -> toolbar.setBackgroundColor((int) animator.getAnimatedValue()));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        @ColorRes int oldColorPrimaryDark = visible ? R.color.selected_status_bar : R.color.colorPrimaryDark;
        @ColorRes int newColorPrimaryDark = visible ? R.color.colorPrimaryDark : R.color.selected_status_bar;
        animateColorChange(mFragment.getContext(), oldColorPrimaryDark, newColorPrimaryDark, animator -> activity.getWindow().setStatusBarColor((int) animator.getAnimatedValue()));
    }
}
Also used : FragmentActivity(android.support.v4.app.FragmentActivity) ColorRes(android.support.annotation.ColorRes) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

ColorRes (android.support.annotation.ColorRes)1 FragmentActivity (android.support.v4.app.FragmentActivity)1 Toolbar (android.support.v7.widget.Toolbar)1