导航菜单

页面标题

页面副标题

微商客 v2.1.2 - WxGroupNoticeActivity.java 源代码

正在查看: 微商客 v2.1.2 应用的 WxGroupNoticeActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.jianzhen.wsk.v1.activity;

import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;
import androidx.activity.result.ActivityResult;
import androidx.activity.result.ActivityResultCallback;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.fastjson.JSON;
import com.auxiliary.library.core.NodeExecutor;
import com.auxiliary.library.service.AuxiliaryService;
import com.auxiliary.library.service.IAccessibility;
import com.auxiliary.library.util.SettingUtil;
import com.auxiliary.library.widget.ExecutorWindow;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.XXPermissions;
import com.jianzhen.wsk.R;
import com.jianzhen.wsk.bean.TagAndGroupBean;
import com.jianzhen.wsk.databinding.ActivityWxGroupNoticeBinding;
import com.jianzhen.wsk.dialog.InteractTimeDialog;
import com.jianzhen.wsk.dialog.PermissionTipDialog;
import com.jianzhen.wsk.ui.groupsend.SelectSendObjectToPartGroupActivity;
import com.jianzhen.wsk.utils.DataSaveUtils;
import com.jianzhen.wsk.utils.GlideEngine;
import com.jianzhen.wsk.utils.ImageSaveUtil;
import com.jianzhen.wsk.utils.ScriptLoadUtil;
import com.jianzhen.wsk.utils.Utils;
import com.jianzhen.wsk.v1.VBaseActivity;
import com.kongzue.dialogx.dialogs.PopNotification;
import com.luck.picture.lib.basic.PictureSelector;
import com.luck.picture.lib.config.SelectMimeType;
import com.luck.picture.lib.entity.LocalMedia;
import com.luck.picture.lib.interfaces.OnResultCallbackListener;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.function.Predicate;

public class WxGroupNoticeActivity extends VBaseActivity<ActivityWxGroupNoticeBinding> implements View.OnClickListener, InteractTimeDialog.OnCompleteListener {
    private ImgAdapter imgAdapter;
    private ActivityResultLauncher<Intent> launcher;
    private InteractTimeDialog mDialog;
    private ExecutorWindow mExecutorWindow;
    private PopNotification mPopNotification;
    private WxDeleteGroupIm mParam = new WxDeleteGroupIm();
    private final String funcId = "10085";
    private List<TagAndGroupBean> selectGroupListData = new ArrayList();
    private List<String> imgList = new ArrayList();

    public static class WxDeleteGroupIm {
        public String noticeStr;
        public boolean isHaveImg = false;
        public List<ImgListData> imgList = new ArrayList();
        public List<WxDeleteGroupName> groupList = new ArrayList();
        public String interactTime = "[10000,15000]";
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_wx_delete_group_im;
    }

    @Override
    protected void initPageView() {
    }

    @Override
    protected void initTitle() {
    }

    @Override
    protected boolean isSetBaseTitle() {
        return false;
    }

    @Override
    public void initView(ActivityWxGroupNoticeBinding activityWxGroupNoticeBinding, Bundle bundle) {
        this.mDialog = new InteractTimeDialog(this, this);
        activityWxGroupNoticeBinding.tvTitle.setText(R.string.group_notice);
        initActivityResult();
        List<TagAndGroupBean> groupNoticeSelectGroupData = DataSaveUtils.getGroupNoticeSelectGroupData(this);
        this.selectGroupListData = groupNoticeSelectGroupData;
        if (groupNoticeSelectGroupData != null && !groupNoticeSelectGroupData.isEmpty()) {
            activityWxGroupNoticeBinding.tvSelectedGroup.setText("已选择" + this.selectGroupListData.size() + "个群聊");
        } else {
            activityWxGroupNoticeBinding.tvSelectedGroup.setText("请选择");
        }
    }

