@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_calendar, container, false); RL_calendar_edit_bar = (RelativeLayout) rootView.findViewById(R.id.RL_calendar_edit_bar); RL_calendar_edit_bar.setBackgroundColor(themeManager.getThemeMainColor(getActivity())); RL_calendar_content = (RelativeLayout) rootView.findViewById(R.id.RL_calendar_content); FAB_calendar_change_mode = (FloatingActionButton) rootView.findViewById(R.id.FAB_calendar_change_mode); //Set the color FAB_calendar_change_mode.getDrawable() .setColorFilter(themeManager.getThemeMainColor(getActivity()), PorterDuff.Mode.SRC_ATOP); FAB_calendar_change_mode.setOnClickListener(this); return rootView; }
public Drawable getDrawable() { return button.getDrawable(); }
@Override public void hideProgress() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (mFab.getDrawable() instanceof Animatable) { ((Animatable) mFab.getDrawable()).stop(); } } else { //低于5.0,显示其他动画 } }
@Override public void showProgress() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (mFab.getDrawable() instanceof Animatable) { ((Animatable) mFab.getDrawable()).start(); } } else { //低于5.0,显示其他动画 // showMessage(getString(R.string.loading)); } }
@Override protected void onDestroy() { // eBookPresenter.cancelLoading(); if (mFab.getDrawable() instanceof Animatable) { ((Animatable) mFab.getDrawable()).stop(); } super.onDestroy(); }
@Override public void showProgress() { mSwipeRefreshLayout.post(() -> mSwipeRefreshLayout.setRefreshing(true)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (mFab.getDrawable() instanceof Animatable) { ((Animatable) mFab.getDrawable()).start(); } } else { //低于5.0,显示其他动画 // showMessage(getString(R.string.loading)); } }
@Override public void hideProgress() { mSwipeRefreshLayout.post(() -> mSwipeRefreshLayout.setRefreshing(false)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (mFab.getDrawable() instanceof Animatable) { ((Animatable) mFab.getDrawable()).stop(); } } else { //低于5.0,显示其他动画 } }
@Override protected void onDestroy() { bookDetailPresenter.cancelLoading(); if (mFab.getDrawable() instanceof Animatable) { ((Animatable) mFab.getDrawable()).stop(); } super.onDestroy(); }
@Override public void onAnimationUpdate(ValueAnimator animation) { DrawableCompat.setTintList(mOkButton.getDrawable(), ColorStateList.valueOf( (int) animation.getAnimatedValue())); } });
@SuppressLint("NewApi") public void animatePencil(View view) { Drawable d = mBinding.icon.getDrawable(); if (Build.VERSION.SDK_INT >= 21 && d instanceof AnimatedVectorDrawable) { ((AnimatedVectorDrawable) d).start(); } else if (d instanceof AnimatedVectorDrawableCompat) { ((AnimatedVectorDrawableCompat) d).start(); } }
/** * Changes the FAB icon to its default value. * @param animate true to use an animation to change the icon, false to change it instantly */ private void changeFABIcon(boolean animate) { Drawable drawable = dialsEnabled ? iconFABOpenClose : iconFABDefault; if (animate) { changeFABIcon(FABMain.getDrawable(), drawable); } else { FABMain.setImageDrawable(drawable); } } }
@Override public void onClick(View v) { Drawable d = mBinding.fab2.getDrawable(); if (d instanceof AnimatedVectorDrawable) { ((AnimatedVectorDrawable)d ).start(); } else if (d instanceof AnimatedVectorDrawableCompat) { ((AnimatedVectorDrawableCompat) d).start(); } } });
public void fabClicked(View v) { if (v instanceof FloatingActionButton) { FloatingActionButton fab = (FloatingActionButton) v; Drawable drawable = fab.getDrawable(); if (drawable instanceof Animatable) { ((Animatable) drawable).start(); } } new Handler().postDelayed(new Runnable() { @Override public void run() { Intent i = new Intent(); i.setAction(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA); if (i.resolveActivity(getPackageManager()) != null) { startActivity(i); } else { Toast.makeText(MainActivity.this, getString(R.string.error), Toast.LENGTH_SHORT).show(); } } }, (int) (500 * Util.getAnimatorSpeed(this))); }
public void activate(int id, OnClickListener handler) { for (int i = 0; i < getChildCount(); i++) { final View v = getChildAt(i); if (getContext() != null && id == v.getId()) { v.setVisibility(View.VISIBLE); v.setOnLongClickListener(this); v.setOnClickListener(handler); if (v instanceof FloatingActionButton) { CompatUtils.setDrawableColorAttr(getContext(), ((FloatingActionButton) v).getDrawable(), R.attr.colorMicroMathFloatingIcon); } } else { v.setVisibility(View.GONE); v.setOnLongClickListener(null); v.setOnClickListener(null); } } } }
@Override public BottomSheetNumberPadTimePickerThemer setFabIconTint(ColorStateList tint) { if (tint != null) { int[] colors = extractColors(tint, STATES_FAB_COLORS); if (mFabIconTintAnimator != null) { mFabIconTintAnimator.setIntValues(colors); } else { mFabIconTintAnimator = createFabIconTintAnimator(colors); } } DrawableCompat.setTintList(mOkButton.getDrawable(), tint); return this; }
private void colorFloatingActionButton( ) { if (ThemeUtil.getActivityThemeFromOptions(this) == R.style.AppThemeBloody) { mUpdateButton.setBackgroundTintList( ColorStateList.valueOf(ColorUtil.getColorFromContext(this, android.R.attr.textColorPrimary)) ); mUpdateButton.setImageDrawable( ColorUtil.tintDrawable(this, mUpdateButton.getDrawable(), R.attr.colorPrimary) ); } else { mUpdateButton.setImageDrawable( ColorUtil.tintDrawable(this, mUpdateButton.getDrawable(), android.R.attr.textColorPrimary) ); } }
Drawable drawable = fab.getDrawable(); if (drawable instanceof Animatable) { ((Animatable) drawable).start();
fab.setRippleColor(rippleColor); fab.setBackgroundTintList(sl); if (fab.getDrawable() != null) fab.setImageDrawable(createTintedDrawable(fab.getDrawable(), textColor)); return; } else {
fab.setRippleColor(rippleColor); fab.setBackgroundTintList(sl); if (fab.getDrawable() != null) fab.setImageDrawable(tintDrawable(fab.getDrawable(), tintColor)); return;
/** * Enables/disables the FAB button and starts/stops the busy animation * @param enable true to disable the FAB button and start the busy animation, false to enable * the FAB button and stop the busy animation. */ public void enableBusyAnimation(boolean enable) { if (enable) { busyAnimation.start(); if (dialSelected != null) { changeFABIcon(FABMain.getDrawable(), dialSelected.getDrawable()); } FABMain.setEnabled(false); } else { busyAnimation.stop(); if (dialSelected != null) { changeFABIcon(true); dialSelected = null; } FABMain.setEnabled(true); } }