Parcourir la source

0.0.50.beta34.pre
- Lifecycle.State.DESTROYED 时机调整到销毁 dialogImpl 之前;
- CustomDialog 中监听 baseView 位置变化的 OnDrawListener 修改为 OnPreDrawListener 以解决部分系统存在的兼容性问题;
- BaseDialog 新增 callDialogDismiss() 用于调用对应对话框实例的 dismiss()
- 新增 bindDismissWithLifecycleOwner(LifecycleOwner) 用于绑定具备特定生命周期的组件,当组件关闭时自动关闭对话框;
- PopTip 增加了限制最大可显示数量设置,例如限制只能显示最多四个提示 `PopTip.maxShowCount = 4;`;
- PopTip 增加了让位位移动画控制拦截器 PopMoveDisplacementInterceptor,可通过 `PopTip.moveDisplacementInterceptor` 进行设置;
- PopNotification 增加了限制最大可显示数量设置,例如限制只能显示最多四个提示 `PopNotification.maxShowCount = 4;`;
- PopNotification 增加了让位位移动画控制拦截器 PopMoveDisplacementInterceptor,可通过 `PopNotification.moveDisplacementInterceptor` 进行设置;
- PopMenu、BottomMenu、MessageMenu 增加了菜单分割线设置:`.setItemDivider(ItemDivider)`,其中ItemDivider 提供了 left(左边距(dp))、right(右边距(dp))、color(颜色)设置项,可通过对应的 set 方法进行设置,颜色设置中支持指定亮暗色模式(参数 light)单独设置不同的颜色;

Kongzue il y a 1 semaine
Parent
commit
3be640050c

+ 7 - 0
DialogX/src/main/java/com/kongzue/dialogx/dialogs/BottomMenu.java

@@ -37,6 +37,7 @@ import com.kongzue.dialogx.interfaces.OnMenuItemClickListener;
 import com.kongzue.dialogx.interfaces.OnMenuItemSelectListener;
 import com.kongzue.dialogx.interfaces.SELECT_MODE;
 import com.kongzue.dialogx.util.BottomMenuArrayAdapter;
+import com.kongzue.dialogx.util.ItemDivider;
 import com.kongzue.dialogx.util.TextInfo;
 import com.kongzue.dialogx.util.views.DialogListView;
 
@@ -62,6 +63,7 @@ public class BottomMenu extends BottomDialog {
     protected boolean showSelectedBackgroundTips = false;
     protected MenuItemLayoutRefreshCallback<BottomMenu> menuMenuItemLayoutRefreshCallback;
     protected Map<Integer, Boolean> menuUsability = new HashMap<Integer, Boolean>();
+    protected ItemDivider itemDivider;
 
     protected OnMenuItemClickListener<BottomMenu> onMenuItemClickListener;
 
@@ -673,6 +675,11 @@ public class BottomMenu extends BottomDialog {
             }
 
         }
+
+        if (itemDivider != null) {
+            listView.setDivider(itemDivider.createDividerDrawable(getOwnActivity(), isLightTheme()));
+            listView.setDividerHeight(itemDivider.getWidth());
+        }
         super.refreshUI();
     }
 

+ 19 - 4
DialogX/src/main/java/com/kongzue/dialogx/dialogs/MessageMenu.java

@@ -37,6 +37,7 @@ import com.kongzue.dialogx.interfaces.OnMenuItemClickListener;
 import com.kongzue.dialogx.interfaces.OnMenuItemSelectListener;
 import com.kongzue.dialogx.interfaces.SELECT_MODE;
 import com.kongzue.dialogx.util.BottomMenuArrayAdapter;
+import com.kongzue.dialogx.util.ItemDivider;
 import com.kongzue.dialogx.util.MessageMenuArrayAdapter;
 import com.kongzue.dialogx.util.TextInfo;
 import com.kongzue.dialogx.util.views.DialogListView;