    @Override
    public void initListener(ActivityWxGroupNoticeBinding activityWxGroupNoticeBinding, Bundle bundle) {
        activityWxGroupNoticeBinding.tvStart.setOnClickListener(this);
        activityWxGroupNoticeBinding.tvSelectedGroup.setOnClickListener(this);
        activityWxGroupNoticeBinding.tvInteractTime.setOnClickListener(this);
    }

    @Override
    public void onTimeComplete(String str, String str2) {
        this.mParam.interactTime = str;
        ((ActivityWxGroupNoticeBinding) this.mViewBinding).tvInteractTime.setText(str2);
    }

    @Override
    public void onClick(View view) {
        InteractTimeDialog interactTimeDialog;
        if (view == ((ActivityWxGroupNoticeBinding) this.mViewBinding).tvSelectedGroup) {
            Intent intent = new Intent((Context) this, (Class<?>) SelectSendObjectToPartGroupActivity.class);
            intent.putExtra("selectGroupData", (Serializable) this.selectGroupListData);
            intent.putExtra(SelectSendObjectToPartGroupActivity.IS_SAVA_DATA, false);
            this.launcher.launch(intent);
            return;
        }
        if (view == ((ActivityWxGroupNoticeBinding) this.mViewBinding).tvInteractTime && (interactTimeDialog = this.mDialog) != null) {
            interactTimeDialog.show(this.mParam.interactTime);
        } else if (view == ((ActivityWxGroupNoticeBinding) this.mViewBinding).tvStart) {
            getFuncLimit("10085");
        }
    }

    @Override
    public void lambda$setNotYearVipTip$7() {
        super.lambda$setNotYearVipTip$7();
        addImg();
        try {
            IAccessibility accessibility = AuxiliaryService.getAccessibility();
            ExecutorWindow executorWindow = this.mExecutorWindow;
            if (executorWindow != null) {
                executorWindow.hideFloatWindow();
            }
            if (((ActivityWxGroupNoticeBinding) this.mViewBinding).noticeMessageTv.getText().toString().isEmpty()) {
                showCenterToast("请输入群公告");
                return;
            }
            List<TagAndGroupBean> list = this.selectGroupListData;
            if (list != null && !list.isEmpty()) {
                this.mParam.groupList = new ArrayList();
                Iterator<TagAndGroupBean> it = this.selectGroupListData.iterator();
                while (it.hasNext()) {
                    this.mParam.groupList.add(new WxDeleteGroupName(it.next().getTagName()));
                }
                this.mParam.noticeStr = ((ActivityWxGroupNoticeBinding) this.mViewBinding).noticeMessageTv.getText().toString();
                if (!this.imgList.isEmpty()) {
                    ArrayList arrayList = new ArrayList();
                    for (int i = 0; i < this.imgList.size(); i++) {
                        if (!this.imgList.get(i).equals("-1")) {
                            arrayList.add(new ImgListData("图片" + (i + 1)));
                        }
                    }
                    this.mParam.isHaveImg = true;
                    this.mParam.imgList = arrayList;
                } else {
                    this.mParam.isHaveImg = false;
                }
                ExecutorWindow loadWx = ScriptLoadUtil.loadWx(accessibility, "10085", "wx_group_notice");
                this.mExecutorWindow = loadWx;
                loadWx.setArgs(this.mParam);
                this.mExecutorWindow.showFloatWindow();
                this.mExecutorWindow.addStatusCallback(new NodeExecutor.DefaultStatusCallback() {
                    public void onFinish(NodeExecutor nodeExecutor, boolean z) {
                        WxGroupNoticeActivity.this.mExecutorWindow.setMessage("群公告发布完成!", true);
                        WxGroupNoticeActivity.this.addFuncLimitCount("10085");
                        super.onFinish(nodeExecutor, z);
                    }
                });
                SettingUtil.startClearActivity(this, "com.tencent.mm", "com.tencent.mm.ui.LauncherUI");
                return;
            }
            showCenterToast("请选择群聊");
        } catch (Exception unused) {
            Toast.makeText((Context) this, (CharSequence) "请先启动辅助服务", 0).show();
        }
    }

