From 1ef9c12f9e1edd46fd3edac5363d3519a5e0c05f Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期四, 30 五月 2024 21:12:37 +0800
Subject: [PATCH] Merge branch 'wjc_new' into develop_new
---
app/src/main/java/com/hdl/photovoltaic/ui/me/PersonalDataActivity.java | 90 ++++++++++++++++++++++++++++++++++++--------
1 files changed, 73 insertions(+), 17 deletions(-)
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/me/PersonalDataActivity.java b/app/src/main/java/com/hdl/photovoltaic/ui/me/PersonalDataActivity.java
index 58b3a7e..8884874 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/me/PersonalDataActivity.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/me/PersonalDataActivity.java
@@ -4,8 +4,13 @@
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
+import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
+
+
+import androidx.activity.result.ActivityResultLauncher;
+
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.google.gson.JsonObject;
@@ -20,8 +25,9 @@
import com.hdl.photovoltaic.databinding.ActivityPersonalDataBinding;
import com.hdl.photovoltaic.listener.CloudCallBeak;
import com.hdl.photovoltaic.other.HdlAccountLogic;
-import com.hdl.photovoltaic.other.HdlLogLogic;
import com.hdl.photovoltaic.other.HdlThreadLogic;
+import com.hdl.photovoltaic.other.HdlUniLogic;
+import com.hdl.photovoltaic.uni.HDLUniMP;
import com.hdl.photovoltaic.utils.GlideUtils;
import com.hdl.photovoltaic.utils.PermissionUtils;
import com.hdl.photovoltaic.widget.ConfirmationInputDialog;
@@ -39,6 +45,7 @@
private CameraAlbumPopWindow cameraAlbumPopWindow;
//澶村儚鍦板潃
private String mMemberHeadIconUrl;
+ private ActivityResultLauncher<String[]> generalPermission;
@Override
@@ -51,7 +58,7 @@
public void onBindView(Bundle savedInstanceState) {
setNotificationBarBackgroundColor(CustomColor.white);
setStatusBarTextColor();
- mMemberHeadIconUrl = getIntent().getStringExtra("memberHeadIcon");
+ mMemberHeadIconUrl = UserConfigManage.getInstance().getUserImageUrl();
//鍒濆鍖�
initView();
//鍒濆鍖栫晫闈㈢洃鍚櫒
@@ -61,32 +68,54 @@
}
private void initData() {
+// generalPermission = registerForActivityResult(new ActivityResultContracts.RequestMultiplePermissions(), new ActivityResultCallback<Map<String, Boolean>>() {
+// @Override
+// public void onActivityResult(Map<String, Boolean> result) {
+//
+// }
+// });
+// generalPermission.launch(new String[]{});
+
+// generalPermission = registerForActivityResult(new ActivityResultContracts.RequestMultiplePermissions(), new ActivityResultCallback<Map<String, Boolean>>() {
+// @Override
+// public void onActivityResult(Map<String, Boolean> result) {
+//
+//// if (value == PermissionUtils.STATUS_REFUSE_PERMANENT) {
+//// HdlThreadLogic.toast(_mActivity, R.string.permission_open);
+//// return;
+//// }
+// changedUserAvatar();
+// }
+// });
}
private void initEvent() {
- viewBinding.toolbarTopFragmentMeRl.topBackBtn.setOnClickListener(new View.OnClickListener() {
+ viewBinding.toolbarTopFragmentMeRl.topBackLl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- backPressedData();
+// backPressedData();
finish();
}
});
viewBinding.personalDataUserPortraitIl.getRoot().setOnClickListener(new View.OnClickListener() {
+
@Override
public void onClick(View v) {
//Manifest.permission.WRITE_EXTERNAL_STORAGE 璇诲啓璁惧涓婄殑鐓х墖浠ュ強鏂囦欢
- PermissionUtils.applyForRight(_mActivity, Manifest.permission.WRITE_EXTERNAL_STORAGE, new PermissionUtils.PermissionState() {
+ //generalPermission.launch(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE});
+
+ PermissionUtils.requestPermissionsResultCallback(_mActivity, Manifest.permission.WRITE_EXTERNAL_STORAGE, new PermissionUtils.PermissionState() {
@Override
public void Success(int value) {
if (value == PermissionUtils.STATUS_REFUSE_PERMANENT) {
- HdlThreadLogic.toast(_mActivity, R.string.permission_open);
+// HdlThreadLogic.toast(_mActivity, R.string.permission_open);
return;
}
changedUserAvatar();
}
- });
+ }, true);
}
});
@@ -103,7 +132,7 @@
private void initView() {
viewBinding.toolbarTopFragmentMeRl.topTitleTv.setText(R.string.me_personal_data);
- viewBinding.toolbarTopFragmentMeRl.topBackBtn.setVisibility(View.VISIBLE);
+ viewBinding.toolbarTopFragmentMeRl.topBackLl.setVisibility(View.VISIBLE);
viewBinding.toolbarTopFragmentMeRl.topTitleTv.setTextColor(getResources().getColor(R.color.text_030D1C, null));
viewBinding.toolbarTopFragmentMeRl.topBarView.setBackgroundColor(getResources().getColor(R.color.text_FFFFFFFF, null));
viewBinding.personalDataUserPortraitIl.sllLlRlNameTv.setText(R.string.me_personal_data_portrait);
@@ -138,19 +167,23 @@
public void onSuccess(Boolean obj) {
mMemberHeadIconUrl = imageKey.getUrl();
setMemberHeadIcon();
+ backPressedData();
}
@Override
public void onFailure(HDLException e) {
- HdlLogLogic.print("uploadUserHeadImage error:" + e.getMsg());
+
+ HdlThreadLogic.toast(_mActivity, e);
+// HdlLogLogic.print("uploadUserHeadImage error:" + error.getMsg());
// hideLoading();
}
});
}
@Override
- public void onFailure(HDLException error) {
- HdlLogLogic.print("uploadUserHeadImage error:" + error.getMsg());
+ public void onFailure(HDLException e) {
+// HdlThreadLogic.tipFlashingBox(_mActivity, false, e.getMsg(), e.getCode());
+ HdlThreadLogic.toast(_mActivity, e);
}
});
}
@@ -184,6 +217,7 @@
viewBinding.personalDataUserNameIl.sllLlRlRightContentTv.setText(UserConfigManage.getInstance().getUserName());
confirmationInputDialog.dismiss();
HdlThreadLogic.tipFlashingBox(_mActivity, true, getString(R.string.home_login_change_name_succeed), 0);
+ backPressedData();
}
@Override
@@ -208,7 +242,12 @@
* 鏄剧ず鐢ㄦ埛澶村儚
*/
private void setMemberHeadIcon() {
- GlideUtils.getRoundedCornersImage(_mActivity, mMemberHeadIconUrl, viewBinding.personalDataUserPortraitIl.sllLlRlRightContentIv, new RoundedCorners(4));
+ if (UserConfigManage.getInstance().isBAccount()) {
+ GlideUtils.getRoundedCornersImage(_mActivity, mMemberHeadIconUrl, viewBinding.personalDataUserPortraitIl.sllLlRlRightContentIv, new RoundedCorners(4), true);
+ } else {
+ GlideUtils.getCircleCropImage(_mActivity, mMemberHeadIconUrl, viewBinding.personalDataUserPortraitIl.sllLlRlRightContentIv, true);
+
+ }
}
@@ -250,7 +289,7 @@
*/
@Override
public void onBackPressed() {
- backPressedData();
+// backPressedData();
super.onBackPressed();
}
@@ -258,10 +297,27 @@
* 杩斿洖缁欎笂涓�绾х晫闈㈡暟鎹�
*/
private void backPressedData() {
- Intent intent = new Intent();
- intent.putExtra("memberHeadIcon", mMemberHeadIconUrl);
- intent.putExtra("memberName", UserConfigManage.getInstance().getUserName());
- setResult(10, intent);
+
+ if (UserConfigManage.getInstance().isBAccount()) {
+ Intent intent = new Intent();
+ intent.putExtra("memberHeadIcon", mMemberHeadIconUrl);
+ intent.putExtra("memberName", UserConfigManage.getInstance().getUserName());
+ setResult(10, intent);
+ } else {
+ //閫氱煡缁欏皬绋嬪簭鏇存柊澶村儚鎴栬�呯敤鎴峰悕
+ HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean();
+ JsonObject jsonObject = new JsonObject();
+ if (!TextUtils.isEmpty(mMemberHeadIconUrl)) {
+ jsonObject.addProperty("memberHeadIcon", mMemberHeadIconUrl);
+ }
+ if (!TextUtils.isEmpty(UserConfigManage.getInstance().getUserName())) {
+ jsonObject.addProperty("memberName", UserConfigManage.getInstance().getUserName());
+ }
+ uniCallBackBaseBean.setType(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_REFRESH_USERINFO);
+ uniCallBackBaseBean.setData(jsonObject);
+ HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean);
+ }
}
+
}
\ No newline at end of file
--
Gitblit v1.8.0