Пример #1
0
  /**
   * call when you want to animate the highlight in or out - this is NOT dependant on {@link
   * #setChecked(boolean)} above because on scroll, among other layout calls, would trigger
   * setChecked many, many times
   *
   * @param checked
   */
  public void animateHighlight(boolean checked) {
    if (mHighlightAnimator != null && mHighlightAnimator.isRunning()) {
      mHighlightAnimator.cancel();
      mHighlightAnimator.removeAllUpdateListeners();
      mHighlightAnimator.removeAllListeners();
    }

    if (checked) {
      mHighlightAnimator = ValueAnimator.ofFloat(0, mMaxWidth);
    } else {
      mHighlightAnimator = ValueAnimator.ofFloat(mMaxWidth, 0);
    }

    mHighlightAnimator.setDuration(250);
    mHighlightAnimator.addListener(mHighlightAnimatorListener);
    mHighlightAnimator.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            mPinkPaint.setStrokeWidth((float) animation.getAnimatedValue());
            postInvalidate();
          }
        });
    mHighlightAnimator.start();
  }
Пример #2
0
 /*package*/ void teardown() {
   if (jumpAnimator != null) {
     jumpAnimator.cancel();
     jumpAnimator.removeAllListeners();
   }
   if (textView.get() != null) {
     textView.clear();
   }
 }
  public MultiLineMarqueeTextView(Context context, AttributeSet attrs) {
    super(context, attrs);

    // get display size and density.
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();
    Point point = new Point();
    display.getSize(point);
    displayWidth = point.x;
    displayHeight = point.y;
    final float density = getResources().getDisplayMetrics().density;

    // load XML settings
    parseXmlSettings(context, attrs, density);

    paint.setAntiAlias(true);

    adjustTextBaseline = paint.descent() + paint.ascent();
    textHeight = Math.abs(paint.getFontMetrics().top) + paint.getFontMetrics().bottom;
    intervalSecondText = (int) (INTERVAL_SECOND_TEXT_DIPS * density);

    LinearInterpolator linearInterpolator = new LinearInterpolator();
    translateAnimator = ValueAnimator.ofFloat(0.0f, -1.0f);
    translateAnimator.setInterpolator(linearInterpolator);
    translateAnimator.removeAllUpdateListeners();
    translateAnimator.addUpdateListener(animatorUpdateListener);
    translateAnimator.removeAllListeners();
    translateAnimator.addListener(animatorListener);
    translateAnimator.setDuration(DURATION_TRANSLATE);

    suspendAnimator = ValueAnimator.ofFloat(0.0f, 0.0f);
    suspendAnimator.setInterpolator(linearInterpolator);
    suspendAnimator.removeAllUpdateListeners();
    suspendAnimator.addUpdateListener(animatorUpdateListener);
    suspendAnimator.removeAllListeners();
    suspendAnimator.addListener(animatorListener);
    suspendAnimator.setDuration(DURATION_SUSPEND);

    changeTapReset();
  }