|
@@ -1,11 +1,16 @@
|
|
|
package com.edufound.reader.popwindow;
|
|
|
|
|
|
import android.app.Activity;
|
|
|
+import android.app.Dialog;
|
|
|
import android.content.Context;
|
|
|
+import android.graphics.Color;
|
|
|
+import android.view.Display;
|
|
|
import android.view.Gravity;
|
|
|
import android.view.KeyEvent;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
+import android.view.Window;
|
|
|
+import android.view.WindowManager;
|
|
|
import android.widget.FrameLayout;
|
|
|
import android.widget.ImageView;
|
|
|
import android.widget.PopupWindow;
|
|
@@ -19,13 +24,28 @@ import com.edufound.reader.cusview.GridRadioGroup;
|
|
|
import com.edufound.reader.listener.PopUtilClickListener;
|
|
|
import com.edufound.reader.listener.PopupRecordStatusListener;
|
|
|
import com.edufound.reader.presenter.PopWindowPresneter;
|
|
|
+import com.edufound.reader.util.Consts;
|
|
|
+import com.edufound.reader.util.DeviceUtil;
|
|
|
+import com.edufound.reader.util.DeviceUuidFactory;
|
|
|
import com.edufound.reader.util.GlideUtils;
|
|
|
+import com.edufound.reader.util.SizeUtils;
|
|
|
import com.jakewharton.rxbinding4.view.RxView;
|
|
|
import com.orhanobut.logger.Logger;
|
|
|
+import com.trello.rxlifecycle4.android.ActivityEvent;
|
|
|
|
|
|
+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;
|
|
|
+import io.reactivex.rxjava3.core.Observer;
|
|
|
import io.reactivex.rxjava3.functions.Consumer;
|
|
|
+import io.reactivex.rxjava3.functions.Function;
|
|
|
+import kotlin.Unit;
|
|
|
+
|
|
|
+import static com.trello.rxlifecycle4.RxLifecycle.bindUntilEvent;
|
|
|
|
|
|
public class PopWindowUtil {
|
|
|
private static PopWindowPresneter mPresenter;
|
|
@@ -51,7 +71,7 @@ public class PopWindowUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static void showExitAppWindow(Context context, View parent) {
|
|
|
+ public static void showExitAppWindow(Activity context, View parent) {
|
|
|
initPresenter();
|
|
|
if (checkWindowShoing()) {
|
|
|
return;
|
|
@@ -69,6 +89,13 @@ public class PopWindowUtil {
|
|
|
setClickListener(cancel, o -> {
|
|
|
mPopupWindow.dismiss();
|
|
|
});
|
|
|
+
|
|
|
+
|
|
|
+ RxView.longClicks(image).subscribe(o -> {
|
|
|
+ //显示deviceInfo
|
|
|
+ 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);
|
|
@@ -194,7 +221,7 @@ public class PopWindowUtil {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public static void showBindWeChatWindow(Activity context, View parent, PopUtilClickListener listener) {
|
|
|
+ public static void showBindWeChatWindow(Activity context, View parent, @Nullable PopUtilClickListener listener) {
|
|
|
initPresenter();
|
|
|
if (checkWindowShoing()) {
|
|
|
return;
|
|
@@ -206,7 +233,9 @@ public class PopWindowUtil {
|
|
|
TextView text = dialog_view.findViewById(R.id.popupwindow_bind_wechat_name);
|
|
|
setClickListener(back, o -> {
|
|
|
mPopupWindow.dismiss();
|
|
|
- listener.clickCancel();
|
|
|
+ if (listener != null) {
|
|
|
+ listener.clickCancel();
|
|
|
+ }
|
|
|
mPresenter.getPopHandler().removeMessages(0x1312);
|
|
|
});
|
|
|
mPresenter.getBindWeChatPath(context, image);
|
|
@@ -295,6 +324,40 @@ public class PopWindowUtil {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ private static void showDeviceInfo(Activity context) {
|
|
|
+ StringBuffer buffer = new StringBuffer();
|
|
|
+ buffer.append("\tchannel:\t" + "\t" + Consts.getUmengChannel() + "\n");
|
|
|
+ buffer.append("\tUUID:\t" + "\t" + DeviceUuidFactory.getUuid() + "\n");
|
|
|
+ buffer.append("\t厂商:\t" + "\t" + DeviceUtil.getDeviceBrand() + "\n");
|
|
|
+ buffer.append("\t型号:\t" + "\t" + DeviceUtil.getSystemModel() + "\n");
|
|
|
+ buffer.append("\t系统版本号:\t" + "\t" + DeviceUtil.getSystemVersion() + "\n");
|
|
|
+ buffer.append("\t应用版本号:\t" + "\t" + DeviceUtil.getVersionCode(context) + "\n");
|
|
|
+ buffer.append("\t应用版本号名称:\t" + "\t" + DeviceUtil.getVersionName(context) + "\n");
|
|
|
+ buffer.append("\t屏幕宽度:\t\t" + DeviceUtil.getWidth(context) + "\n");
|
|
|
+ buffer.append("\t屏幕高度:\t\t" + DeviceUtil.getHeight(context) + "\n");
|
|
|
+ buffer.append("\t屏幕密度:\t\t" + DeviceUtil.getDensity(context) + "\n");
|
|
|
+ buffer.append("\t屏幕DPI:\t\t" + DeviceUtil.getDensityDpi(context) + "\n");
|
|
|
+
|
|
|
+ View infoView = LayoutInflater.from(context).inflate(R.layout.window_deviceinfo, null);
|
|
|
+ TextView text = (TextView) infoView.findViewById(R.id.deviceinfo);
|
|
|
+ text.setText(buffer.toString());
|
|
|
+ text.setTextSize(SizeUtils.dp2px(context, 20));
|
|
|
+ text.setTextColor(Color.WHITE);
|
|
|
+ Dialog dialog = new Dialog(context);
|
|
|
+ dialog.setContentView(infoView);
|
|
|
+ Window dialogWindow = dialog.getWindow();
|
|
|
+ dialogWindow.setGravity(Gravity.CENTER);
|
|
|
+ WindowManager m = context.getWindowManager();
|
|
|
+ Display d = m.getDefaultDisplay(); // 获取屏幕宽、高用
|
|
|
+ WindowManager.LayoutParams p = dialogWindow.getAttributes(); // 获取对话框当前的参数值
|
|
|
+ p.height = (int) (d.getHeight() * 0.8);
|
|
|
+ p.width = (int) (d.getWidth() * 0.6);
|
|
|
+ dialogWindow.setAttributes(p);
|
|
|
+ dialog.setTitle("Device信息");
|
|
|
+ dialog.show();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private static void setClickListener(View view, Consumer onNext) {
|
|
|
RxView.clicks(view).throttleFirst(2, TimeUnit.SECONDS).subscribe(onNext);
|
|
|
}
|