소스 검색

评论头像兼容问题解决

DESKTOP-JJ6HLMB 1 년 전
부모
커밋
e90c036299

+ 24 - 20
TMessagesProj/src/main/java/org/telegram/cricdit/ui/NewsDetailCommentFragment.java

@@ -179,7 +179,7 @@ public class NewsDetailCommentFragment extends BaseActivity<CommentPresenter> im
     public void setHeadViewHolder(BaseHeadViewHolder holder) {
         mHolder = holder;
         rv.setLayoutManager(new LinearLayoutManager(getContext()));
-        adapter = new CommentAdapter(this,null, getParentActivity(), mHolder);
+        adapter = new CommentAdapter(this, null, getParentActivity(), mHolder);
         if (newsBean != null) {
             adapter.setNewsBean(newsBean);
         }
@@ -327,12 +327,14 @@ public class NewsDetailCommentFragment extends BaseActivity<CommentPresenter> im
             BackupImageView backupImageView = new BackupImageView(getContext());
             backupImageView.setForUserOrChat(UserConfig.getInstance(currentAccount).getCurrentUser(), new AvatarDrawable(UserConfig.getInstance(currentAccount).getCurrentUser()));
             Bitmap bitmap = backupImageView.getImageReceiver().getBitmap();
-            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+            if (bitmap != null) {
+                ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
 //该方法用来压缩图片,第一个参数为图片格式,第二个参数为截取图片的保留率,如当前为90,则保留之前图片90%的区域
-            bitmap.compress(Bitmap.CompressFormat.JPEG, 90, outputStream);
-            byte[] imagebyte = outputStream.toByteArray();
-            String toBase64 = Base64Utils.toBase64(imagebyte);
-            faceURL = toBase64;
+                bitmap.compress(Bitmap.CompressFormat.JPEG, 90, outputStream);
+                byte[] imagebyte = outputStream.toByteArray();
+                String toBase64 = Base64Utils.toBase64(imagebyte);
+                faceURL = toBase64;
+            }
         }
         if (multiItem == null) {
             MainCommendBean addMainCommendBean = new MainCommendBean(content);
@@ -793,20 +795,22 @@ public class NewsDetailCommentFragment extends BaseActivity<CommentPresenter> im
 
     @Override
     public void onDeleteComment(MultiItemEntity o) {
-        if (o.getUser_id().equals((UserConfig.getInstance(currentAccount).getCurrentUser().id + ""))) {
-            // TODO: 2022/9/8   这里给出一个弹窗确定是否删除评论
-            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
-            builder.setMessage(LocaleController.getString(R.string.delete_comment_tip));
-            builder.setPositiveButton(LocaleController.getString(R.string.OK), (dialogInterface, i) -> {
-                if (!UserConfig.getInstance(currentAccount).isClientActivated()) {
-                    presentFragment(new LoginActivity());
-                } else {
-                    long clientUserId = UserConfig.getInstance(currentAccount).getClientUserId();
-                    presenter.recallComment(clientUserId + "", o.getId(), o);
-                }
-            });
-            builder.setNegativeButton(LocaleController.getString(R.string.Cancel), null);
-            showDialog(builder.create());
+        if (UserConfig.getInstance(currentAccount).isClientActivated()) {
+            if (o.getUser_id().equals((UserConfig.getInstance(currentAccount).getCurrentUser().id + ""))) {
+                // TODO: 2022/9/8   这里给出一个弹窗确定是否删除评论
+                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
+                builder.setMessage(LocaleController.getString(R.string.delete_comment_tip));
+                builder.setPositiveButton(LocaleController.getString(R.string.OK), (dialogInterface, i) -> {
+                    if (!UserConfig.getInstance(currentAccount).isClientActivated()) {
+                        presentFragment(new LoginActivity());
+                    } else {
+                        long clientUserId = UserConfig.getInstance(currentAccount).getClientUserId();
+                        presenter.recallComment(clientUserId + "", o.getId(), o);
+                    }
+                });
+                builder.setNegativeButton(LocaleController.getString(R.string.Cancel), null);
+                showDialog(builder.create());
+            }
         }
     }
 

+ 15 - 13
TMessagesProj/src/main/java/org/telegram/cricdit/ui/RankDetailCommentFragment.java

@@ -826,19 +826,21 @@ public class RankDetailCommentFragment extends BaseActivity<CommentPresenter> im
 
     @Override
     public void onDeleteComment(MultiItemEntity o) {
-        if (o.getUser_id().equals((UserConfig.getInstance(currentAccount).getCurrentUser().id + ""))) {
-            // TODO: 2022/9/8   这里给出一个弹窗确定是否删除评论
-            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
-            builder.setMessage(LocaleController.getString(R.string.delete_comment_tip));
-            builder.setPositiveButton(LocaleController.getString(R.string.OK), (dialogInterface, i) -> {
-                if (!UserConfig.getInstance(currentAccount).isClientActivated()) {
-                    presentFragment(new LoginActivity());
-                } else {
-                    presenter.recallComment(UserConfig.getInstance(currentAccount).getCurrentUser().id + "", o.getId(), o);
-                }
-            });
-            builder.setNegativeButton(LocaleController.getString(R.string.Cancel), null);
-            showDialog(builder.create());
+        if (UserConfig.getInstance(currentAccount).isClientActivated()) {
+            if (o.getUser_id().equals((UserConfig.getInstance(currentAccount).getCurrentUser().id + ""))) {
+                // TODO: 2022/9/8   这里给出一个弹窗确定是否删除评论
+                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
+                builder.setMessage(LocaleController.getString(R.string.delete_comment_tip));
+                builder.setPositiveButton(LocaleController.getString(R.string.OK), (dialogInterface, i) -> {
+                    if (!UserConfig.getInstance(currentAccount).isClientActivated()) {
+                        presentFragment(new LoginActivity());
+                    } else {
+                        presenter.recallComment(UserConfig.getInstance(currentAccount).getCurrentUser().id + "", o.getId(), o);
+                    }
+                });
+                builder.setNegativeButton(LocaleController.getString(R.string.Cancel), null);
+                showDialog(builder.create());
+            }
         }
     }
 

+ 6 - 2
TMessagesProj/src/main/java/org/telegram/cricdit/utils/Base64Utils.java

@@ -78,6 +78,7 @@ public class Base64Utils {
 //    public static BitmapDrawable base64ToBitmap(String base64) {
 //        return new BitmapDrawable(ImageLoader.getStrippedPhotoBitmap(fromBase64String(base64), "b"));
 //    }
+
     /**
      * 直接将Base64转为BitmapDrawable
      *
@@ -86,8 +87,11 @@ public class Base64Utils {
      */
 
     public static Bitmap base64ToBitmap(String base64) {
-        byte[] imageByte = Base64.decode(base64,Base64.DEFAULT);
-        return BitmapFactory.decodeByteArray(imageByte,0,imageByte.length);
+        if (!TextUtils.isEmpty(base64)) {
+            byte[] imageByte = Base64.decode(base64, Base64.DEFAULT);
+            return BitmapFactory.decodeByteArray(imageByte, 0, imageByte.length);
+        }
+        return null;
     }
 
 }