|
@@ -31,6 +31,7 @@ import com.kongzue.dialogx.interfaces.OnBindView;
|
|
import com.kongzue.dialogx.interfaces.OnIconChangeCallBack;
|
|
import com.kongzue.dialogx.interfaces.OnIconChangeCallBack;
|
|
import com.kongzue.dialogx.interfaces.OnMenuItemClickListener;
|
|
import com.kongzue.dialogx.interfaces.OnMenuItemClickListener;
|
|
import com.kongzue.dialogx.util.PopMenuArrayAdapter;
|
|
import com.kongzue.dialogx.util.PopMenuArrayAdapter;
|
|
|
|
+import com.kongzue.dialogx.util.TextInfo;
|
|
import com.kongzue.dialogx.util.views.DialogXBaseRelativeLayout;
|
|
import com.kongzue.dialogx.util.views.DialogXBaseRelativeLayout;
|
|
import com.kongzue.dialogx.util.views.MaxLinearLayout;
|
|
import com.kongzue.dialogx.util.views.MaxLinearLayout;
|
|
import com.kongzue.dialogx.util.views.PopMenuListView;
|
|
import com.kongzue.dialogx.util.views.PopMenuListView;
|
|
@@ -63,6 +64,7 @@ public class PopMenu extends BaseDialog {
|
|
protected OnIconChangeCallBack<PopMenu> onIconChangeCallBack; //设置图标
|
|
protected OnIconChangeCallBack<PopMenu> onIconChangeCallBack; //设置图标
|
|
protected int width = -1; //指定菜单宽度
|
|
protected int width = -1; //指定菜单宽度
|
|
protected int height = -1; //指定菜单高度
|
|
protected int height = -1; //指定菜单高度
|
|
|
|
+ protected TextInfo menuTextInfo;
|
|
|
|
|
|
protected int alignGravity = -1; //指定菜单相对 baseView 的位置
|
|
protected int alignGravity = -1; //指定菜单相对 baseView 的位置
|
|
|
|
|
|
@@ -199,8 +201,6 @@ public class PopMenu extends BaseDialog {
|
|
int width = baseView.getWidth();
|
|
int width = baseView.getWidth();
|
|
int height = baseView.getHeight();
|
|
int height = baseView.getHeight();
|
|
|
|
|
|
- log("width=" + width);
|
|
|
|
-
|
|
|
|
int left = baseViewLoc[0];
|
|
int left = baseViewLoc[0];
|
|
int top = baseViewLoc[1] + (overlayBaseView ? 0 : height);
|
|
int top = baseViewLoc[1] + (overlayBaseView ? 0 : height);
|
|
|
|
|
|
@@ -390,6 +390,7 @@ public class PopMenu extends BaseDialog {
|
|
rLp.width = RelativeLayout.LayoutParams.MATCH_PARENT;
|
|
rLp.width = RelativeLayout.LayoutParams.MATCH_PARENT;
|
|
rLp.leftMargin = dip2px(50);
|
|
rLp.leftMargin = dip2px(50);
|
|
rLp.rightMargin = dip2px(50);
|
|
rLp.rightMargin = dip2px(50);
|
|
|
|
+ boxBody.setLayoutParams(rLp);
|
|
boxBody.setAlpha(0f);
|
|
boxBody.setAlpha(0f);
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
boxBody.setElevation(dip2px(20));
|
|
boxBody.setElevation(dip2px(20));
|
|
@@ -472,25 +473,25 @@ public class PopMenu extends BaseDialog {
|
|
@Override
|
|
@Override
|
|
public void doDismiss(View v) {
|
|
public void doDismiss(View v) {
|
|
if (v != null) v.setEnabled(false);
|
|
if (v != null) v.setEnabled(false);
|
|
-
|
|
|
|
|
|
+
|
|
if (!dismissAnimFlag) {
|
|
if (!dismissAnimFlag) {
|
|
dismissAnimFlag = true;
|
|
dismissAnimFlag = true;
|
|
boxRoot.post(new Runnable() {
|
|
boxRoot.post(new Runnable() {
|
|
@Override
|
|
@Override
|
|
public void run() {
|
|
public void run() {
|
|
-
|
|
|
|
|
|
+
|
|
if (overrideExitDuration != -1) exitAnimDuration = overrideExitDuration;
|
|
if (overrideExitDuration != -1) exitAnimDuration = overrideExitDuration;
|
|
Animation exitAnim = AnimationUtils.loadAnimation(getContext() == null ? boxRoot.getContext() : getContext(), R.anim.anim_dialogx_default_exit);
|
|
Animation exitAnim = AnimationUtils.loadAnimation(getContext() == null ? boxRoot.getContext() : getContext(), R.anim.anim_dialogx_default_exit);
|
|
if (exitAnimDuration != -1) {
|
|
if (exitAnimDuration != -1) {
|
|
exitAnim.setDuration(exitAnimDuration);
|
|
exitAnim.setDuration(exitAnimDuration);
|
|
}
|
|
}
|
|
boxBody.startAnimation(exitAnim);
|
|
boxBody.startAnimation(exitAnim);
|
|
-
|
|
|
|
|
|
+
|
|
boxRoot.animate()
|
|
boxRoot.animate()
|
|
.alpha(0f)
|
|
.alpha(0f)
|
|
.setInterpolator(new AccelerateInterpolator())
|
|
.setInterpolator(new AccelerateInterpolator())
|
|
.setDuration(exitAnimDuration == -1 ? exitAnim.getDuration() : exitAnimDuration);
|
|
.setDuration(exitAnimDuration == -1 ? exitAnim.getDuration() : exitAnimDuration);
|
|
-
|
|
|
|
|
|
+
|
|
if (baseView == null) {
|
|
if (baseView == null) {
|
|
ValueAnimator bkgAlpha = ValueAnimator.ofFloat(1, 0f);
|
|
ValueAnimator bkgAlpha = ValueAnimator.ofFloat(1, 0f);
|
|
bkgAlpha.setDuration(exitAnimDuration == -1 ? exitAnim.getDuration() : exitAnimDuration);
|
|
bkgAlpha.setDuration(exitAnimDuration == -1 ? exitAnim.getDuration() : exitAnimDuration);
|
|
@@ -503,7 +504,7 @@ public class PopMenu extends BaseDialog {
|
|
});
|
|
});
|
|
bkgAlpha.start();
|
|
bkgAlpha.start();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
|
|
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
|
|
@Override
|
|
@Override
|
|
public void run() {
|
|
public void run() {
|
|
@@ -717,4 +718,14 @@ public class PopMenu extends BaseDialog {
|
|
this.dialogImplMode = dialogImplMode;
|
|
this.dialogImplMode = dialogImplMode;
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public TextInfo getMenuTextInfo() {
|
|
|
|
+ if (menuTextInfo == null) return DialogX.menuTextInfo;
|
|
|
|
+ return menuTextInfo;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public PopMenu setMenuTextInfo(TextInfo menuTextInfo) {
|
|
|
|
+ this.menuTextInfo = menuTextInfo;
|
|
|
|
+ return this;
|
|
|
|
+ }
|
|
}
|
|
}
|