private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    setClickable(true);
    mSwitchIconAnimator = new SwitchIconAnimator();
    applyStyle(context, attrs, defStyleAttr, defStyleRes);

    mStyleId = ThemeManager.getStyleId(context, attrs, defStyleAttr, defStyleRes);
  }
 @Override
 protected void onAttachedToWindow() {
   super.onAttachedToWindow();
   if (mStyleId != 0) {
     ThemeManager.getInstance().registerOnThemeChangedListener(this);
     onThemeChanged(null);
   }
 }
 @Override
 public void onThemeChanged(ThemeManager.OnThemeChangedEvent event) {
   int style = ThemeManager.getInstance().getCurrentStyle(mStyleId);
   if (mCurrentStyle != style) {
     mCurrentStyle = style;
     applyStyle(mCurrentStyle);
   }
 }
Exemple #4
0
  protected void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);

    mDrawRect = new RectF();
    mTempRect = new RectF();
    mTrackPath = new Path();

    mFlingVelocity = ViewConfiguration.get(context).getScaledMinimumFlingVelocity();

    applyStyle(context, attrs, defStyleAttr, defStyleRes);

    if (!isInEditMode())
      mStyleId = ThemeManager.getStyleId(context, attrs, defStyleAttr, defStyleRes);
  }
 @Override
 protected void onDetachedFromWindow() {
   super.onDetachedFromWindow();
   mRippleManager.cancelRipple(this);
   if (mStyleId != 0) ThemeManager.getInstance().unregisterOnThemeChangedListener(this);
 }
  private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    applyStyle(context, attrs, defStyleAttr, defStyleRes);

    mStyleId = ThemeManager.getStyleId(context, attrs, defStyleAttr, defStyleRes);
  }