wjc
16 小时以前 abede488312c289351ea3724e25416e5889b206e
app/src/main/java/com/hdl/photovoltaic/ui/StartActivity.java
@@ -8,11 +8,13 @@
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import androidx.annotation.NonNull;
import com.alibaba.fastjson.JSONObject;
import com.hdl.linkpm.sdk.core.exception.HDLException;
import com.hdl.linkpm.sdk.user.HDLLinkPMUser;
import com.hdl.photovoltaic.HDLApp;
@@ -20,19 +22,22 @@
import com.hdl.photovoltaic.base.CustomBaseActivity;
import com.hdl.photovoltaic.config.AppConfigManage;
import com.hdl.photovoltaic.config.UserConfigManage;
import com.hdl.photovoltaic.enums.Languages;
import com.hdl.photovoltaic.listener.CloudCallBeak;
import com.hdl.photovoltaic.other.HdlCommonLogic;
import com.hdl.photovoltaic.other.HdlResidenceLogic;
import com.hdl.photovoltaic.other.HdlUniLogic;
import com.hdl.photovoltaic.ui.bean.HouseIdBean;
import com.hdl.photovoltaic.ui.me.WebActivity;
import com.hdl.photovoltaic.uni.HDLUniMP;
import com.hdl.photovoltaic.uni.HDLUniMPSDKManager;
import com.hdl.photovoltaic.utils.LocalManageUtil;
import com.hdl.photovoltaic.utils.BadgeUtils;
import com.hdl.photovoltaic.utils.SharedPreUtils;
import com.hdl.photovoltaic.widget.ConfirmationCancelDialog;
import com.umeng.commonsdk.UMConfigure;
//import com.umeng.commonsdk.UMConfigure;
import java.util.List;
import java.util.Objects;
import cn.jpush.android.api.JPushInterface;
@@ -49,8 +54,11 @@
    @Override
    public void onBindView(Bundle savedInstanceState) {
        Log.d("StartActivity====", "onBindView");
        setStatusBarTranslucent();
        getWindow().setNavigationBarColor(getColor(R.color.text_FF000000));
        BadgeUtils.cancelAllNotifications(_mActivity);
        BadgeUtils.clearBadge(_mActivity);
        //发布审核小米应用市场要求APP第一次启动提前提示《用户协议》和《隐私政策》才允许上线
        final String key = "is_login";
        HDLUniMPSDKManager.isExistsActivity = false;
@@ -93,6 +101,7 @@
                        //安装商跳转界面
                        Intent intent = new Intent();
                        intent.setClass(StartActivity.this, BPowerStationActivity.class);
                        intent.putExtra("pushData", getIntentExpantData());
                        openActivity(intent);
                    } else {
                        //C端用户跳转界面
@@ -104,6 +113,7 @@
                                HdlResidenceLogic.getInstance().setHouseIdList(obj);
                                Intent intent = new Intent();
                                intent.setClass(StartActivity.this, CPowerStationActivity.class);
                                intent.putExtra("pushData", getIntentExpantData());
                                openActivity(intent);
                            }
@@ -123,12 +133,14 @@
                }
            } else {
                //无网模式-跳到小程序设备列表界面
                String path = HDLUniMP.UNI_EVENT_OPEN_NONETWORKDEVICELIST + "?mac=" + UserConfigManage.getInstance().getNoNetworkDeviceMac() + "&password=" + UserConfigManage.getInstance().getNoNetworkPassword() + "&autoVerify=" +UserConfigManage.getInstance().isNoNetworkFlag();
                String path = HDLUniMP.UNI_EVENT_OPEN_NONETWORKDEVICELIST + "?mac=" + UserConfigManage.getInstance().getNoNetworkDeviceMac() + "&password=" + UserConfigManage.getInstance().getNoNetworkPassword() + "&autoVerify=true";
                HdlUniLogic.getInstance().openUniMP(path, null);
            }
        }
    }
    @Override
    public void startActivity(Intent intent) {
@@ -145,6 +157,7 @@
    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.d("StartActivity", "onDestroy");
        overridePendingTransition(0, 0);
    }
@@ -172,7 +185,7 @@
            int startIndex2 = s.lastIndexOf("《");
            int endIndex2 = s.lastIndexOf("》") + 1;
            if (UserConfigManage.getInstance().getCurrentAppLanguage().equals(LocalManageUtil.en)) {
            if (UserConfigManage.getInstance().getCurrentAppLanguage().equals(Languages.en)) {
                s = s.replace("《", "").replace("》", "");
                endIndex1 -= 1;
                startIndex2 -= 2;//移除"《"和"》"总长度发生变化,索引也改变;
@@ -196,8 +209,8 @@
                        super.updateDrawState(ds);
                        //设置字体颜色
                        ds.setColor(getResources().getColor(R.color.text_38C494, null));
                        // 去掉下划线
                        ds.setUnderlineText(!UserConfigManage.getInstance().isZh());
                        // 去掉下划线(中文保留下划线)
                        ds.setUnderlineText(!UserConfigManage.getInstance().getCurrentAppLanguage().equals(Languages.zh));
                    }
@@ -220,7 +233,7 @@
                        //设置字体颜色
                        ds.setColor(getResources().getColor(R.color.text_38C494, null));
                        // 去掉下划线
                        ds.setUnderlineText(!UserConfigManage.getInstance().isZh());
                        ds.setUnderlineText(!UserConfigManage.getInstance().getCurrentAppLanguage().equals(Languages.zh));
                    }
@@ -249,9 +262,10 @@
        }
        HDLApp.getInstance().isStartInitThirdSDK = true;
        //初始化友盟SDK
        initUMengSDK();
        //初始化极光推送
        initJPush();
        // initUMengSDK();
//        //初始化极光推送
//        initJPush();
    }
@@ -268,12 +282,35 @@
     * 集成教程地址:https://developer.umeng.com/docs/119267/detail/118588
     */
    private void initUMengSDK() {
        UMConfigure.preInit(this, "6801aec0bc47b67d833fd76d", "XenterraSolar");
        //appkey和channl必须保持和预初始化一致!!!
        //deviceType:设备类型,UMConfigure.DEVICE_TYPE_PHONE为手机、UMConfigure.DEVICE_TYPE_BOX为盒子
        //pushSecret:Push推送业务的secret
        UMConfigure.init(this, "6801aec0bc47b67d833fd76d", "XenterraSolar", UMConfigure.DEVICE_TYPE_PHONE, "");
        UMConfigure.setLogEnabled(false);//AppConfigManage.isDebug()
//        UMConfigure.preInit(this, "6801aec0bc47b67d833fd76d", "XenterraSolar");
//        //appkey和channl必须保持和预初始化一致!!!
//        //deviceType:设备类型,UMConfigure.DEVICE_TYPE_PHONE为手机、UMConfigure.DEVICE_TYPE_BOX为盒子
//        //pushSecret:Push推送业务的secret
//        UMConfigure.init(this, "6801aec0bc47b67d833fd76d", "XenterraSolar", UMConfigure.DEVICE_TYPE_PHONE, "");
//        UMConfigure.setLogEnabled(false);//AppConfigManage.isDebug()
    }
    /**
     * 处理从通知点击带来的数据,这里获取数据,然后透传给主界面做处理
     *
     * @return 返回附加数据
     */
    private String getIntentExpantData() {
        try {
            // 处理从通知点击带来的数据,这里获取数据,然后透传给主界面做处理
            if (getIntent().getExtras() != null) {
                Log.d("来自点击消息的数据===", JSONObject.toJSONString(getIntent().getExtras()));
                for (String key : getIntent().getExtras().keySet()) {
                    Log.d("来自点击消息的数据", "key: " + key + "  value: " + getIntent().getExtras().get(key));
                    if (key.equals("pushData") || key.equals("extraMap")) {
                        return Objects.requireNonNull(getIntent().getExtras().get(key)).toString();
                    }
                }
            }
        } catch (Exception e) {
            return "";
        }
        return "";
    }
}