From 5df76d441a853b1a5d2dff018c01327eb3a717b3 Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期三, 27 十二月 2023 19:25:57 +0800
Subject: [PATCH] 2023年12月27日19:25:46
---
app/src/main/java/com/hdl/photovoltaic/widget/ListDialog.java | 103 +++++++++++++++++++++++++++++----------------------
1 files changed, 59 insertions(+), 44 deletions(-)
diff --git a/app/src/main/java/com/hdl/photovoltaic/widget/ListDialog.java b/app/src/main/java/com/hdl/photovoltaic/widget/ListDialog.java
index 0443c67..291350a 100644
--- a/app/src/main/java/com/hdl/photovoltaic/widget/ListDialog.java
+++ b/app/src/main/java/com/hdl/photovoltaic/widget/ListDialog.java
@@ -1,5 +1,6 @@
package com.hdl.photovoltaic.widget;
+import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
@@ -19,6 +20,7 @@
import com.hdl.photovoltaic.HDLApp;
import com.hdl.photovoltaic.R;
+import com.hdl.photovoltaic.base.BaseDialog;
import com.hdl.photovoltaic.config.UserConfigManage;
import com.hdl.photovoltaic.databinding.DialogListBinding;
import com.hdl.photovoltaic.ui.StartActivity;
@@ -33,7 +35,7 @@
/**
* 鍔ㄦ�佸垪琛ㄥ脊绐�
*/
-public class ListDialog extends Dialog {
+public class ListDialog extends BaseDialog {
private DialogListBinding viewBinding;
private ListDialogAdapter listDialogAdapter;
@@ -47,29 +49,13 @@
this.mContext = context;
}
- @Override
- protected void onStart() {
- super.onStart();
- // 鑾峰彇绐楀彛瀵硅薄
- Window dialogWindow = this.getWindow();
- if (dialogWindow != null) {
- // 鑾峰彇瀵硅瘽妗嗗綋鍓嶇殑鍙傛暟鍊�
- WindowManager.LayoutParams p = dialogWindow.getAttributes();
- p.width = LinearLayout.LayoutParams.MATCH_PARENT;
- p.height = LinearLayout.LayoutParams.WRAP_CONTENT;
- p.gravity = Gravity.TOP;
- // 璁剧疆鍒板睘鎬ч厤缃腑
- dialogWindow.setAttributes(p);
- }
- }
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
viewBinding = DialogListBinding.inflate(getLayoutInflater());
setContentView(viewBinding.getRoot());
- this.setCanceledOnTouchOutside(true);
-// setDialogTouchOutsideCloseable(this);
+ setDialogTouchOutsideCloseable(this);
initData();
LinearLayoutManager linearLayout = new LinearLayoutManager(mContext);
listDialogAdapter = new ListDialogAdapter(this.list, mContext);
@@ -84,6 +70,10 @@
}
list.get(position).setState(true);
listDialogAdapter.notifyDataSetChanged();
+ if (UserConfigManage.getInstance().getCurrentAppLanguage().equals(itemData.getLanguage())) {
+ //鍚屼竴涓笉鎵ц寮圭獥
+ return;
+ }
languageSelectionDialog(position, itemData);
}
});
@@ -134,46 +124,71 @@
dialog.setNoOnclickListener(new ConfirmationCancelDialog.onNoOnclickListener() {
@Override
public void Cancel() {
+ //鍙栨秷涔嬪悗杩樺師涔嬪墠鐘舵��
+ for (int i = 0; i < list.size(); i++) {
+ LanguageAdapter.ItemData data = list.get(i);
+ data.setState(false);
+ if (UserConfigManage.getInstance().getCurrentAppLanguage().equals(data.getLanguage())) {
+ data.setState(true);
+ }
+ }
+ listDialogAdapter.notifyDataSetChanged();
dialog.dismiss();
}
});
}
+ @SuppressLint("ClickableViewAccessibility")
public void setDialogTouchOutsideCloseable(Dialog dialog) {
- viewBinding.getRoot().setOnTouchListener(new View.OnTouchListener() {
+// viewBinding.getRoot().setOnTouchListener(new View.OnTouchListener() {
+//
+// @Override
+// public boolean onTouch(View v, MotionEvent event) {
+// int top = viewBinding.dialogParent.getTop();
+// int left = viewBinding.dialogParent.getLeft();
+// int bottom = viewBinding.dialogParent.getBottom();
+// int right = viewBinding.dialogParent.getRight();
+// int y = (int) event.getY();
+// int x = (int) event.getX();
+// if (event.getAction() == MotionEvent.ACTION_UP) {
+// if (top < y && y < bottom) {
+//
+// } else {
+// dismiss();
+// }
+//
+// if (left < x && x < right) {
+//
+// } else {
+// dismiss();
+// }
+//
+//
+// }
+// return true;
+// }
+// });
+ viewBinding.getRoot().setOnClickListener(new View.OnClickListener() {
@Override
- public boolean onTouch(View v, MotionEvent event) {
+ public void onClick(View v) {
int top = viewBinding.dialogParent.getTop();
int left = viewBinding.dialogParent.getLeft();
int bottom = viewBinding.dialogParent.getBottom();
int right = viewBinding.dialogParent.getRight();
- int y = (int) event.getY();
- int x = (int) event.getX();
- if (event.getAction() == MotionEvent.ACTION_UP) {
- if (top < y && y < bottom) {
-
- } else {
- dismiss();
- }
-
- if (left < x && x < right) {
-
- } else {
- dismiss();
- }
-
-
+ int y = (int) v.getY();
+ int x = (int) v.getX();
+ if (top < y && y < bottom) {
+ } else {
+ dismiss();
}
- return true;
+ if (left < x && x < right) {
+
+ } else {
+ dismiss();
+ }
+
}
});
-// Window window = dialog.getWindow();
-// WindowManager.LayoutParams params = window.getAttributes();
-// params.width = ViewGroup.LayoutParams.MATCH_PARENT;
-// params.height = ViewGroup.LayoutParams.MATCH_PARENT;
-// window.setAttributes(params);
-// //绌虹櫧澶勪笉鑳藉彇娑堝姩鐢�
-// setCanceledOnTouchOutside(true);
}
}
--
Gitblit v1.8.0