Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -558,23 +558,62 @@ public boolean onAnimationCancel(View view) {
}

/**
* Close search view.
* Close search view. This will animate the closing of the view.
*/
public void closeSearch() {
closeSearch(true);
}

/**
* Close Search View. If animate is true, Animate the closing of the view.
*
* @param animate true for animate
*/
public void closeSearch(boolean animate) {
if (!isSearchOpen()) {
return;
}

mSearchSrcTextView.setText(null);
dismissSuggestions();
clearFocus();

mSearchLayout.setVisibility(GONE);
if (mSearchViewListener != null) {
mSearchViewListener.onSearchViewClosed();
if (animate) {
setInvisibleWithAnimation();
} else {
mSearchLayout.setVisibility(GONE);
if (mSearchViewListener != null) {
mSearchViewListener.onSearchViewClosed();
}
}
mIsSearchOpen = false;
}

private void setInvisibleWithAnimation() {
AnimationUtil.AnimationListener animationListener = new AnimationUtil.AnimationListener() {
@Override
public boolean onAnimationStart(View view) {
return false;
}

@Override
public boolean onAnimationEnd(View view) {
if (mSearchViewListener != null) {
mSearchViewListener.onSearchViewClosed();
}
return false;
}

@Override
public boolean onAnimationCancel(View view) {
return false;
}
};

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
AnimationUtil.disappear(mSearchTopBar, animationListener);
} else {
AnimationUtil.fadeOutView(mSearchLayout, mAnimationDuration, animationListener);
}
}

/**
Expand Down Expand Up @@ -725,4 +764,4 @@ public interface SearchViewListener {
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,40 @@ public void onAnimationRepeat(Animator animation) {
anim.start();
}

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void disappear(final View view, final AnimationListener listener) {
int cx = view.getWidth() - (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, 24, view.getResources().getDisplayMetrics());
int cy = view.getHeight() / 2;
int finalRadius = Math.max(view.getWidth(), view.getHeight());

Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, finalRadius, 0);
view.setVisibility(View.VISIBLE);
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
listener.onAnimationStart(view);
}

@Override
public void onAnimationEnd(Animator animation) {
view.setVisibility(View.GONE);
listener.onAnimationEnd(view);
}

@Override
public void onAnimationCancel(Animator animation) {
listener.onAnimationCancel(view);
}

@Override
public void onAnimationRepeat(Animator animation) {

}
});
anim.start();
}

public static void fadeOutView(View view) {
fadeOutView(view, ANIMATION_DURATION_SHORT);
}
Expand Down Expand Up @@ -139,4 +173,4 @@ public void onAnimationCancel(View view) {
}
});
}
}
}