| | |
| | | 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.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.ChatInfoBean; |
| | | import com.hdl.photovoltaic.ui.bean.ChatMessageListBean; |
| | | import com.hdl.photovoltaic.ui.bean.ChatMessagePageBean; |
| | | import com.hdl.photovoltaic.ui.bean.DeviceRemoteInfo; |
| | | import com.hdl.photovoltaic.ui.bean.MessageBean; |
| | |
| | | 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.petterp.floatingx.FloatingX; |
| | | import com.petterp.floatingx.assist.FxGravity; |
| | | import com.petterp.floatingx.assist.FxScopeType; |
| | | import com.petterp.floatingx.assist.helper.FxAppHelper; |
| | | import com.petterp.floatingx.listener.control.IFxAppControl; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | |
| | | import org.greenrobot.eventbus.Subscribe; |
| | |
| | | private ActivityMyPowerStationBinding viewBinding; |
| | | private EventListener allTopicsListener; |
| | | private int backPressTimes; |
| | | public IFxAppControl iFxAppControl; |
| | | |
| | | @Override |
| | | public Object getContentView() { |
| | |
| | | //获取云端脚本 |
| | | HdlESLocalJsonLogic.getInstance().getAllHdlESLocalJson(); |
| | | this.getChatInfo(); |
| | | this.createAppFloatWindow(); |
| | | |
| | | } |
| | | |
| | |
| | | if (obj != null && !obj.getData().isEmpty()) { |
| | | UserConfigManage.getInstance().setConversationId(obj.getData().get(0).getId()); |
| | | UserConfigManage.getInstance().Save(); |
| | | } else { |
| | | //没有拿到对话列表,把旧的当前会话ID清空 |
| | | UserConfigManage.getInstance().setConversationId(""); |
| | | HdlLogLogic.print("没有拿到对话列表,把旧的当前会话ID清空 ", true); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HdlLogLogic.print("获取智能体AppKey失败 Pu" + e.getMessage(), true); |
| | | HdlLogLogic.print("获取智能体AppKey失败 " + e.getMessage(), true); |
| | | } |
| | | }); |
| | | } |
| | |
| | | HdlUniLogic.getInstance().checkRemoveOtherUniMPEventCallBack(); |
| | | //移除监听 |
| | | HDLLinkLocalSdk.getInstance().removeAllTopicsListener(allTopicsListener); |
| | | |
| | | if (this.iFxAppControl != null) { |
| | | this.iFxAppControl.cancel(); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | public void run() { |
| | | //防止app启动的时候没有网络(app也登录不了),导致获取不了mqtt远程连接信息; |
| | | initMqttClient(); |
| | | HdlDeviceLogic.getInstance().getCurrentHomeLocalAndCloudGatewayList(UserConfigManage.getInstance().getHomeId(), new CloudCallBeak<List<GatewayBean>>() { |
| | | HdlDeviceLogic.getInstance().getCurrentHomeLocalAndCloudGatewayList(UserConfigManage.getInstance().getHomeId(), UserConfigManage.getInstance().getPowerStationType(), new CloudCallBeak<List<GatewayBean>>() { |
| | | @Override |
| | | public void onSuccess(List<GatewayBean> obj) { |
| | | // AppManagerUtils.getAppManager().hideLoading(); |
| | |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 创建应用级AI小组件悬浮窗 |
| | | */ |
| | | private void createAppFloatWindow() { |
| | | if (this.iFxAppControl != null) { |
| | | //彻底销毁悬浮窗(会从界面上移除) |
| | | this.iFxAppControl.cancel(); |
| | | } |
| | | FxAppHelper helper = FxAppHelper.builder() |
| | | .setContext(_mActivity) // 设置上下文 |
| | | .setLayout(R.layout.item_ai) // 设置悬浮窗布局 |
| | | .setScopeType(FxScopeType.APP) // 设置为应用内悬浮窗类型,无需权限 |
| | | .setEnableEdgeAdsorption(true)// 开启边缘吸附 |
| | | // .setEnableHalfHide(true) // 开启半隐藏模式(实现“靠边隐藏”) |
| | | // 1. 设置重力为右下角 |
| | | .setGravity(FxGravity.RIGHT_OR_BOTTOM) |
| | | // 2. 设置底部边界边距,确保浮窗不被拖拽到边界以下,留出空间 |
| | | .setBottomBorderMargin(230f) |
| | | .setRightBorderMargin(40f) |
| | | .setTopBorderMargin(250f) |
| | | .build(); // 最后调用 build() 完成构建 |
| | | // 获取控制对象 |
| | | this.iFxAppControl = FloatingX.install(helper); |
| | | this.iFxAppControl.show(); |
| | | this.iFxAppControl.setClickListener(300, new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_AIChatBox, null); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | } |