|
@@ -4,6 +4,7 @@ import static android.view.View.OVER_SCROLL_NEVER;
|
|
|
import static android.view.View.VISIBLE;
|
|
|
|
|
|
import android.animation.ValueAnimator;
|
|
|
+import android.app.Activity;
|
|
|
import android.graphics.Outline;
|
|
|
import android.graphics.drawable.GradientDrawable;
|
|
|
import android.os.Build;
|
|
@@ -289,6 +290,62 @@ public class PopMenu extends BaseDialog {
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
+ public PopMenu show(Activity activity) {
|
|
|
+ if (isHide && getDialogView() != null && isShow) {
|
|
|
+ if (hideWithExitAnim && getDialogImpl() != null) {
|
|
|
+ getDialogImpl().boxBody.clearAnimation();
|
|
|
+ getDialogView().setVisibility(View.VISIBLE);
|
|
|
+ getDialogImpl().boxRoot.animate().alpha(1f);
|
|
|
+ getDialogImpl().getDialogXAnimImpl().doShowAnim(me, getDialogImpl().boxBody);
|
|
|
+ } else {
|
|
|
+ getDialogView().setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ super.beforeShow();
|
|
|
+ if (getDialogView() == null) {
|
|
|
+ int layoutId = isLightTheme() ? R.layout.layout_dialogx_popmenu_material : R.layout.layout_dialogx_popmenu_material_dark;
|
|
|
+ if (getStyle().popMenuSettings() != null) {
|
|
|
+ if (getStyle().popMenuSettings().layout(isLightTheme()) != 0) {
|
|
|
+ layoutId = getStyle().popMenuSettings().layout(isLightTheme());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ View dialogView = createView(layoutId);
|
|
|
+ dialogImpl = new DialogImpl(dialogView);
|
|
|
+ if (dialogView != null) {
|
|
|
+ dialogView.setTag(me);
|
|
|
+ }
|
|
|
+ show(activity, dialogView);
|
|
|
+ } else {
|
|
|
+ show(activity, getDialogView());
|
|
|
+ }
|
|
|
+ if (baseView() != null) {
|
|
|
+ viewTreeObserver = baseView().getViewTreeObserver();
|
|
|
+ viewTreeObserver.addOnDrawListener(baseViewDrawListener = new ViewTreeObserver.OnDrawListener() {
|
|
|
+ @Override
|
|
|
+ public void onDraw() {
|
|
|
+ int[] baseViewLocCache = new int[2];
|
|
|
+ if (baseView() != null) {
|
|
|
+ baseView().getLocationInWindow(baseViewLocCache);
|
|
|
+ if (getDialogImpl() != null && !baseViewLoc.isSameLoc(baseViewLocCache) && baseView().getVisibility() == VISIBLE) {
|
|
|
+ baseViewLoc.set(baseViewLocCache);
|
|
|
+ refreshMenuLoc();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (viewTreeObserver != null) {
|
|
|
+ removeDrawListener(viewTreeObserver, this);
|
|
|
+ viewTreeObserver = null;
|
|
|
+ baseViewDrawListener = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
private void refreshMenuLoc() {
|
|
|
if (getDialogImpl() == null || getDialogImpl().boxRoot == null || baseView() == null) {
|
|
|
return;
|