use of com.hippo.yorozuya.SimpleAnimatorListener in project EhViewer by seven332.
the class FabLayout method setSecondaryFabAnimation.
private void setSecondaryFabAnimation(final View child, final boolean expanded, boolean delay) {
float startTranslationY;
float endTranslationY;
float startAlpha;
float endAlpha;
Interpolator interpolator;
if (expanded) {
startTranslationY = mMainFabCenterY - (child.getTop() + (child.getHeight() / 2));
endTranslationY = 0f;
startAlpha = 0f;
endAlpha = 1f;
interpolator = AnimationUtils.FAST_SLOW_INTERPOLATOR;
} else {
startTranslationY = 0f;
endTranslationY = mMainFabCenterY - (child.getTop() + (child.getHeight() / 2));
startAlpha = 1f;
endAlpha = 0f;
interpolator = AnimationUtils.SLOW_FAST_INTERPOLATOR;
}
child.setAlpha(startAlpha);
child.setTranslationY(startTranslationY);
child.animate().alpha(endAlpha).translationY(endTranslationY).setStartDelay(delay ? ANIMATE_TIME : 0L).setDuration(ANIMATE_TIME).setInterpolator(interpolator).setListener(new SimpleAnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
if (expanded) {
child.setVisibility(View.VISIBLE);
}
}
@Override
public void onAnimationEnd(Animator animation) {
if (!expanded) {
child.setVisibility(View.INVISIBLE);
}
}
}).start();
}
use of com.hippo.yorozuya.SimpleAnimatorListener in project EhViewer by seven332.
the class SearchBarMover method returnSearchBarPosition.
@SuppressWarnings("SimplifiableIfStatement")
public void returnSearchBarPosition(boolean animation) {
if (mSearchBar.getHeight() == 0) {
// Layout not called
return;
}
boolean show;
if (mHelper.forceShowSearchBar()) {
show = true;
} else {
RecyclerView recyclerView = mHelper.getValidRecyclerView();
if (recyclerView == null) {
return;
}
if (!recyclerView.isShown()) {
show = true;
} else if (recyclerView.computeVerticalScrollOffset() < mSearchBar.getBottom()) {
show = true;
} else {
show = (int) ViewUtils.getY2(mSearchBar) > (mSearchBar.getHeight()) / 2;
}
}
int offset;
if (show) {
offset = -(int) mSearchBar.getTranslationY();
} else {
offset = -(int) ViewUtils.getY2(mSearchBar);
}
if (offset == 0) {
// No need to scroll
return;
}
if (animation) {
if (mSearchBarMoveAnimator != null) {
if (mShow == show) {
// The same target, no need to do animation
return;
} else {
// Cancel it
mSearchBarMoveAnimator.cancel();
mSearchBarMoveAnimator = null;
}
}
mShow = show;
final ValueAnimator va = ValueAnimator.ofInt(0, offset);
va.setDuration(ANIMATE_TIME);
va.addListener(new SimpleAnimatorListener() {
@Override
public void onAnimationEnd(Animator animation) {
mSearchBarMoveAnimator = null;
}
});
va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
int lastValue;
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int value = (Integer) animation.getAnimatedValue();
int offsetStep = value - lastValue;
lastValue = value;
ViewUtils.translationYBy(mSearchBar, offsetStep);
}
});
mSearchBarMoveAnimator = va;
va.start();
} else {
if (mSearchBarMoveAnimator != null) {
mSearchBarMoveAnimator.cancel();
}
ViewUtils.translationYBy(mSearchBar, offset);
}
}
use of com.hippo.yorozuya.SimpleAnimatorListener in project EhViewer by seven332.
the class SearchBarMover method showSearchBar.
public void showSearchBar(boolean animation) {
if (mSearchBar.getHeight() == 0) {
// Layout not called
return;
}
final int offset = -(int) mSearchBar.getTranslationY();
if (offset == 0) {
// No need to scroll
return;
}
if (animation) {
if (mSearchBarMoveAnimator != null) {
if (mShow) {
// The same target, no need to do animation
return;
} else {
// Cancel it
mSearchBarMoveAnimator.cancel();
mSearchBarMoveAnimator = null;
}
}
mShow = true;
final ValueAnimator va = ValueAnimator.ofInt(0, offset);
va.setDuration(ANIMATE_TIME);
va.addListener(new SimpleAnimatorListener() {
@Override
public void onAnimationEnd(Animator animation) {
mSearchBarMoveAnimator = null;
}
});
va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
int lastValue;
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int value = (Integer) animation.getAnimatedValue();
int offsetStep = value - lastValue;
lastValue = value;
ViewUtils.translationYBy(mSearchBar, offsetStep);
}
});
mSearchBarMoveAnimator = va;
va.start();
} else {
if (mSearchBarMoveAnimator != null) {
mSearchBarMoveAnimator.cancel();
}
ViewUtils.translationYBy(mSearchBar, offset);
}
}
use of com.hippo.yorozuya.SimpleAnimatorListener in project EhViewer by seven332.
the class SearchBar method showImeAndSuggestionsList.
public void showImeAndSuggestionsList(boolean animation) {
// Show ime
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(mEditText, 0);
// update suggestion for show suggestions list
updateSuggestions();
// Show suggestions list
if (animation) {
ObjectAnimator oa = ObjectAnimator.ofFloat(this, "progress", 1f);
oa.setDuration(ANIMATE_TIME);
oa.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR);
oa.addListener(new SimpleAnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
mListContainer.setVisibility(View.VISIBLE);
mInAnimation = true;
}
@Override
public void onAnimationEnd(Animator animation) {
mInAnimation = false;
}
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
oa.setAutoCancel(true);
}
oa.start();
} else {
mListContainer.setVisibility(View.VISIBLE);
setProgress(1f);
}
}
Aggregations