| | |
| | | import android.os.SystemClock; |
| | | import android.provider.Settings; |
| | | import android.text.TextUtils; |
| | | import android.util.Log; |
| | | import android.view.View; |
| | | import android.widget.TextView; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.hdl.linkpm.sdk.core.exception.HDLException; |
| | |
| | | import com.hdl.photovoltaic.listener.CloudCallBeak; |
| | | import com.hdl.photovoltaic.other.HdlCommonLogic; |
| | | import com.hdl.photovoltaic.other.HdlDeviceLogic; |
| | | import com.hdl.photovoltaic.other.HdlESLocalJsonLogic; |
| | | import com.hdl.photovoltaic.other.HdlLogLogic; |
| | | import com.hdl.photovoltaic.other.HdlMessageLogic; |
| | | import com.hdl.photovoltaic.other.HdlMqttLogic; |
| | | import com.hdl.photovoltaic.other.HdlOtaLogic; |
| | | import com.hdl.photovoltaic.other.HdlPushLogic; |
| | | import com.hdl.photovoltaic.other.HdlResidenceLogic; |
| | | import com.hdl.photovoltaic.other.HdlThreadLogic; |
| | | import com.hdl.photovoltaic.other.HdlUniLogic; |
| | | import com.hdl.photovoltaic.push.PushMessageInfoBean; |
| | | import com.hdl.photovoltaic.ui.bean.DeviceRemoteInfo; |
| | | import com.hdl.photovoltaic.ui.bean.MessageBean; |
| | | import com.hdl.photovoltaic.ui.bean.OidBean; |
| | | import com.hdl.photovoltaic.ui.bean.UnCountBean; |
| | | import com.hdl.photovoltaic.ui.home.HomePageFragment; |
| | | import com.hdl.photovoltaic.ui.me.MeFragment; |
| | | import com.hdl.photovoltaic.ui.message.MessageFragment; |
| | | import com.hdl.photovoltaic.ui.message.MessageHouseFragment; |
| | | import com.hdl.photovoltaic.ui.message.MessageInfoActivity; |
| | | import com.hdl.photovoltaic.ui.powerstation.HouseAndDeviceFragment; |
| | | import com.hdl.photovoltaic.uni.HDLUniMP; |
| | | import com.hdl.photovoltaic.uni.HDLUniMPSDKManager; |
| | | import com.hdl.photovoltaic.utils.AppManagerUtils; |
| | | import com.hdl.photovoltaic.utils.GPSManagerUtils; |
| | | import com.hdl.photovoltaic.utils.PermissionUtils; |
| | | import com.hdl.photovoltaic.utils.SharedPreUtils; |
| | | import com.hdl.photovoltaic.widget.ConfirmationCancelDialog; |
| | | import com.hdl.photovoltaic.widget.ConfirmationTipDialog; |
| | | import com.hdl.sdk.link.HDLLinkLocalSdk; |
| | |
| | | import com.hdl.sdk.link.core.config.HDLLinkConfig; |
| | | import com.hdl.sdk.link.core.connect.HDLUdpConnect; |
| | | import com.hdl.sdk.link.core.utils.mqtt.MqttRecvClient; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | |
| | | import org.greenrobot.eventbus.Subscribe; |
| | | import org.greenrobot.eventbus.ThreadMode; |
| | |
| | | import java.lang.reflect.Type; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | import cn.jpush.android.api.JPushInterface; |
| | | |
| | |
| | | |
| | | @Override |
| | | public void onBindView(Bundle savedInstanceState) { |
| | | // setNotificationBarBackgroundColor(CustomColor.blue); |
| | | setStatusBarTranslucent(); |
| | | |
| | | getWindow().setNavigationBarColor(getColor(R.color.text_FF1C1C1E)); |
| | | //初始化碎片 |
| | | initFragment(savedInstanceState); |
| | | initFragment(null); |
| | | //初始化 |
| | | this.initView(); |
| | | //初始化界面监听器 |
| | |
| | | this.registerAllTopicsListener(); |
| | | //初始化mqtt客户端 |
| | | this.initMqttClient(); |
| | | //上传极光注册ID到云端 |
| | | this.pushTokens(); |
| | | //点击极光通知栏消息进来 |
| | | this.clickJpushNotificationMessage(); |
| | | // //上传极光注册ID到云端 隐藏2025-11-21 11:52:27 |
| | | // this.pushTokens(); |
| | | //上传推动令牌到云端(谷歌FCM推送) |
| | | this.sendPushTokenToServer(UserConfigManage.getInstance().getPushToken()); |
| | | // //点击极光通知栏消息进来 |
| | | // this.clickJpushNotificationMessage(); |
| | | //点击通知栏消息进来 |
| | | this.OpenSpecifiedPage(getIntent(), "onBindView"); |
| | | //初始化权限 |
| | | this.requestPermissions(); |
| | | //读取消息未读数量 |
| | | this.getUnreadCount(); |
| | | //获取云端脚本 |
| | | HdlESLocalJsonLogic.getInstance().getAllHdlESLocalJson(); |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 点击通知栏消息进来 |
| | | */ |
| | | private void OpenSpecifiedPage(Intent intent, String tag) { |
| | | Log.d("==========", tag); |
| | | try { |
| | | String data = getIntentExpantData(intent); |
| | | if (TextUtils.isEmpty(data)) { |
| | | return; |
| | | } |
| | | PushMessageInfoBean pushMessageInfoBean = HdlPushLogic.getInstance().pushDataProcessing("", "", data); |
| | | if (TextUtils.isEmpty(pushMessageInfoBean.getMsgId())) { |
| | | return; |
| | | } |
| | | MessageBean messageBean = new MessageBean(); |
| | | messageBean.setMsgId(Long.valueOf(pushMessageInfoBean.getMsgId())); |
| | | Intent intentMessageInfoActivity = new Intent(); |
| | | intentMessageInfoActivity.setClass(_mActivity, MessageInfoActivity.class); |
| | | intentMessageInfoActivity.putExtra("messageBean", JSONObject.toJSONString(messageBean)); |
| | | startActivity(intentMessageInfoActivity); |
| | | this.clickNotificationMessageTab(); |
| | | if (null != HDLUniMPSDKManager.getInstance().getUniMP()) { |
| | | Log.d("HDLUniMPSDKManager.getInstance().getUniMP()", "HDLUniMPSDKManager.getInstance().getUniMP()"); |
| | | HDLUniMPSDKManager.getInstance().getUniMP().closeUniMP(); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | Log.d("错误", " " + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 初始化Fragment |
| | |
| | | //碎片初始化 |
| | | HomePageFragment mHomePageFragment = new HomePageFragment(); |
| | | HouseAndDeviceFragment mHouseAndDeviceFragment = new HouseAndDeviceFragment(); |
| | | MessageFragment mMessageFragment = new MessageFragment(); |
| | | MessageHouseFragment mMessageHouseFragment = new MessageHouseFragment(); |
| | | MeFragment mMeFragment = new MeFragment(); |
| | | if (savedInstanceState != null) { |
| | | //“内存重启”时调用 获取“内存重启”时保存的索引下标 |
| | | currentFragmentIndex = savedInstanceState.getInt(CURRENT_FRAGMENT, 0); |
| | | if (fragmentList.size() != 0) { |
| | | if (!fragmentList.isEmpty()) { |
| | | fragmentList.clear(); |
| | | } |
| | | fragmentList.add(mFragmentManager.findFragmentByTag(0 + "")); |
| | | fragmentList.add(mFragmentManager.findFragmentByTag(1 + "")); |
| | | fragmentList.add(mFragmentManager.findFragmentByTag(2 + "")); |
| | | fragmentList.add(mFragmentManager.findFragmentByTag(3 + "")); |
| | | restoreFragment();//恢复fragment页面 |
| | | this.restoreFragment();//恢复fragment页面 |
| | | } else { |
| | | // |
| | | this.removeAllFragments(mFragmentManager); |
| | | //正常启动时调用 |
| | | if (!fragmentList.isEmpty()) { |
| | | fragmentList.clear(); |
| | | } |
| | | fragmentList.add(mHomePageFragment); |
| | | fragmentList.add(mHouseAndDeviceFragment); |
| | | fragmentList.add(mMessageFragment); |
| | | fragmentList.add(mMessageHouseFragment); |
| | | fragmentList.add(mMeFragment); |
| | | showFragment(); |
| | | this.showFragment(); |
| | | } |
| | | |
| | | |
| | | // if (!fragmentList.isEmpty()) { |
| | | // fragmentList.clear(); |
| | | // } |
| | | // // 正常启动时调用 |
| | | // fragmentList.add(mHomePageFragment); |
| | | // fragmentList.add(mHouseAndDeviceFragment); |
| | | // fragmentList.add(mMessageFragment); |
| | | // fragmentList.add(mMeFragment); |
| | | // FragmentUtils.loadMultipleFragment(R.id.module_fcv, mFragmentManager, fragmentList.toArray(new Fragment[0])); |
| | | } |
| | | |
| | | |
| | |
| | | * 显示fragment |
| | | */ |
| | | private void showFragment() { |
| | | // FragmentUtils.showHideFragment(mFragmentManager, fragmentList.toArray(new Fragment[0])[currentFragmentIndex]); |
| | | FragmentTransaction ft = mFragmentManager.beginTransaction(); |
| | | //如果之前没有添加过 |
| | | if (!fragmentList.get(currentFragmentIndex).isAdded()) { |
| | |
| | | } else { |
| | | ft.hide(currentFragment).show(fragmentList.get(currentFragmentIndex)); |
| | | } |
| | | //把当前显示的fragment记录下来 |
| | | currentFragment = fragmentList.get(currentFragmentIndex); |
| | | ft.commit(); |
| | | //把当前显示的fragment记录下来 |
| | | currentFragment = fragmentList.get(currentFragmentIndex); |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | ft.commit(); |
| | | } |
| | | |
| | | private void removeAllFragments(FragmentManager manager) { |
| | | if (manager == null) return; |
| | | try { |
| | | final List<Fragment> fragments = manager.getFragments(); |
| | | if (fragments.isEmpty()) { |
| | | return; |
| | | } |
| | | FragmentTransaction transaction = manager.beginTransaction(); |
| | | for (int i = 0; i < fragments.size(); i++) { |
| | | Fragment fragment = fragments.get(i); |
| | | if (fragment != null) { |
| | | // FragmentManager childManager = fragment.getChildFragmentManager(); |
| | | // removeAllFragments(childManager); |
| | | transaction.remove(fragment); |
| | | } |
| | | } |
| | | transaction.commit(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | if (!TextUtils.isEmpty(registrationID)) { |
| | | UserConfigManage.getInstance().setRegistrationID(registrationID); |
| | | UserConfigManage.getInstance().Save(); |
| | | // UserConfigManage.getInstance().setRegistrationID(registrationID); |
| | | // UserConfigManage.getInstance().Save(); |
| | | String finalRegistrationID = registrationID; |
| | | HdlResidenceLogic.getInstance().pushAdd(new CloudCallBeak<String>() { |
| | | @Override |
| | | public void onSuccess(String pushId) { |
| | | |
| | | if (!TextUtils.isEmpty(pushId)) { |
| | | UserConfigManage.getInstance().setPushToken(finalRegistrationID); |
| | | UserConfigManage.getInstance().setPushId(pushId); |
| | | UserConfigManage.getInstance().Save(); |
| | | } |
| | | HDLApp.getInstance().setInfoMap(registrationId_tag, "true");//记录一下状态,后台杀死app会清空; |
| | | HdlLogLogic.print("添加极光ID到云端--->registrationID:" + UserConfigManage.getInstance().getUserName() + "--->" + finalRegistrationID, true); |
| | | HdlLogLogic.print("添加极光ID到云端---registrationID:" + UserConfigManage.getInstance().getUserName() + "---" + finalRegistrationID, true); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HDLApp.getInstance().setInfoMap(registrationId_tag, "false");//记录一下状态,后台杀死app会清空; |
| | | HdlLogLogic.print("添加极光ID到云端失败--->registrationID:" + UserConfigManage.getInstance().getUserName() + "--->" + finalRegistrationID, true); |
| | | HdlLogLogic.print("添加极光ID到云端失败---registrationID:" + UserConfigManage.getInstance().getUserName() + "---" + finalRegistrationID, true); |
| | | } |
| | | }); |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 上传 token 到服务器 |
| | | * |
| | | * @param token 令牌 |
| | | */ |
| | | private void sendPushTokenToServer(final String token) { |
| | | if (TextUtils.isEmpty(token)) { |
| | | return; |
| | | } |
| | | HdlResidenceLogic.getInstance().pushAdd(new CloudCallBeak<String>() { |
| | | @Override |
| | | public void onSuccess(String pushId) { |
| | | |
| | | if (!TextUtils.isEmpty(pushId)) { |
| | | UserConfigManage.getInstance().setToken(token); |
| | | UserConfigManage.getInstance().setPushId(pushId); |
| | | UserConfigManage.getInstance().Save(); |
| | | } |
| | | HdlLogLogic.print("添加令牌到云端 PushToken:" + UserConfigManage.getInstance().getPushToken() + " pushId:" + pushId, true); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HdlLogLogic.print("添加令牌到云端失败 PushToken:" + UserConfigManage.getInstance().getPushToken() + " 错误:" + e.getMessage(), true); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 开启通知权限 |
| | | */ |
| | | private void notificationSet() { |
| | | boolean isBoolean = PermissionUtils.isNotificationEnabled(_mActivity); |
| | | if (!isBoolean) { |
| | | ConfirmationCancelDialog confirmationCancelDialog = new ConfirmationCancelDialog(_mActivity); |
| | | confirmationCancelDialog.setTitle(getString(R.string.loading_title_tip)); |
| | | confirmationCancelDialog.setContent(getString(R.string.no_permissions_unable_to_receive_push)); |
| | | confirmationCancelDialog.setConfirmation(getString(R.string.go_to_settings)); |
| | | confirmationCancelDialog.show(); |
| | | confirmationCancelDialog.isHideTitle(true); |
| | | confirmationCancelDialog.setYesOnclickListener(new ConfirmationCancelDialog.onYesOnclickListener() { |
| | | @Override |
| | | public void Confirm() { |
| | | confirmationCancelDialog.dismiss(); |
| | | PermissionUtils.openNotificationSettings(_mActivity); |
| | | String key = "isOpenNotificationEnabled"; |
| | | boolean isCancel = SharedPreUtils.getBoolean(key); |
| | | if (!isCancel) { |
| | | boolean isBoolean = PermissionUtils.isNotificationEnabled(_mActivity); |
| | | if (!isBoolean) { |
| | | ConfirmationCancelDialog confirmationCancelDialog = new ConfirmationCancelDialog(_mActivity); |
| | | confirmationCancelDialog.setTitle(getString(R.string.loading_title_tip)); |
| | | confirmationCancelDialog.setContent(getString(R.string.no_permissions_unable_to_receive_push)); |
| | | confirmationCancelDialog.setConfirmation(getString(R.string.go_to_settings)); |
| | | confirmationCancelDialog.show(); |
| | | confirmationCancelDialog.isHideTitle(true); |
| | | confirmationCancelDialog.setYesOnclickListener(new ConfirmationCancelDialog.onYesOnclickListener() { |
| | | @Override |
| | | public void Confirm() { |
| | | SharedPreUtils.putBoolean(key, true); |
| | | confirmationCancelDialog.dismiss(); |
| | | PermissionUtils.openNotificationSettings(_mActivity); |
| | | |
| | | } |
| | | }); |
| | | confirmationCancelDialog.setNoOnclickListener(new ConfirmationCancelDialog.onNoOnclickListener() { |
| | | @Override |
| | | public void Cancel() { |
| | | confirmationCancelDialog.dismiss(); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | confirmationCancelDialog.setNoOnclickListener(new ConfirmationCancelDialog.onNoOnclickListener() { |
| | | @Override |
| | | public void Cancel() { |
| | | SharedPreUtils.putBoolean(key, true); |
| | | confirmationCancelDialog.dismiss(); |
| | | } |
| | | }); |
| | | |
| | | } else { |
| | | SharedPreUtils.putBoolean(key, true); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | @Override |
| | | protected void onDestroy() { |
| | | super.onDestroy(); |
| | | Log.d("BPowerStationActivity", "onDestroy"); |
| | | HdlUniLogic.getInstance().checkRemoveOtherUniMPEventCallBack(); |
| | | //移除监听 |
| | | HDLLinkLocalSdk.getInstance().removeAllTopicsListener(allTopicsListener); |
| | | |
| | | |
| | | } |
| | | |
| | | private void initView() { |
| | |
| | | if (this.currentFragmentIndex == 0) { |
| | | //概览界面 |
| | | viewBinding.myPowerStationBottomIl0.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.home_page_selected)); |
| | | viewBinding.myPowerStationBottomIl0.titleTv.setTextColor(getColor(R.color.text_E6000000)); |
| | | viewBinding.myPowerStationBottomIl0.titleTv.setTextColor(getColor(R.color.text_FFACACAC)); |
| | | viewBinding.myPowerStationBottomIl1.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.power_station_unselected)); |
| | | viewBinding.myPowerStationBottomIl1.titleTv.setTextColor(getColor(R.color.text_65000000)); |
| | | viewBinding.myPowerStationBottomIl1.titleTv.setTextColor(getColor(R.color.text_FF5B5B5B)); |
| | | viewBinding.myMessageBottomIl2.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.message_unselected)); |
| | | viewBinding.myMessageBottomIl2.titleTv.setTextColor(getColor(R.color.text_65000000)); |
| | | viewBinding.myMessageBottomIl2.titleTv.setTextColor(getColor(R.color.text_FF5B5B5B)); |
| | | viewBinding.myMeBottomIl3.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.me_unselected)); |
| | | viewBinding.myMeBottomIl3.titleTv.setTextColor(getColor(R.color.text_65000000)); |
| | | viewBinding.myMeBottomIl3.titleTv.setTextColor(getColor(R.color.text_FF5B5B5B)); |
| | | } else if (this.currentFragmentIndex == 1) { |
| | | //电站界面 |
| | | viewBinding.myPowerStationBottomIl0.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.home_page_unselected)); |
| | | viewBinding.myPowerStationBottomIl0.titleTv.setTextColor(getColor(R.color.text_65000000)); |
| | | viewBinding.myPowerStationBottomIl0.titleTv.setTextColor(getColor(R.color.text_FF5B5B5B)); |
| | | viewBinding.myPowerStationBottomIl1.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.power_station_selected)); |
| | | viewBinding.myPowerStationBottomIl1.titleTv.setTextColor(getColor(R.color.text_E6000000)); |
| | | viewBinding.myPowerStationBottomIl1.titleTv.setTextColor(getColor(R.color.text_FFACACAC)); |
| | | viewBinding.myMessageBottomIl2.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.message_unselected)); |
| | | viewBinding.myMessageBottomIl2.titleTv.setTextColor(getColor(R.color.text_65000000)); |
| | | viewBinding.myMessageBottomIl2.titleTv.setTextColor(getColor(R.color.text_FF5B5B5B)); |
| | | viewBinding.myMeBottomIl3.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.me_unselected)); |
| | | viewBinding.myMeBottomIl3.titleTv.setTextColor(getColor(R.color.text_65000000)); |
| | | viewBinding.myMeBottomIl3.titleTv.setTextColor(getColor(R.color.text_FF5B5B5B)); |
| | | } else if (this.currentFragmentIndex == 2) { |
| | | //消息界面 |
| | | viewBinding.myPowerStationBottomIl0.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.home_page_unselected)); |
| | | viewBinding.myPowerStationBottomIl0.titleTv.setTextColor(getColor(R.color.text_65000000)); |
| | | viewBinding.myPowerStationBottomIl0.titleTv.setTextColor(getColor(R.color.text_FF5B5B5B)); |
| | | viewBinding.myPowerStationBottomIl1.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.power_station_unselected)); |
| | | viewBinding.myPowerStationBottomIl1.titleTv.setTextColor(getColor(R.color.text_65000000)); |
| | | viewBinding.myMessageBottomIl2.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.message_select)); |
| | | viewBinding.myMessageBottomIl2.titleTv.setTextColor(getColor(R.color.text_E6000000)); |
| | | viewBinding.myPowerStationBottomIl1.titleTv.setTextColor(getColor(R.color.text_FF5B5B5B)); |
| | | viewBinding.myMessageBottomIl2.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.message_selected)); |
| | | viewBinding.myMessageBottomIl2.titleTv.setTextColor(getColor(R.color.text_FFACACAC)); |
| | | viewBinding.myMeBottomIl3.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.me_unselected)); |
| | | viewBinding.myMeBottomIl3.titleTv.setTextColor(getColor(R.color.text_65000000)); |
| | | viewBinding.myMeBottomIl3.titleTv.setTextColor(getColor(R.color.text_FF5B5B5B)); |
| | | } else if (this.currentFragmentIndex == 3) { |
| | | //我的界面 |
| | | viewBinding.myPowerStationBottomIl0.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.home_page_unselected)); |
| | | viewBinding.myPowerStationBottomIl0.titleTv.setTextColor(getColor(R.color.text_65000000)); |
| | | viewBinding.myPowerStationBottomIl0.titleTv.setTextColor(getColor(R.color.text_FF5B5B5B)); |
| | | viewBinding.myPowerStationBottomIl1.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.power_station_unselected)); |
| | | viewBinding.myPowerStationBottomIl1.titleTv.setTextColor(getColor(R.color.text_65000000)); |
| | | viewBinding.myPowerStationBottomIl1.titleTv.setTextColor(getColor(R.color.text_FF5B5B5B)); |
| | | viewBinding.myMessageBottomIl2.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.message_unselected)); |
| | | viewBinding.myMessageBottomIl2.titleTv.setTextColor(getColor(R.color.text_65000000)); |
| | | viewBinding.myMessageBottomIl2.titleTv.setTextColor(getColor(R.color.text_FF5B5B5B)); |
| | | viewBinding.myMeBottomIl3.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.me_selected)); |
| | | viewBinding.myMeBottomIl3.titleTv.setTextColor(getColor(R.color.text_E6000000)); |
| | | viewBinding.myMeBottomIl3.titleTv.setTextColor(getColor(R.color.text_FFACACAC)); |
| | | } |
| | | } |
| | | |
| | |
| | | @Override |
| | | public void onMessage(Object msg) { |
| | | |
| | | |
| | | if (msg == null) { |
| | | return; |
| | | } |
| | |
| | | if (response.getTopic() == null) { |
| | | return; |
| | | } |
| | | HdlLogLogic.print("监听到Modbus数据--->" + new Gson().toJson(response), false); |
| | | HdlLogLogic.print("监听到Modbus数据---" + new Gson().toJson(response), false); |
| | | // if (response.getTopic().endsWith("custom/native/inverter/up")) { |
| | | HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean(); |
| | | uniCallBackBaseBean.setType(response.getTopic()); |
| | |
| | | } else if (linkResponse.getTopic().endsWith("/custom/device/list/upload")) { |
| | | //逆变器有新oid通知主题 |
| | | if (linkResponse.getData() == null) { |
| | | HdlLogLogic.print("逆变器有新oid通知--->数据为空", false); |
| | | HdlLogLogic.print("逆变器有新oid通知---数据为空", false); |
| | | return; |
| | | } |
| | | try { |
| | |
| | | uniCallBackBaseBean.setData(linkResponse.getData()); |
| | | HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean); |
| | | HdlLogLogic.print(linkResponse.getTopic() + new Gson().toJson(linkResponse.getData()), true); |
| | | // HdlDeviceLogic.getInstance().searchAllNetworkGateway(null);//逆变器wifi状态-重新搜索一下逆变器-重新更新连接状态 |
| | | } else if (linkResponse.getTopic().endsWith("/app/thing/event/appHomeRemoveRefresh/up")) { |
| | | String[] topicArray = linkResponse.getTopic().split("/"); |
| | | //住宅删除通知 |
| | |
| | | uniCallBackBaseBean.setData(topicArray[1]); |
| | | HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean); |
| | | HdlLogLogic.print(linkResponse.getTopic() + new Gson().toJson(linkResponse.getData()), true); |
| | | } else if (linkResponse.getTopic().endsWith("/app/thing/event/appHomeDeliverRollbackRefresh/up")) { |
| | | //B端登录电站回滚时,收到回滚的事件时,发个通知给uniapp,uniapp刷新下电站的权限,调整下菜单栏的内容。 |
| | | String[] topicArray = linkResponse.getTopic().split("/"); |
| | | if (topicArray.length < 2) { |
| | | return; |
| | | } |
| | | final String HomeId = topicArray[2]; |
| | | HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean(); |
| | | uniCallBackBaseBean.setType(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_home_delivery_rollback); |
| | | uniCallBackBaseBean.setData(HomeId); |
| | | HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean); |
| | | } else if (linkResponse.getTopic().endsWith("/app/thing/property/send")) { |
| | | //设备状态变更topic:/user/${homeId}/app/thing/property/send |
| | | if (linkResponse.getData() == null) { |
| | | HdlLogLogic.print("设备状态变更--->数据为空", false); |
| | | return; |
| | | } |
| | | HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean(); |
| | | uniCallBackBaseBean.setType(linkResponse.getTopic()); |
| | | uniCallBackBaseBean.setData(linkResponse.getData()); |
| | | HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (info != null) { |
| | | MqttRecvClient.getInstance().setConnectParam(info.getUrl(), info.getClientId(), info.getUserName(), info.getPassWord()); |
| | | MqttRecvClient.getInstance().connect(); |
| | | HdlLogLogic.print("mqtt链接成功---ClientId---" + info.getClientId(), true); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HdlLogLogic.print("读取mqtt远程信息失败--->" + e.getMessage(), e.getCode(), true); |
| | | HdlLogLogic.print("读取mqtt远程信息失败---" + e.getMessage(), e.getCode(), true); |
| | | } |
| | | }); |
| | | } |
| | |
| | | bottomViewChangeOfStyle(); |
| | | showFragment(); |
| | | } |
| | | } else if (event.getTopic().contains(ConstantManage.refresh_push_token)) { |
| | | //pushToken更新 |
| | | sendPushTokenToServer(UserConfigManage.getInstance().getPushToken()); |
| | | } |
| | | } |
| | | |
| | |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | protected void onNewIntent(Intent intent) { |
| | | super.onNewIntent(intent); |
| | | //AndroidManifest.xml 需要添加启动模式android:launchMode="singleTask"才执行这个方法 |
| | | OpenSpecifiedPage(intent, "onNewIntent"); |
| | | } |
| | | |
| | | /** |
| | | * 点击极光通知栏消息进来 |
| | | * 点击通知栏消息进来,默认选择消息模块 |
| | | */ |
| | | private void clickJpushNotificationMessage() { |
| | | Intent intent = getIntent(); |
| | | if (intent != null) { |
| | | String key = intent.getStringExtra("skip"); |
| | | if (key != null) { |
| | | //触发消息点击事件 |
| | | viewBinding.myMessageBottomIl2.clickTv.performClick(); |
| | | } |
| | | } |
| | | private void clickNotificationMessageTab() { |
| | | //触发消息点击事件 |
| | | viewBinding.myMessageBottomIl2.clickTv.performClick(); |
| | | // if (currentFragmentIndex == 2) { |
| | | // return; |
| | | // } |
| | | // currentFragmentIndex = 2; |
| | | // bottomViewChangeOfStyle(); |
| | | // showFragment(); |
| | | // HdlCommonLogic.lowerTagType = LowerTagType.message; |
| | | // HdlCommonLogic.getInstance().postEventBusSticky(ConstantManage.homepage_title_tab_switch, HomepageTitleTabSwitch.message.toString()); |
| | | } |
| | | |
| | | |
| | |
| | | return; |
| | | } else { |
| | | AppManagerUtils.getAppManager().finishAllActivity(); |
| | | //如果开发者调用kill或者exit之类的方法杀死进程,或者双击back键会杀死进程,请务必在此之前调用MobclickAgent.onKillProcess方法,用来保存统计数据。 |
| | | MobclickAgent.onKillProcess(_mActivity); |
| | | Process.killProcess(Process.myPid()); |
| | | |
| | | } |
| | | } |
| | | super.onBackPressed(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 处理从通知点击带来的数据,这里获取数据,然后透传给主界面做处理 |
| | | * |
| | | * @return 返回附加数据 |
| | | */ |
| | | private String getIntentExpantData(Intent intent) { |
| | | try { |
| | | if (intent == null) { |
| | | return ""; |
| | | } |
| | | // 处理从通知点击带来的数据,这里获取数据,然后透传给主界面做处理 |
| | | if (intent.getExtras() != null) { |
| | | for (String key : intent.getExtras().keySet()) { |
| | | if (key.equals("pushData")) { |
| | | return Objects.requireNonNull(intent.getExtras().get(key)).toString(); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | return ""; |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | |
| | | } |