/** * Set the enabled state of automatically resizing text. */ public AutofitHelper setEnabled(boolean enabled) { if (mEnabled != enabled) { mEnabled = enabled; if (enabled) { mTextView.addTextChangedListener(mTextWatcher); mTextView.addOnLayoutChangeListener(mOnLayoutChangeListener); autofit(); } else { mTextView.removeTextChangedListener(mTextWatcher); mTextView.removeOnLayoutChangeListener(mOnLayoutChangeListener); mTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize); } } return this; }
/** * Set the enabled state of automatically resizing text. */ public AutofitHelper setEnabled(boolean enabled) { if (mEnabled != enabled) { mEnabled = enabled; if (enabled) { mTextView.addTextChangedListener(mTextWatcher); mTextView.addOnLayoutChangeListener(mOnLayoutChangeListener); autofit(); } else { mTextView.removeTextChangedListener(mTextWatcher); mTextView.removeOnLayoutChangeListener(mOnLayoutChangeListener); mTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize); } } return this; }
@Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { mUrlBar.removeOnLayoutChangeListener(this); int[] newLoc = new int[2]; mUrlBar.getLocationInWindow(newLoc); mUrlBar.setScaleX(scale); mUrlBar.setScaleY(scale); mUrlBar.setTranslationX(oldLoc[0] - newLoc[0]); mUrlBar.setTranslationY(oldLoc[1] - newLoc[1]); mUrlBar.animate().scaleX(1f).scaleY(1f).translationX(0).translationY(0) .setDuration(CUSTOM_TAB_TOOLBAR_SLIDE_DURATION_MS) .setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mTitleBar.animate().alpha(1f) .setInterpolator(BakedBezierInterpolator.FADE_IN_CURVE) .setDuration(CUSTOM_TAB_TOOLBAR_FADE_DURATION_MS).start(); } }).start(); } });