@@ -58,6 +59,7 @@ public class MessageMenu extends MessageDialog {
     protected boolean showSelectedBackgroundTips = false;
     protected MenuItemLayoutRefreshCallback<MessageMenu> menuMenuItemLayoutRefreshCallback;
     protected Map<Integer, Boolean> menuUsability = new HashMap<Integer, Boolean>();
+    protected ItemDivider itemDivider;
 
     protected OnMenuItemClickListener<MessageMenu> onMenuItemClickListener;
 
@@ -665,6 +667,11 @@ public class MessageMenu extends MessageDialog {
             }
 
         }
+
+        if (itemDivider != null && listView != null) {
+            listView.setDivider(itemDivider.createDividerDrawable(getOwnActivity(), isLightTheme()));
+            listView.setDividerHeight(itemDivider.getWidth());
+        }
         super.refreshUI();
     }
 
@@ -1562,24 +1569,32 @@ public class MessageMenu extends MessageDialog {
         return this;
     }
 
-    public MessageMenu cleanAction(int actionId){
+    public MessageMenu cleanAction(int actionId) {
         dialogActionRunnableMap.remove(actionId);
         return this;
     }
 
-    public MessageMenu cleanAllAction(){
+    public MessageMenu cleanAllAction() {
         dialogActionRunnableMap.clear();
         return this;
     }
 
     // for BaseDialog use
-    public void callDialogDismiss(){
+    public void callDialogDismiss() {
         dismiss();
     }
 
-    public MessageMenu bindDismissWithLifecycleOwner(LifecycleOwner owner){
+    public MessageMenu bindDismissWithLifecycleOwner(LifecycleOwner owner) {
         super.bindDismissWithLifecycleOwnerPrivate(owner);
         return this;
     }
 
+    public ItemDivider getItemDivider() {
+        return itemDivider;
+    }
+
+    public MessageMenu setItemDivider(ItemDivider itemDivider) {
+        this.itemDivider = itemDivider;
+        return this;
+    }
 }

+ 20 - 4
DialogX/src/main/java/com/kongzue/dialogx/dialogs/PopMenu.java

@@ -43,6 +43,7 @@ import com.kongzue.dialogx.interfaces.OnBindView;
 import com.kongzue.dialogx.interfaces.OnIconChangeCallBack;
 import com.kongzue.dialogx.interfaces.OnMenuItemClickListener;
 import com.kongzue.dialogx.util.DialogXViewLoc;
+import com.kongzue.dialogx.util.ItemDivider;
 import com.kongzue.dialogx.util.PopMenuArrayAdapter;
 import com.kongzue.dialogx.util.TextInfo;
 import com.kongzue.dialogx.util.views.DialogXBaseRelativeLayout;
@@ -91,6 +92,7 @@ public class PopMenu extends BaseDialog {
     protected MenuItemLayoutRefreshCallback<PopMenu> menuMenuItemLayoutRefreshCallback;
     protected int pressedIndex = -1;
     protected Map<Integer, Boolean> menuUsability = new HashMap<Integer, Boolean>();
+    protected ItemDivider itemDivider;
 
     protected int alignGravity = -1;                                        // 指定菜单相对 baseView 的位置
 
@@ -673,6 +675,11 @@ public class PopMenu extends BaseDialog {
                 }
             }
 
+            if (itemDivider != null) {
+                listMenu.setDivider(itemDivider.createDividerDrawable(getOwnActivity(), isLightTheme()));
+                listMenu.setDividerHeight(itemDivider.getWidth());
+            }
+
             onDialogRefreshUI();
         }
 
@@ -1536,23 +1543,32 @@ public class PopMenu extends BaseDialog {
         return this;
     }
 
-    public PopMenu cleanAction(int actionId){
+    public PopMenu cleanAction(int actionId) {
         dialogActionRunnableMap.remove(actionId);
         return this;
     }
 
-    public PopMenu cleanAllAction(){
+    public PopMenu cleanAllAction() {
         dialogActionRunnableMap.clear();
         return this;
     }
 
     // for BaseDialog use
-    public void callDialogDismiss(){
+    public void callDialogDismiss() {
         dismiss();
     }
 
-    public PopMenu bindDismissWithLifecycleOwner(LifecycleOwner owner){
+    public PopMenu bindDismissWithLifecycleOwner(LifecycleOwner owner) {
         super.bindDismissWithLifecycleOwnerPrivate(owner);
         return this;
     }
+
+    public ItemDivider getItemDivider() {
+        return itemDivider;
+    }
+
+    public PopMenu setItemDivider(ItemDivider itemDivider) {
+        this.itemDivider = itemDivider;
+        return this;
+    }
 }

+ 124 - 21
DialogX/src/main/java/com/kongzue/dialogx/dialogs/PopNotification.java

@@ -40,6 +40,7 @@ import com.kongzue.dialogx.interfaces.NoTouchInterface;
 import com.kongzue.dialogx.interfaces.OnBindView;
 import com.kongzue.dialogx.interfaces.OnDialogButtonClickListener;
 import com.kongzue.dialogx.interfaces.OnSafeInsetsChangeListener;
+import com.kongzue.dialogx.interfaces.PopMoveDisplacementInterceptor;
 import com.kongzue.dialogx.util.PopValueAnimator;
 import com.kongzue.dialogx.util.TextInfo;
 import com.kongzue.dialogx.util.views.DialogXBaseRelativeLayout;
@@ -70,6 +71,9 @@ public class PopNotification extends BaseDialog implements NoTouchInterface {
     public static int overrideEnterAnimRes = 0;
     public static int overrideExitAnimRes = 0;
 
+    public static int maxShowCount = Integer.MAX_VALUE;
+    public static PopMoveDisplacementInterceptor<PopNotification> moveDisplacementInterceptor;
+
     protected OnBindView<PopNotification> onBindView;
     protected DialogLifecycleCallback<PopNotification> dialogLifecycleCallback;
     protected PopNotification me = this;
@@ -352,12 +356,21 @@ public class PopNotification extends BaseDialog implements NoTouchInterface {
         super.beforeShow();
         if (getDialogView() == null) {
             if (DialogX.onlyOnePopNotification) {
-                PopNotification oldInstance = null;
                 if (popNotificationList != null && !popNotificationList.isEmpty()) {
-                    oldInstance = popNotificationList.get(popNotificationList.size() - 1);
+                    popNotificationList.get(popNotificationList.size() - 1).dismiss();
                 }
-                if (oldInstance != null) {
-                    oldInstance.dismiss();
+            }else{
+                if (popNotificationList!=null) {
+                    CopyOnWriteArrayList<PopNotification> popNotificationCopyOnWriteArrayList = new CopyOnWriteArrayList<>(popNotificationList);
+                    for (int i = 0; i < popNotificationCopyOnWriteArrayList.size(); i++) {
+                        PopNotification popInstance = popNotificationCopyOnWriteArrayList.get(i);
+                        if (popNotificationCopyOnWriteArrayList.size() >= maxShowCount) {
+                            if (i <= popNotificationCopyOnWriteArrayList.size() - maxShowCount) {
+                                popInstance.dismiss();
+                                popNotificationList.remove(popInstance);
+                            }
+                        }
+                    }
                 }
             }
             if (popNotificationList == null) popNotificationList = new ArrayList<>();
@@ -630,7 +643,7 @@ public class PopNotification extends BaseDialog implements NoTouchInterface {
                         if (popNotificationList != null) {
                             for (int i = 0; i < popNotificationList.size() - 1; i++) {
                                 PopNotification popInstance = popNotificationList.get(i);
-                                popInstance.moveUp(boxBody.getHeight());
+                                popInstance.moveBack(boxBody.getHeight());
                             }
                         }
                     }
@@ -873,12 +886,22 @@ public class PopNotification extends BaseDialog implements NoTouchInterface {
                     public void run() {
                         getDialogXAnimImpl().doExitAnim(me, boxBody);
 
+                        preRecycle = true;
                         runOnMainDelay(new Runnable() {
                             @Override
                             public void run() {
                                 waitForDismiss();
                             }
                         }, getExitAnimationDuration(null));
+
+                        if (popNotificationList != null) {
+                            //使位于自己之前的PopTip moveDown
+                            int index = popNotificationList.indexOf(me);
+                            for (int i = 0; i < index; i++) {
+                                PopNotification popNotification = popNotificationList.get(i);
+                                popNotification.moveFront(boxBody.getHeight());
+                            }
+                        }
                     }
                 });
             }
@@ -962,6 +985,7 @@ public class PopNotification extends BaseDialog implements NoTouchInterface {
             return;
         }
         preRecycle = true;
+        getDialogView().setVisibility(View.GONE);
         CopyOnWriteArrayList<PopNotification> copyPopNotificationList = new CopyOnWriteArrayList<>(popNotificationList);
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
             copyPopNotificationList.removeIf(Objects::isNull);
@@ -973,21 +997,22 @@ public class PopNotification extends BaseDialog implements NoTouchInterface {
                 }
             }
         }
-        boolean allPreRecycled = true;
-        for (PopNotification popTip : copyPopNotificationList) {
-            if (!popTip.preRecycle) {
-                allPreRecycled = false;
-                break;
-            }
-        }
-        if (allPreRecycled) {
-            for (PopNotification popTip : copyPopNotificationList) {
-                dismiss(popTip.getDialogView());
-            }
-        }
-    }
-
-    private void moveUp(int newDialogHeight) {
+//        boolean allPreRecycled = true;
+//        for (PopNotification popTip : copyPopNotificationList) {
+//            if (!popTip.preRecycle) {
+//                allPreRecycled = false;
+//                break;
+//            }
+//        }
+//        if (allPreRecycled) {
+//            for (PopNotification popTip : copyPopNotificationList) {
+//                dismiss(popTip.getDialogView());
+//            }
+//        }
+        dismiss(getDialogView());
+    }
+
+    private void moveBack(int newDialogHeight) {
         if (getDialogImpl() != null && getDialogImpl().boxBody != null) {
             View bodyView = getDialogImpl().boxBody;
             if (getDialogImpl() == null || bodyView == null) return;
@@ -1013,6 +1038,11 @@ public class PopNotification extends BaseDialog implements NoTouchInterface {
                     moveAimTop = y - newDialogHeight * 1.1f;
                     break;
             }
+            if (moveDisplacementInterceptor != null) {
+                moveAimTop = moveDisplacementInterceptor.resetAnimY(popNotificationList == null ? 0 : popNotificationList.indexOf(me), me, bodyView.getY(), moveAimTop, (int) (bodyView.getHeight() / bodyView.getScaleY()), popNotificationList == null ? 1 : popNotificationList.size(), true);
+            }
+            final float fromY = bodyView.getY();
+            float toY = moveAimTop;
             PopValueAnimator valueAnimator = PopValueAnimator.ofFloat(bodyView.getY(), moveAimTop);
             bodyView.setTag(valueAnimator);
             valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@@ -1023,8 +1053,13 @@ public class PopNotification extends BaseDialog implements NoTouchInterface {
                         return;
                     }
                     View bodyView = getDialogImpl().boxBody;
+                    float value = (Float) animation.getAnimatedValue();
+                    float totalDistance = toY - fromY;
+                    if (moveDisplacementInterceptor != null && moveDisplacementInterceptor.animUpdater(popNotificationList == null ? 0 : popNotificationList.indexOf(me), me, bodyView, fromY, toY, Math.max(0f, Math.min(1f, (totalDistance == 0f ? 1f : (value - fromY) / totalDistance))), animation, popNotificationList == null ? 1 : countDisplayPopNotificationNum(), true)) {
+                        return;
+                    }
                     if (bodyView != null && bodyView.isAttachedToWindow()) {
-                        bodyView.setY(defaultTop = (Float) animation.getAnimatedValue());
+                        bodyView.setY(defaultTop = value);
                     }
                 }
             });
@@ -1033,6 +1068,74 @@ public class PopNotification extends BaseDialog implements NoTouchInterface {
         }
     }
 
+    private void moveFront(int newDialogHeight) {
+        if (getDialogImpl() != null && getDialogImpl().boxBody != null) {
+            View bodyView = getDialogImpl().boxBody;
+            if (getDialogImpl() == null || bodyView == null) return;
+            if (style.popNotificationSettings() != null)
+                align = style.popNotificationSettings().align();
+            if (align == null) align = DialogXStyle.PopNotificationSettings.ALIGN.TOP;
+            float moveAimTop = 0;
+            float y = bodyView.getY();
+            if (bodyView.getTag() instanceof PopValueAnimator) {
+                ((PopValueAnimator) bodyView.getTag()).end();
+                y = ((PopValueAnimator) bodyView.getTag()).getEndValue();
+            }
+            switch (align) {
+                case TOP:
+                    moveAimTop = y - newDialogHeight * 1.1f;
+                    break;
+                case TOP_INSIDE:
+                    moveAimTop = y - newDialogHeight + bodyView.getPaddingTop();
+                    break;
+                case CENTER:
+                case BOTTOM:
+                case BOTTOM_INSIDE:
+                    moveAimTop = y + newDialogHeight * 1.1f;
+                    break;
+            }
+            if (moveDisplacementInterceptor != null) {
+                moveAimTop = moveDisplacementInterceptor.resetAnimY(popNotificationList == null ? 0 : popNotificationList.indexOf(me), me, bodyView.getY(), moveAimTop, (int) (bodyView.getHeight() / bodyView.getScaleY()), popNotificationList == null ? 1 : popNotificationList.size(), false);
+            }
+            final float fromY = bodyView.getY();
+            float toY = moveAimTop;
+            PopValueAnimator valueAnimator = PopValueAnimator.ofFloat(fromY, toY);
+            bodyView.setTag(valueAnimator);
+            valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+                @Override
+                public void onAnimationUpdate(ValueAnimator animation) {
+                    if (getDialogImpl() == null || !isShow) {
+                        animation.cancel();
+                        return;
+                    }
+                    View bodyView = getDialogImpl().boxBody;
+                    float value = (Float) animation.getAnimatedValue();
+                    float totalDistance = toY - fromY;
+                    if (moveDisplacementInterceptor != null && moveDisplacementInterceptor.animUpdater(popNotificationList == null ? 0 : popNotificationList.indexOf(me), me, bodyView, fromY, toY, Math.max(0f, Math.min(1f, (totalDistance == 0f ? 1f : (value - fromY) / totalDistance))), animation, popNotificationList == null ? 1 : countDisplayPopNotificationNum(), false)) {
+                        return;
+                    }
+                    if (bodyView != null && bodyView.isAttachedToWindow()) {
+                        bodyView.setY(defaultTop = value);
+                    }
+                }
+            });
+            valueAnimator.setDuration(exitAnimDuration == -1 ? 300 : exitAnimDuration).setInterpolator(new DecelerateInterpolator(2f));
+            valueAnimator.start();
+        }
+    }
+
+    private int countDisplayPopNotificationNum() {
+        if (popNotificationList == null) return 0;
+        int count = 0;
+        for (int i = 0; i < popNotificationList.size(); i++) {
+            PopNotification tips = popNotificationList.get(i);
+            if (tips != null && !tips.preRecycle) {
+                count++;
+            }
+        }
+        return count;
+    }
+
     public void refreshUI() {
         if (getDialogImpl() == null) return;
         runOnMain(new Runnable() {

+ 8 - 8
DialogX/src/main/java/com/kongzue/dialogx/dialogs/PopTip.java

@@ -68,7 +68,7 @@ public class PopTip extends BaseDialog implements NoTouchInterface {
     public static int overrideEnterAnimRes = 0;
     public static int overrideExitAnimRes = 0;
     public static int maxShowCount = Integer.MAX_VALUE;
-    public static PopMoveDisplacementInterceptor<PopTip> moveUpDisplacementInterceptor;
+    public static PopMoveDisplacementInterceptor<PopTip> moveDisplacementInterceptor;
 
     protected OnBindView<PopTip> onBindView;
     protected DialogLifecycleCallback<PopTip> dialogLifecycleCallback;
@@ -885,8 +885,8 @@ public class PopTip extends BaseDialog implements NoTouchInterface {
                             moveAimTop = bodyView.getY() - bodyView.getHeight() * 1.3f;
                             break;
                     }
-                    if (moveUpDisplacementInterceptor != null) {
-                        moveAimTop = moveUpDisplacementInterceptor.resetAnimY(popTipList == null ? 0 : popTipList.indexOf(me), me, bodyView.getY(), moveAimTop, (int) (bodyView.getHeight() / bodyView.getScaleY()), popTipList == null ? 1 : popTipList.size(), true);
+                    if (moveDisplacementInterceptor != null) {
+                        moveAimTop = moveDisplacementInterceptor.resetAnimY(popTipList == null ? 0 : popTipList.indexOf(me), me, bodyView.getY(), moveAimTop, (int) (bodyView.getHeight() / bodyView.getScaleY()), popTipList == null ? 1 : popTipList.size(), true);
                     }
                     if (bodyView.getTag() instanceof ValueAnimator) {
                         ((ValueAnimator) bodyView.getTag()).end();
@@ -906,7 +906,7 @@ public class PopTip extends BaseDialog implements NoTouchInterface {
                             View bodyView = getDialogImpl().boxBody;
                             float value = (Float) animation.getAnimatedValue();
                             float totalDistance = toY - fromY;
-                            if (moveUpDisplacementInterceptor != null && moveUpDisplacementInterceptor.animUpdater(popTipList == null ? 0 : popTipList.indexOf(me), me, bodyView, fromY, toY, Math.max(0f, Math.min(1f, (totalDistance == 0f ? 1f : (value - fromY) / totalDistance))), animation, popTipList == null ? 1 : countDisplayPopTipsNum(), true)) {
+                            if (moveDisplacementInterceptor != null && moveDisplacementInterceptor.animUpdater(popTipList == null ? 0 : popTipList.indexOf(me), me, bodyView, fromY, toY, Math.max(0f, Math.min(1f, (totalDistance == 0f ? 1f : (value - fromY) / totalDistance))), animation, popTipList == null ? 1 : countDisplayPopTipsNum(), true)) {
                                 return;
                             }
                             if (bodyView != null && bodyView.isAttachedToWindow()) {
@@ -949,8 +949,8 @@ public class PopTip extends BaseDialog implements NoTouchInterface {
                             moveAimTop = bodyView.getY() + bodyView.getHeight() * 1.3f;
                             break;
                     }
-                    if (moveUpDisplacementInterceptor != null) {
-                        moveAimTop = moveUpDisplacementInterceptor.resetAnimY(popTipList == null ? 0 : popTipList.indexOf(me), me, bodyView.getY(), moveAimTop, (int) (bodyView.getHeight() / bodyView.getScaleY()), popTipList == null ? 1 : popTipList.size(), false);
+                    if (moveDisplacementInterceptor != null) {
+                        moveAimTop = moveDisplacementInterceptor.resetAnimY(popTipList == null ? 0 : popTipList.indexOf(me), me, bodyView.getY(), moveAimTop, (int) (bodyView.getHeight() / bodyView.getScaleY()), popTipList == null ? 1 : popTipList.size(), false);
                     }
                     if (bodyView.getTag() instanceof ValueAnimator) {
                         ((ValueAnimator) bodyView.getTag()).end();
@@ -970,7 +970,7 @@ public class PopTip extends BaseDialog implements NoTouchInterface {
                             View bodyView = getDialogImpl().boxBody;
                             float value = (Float) animation.getAnimatedValue();
                             float totalDistance = toY - fromY;
-                            if (moveUpDisplacementInterceptor != null && moveUpDisplacementInterceptor.animUpdater(popTipList == null ? 0 : popTipList.indexOf(me), me, bodyView, fromY, toY, Math.max(0f, Math.min(1f, (totalDistance == 0f ? 1f : (value - fromY) / totalDistance))), animation, popTipList == null ? 1 : countDisplayPopTipsNum(), false)) {
+                            if (moveDisplacementInterceptor != null && moveDisplacementInterceptor.animUpdater(popTipList == null ? 0 : popTipList.indexOf(me), me, bodyView, fromY, toY, Math.max(0f, Math.min(1f, (totalDistance == 0f ? 1f : (value - fromY) / totalDistance))), animation, popTipList == null ? 1 : countDisplayPopTipsNum(), false)) {
                                 return;
                             }
                             if (bodyView != null && bodyView.isAttachedToWindow()) {
@@ -978,7 +978,7 @@ public class PopTip extends BaseDialog implements NoTouchInterface {
                             }
                         }
                     });
-                    valueAnimator.setDuration(enterAnimDuration == -1 ? 300 : enterAnimDuration).setInterpolator(new DecelerateInterpolator(2f));
+                    valueAnimator.setDuration(exitAnimDuration == -1 ? 300 : exitAnimDuration).setInterpolator(new AccelerateInterpolator(2f));
                     valueAnimator.start();
                 }
             });

+ 88 - 0
DialogX/src/main/java/com/kongzue/dialogx/util/ItemDivider.java

@@ -0,0 +1,88 @@
+package com.kongzue.dialogx.util;
+
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.GradientDrawable;
+import android.graphics.drawable.InsetDrawable;
+
+public class ItemDivider {
+
+    private int left;       //左边距(dp)
+    private int right;      //右边距(dp)
+    private int width = 1;  //分割线宽度(px)
+    private int[] color = {0xFFF3F4F6, 0xFF3A3A3A};     //颜色
+
+    public ItemDivider(int left, int right, int width) {
+        this.left = left;
+        this.right = right;
+        this.width = width;
+    }
+
+    public int getLeft() {
+        return left;
+    }
+
+    public ItemDivider setLeft(int left) {
+        this.left = left;
+        return this;
+    }
+
+    public int getRight() {
+        return right;
+    }
+
+    public ItemDivider setRight(int right) {
+        this.right = right;
+        return this;
+    }
+
+    public int getWidth() {
+        return width;
+    }
+
+    public ItemDivider setWidth(int width) {
+        this.width = width;
+        return this;
+    }
+
+    public int getColor(boolean light) {
+        return light ? color[0] : color[1];
+    }
+
+    public ItemDivider setColor(boolean light, int color) {
+        if (light) {
+            this.color[0] = color;
+        } else {
+            this.color[1] = color;
+        }
+        return this;
+    }
+
+    @Override
+    public String toString() {
+        return "ItemDivider{" +
+                "left(dp)=" + left +
+                ", right(dp)=" + right +
+                ", width(px)=" + width +
+                ", color(light)=" + String.format("#%06X", (0xFFFFFF & color[0])) +
+                ", color(night)=" + String.format("#%06X", (0xFFFFFF & color[1])) +
+                '}';
+    }
+
+    public Drawable createDividerDrawable(Context c, boolean light) {
+        GradientDrawable dividerShape = new GradientDrawable();
+        dividerShape.setShape(GradientDrawable.RECTANGLE);
+        dividerShape.setColor(getColor(light));
+
+        InsetDrawable insetDivider = new InsetDrawable(
+                dividerShape,
+                dip2px(c, left), 0, dip2px(c, right), 0
+        );
+        return insetDivider;
+    }
+
+    private int dip2px(Context c, float dpValue) {
+        final float scale = c.getResources().getDisplayMetrics().density;
+        return (int) (dpValue * scale + 0.5f);
+    }
+}

+ 2 - 2
app/src/main/java/com/kongzue/dialogxdemo/activity/MainActivity.java

@@ -1287,7 +1287,7 @@ public class MainActivity extends BaseActivity {
         };
 
         //重置位移动画位置
-        PopTip.moveUpDisplacementInterceptor = new PopMoveDisplacementInterceptor<PopTip>() {
+        PopTip.moveDisplacementInterceptor = new PopMoveDisplacementInterceptor<PopTip>() {
             @Override
             public float resetAnimY(int index, PopTip dialog, float fromY, float toY, int dialogHeight, int allTipSize, boolean moveBack) {
                 if (moveBack) {
@@ -1464,7 +1464,7 @@ public class MainActivity extends BaseActivity {
                 }).setScrollableWhenContentLargeThanVisibleRange(false).show();
             }
         });
-
+        PopNotification.maxShowCount=3;
         btnPopnotification.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {