admin
2021-07-06 abce02c7a61820f5d580f87364d542e817be429c
app/src/main/java/com/tejia/lijin/app/util/ToolUtil.java
@@ -39,10 +39,9 @@
import com.alibaba.baichuan.android.trade.model.AlibcShowParams;
import com.alibaba.baichuan.android.trade.model.OpenType;
import com.app.hubert.guide.util.ScreenUtils;
import com.coloros.mcssdk.PushManager;
import com.google.gson.Gson;
import com.huawei.android.hms.agent.HMSAgent;
import com.huawei.android.hms.agent.push.handler.EnableReceiveNormalMsgHandler;
import com.heytap.msp.push.HeytapPushManager;
import com.heytap.msp.push.callback.ICallBackResultService;
import com.nostra13.universalimageloader.cache.disc.naming.HashCodeFileNameGenerator;
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache;
@@ -391,39 +390,6 @@
    }
    /**
     * 注册 OPPO RegId
     */
    public static void registeredOPPOId(Context context) {
        String registerId = null;
        if (PushManager.getInstance() != null)
            registerId = PushManager.getInstance().getRegisterID();
        if (!StringUtils.isEmpty(registerId))
            ShoppingApi.bindOPPOPush(context, UserUtil.getUid(ShoppingApplication.application), registerId, new BasicTextHttpResponseHandler() {
                @Override
                public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
                    super.onSuccessPerfect(statusCode, headers, jsonObject);
                }
            });
    }
    /**
     * 注册 VIVO RegId
     */
    public static void registeredVIVORegId(Context context) {
//        Log.e("eee", "registeredVIVORegId-uid: " + uid);
        String registerId = null;
        if (PushClient.getInstance(context) != null)
            registerId = PushClient.getInstance(context).getRegId();
        if (!StringUtils.isEmpty(registerId))
            ShoppingApi.bindVIVOPush(context, UserUtil.getUid(ShoppingApplication.application), registerId, new BasicTextHttpResponseHandler() {
                @Override
                public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
                    super.onSuccessPerfect(statusCode, headers, jsonObject);
                }
            });
    }
    /**
     * 推送免打扰模式
     *
     * @param mContext  上下文
@@ -450,73 +416,15 @@
                        weekDays.add(i);
                    }
                    if (isChecked)
                        PushManager.getInstance().setPushTime(weekDays, 20, 0, 8, 0);
                        HeytapPushManager.setPushTime(weekDays, 20, 0, 8, 0);
                    else
                        PushManager.getInstance().setPushTime(weekDays, 0, 0, 23, 59);
                        HeytapPushManager.setPushTime(weekDays, 0, 0, 23, 59);
                    break;
                case "vivo":
                    break;
                default:
                    break;
            }
        }
    }
    /**
     * 打开或关闭推送
     */
    public static void setPush_OFF_NO(MainActivity mContext) {
        if (mContext != null) {
            /**
             * false 关闭推送
             * _01 第一次查询(第一次查询 关闭推送 只关闭一次)
             * true 开启推送
             * _02 二次查询(只开启一次)
             * */
            SharedPreferences sp = mContext.getSharedPreferences("user", Context.MODE_PRIVATE);
            String off_no = sp.getString("push_off_no", "false_01");
            SharedPreferences.Editor editor = sp.edit();
            String mBRAND = Build.BRAND.toLowerCase();
            if (mBRAND.equals("xiaomi")) {
//                Log.e("eee", "setPush_OFF_NO: " + mBRAND + "--" + off_no);
                if (off_no.equals("false_01")) {//关闭一次推送
//                    Log.e("eee", "setPush_OFF_NO: 关闭MiPush推送服务");
                    MiPushClient.pausePush(mContext, null);/**暂停接收MiPush服务推送的消息*/
                    editor.putString("push_off_no", "false_02");
                } else if (off_no.equals("true_01")) {
//                    Log.e("eee", "setPush_OFF_NO: 启用MiPush推送服务");
                    MiPushClient.resumePush(mContext, null);/**恢复接收MiPush服务推送的消息,这时服务器会把暂停时期的推送消息重新推送过来*/
                    editor.putString("push_off_no", "true_02");
                }
            } else if (mBRAND.equals("huawei") || mBRAND.equals("honor")) {
//                Log.e("eee", "honor: ");
                if (off_no.equals("false_01")) {
                    editor.putString("push_off_no", "false_02");
                    HMSAgent.Push.enableReceiveNormalMsg(false, new EnableReceiveNormalMsgHandler() {
                        @Override
                        public void onResult(int rst) {
                        }
                    });
                } else if (off_no.equals("true_01")) {
                    editor.putString("push_off_no", "true_02");
                    HMSAgent.Push.enableReceiveNormalMsg(true, new EnableReceiveNormalMsgHandler() {
                        @Override
                        public void onResult(int rst) {
                        }
                    });
                }
            } else if (mBRAND.equals("oppo")) {
                if (off_no.equals("false_01")) {
                    PushManager.getInstance().pausePush();/*** 暂停接收OPush服务推送的消息*/
                    editor.putString("push_off_no", "false_02");
                } else if (off_no.equals("true_01")) {
                    PushManager.getInstance().resumePush();/*** 恢复接收OPush服务推送的消息,这时服务器会把暂停时期的推送消息重新推送过来*/
                    editor.putString("push_off_no", "true_02");
                }
            } else if (mBRAND.equals("vivo")) {
            }
            editor.commit();
        }
    }