fix ActionBarPopupWindow

This commit is contained in:
世界 2020-05-02 15:11:27 +08:00
parent 639fa39e1e
commit 83440a5cb1
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
1 changed files with 8 additions and 5 deletions

View File

@ -401,9 +401,14 @@ public class ActionBarPopupWindow extends PopupWindow {
content.setPivotX(content.getMeasuredWidth());
content.setPivotY(0);
int count = content.getItemsCount();
int height = AndroidUtilities.displayMetrics.heightPixels;
int item = content.getItemAt(0).getMeasuredHeight();
if (item > 0) {
int maxItems = height / item;
if (count > maxItems) count = maxItems;
}
content.positions.clear();
int visibleCount = 0;
int height = AndroidUtilities.displayMetrics.heightPixels;
for (int a = 0; a < count; a++) {
View child = content.getItemAt(a);
child.setAlpha(0.0f);
@ -413,8 +418,6 @@ public class ActionBarPopupWindow extends PopupWindow {
content.positions.put(child, visibleCount);
visibleCount++;
}
int maxItems = height / content.getItemAt(0).getMeasuredHeight();
if (visibleCount > maxItems) visibleCount = maxItems;
if (content.showedFromBotton) {
content.lastStartedChild = count - 1;
} else {
@ -425,6 +428,7 @@ public class ActionBarPopupWindow extends PopupWindow {
ObjectAnimator.ofFloat(content, "backScaleY", 0.0f, 1.0f),
ObjectAnimator.ofInt(content, "backAlpha", 0, 255));
windowAnimatorSet.setDuration(150 + 16 * visibleCount);
int finalCount = count;
windowAnimatorSet.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
@ -435,8 +439,7 @@ public class ActionBarPopupWindow extends PopupWindow {
public void onAnimationEnd(Animator animation) {
windowAnimatorSet = null;
ActionBarPopupWindowLayout content = (ActionBarPopupWindowLayout) getContentView();
int count = content.getItemsCount();
for (int a = 0; a < count; a++) {
for (int a = 0; a < finalCount; a++) {
View child = content.getItemAt(a);
child.setAlpha(1.0f);
}