    public static class WxDeleteGroupName {
        public String groupName;

        public WxDeleteGroupName() {
        }

        public WxDeleteGroupName(String str) {
            this.groupName = str;
        }
    }

    public static class ImgListData {
        public String imgStr;

        public ImgListData() {
        }

        public ImgListData(String str) {
            this.imgStr = str;
        }
    }

    protected void onResume() {
        super.onResume();
        ExecutorWindow executorWindow = this.mExecutorWindow;
        if (executorWindow != null) {
            executorWindow.hideFloatWindow();
            this.mExecutorWindow.stop();
        }
    }

    public void initActivityResult() {
        this.launcher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback() {
            public final void onActivityResult(Object obj) {
                WxGroupNoticeActivity.this.lambda$initActivityResult$0((ActivityResult) obj);
            }
        });
    }

    public void lambda$initActivityResult$0(ActivityResult activityResult) {
        if (activityResult.getResultCode() != -1 || activityResult.getData() == null) {
            return;
        }
        this.selectGroupListData = new ArrayList();
        this.mParam.groupList = new ArrayList();
        List<TagAndGroupBean> list = (List) activityResult.getData().getSerializableExtra("selectGroup");
        this.selectGroupListData = list;
        if (list != null && !list.isEmpty()) {
            ((ActivityWxGroupNoticeBinding) this.mViewBinding).tvSelectedGroup.setText("已选择" + this.selectGroupListData.size() + "个群聊");
            DataSaveUtils.setGroupNoticeSelectGroupData(this, JSON.toJSONString(this.selectGroupListData));
        } else {
            ((ActivityWxGroupNoticeBinding) this.mViewBinding).tvSelectedGroup.setText("请选择");
        }
    }

    private void initImg() {
        RecyclerView findViewById = findViewById(R.id.img_rv);
        findViewById.setVisibility(0);
        findViewById.setLayoutManager(new GridLayoutManager(this, 3));
        ImgAdapter imgAdapter = new ImgAdapter(this.imgList);
        this.imgAdapter = imgAdapter;
        findViewById.setAdapter(imgAdapter);
        if (this.imgList.isEmpty()) {
            this.imgList.add("-1");
            this.imgAdapter.notifyDataSetChanged();
        }
        this.imgAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
            public final void onItemChildClick(BaseQuickAdapter baseQuickAdapter, View view, int i) {
                WxGroupNoticeActivity.this.lambda$initImg$2(baseQuickAdapter, view, i);
            }
        });
    }

    public void lambda$initImg$2(BaseQuickAdapter baseQuickAdapter, View view, int i) {
        if (view.getId() == 2131363375) {
            if (this.imgList.get(i).equals("-1")) {
                if (Build.VERSION.SDK_INT >= 30) {
                    if (!Environment.isExternalStorageManager()) {
                        new PermissionTipDialog(this, "获取文件访问权限说明:\n用于拍摄、储存照片以及在相册中浏览查看照片", new PermissionTipDialog.Callback() {
                            @Override
                            public void onSure() {
                                Intent intent = new Intent("android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION");
                                intent.setData(Uri.parse("package:" + WxGroupNoticeActivity.this.getPackageName()));
                                WxGroupNoticeActivity.this.startActivityForResult(intent, 2);
                            }
                        }).show();
                        return;
                    } else {
                        toSelectImg();
                        return;
                    }
                }
                toSelectImg();
                return;
            }
            return;
        }
        if (view.getId() == 2131363367) {
            this.imgList.remove(i);
            if (this.imgList.size() > 0) {
                this.imgList.removeIf(new Predicate() {
                    @Override
                    public final boolean test(Object obj) {
                        boolean equals;
                        equals = ((String) obj).equals("-1");
                        return equals;
                    }
                });
            }
            if (this.imgList.size() < 9) {
                this.imgList.add("-1");
            }
            this.imgAdapter.notifyDataSetChanged();
        }
    }

    private static class ImgAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
        public ImgAdapter(List<String> list) {
            super(R.layout.item_show_list, list);
        }

        public void convert(BaseViewHolder baseViewHolder, String str) {
            ImageView imageView = (ImageView) baseViewHolder.getView(R.id.video_show);
            ImageView imageView2 = (ImageView) baseViewHolder.getView(R.id.video_delete);
            if (!str.equals("-1")) {
                imageView2.setVisibility(0);
                Glide.with(this.mContext).load(str).into(imageView);
            } else {
                imageView.setImageResource(R.mipmap.add_img_big);
                imageView2.setVisibility(4);
            }
            baseViewHolder.addOnClickListener(new int[]{R.id.video_show});
            baseViewHolder.addOnClickListener(new int[]{R.id.video_delete});
        }
    }

    private void toSelectImg() {
        if (!XXPermissions.isGranted((Context) this, Utils.cameraPermission())) {
            PopNotification build = PopNotification.build();
            this.mPopNotification = build;
            build.setTitle("相机和存储权限使用说明:").setMessage("用于拍摄、储存照片以及在相册中浏览查看照片").noAutoDismiss().show();
        }
        XXPermissions.with((Context) this).permission(Utils.cameraPermission()).request(new OnPermissionCallback() {
            @Override
            public void onGranted(List<String> list, boolean z) {
                WxGroupNoticeActivity.this.imgSelect();
                if (WxGroupNoticeActivity.this.mPopNotification != null) {
                    WxGroupNoticeActivity.this.mPopNotification.dismiss();
                }
            }

            @Override
            public void onDenied(List<String> list, boolean z) {
                if (WxGroupNoticeActivity.this.mPopNotification != null) {
                    WxGroupNoticeActivity.this.mPopNotification.dismiss();
                }
            }
        });
    }

    private void addImg() {
        for (String str : this.imgList) {
            if (!str.isEmpty() && !str.equals("-1")) {
                ImageSaveUtil.saveAlbum((Context) this, str, Bitmap.CompressFormat.JPEG, 100, false);
            }
        }
    }

    public void imgSelect() {
        if (!this.imgList.isEmpty()) {
            this.imgList.removeIf(new Predicate() {
                @Override
                public final boolean test(Object obj) {
                    boolean equals;
                    equals = ((String) obj).equals("-1");
                    return equals;
                }
            });
        }
        PictureSelector.create(this).openGallery(SelectMimeType.ofImage()).setMaxSelectNum(9 - this.imgList.size()).setMinSelectNum(1).setImageEngine(GlideEngine.createGlideEngine()).setSelectorUIStyle(Utils.selectorStyle()).forResult(new AnonymousClass4());
    }

    class AnonymousClass4 implements OnResultCallbackListener<LocalMedia> {
        AnonymousClass4() {
        }

        public void onResult(ArrayList<LocalMedia> arrayList) {
            Iterator<LocalMedia> it = arrayList.iterator();
            while (it.hasNext()) {
                LocalMedia next = it.next();
                if (!WxGroupNoticeActivity.this.imgList.isEmpty()) {
                    WxGroupNoticeActivity.this.imgList.removeIf(new Predicate() {
                        @Override
                        public final boolean test(Object obj) {
                            boolean equals;
                            equals = ((String) obj).equals("-1");
                            return equals;
                        }
                    });
                }
                WxGroupNoticeActivity.this.imgList.add(next.getPath());
            }
            if (WxGroupNoticeActivity.this.imgList.size() < 9) {
                WxGroupNoticeActivity.this.imgList.add("-1");
            }
            WxGroupNoticeActivity.this.imgAdapter.setNewData(WxGroupNoticeActivity.this.imgList);
        }

        public void onCancel() {
            if (WxGroupNoticeActivity.this.imgList.size() < 9) {
                WxGroupNoticeActivity.this.imgList.add("-1");
            }
        }
    }
}