|
@@ -38,6 +38,7 @@ import java.util.List;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
+
|
|
|
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
|
|
import io.reactivex.rxjava3.annotations.NonNull;
|
|
|
import io.reactivex.rxjava3.core.Observable;
|
|
@@ -51,6 +52,7 @@ import static com.trello.rxlifecycle4.RxLifecycle.bindUntilEvent;
|
|
|
public class PopWindowUtil {
|
|
|
private static PopWindowPresneter mPresenter;
|
|
|
private static PopupWindow mPopupWindow;
|
|
|
+ private static FrameLayout dialog_view;
|
|
|
|
|
|
|
|
|
private static void initPresenter() {
|
|
@@ -77,9 +79,8 @@ public class PopWindowUtil {
|
|
|
if (checkWindowShoing()) {
|
|
|
return;
|
|
|
}
|
|
|
- View dialog_view = LayoutInflater.from(context).inflate(R.layout.popupwindow_exit_app, null);
|
|
|
+ dialog_view = (FrameLayout) LayoutInflater.from(context).inflate(R.layout.popupwindow_exit_app, null);
|
|
|
dialog_view.setFocusable(true);
|
|
|
-
|
|
|
ImageView image = dialog_view.findViewById(R.id.popupwindow_exit_app_image);
|
|
|
GlideUtils.loadImageSizeKipMemoryCache(context, "http://reader-apk.ai160.com/reader-apk/res/exit_app.png", image);
|
|
|
FrameLayout exit = dialog_view.findViewById(R.id.popupwindow_exit_app_ok);
|
|
@@ -97,9 +98,8 @@ public class PopWindowUtil {
|
|
|
showDeviceInfo(context);
|
|
|
});
|
|
|
|
|
|
- mPopupWindow = new PopupWindow(dialog_view, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
|
|
|
- mPopupWindow.setFocusable(true);
|
|
|
- mPopupWindow.showAtLocation(parent, Gravity.CENTER, 0, 0);
|
|
|
+
|
|
|
+ newPopupWindow(parent, true);
|
|
|
}
|
|
|
|
|
|
public static void showSelectGradeWindow(Context context, View parent, int checked, PopUtilClickListener listener) {
|
|
@@ -107,7 +107,7 @@ public class PopWindowUtil {
|
|
|
if (checkWindowShoing()) {
|
|
|
return;
|
|
|
}
|
|
|
- View dialog_view = LayoutInflater.from(context).inflate(R.layout.popupwindow_select_grade, null);
|
|
|
+ dialog_view = (FrameLayout) LayoutInflater.from(context).inflate(R.layout.popupwindow_select_grade, null);
|
|
|
dialog_view.setFocusable(true);
|
|
|
FrameLayout btn_ok = dialog_view.findViewById(R.id.popupwindow_select_ok);
|
|
|
GridRadioGroup gridRadioGroup = dialog_view.findViewById(R.id.popupwindow_select_grade_gridgroup);
|
|
@@ -171,9 +171,7 @@ public class PopWindowUtil {
|
|
|
mPopupWindow.dismiss();
|
|
|
listener.clickSubmit(checkText[0]);
|
|
|
});
|
|
|
- mPopupWindow = new PopupWindow(dialog_view, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
|
|
|
- mPopupWindow.setFocusable(true);
|
|
|
- mPopupWindow.showAtLocation(parent, Gravity.CENTER, 0, 0);
|
|
|
+ newPopupWindow(parent, true);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -182,7 +180,7 @@ public class PopWindowUtil {
|
|
|
if (checkWindowShoing()) {
|
|
|
return;
|
|
|
}
|
|
|
- View dialog_view = LayoutInflater.from(context).inflate(R.layout.popupwindow_exit_login, null);
|
|
|
+ dialog_view = (FrameLayout) LayoutInflater.from(context).inflate(R.layout.popupwindow_exit_login, null);
|
|
|
dialog_view.setFocusable(true);
|
|
|
ImageView image = dialog_view.findViewById(R.id.popupwindow_exit_login_image);
|
|
|
GlideUtils.loadImageSizeKipMemoryCache(context, "http://reader-apk.ai160.com/reader-apk/res/exit_login.png", image);
|
|
@@ -196,9 +194,7 @@ public class PopWindowUtil {
|
|
|
mPopupWindow.dismiss();
|
|
|
listener.clickCancel();
|
|
|
});
|
|
|
- mPopupWindow = new PopupWindow(dialog_view, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
|
|
|
- mPopupWindow.setFocusable(true);
|
|
|
- mPopupWindow.showAtLocation(parent, Gravity.CENTER, 0, 0);
|
|
|
+ newPopupWindow(parent, true);
|
|
|
}
|
|
|
|
|
|
public static void showCancellationAccountWindow(Context context, View parent, PopUtilClickListener listener) {
|
|
@@ -206,7 +202,7 @@ public class PopWindowUtil {
|
|
|
if (checkWindowShoing()) {
|
|
|
return;
|
|
|
}
|
|
|
- View dialog_view = LayoutInflater.from(context).inflate(R.layout.popupwindow_cancellation_account, null);
|
|
|
+ dialog_view = (FrameLayout) LayoutInflater.from(context).inflate(R.layout.popupwindow_cancellation_account, null);
|
|
|
dialog_view.setFocusable(true);
|
|
|
FrameLayout exit = dialog_view.findViewById(R.id.popupwindow_cancellation_account_ok);
|
|
|
FrameLayout cancel = dialog_view.findViewById(R.id.popupwindow_cancellation_account_cancel);
|
|
@@ -218,9 +214,7 @@ public class PopWindowUtil {
|
|
|
mPopupWindow.dismiss();
|
|
|
listener.clickCancel();
|
|
|
});
|
|
|
- mPopupWindow = new PopupWindow(dialog_view, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
|
|
|
- mPopupWindow.setFocusable(true);
|
|
|
- mPopupWindow.showAtLocation(parent, Gravity.CENTER, 0, 0);
|
|
|
+ newPopupWindow(parent, true);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -229,7 +223,7 @@ public class PopWindowUtil {
|
|
|
if (checkWindowShoing()) {
|
|
|
return;
|
|
|
}
|
|
|
- View dialog_view = LayoutInflater.from(context).inflate(R.layout.popupwindow_bind_wechat, null);
|
|
|
+ dialog_view = (FrameLayout) LayoutInflater.from(context).inflate(R.layout.popupwindow_bind_wechat, null);
|
|
|
dialog_view.setFocusable(true);
|
|
|
ImageView back = dialog_view.findViewById(R.id.popupwindow_bindwechat_back);
|
|
|
ImageView image = dialog_view.findViewById(R.id.popupwindow_bind_wechat_image);
|
|
@@ -243,9 +237,7 @@ public class PopWindowUtil {
|
|
|
});
|
|
|
mPresenter.getBindWeChatPath(context, image);
|
|
|
mPresenter.getMyInfo(context, text);
|
|
|
- mPopupWindow = new PopupWindow(dialog_view, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
|
|
|
- mPopupWindow.setFocusable(true);
|
|
|
- mPopupWindow.showAtLocation(parent, Gravity.CENTER, 0, 0);
|
|
|
+ newPopupWindow(parent, false);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -254,7 +246,7 @@ public class PopWindowUtil {
|
|
|
if (checkWindowShoing()) {
|
|
|
return;
|
|
|
}
|
|
|
- View dialog_view = LayoutInflater.from(context).inflate(R.layout.popupwindow_record_status, null);
|
|
|
+ dialog_view = (FrameLayout) LayoutInflater.from(context).inflate(R.layout.popupwindow_record_status, null);
|
|
|
dialog_view.setFocusable(true);
|
|
|
dialog_view.setOnKeyListener(new View.OnKeyListener() {
|
|
|
@Override
|
|
@@ -270,9 +262,7 @@ public class PopWindowUtil {
|
|
|
mPopupWindow.dismiss();
|
|
|
});
|
|
|
mPresenter.initRecordStatusWindow(context, dialog_view, bean, userread, listener);
|
|
|
- mPopupWindow = new PopupWindow(dialog_view, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
|
|
|
- mPopupWindow.setFocusable(false);
|
|
|
- mPopupWindow.showAtLocation(parent, Gravity.CENTER, 0, 0);
|
|
|
+ newPopupWindow(parent, false);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -281,7 +271,7 @@ public class PopWindowUtil {
|
|
|
if (checkWindowShoing()) {
|
|
|
return;
|
|
|
}
|
|
|
- View dialog_view = LayoutInflater.from(context).inflate(R.layout.popupwindow_myorder, null);
|
|
|
+ dialog_view = (FrameLayout) LayoutInflater.from(context).inflate(R.layout.popupwindow_myorder, null);
|
|
|
dialog_view.setFocusable(true);
|
|
|
dialog_view.setOnKeyListener(new View.OnKeyListener() {
|
|
|
@Override
|
|
@@ -297,9 +287,7 @@ public class PopWindowUtil {
|
|
|
mPopupWindow.dismiss();
|
|
|
});
|
|
|
mPresenter.myOrderWindowInit(context, dialog_view);
|
|
|
- mPopupWindow = new PopupWindow(dialog_view, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
|
|
|
- mPopupWindow.setFocusable(false);
|
|
|
- mPopupWindow.showAtLocation(parent, Gravity.CENTER, 0, 0);
|
|
|
+ newPopupWindow(parent, false);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -308,7 +296,7 @@ public class PopWindowUtil {
|
|
|
if (checkWindowShoing()) {
|
|
|
return;
|
|
|
}
|
|
|
- View dialog_view = LayoutInflater.from(context).inflate(R.layout.popupwindow_record_remove, null);
|
|
|
+ dialog_view = (FrameLayout) LayoutInflater.from(context).inflate(R.layout.popupwindow_record_remove, null);
|
|
|
dialog_view.setFocusable(true);
|
|
|
FrameLayout ok = dialog_view.findViewById(R.id.popupwindow_record_remove_ok);
|
|
|
FrameLayout cancel = dialog_view.findViewById(R.id.popupwindow_record_remove_cancel);
|
|
@@ -321,9 +309,7 @@ public class PopWindowUtil {
|
|
|
mPopupWindow.dismiss();
|
|
|
listener.clickCancel();
|
|
|
});
|
|
|
- mPopupWindow = new PopupWindow(dialog_view, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
|
|
|
- mPopupWindow.setFocusable(true);
|
|
|
- mPopupWindow.showAtLocation(parent, Gravity.CENTER, 0, 0);
|
|
|
+ newPopupWindow(parent, true);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -366,6 +352,20 @@ public class PopWindowUtil {
|
|
|
private static void setClickListener(View view, Consumer onNext) {
|
|
|
RxView.clicks(view).throttleFirst(2, TimeUnit.SECONDS).subscribe(onNext);
|
|
|
}
|
|
|
+
|
|
|
+ private static void newPopupWindow(View parent, boolean nedFocus) {
|
|
|
+ mPopupWindow = new PopupWindow(dialog_view, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
|
|
|
+ mPopupWindow.setFocusable(nedFocus);
|
|
|
+ mPopupWindow.showAtLocation(parent, Gravity.CENTER, 0, 0);
|
|
|
+ mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
|
|
+ @Override
|
|
|
+ public void onDismiss() {
|
|
|
+ dialog_view.removeAllViews();
|
|
|
+ dialog_view = null;
|
|
|
+ mPopupWindow = null;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|