| | |
| | | import android.provider.Settings; |
| | | import android.text.TextUtils; |
| | | import android.view.View; |
| | | import android.widget.TextView; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.reflect.TypeToken; |
| | |
| | | import com.hdl.photovoltaic.config.UserConfigManage; |
| | | import com.hdl.photovoltaic.databinding.ActivityMyPowerStationBinding; |
| | | import com.hdl.photovoltaic.enums.HomepageTitleTabSwitch; |
| | | import com.hdl.photovoltaic.enums.LowerTagType; |
| | | import com.hdl.photovoltaic.enums.NetworkType; |
| | | import com.hdl.photovoltaic.enums.PowerStationStatusType; |
| | | import com.hdl.photovoltaic.listener.CloudCallBeak; |
| | | import com.hdl.photovoltaic.other.HdlCommonLogic; |
| | | import com.hdl.photovoltaic.other.HdlDeviceLogic; |
| | | 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.HdlResidenceLogic; |
| | |
| | | import com.hdl.photovoltaic.other.HdlUniLogic; |
| | | import com.hdl.photovoltaic.ui.bean.DeviceRemoteInfo; |
| | | 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.powerstation.HouseListFragment; |
| | | import com.hdl.photovoltaic.ui.powerstation.HouseAndDeviceFragment; |
| | | import com.hdl.photovoltaic.uni.HDLUniMP; |
| | | import com.hdl.photovoltaic.utils.AppManagerUtils; |
| | | import com.hdl.photovoltaic.utils.GPSManagerUtils; |
| | |
| | | this.clickJpushNotificationMessage(); |
| | | //初始化权限 |
| | | this.requestPermissions(); |
| | | //读取消息未读数量 |
| | | this.getUnreadCount(); |
| | | |
| | | } |
| | | |
| | |
| | | mFragmentManager = getSupportFragmentManager(); |
| | | //碎片初始化 |
| | | HomePageFragment mHomePageFragment = new HomePageFragment(); |
| | | HouseListFragment mHouseListFragment = new HouseListFragment(); |
| | | HouseAndDeviceFragment mHouseAndDeviceFragment = new HouseAndDeviceFragment(); |
| | | MessageFragment mMessageFragment = new MessageFragment(); |
| | | MeFragment mMeFragment = new MeFragment(); |
| | | if (savedInstanceState != null) { |
| | |
| | | } else { |
| | | //正常启动时调用 |
| | | fragmentList.add(mHomePageFragment); |
| | | fragmentList.add(mHouseListFragment); |
| | | fragmentList.add(mHouseAndDeviceFragment); |
| | | fragmentList.add(mMessageFragment); |
| | | fragmentList.add(mMeFragment); |
| | | showFragment(); |
| | |
| | | currentFragmentIndex = 0; |
| | | bottomViewChangeOfStyle(); |
| | | showFragment(); |
| | | postEventBus(HomepageTitleTabSwitch.homepage); |
| | | HdlCommonLogic.lowerTagType = LowerTagType.home; |
| | | HdlCommonLogic.getInstance().postEventBusSticky(ConstantManage.homepage_title_tab_switch, HomepageTitleTabSwitch.homepage.toString()); |
| | | } |
| | | }); |
| | | viewBinding.myPowerStationBottomIl1.clickTv.setOnClickListener(new View.OnClickListener() { |
| | |
| | | currentFragmentIndex = 1; |
| | | bottomViewChangeOfStyle(); |
| | | showFragment(); |
| | | postEventBus(HomepageTitleTabSwitch.powerstation); |
| | | HdlCommonLogic.lowerTagType = LowerTagType.power_station; |
| | | HdlCommonLogic.getInstance().postEventBusSticky(ConstantManage.homepage_title_tab_switch, HomepageTitleTabSwitch.powerstation.toString()); |
| | | } |
| | | }); |
| | | viewBinding.myMessageBottomIl2.clickTv.setOnClickListener(new View.OnClickListener() { |
| | |
| | | currentFragmentIndex = 2; |
| | | bottomViewChangeOfStyle(); |
| | | showFragment(); |
| | | postEventBus(HomepageTitleTabSwitch.message); |
| | | HdlCommonLogic.lowerTagType = LowerTagType.message; |
| | | HdlCommonLogic.getInstance().postEventBusSticky(ConstantManage.homepage_title_tab_switch, HomepageTitleTabSwitch.message.toString()); |
| | | } |
| | | }); |
| | | viewBinding.myMeBottomIl3.clickTv.setOnClickListener(new View.OnClickListener() { |
| | |
| | | currentFragmentIndex = 3; |
| | | bottomViewChangeOfStyle(); |
| | | showFragment(); |
| | | postEventBus(HomepageTitleTabSwitch.me); |
| | | HdlCommonLogic.lowerTagType = LowerTagType.me; |
| | | HdlCommonLogic.getInstance().postEventBusSticky(ConstantManage.homepage_title_tab_switch, HomepageTitleTabSwitch.me.toString()); |
| | | } |
| | | }); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 发布点击事件 |
| | | * |
| | | * @param tabSwitch - |
| | | */ |
| | | private void postEventBus(HomepageTitleTabSwitch tabSwitch) { |
| | | BaseEventBus baseEventBus = new BaseEventBus(); |
| | | baseEventBus.setTopic(ConstantManage.homepage_title_tab_switch); |
| | | baseEventBus.setType(tabSwitch.toString()); |
| | | EventBus.getDefault().postSticky(baseEventBus); |
| | | } |
| | | |
| | | public void requestPermissions() { |
| | | //消息通知限权 |
| | |
| | | } |
| | | }); |
| | | } |
| | | } else if (event.getTopic().contains(ConstantManage.station_status)) { |
| | | currentFragmentIndex = 1; |
| | | bottomViewChangeOfStyle(); |
| | | showFragment(); |
| | | HdlCommonLogic.getInstance().postEventBusSticky(ConstantManage.homepage_title_tab_switch, event.getType()); |
| | | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 读取消息【未读数量,未处理总数量,已处理总数量】 |
| | | */ |
| | | private void getUnreadCount() { |
| | | HdlMessageLogic.getInstance().getMessageUntreatedCount("", new CloudCallBeak<UnCountBean>() { |
| | | @Override |
| | | public void onSuccess(UnCountBean unCountBean) { |
| | | |
| | | HdlThreadLogic.runMainThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if (unCountBean == null) { |
| | | return; |
| | | } |
| | | //刷新【消息模块】下角标数值 |
| | | TextView textView = _mActivity.findViewById(R.id.my_message_bottom_il2).findViewById(R.id.red_count_tv); |
| | | if (textView != null) { |
| | | if (unCountBean.getUnreadCount() == 0) { |
| | | textView.setVisibility(View.GONE); |
| | | } else { |
| | | textView.setVisibility(View.VISIBLE); |
| | | if (unCountBean.getUnreadCount() > 99) { |
| | | textView.setText("99+"); |
| | | } else { |
| | | textView.setText(unCountBean.getUnreadCount() + ""); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HdlThreadLogic.runMainThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | TextView textView = _mActivity.findViewById(R.id.my_message_bottom_il2).findViewById(R.id.red_count_tv); |
| | | if (textView != null) { |
| | | textView.setVisibility(View.GONE); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 点击极光通知栏消息进来 |
| | | */ |
| | | private void clickJpushNotificationMessage() { |