| | |
| | | import android.support.v4.app.ActivityCompat; |
| | | import android.widget.Toast; |
| | | |
| | | import com.callBack.IAddCamera; |
| | | import com.common.openapi.ClassInstanceManager; |
| | | import com.lechange.demo.tools.MediaPlayHelper; |
| | | import com.mm.android.deviceaddmodule.CommonParam; |
| | |
| | | import com.usermodule.net.IUserDataCallBack; |
| | | import com.usermodule.net.UserNetManager; |
| | | |
| | | import org.greenrobot.eventbus.EventBus; |
| | | import org.greenrobot.eventbus.Subscribe; |
| | | import org.greenrobot.eventbus.ThreadMode; |
| | | |
| | | public class HdlToLcUtils { |
| | | |
| | | private Activity activity; |
| | | private Activity activity; |
| | | private String homeId; |
| | | private String token; |
| | | private String subAccessToken; |
| | | private IAddCamera iAddCamera; |
| | | |
| | | public Activity getActivity() { |
| | | public Activity getActivity() { |
| | | return activity; |
| | | } |
| | | |
| | |
| | | return instance; |
| | | } |
| | | |
| | | public void initData(Activity activity, String appKey, String secretKey, boolean isChina) { |
| | | public void initData(Activity activity, String appKey, String secretKey,String url) { |
| | | this.activity = activity; |
| | | MediaPlayHelper.initContext(activity.getApplication().getApplicationContext()); |
| | | ClassInstanceManager.newInstance().init(activity.getApplication()); |
| | | String mUrl; |
| | | if (isChina) { |
| | | // mAppSecret = "f869433de68a4a06bb8f9bb89118fc"; |
| | | // mAppid = "lc2ea929282d5f4636"; |
| | | mUrl = CONST.Envirment.CHINA_TEST.url; |
| | | ProviderManager.getAppProvider().setAppType(0); |
| | | } else { |
| | | ClassInstanceManager.newInstance().init(activity.getApplication().getApplicationContext()); |
| | | // if (isChina) { |
| | | //// mAppSecret = "f869433de68a4a06bb8f9bb89118fc"; |
| | | //// mAppid = "lc2ea929282d5f4636"; |
| | | // mUrl = CONST.Envirment.CHINA_TEST.url; |
| | | // ProviderManager.getAppProvider().setAppType(0); |
| | | // } else { |
| | | // mAppSecret = "017fc27bb987496f9a677e4e6f0c88"; |
| | | // mAppid = "lc0285433bc7e8423d"; |
| | | // mUrl = CONST.Envirment.OVERSEAS_PRO.url; |
| | | mUrl=CONST.Envirment.CHINA_TEST.url; |
| | | ProviderManager.getAppProvider().setAppType(1); |
| | | } |
| | | ProviderManager.getAppProvider().setAppType(1); |
| | | // } |
| | | |
| | | |
| | | |
| | | try { |
| | | CommonParam commonParam = new CommonParam(); |
| | | commonParam.setEnvirment(mUrl);//云端连接 |
| | | commonParam.setEnvirment(url);//云端连接 |
| | | commonParam.setContext(activity.getApplication()); |
| | | commonParam.setAppId(appKey); |
| | | commonParam.setAppSecret(secretKey); |
| | |
| | | } |
| | | } |
| | | |
| | | public void addCamera() { |
| | | public void addCamera(IAddCamera iAddCamera) { |
| | | if(!EventBus.getDefault().isRegistered(this)){ |
| | | EventBus.getDefault().register(this); |
| | | } |
| | | //开启添加页面 |
| | | activity.startActivity(new Intent(activity.getApplication(), DeviceAddActivity.class)); |
| | | |
| | | } |
| | | |
| | | @Subscribe(threadMode = ThreadMode.MAIN) |
| | | public void onGetMessage(String obj) { |
| | | if(obj.equals("backXamarin")){ |
| | | iAddCamera.back(); |
| | | |
| | | if(EventBus.getDefault().isRegistered(this)){ |
| | | EventBus.getDefault().unregister(this); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void play(String deviceId){ |