1
0
mirror of https://github.com/NekoX-Dev/NekoX.git synced 2024-12-13 20:11:11 +01:00
This commit is contained in:
世界 2021-03-24 14:19:35 +08:00
parent d56dc04314
commit 352eafcb9e
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4

View File

@ -665,7 +665,6 @@ public class ActionBarMenuItem extends FrameLayout {
return searchContainer.getVisibility() == VISIBLE;
}
AnimatorSet searchContainerAnimator;
public boolean toggleSearch(boolean openKeyboard) {
if (searchContainer == null || (listener != null && !listener.canToggleSearch())) {
@ -678,41 +677,8 @@ public class ActionBarMenuItem extends FrameLayout {
return true;
}
}
ArrayList<View> menuIcons = new ArrayList<>();
for (int i = 0; i < parentMenu.getChildCount(); i++) {
View view = parentMenu.getChildAt(i);
if (view instanceof ActionBarMenuItem) {
View iconView = ((ActionBarMenuItem) view).getIconView();
if (iconView != null) {
menuIcons.add(iconView);
}
}
}
if (searchContainer.getTag() != null) {
searchContainer.setTag(null);
if (searchContainerAnimator != null) {
searchContainerAnimator.removeAllListeners();
searchContainerAnimator.cancel();
}
searchContainerAnimator = new AnimatorSet();
searchContainerAnimator.playTogether(ObjectAnimator.ofFloat(searchContainer, View.ALPHA, searchContainer.getAlpha(), 0f));
for (int i = 0; i < menuIcons.size(); i++) {
menuIcons.get(i).setAlpha(0f);
searchContainerAnimator.playTogether(ObjectAnimator.ofFloat(menuIcons.get(i), View.ALPHA, menuIcons.get(i).getAlpha(), 1f));
}
searchContainerAnimator.setDuration(150);
searchContainerAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
searchContainer.setAlpha(0);
for (int i = 0; i < menuIcons.size(); i++) {
menuIcons.get(i).setAlpha(1f);
}
searchContainer.setVisibility(View.GONE);
}
});
searchContainerAnimator.start();
if (searchContainer.getVisibility() == VISIBLE) {
searchContainer.setVisibility(GONE);
searchField.clearFocus();
setVisibility(VISIBLE);
@ -734,29 +700,8 @@ public class ActionBarMenuItem extends FrameLayout {
}
return false;
} else {
searchContainer.setTag(1);
searchContainer.setVisibility(VISIBLE);
searchContainer.setAlpha(0);
if (searchContainerAnimator != null) {
searchContainerAnimator.removeAllListeners();
searchContainerAnimator.cancel();
}
searchContainerAnimator = new AnimatorSet();
searchContainerAnimator.playTogether(ObjectAnimator.ofFloat(searchContainer, View.ALPHA, searchContainer.getAlpha(), 1f));
for (int i = 0; i < menuIcons.size(); i++) {
searchContainerAnimator.playTogether(ObjectAnimator.ofFloat(menuIcons.get(i), View.ALPHA, menuIcons.get(i).getAlpha(), 0f));
}
searchContainerAnimator.setDuration(150);
searchContainerAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
searchContainer.setAlpha(1f);
for (int i = 0; i < menuIcons.size(); i++) {
menuIcons.get(i).setAlpha(0f);
}
}
});
searchContainerAnimator.start();
setVisibility(GONE);
searchField.setText("");
searchField.requestFocus();