@TargetApi(Build.VERSION_CODES.LOLLIPOP)
 void onActionUp() {
   if (mBackgroundDrawable instanceof StateListDrawable) {
     StateListDrawable drawable = (StateListDrawable) mBackgroundDrawable;
     drawable.setState(new int[] {android.R.attr.state_enabled});
   } else if (Util.hasLollipop()) {
     RippleDrawable ripple = (RippleDrawable) mBackgroundDrawable;
     ripple.setState(new int[] {android.R.attr.state_enabled});
     ripple.setHotspot(calculateCenterX(), calculateCenterY());
     ripple.setVisible(true, true);
   }
 }
Beispiel #2
0
  private void startRipple() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      final CoordinatorLayout coordinatorLayout =
          (CoordinatorLayout) findViewById(R.id.coordinator_layout);
      Drawable d = coordinatorLayout.getBackground();
      final RippleDrawable rippleDrawable = (RippleDrawable) d;
      rippleDrawable.setHotspot(
          mReset.getX() + mReset.getWidth() / 2, mReset.getY() + mReset.getHeight() / 2);
      rippleDrawable.setState(
          new int[] {android.R.attr.state_pressed, android.R.attr.state_enabled});
      coordinatorLayout.getBackground().setState(new int[] {});
    }

    mReset.hide();
    mElapsedTime = 0;
    setTime();
  }