1
0
kongzue 3 жил өмнө
parent
commit
c6406113ec

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

@@ -249,6 +249,7 @@ public class PopMenu extends BaseDialog {
         
         @Override
         public void init() {
+            closing = false;
             if (menuListAdapter == null) {
                 menuListAdapter = new PopMenuArrayAdapter(me, getTopActivity(), menuList);
             }
@@ -537,8 +538,10 @@ public class PopMenu extends BaseDialog {
             listMenu.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                 @Override
                 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
-                    if (!getOnMenuItemClickListener().onClick(me, menuList.get(position), position)) {
-                        dismiss();
+                    if (!closing) {
+                        if (!getOnMenuItemClickListener().onClick(me, menuList.get(position), position)) {
+                            dismiss();
+                        }
                     }
                 }
             });
@@ -651,7 +654,10 @@ public class PopMenu extends BaseDialog {
         return getDialogImpl().boxBody.getMeasuredHeight();
     }
     
+    private boolean closing;
+    
     public void dismiss() {
+        closing = true;
         runOnMain(new Runnable() {
             @Override
             public void run() {

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

@@ -72,6 +72,7 @@ public class PopTip extends BaseDialog {
     
     protected TextInfo messageTextInfo;
     protected TextInfo buttonTextInfo = new TextInfo().setBold(true);
+    protected int[] bodyMargin = new int[4];
     
     protected PopTip() {
         super();
@@ -461,6 +462,10 @@ public class PopTip extends BaseDialog {
             RelativeLayout.LayoutParams rlp;
             rlp = ((RelativeLayout.LayoutParams) boxBody.getLayoutParams());
             if (align == null) align = DialogXStyle.PopTipSettings.ALIGN.BOTTOM;
+            rlp.leftMargin = bodyMargin[0];
+            rlp.topMargin = bodyMargin[1];
+            rlp.rightMargin = bodyMargin[2];
+            rlp.bottomMargin = bodyMargin[3];
             switch (align) {
                 case TOP:
                     rlp.removeRule(RelativeLayout.CENTER_IN_PARENT);
@@ -483,7 +488,7 @@ public class PopTip extends BaseDialog {
                 @Override
                 public void onChange(Rect unsafeRect) {
                     if (align == DialogXStyle.PopTipSettings.ALIGN.TOP) {
-                        boxBody.setY(unsafeRect.top);
+                        boxBody.setY(unsafeRect.top + bodyMargin[1]);
                     } else if (align == DialogXStyle.PopTipSettings.ALIGN.TOP_INSIDE) {
                         boxBody.setPadding(0, unsafeRect.top, 0, 0);
                     }
@@ -584,25 +589,25 @@ public class PopTip extends BaseDialog {
         @Override
         public void doDismiss(final View v) {
             if (v != null) v.setEnabled(false);
-    
+            
             if (!dismissAnimFlag) {
                 dismissAnimFlag = true;
                 boxRoot.post(new Runnable() {
                     @Override
                     public void run() {
-            
+                        
                         Animation exitAnim = AnimationUtils.loadAnimation(getTopActivity() == null ? boxRoot.getContext() : getTopActivity(), exitAnimResId == 0 ? R.anim.anim_dialogx_default_exit : exitAnimResId);
                         if (exitAnimDuration != -1) {
                             exitAnim.setDuration(exitAnimDuration);
                         }
                         exitAnim.setFillAfter(true);
                         boxBody.startAnimation(exitAnim);
-            
+                        
                         boxRoot.animate()
                                 .alpha(0f)
                                 .setInterpolator(new AccelerateInterpolator())
                                 .setDuration(exitAnimDuration == -1 ? exitAnim.getDuration() : exitAnimDuration);
-            
+                        
                         new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
                             @Override
                             public void run() {
@@ -664,7 +669,7 @@ public class PopTip extends BaseDialog {
                             .setInterpolator(new DecelerateInterpolator(2f))
                     ;
                 }
-            },150);
+            }, 150);
         }
     }
     
@@ -972,4 +977,48 @@ public class PopTip extends BaseDialog {
         this.dialogImplMode = dialogImplMode;
         return this;
     }
+    
+    public PopTip setMargin(int left, int top, int right, int bottom) {
+        bodyMargin[0] = left;
+        bodyMargin[1] = top;
+        bodyMargin[2] = right;
+        bodyMargin[3] = bottom;
+        return this;
+    }
+    
+    public PopTip setMarginLeft(int left) {
+        bodyMargin[0] = left;
+        return this;
+    }
+    
+    public PopTip setMarginTop(int top) {
+        bodyMargin[1] = top;
+        return this;
+    }
+    
+    public PopTip setMarginRight(int right) {
+        bodyMargin[2] = right;
+        return this;
+    }
+    
+    public PopTip setMarginBottom(int bottom) {
+        bodyMargin[3] = bottom;
+        return this;
+    }
+    
+    public int getMarginLeft() {
+        return bodyMargin[0];
+    }
+    
+    public int getMarginTop() {
+        return bodyMargin[1];
+    }
+    
+    public int getMarginRight() {
+        return bodyMargin[2];
+    }
+    
+    public int getMarginBottom() {
+        return bodyMargin[3];
+    }
 }

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

@@ -47,6 +47,7 @@ import com.kongzue.dialogx.dialogs.TipDialog;
 import com.kongzue.dialogx.dialogs.WaitDialog;
 import com.kongzue.dialogx.interfaces.BaseDialog;
 import com.kongzue.dialogx.interfaces.DialogLifecycleCallback;
+import com.kongzue.dialogx.interfaces.DialogXStyle;
 import com.kongzue.dialogx.interfaces.MenuItemTextInfoInterceptor;
 import com.kongzue.dialogx.interfaces.OnBackPressedListener;
 import com.kongzue.dialogx.interfaces.OnBindView;
@@ -820,7 +821,7 @@ public class MainActivity extends BaseActivity {
             @Override
             public void onClick(View v) {
                 CustomDialog.show(new OnBindView<CustomDialog>(R.layout.layout_custom_dialog_align) {
-            
+                            
                             private TextView btnSelectPositive;
                             
                             @Override
@@ -1050,7 +1051,7 @@ public class MainActivity extends BaseActivity {
     public void onConfigurationChanged(@NonNull Configuration newConfig) {
         super.onConfigurationChanged(newConfig);
         refreshUIMode();
-      
+        
     }
     
     /**

+ 1 - 1
gradle.properties

@@ -19,5 +19,5 @@ android.useAndroidX=true
 # Automatically convert third-party libraries to use AndroidX
 android.enableJetifier=true
 
-BUILD_VERSION=0.0.45.beta21
+BUILD_VERSION=0.0.45.beta22
 BUILD_VERSION_INT=44