| | |
| | | import android.app.Application; |
| | | |
| | | import cn.com.basic.face.discern.entity.Device; |
| | | import cn.com.basic.face.service.CheckInMng; |
| | | import cn.com.basic.face.service.DictionaryMng; |
| | | import cn.com.basic.face.service.DeviceMng; |
| | | import cn.com.basic.face.service.RegisterMng; |
| | | import cn.com.basic.face.service.SurveillanceMng; |
| | | |
| | | import com.facebook.drawee.backends.pipeline.Fresco; |
| | | import com.lzy.okhttputils.OkHttpUtils; |
| | |
| | | return application; |
| | | } |
| | | |
| | | private Device device; |
| | | private Device androidDevice; |
| | | private Device camera1; |
| | | private Device camera2; |
| | | |
| | | |
| | | public static boolean deviceAvailable = false; |
| | | |
| | | public void setDevice(Device device) { |
| | | this.device = device; |
| | | public void setAndroidDevice(Device device) { |
| | | this.androidDevice = device; |
| | | if (device != null && device.getDeviceId() != null && !"".equals(device.getDeviceId())) { |
| | | deviceAvailable = true; |
| | | DictionaryMng.getInstance().loadAllDictionaryData(); |
| | | } |
| | | } |
| | | |
| | | public Device getDevice() { |
| | | if (device == null) { |
| | | device = new Device(); |
| | | public void setCamera1(Device camera1) { |
| | | this.camera1 = camera1; |
| | | if (camera1 != null && camera1.getDeviceId() != null && !"".equals(camera1.getDeviceId())) { |
| | | DictionaryMng.getInstance().loadAllDictionaryData(); |
| | | } |
| | | return device; |
| | | } |
| | | |
| | | public void setCamera2(Device camera2) { |
| | | this.camera2 = camera2; |
| | | if (camera2 != null && camera2.getDeviceId() != null && !"".equals(camera2.getDeviceId())) { |
| | | DictionaryMng.getInstance().loadAllDictionaryData(); |
| | | } |
| | | } |
| | | |
| | | public Device getAndroidDevice() { |
| | | if (androidDevice == null) { |
| | | androidDevice = new Device(); |
| | | } |
| | | return androidDevice; |
| | | } |
| | | |
| | | @Override |
| | |
| | | Fresco.initialize(this); |
| | | initOkHttpUtils(); |
| | | application = this; |
| | | DeviceMng.getInstance().findDevice(); |
| | | |
| | | } |
| | | |
| | | private void initOkHttpUtils() { |
| | |
| | | OkHttpUtils.init(this); |
| | | } |
| | | |
| | | |
| | | public boolean networkNotAvailable() { |
| | | return !networkAvailable(); |
| | | } |
| | | |
| | | public boolean networkAvailable() { |
| | | boolean connected = true; |
| | | // ConnectivityManager connectivityManager = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); |
| | | // if(connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState() == NetworkInfo.State.CONNECTED || |
| | | // connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState() == NetworkInfo.State.CONNECTED) { |
| | | // connected = true; |
| | | // } |
| | | if (connected) { |
| | | // sendOfflineDataToServer(); |
| | | } |
| | | return connected; |
| | | } |
| | | |
| | | public void sendOfflineDataToServer() { |
| | | // RegisterMng.getInstance().sendOfflineVisitorRegisterToServer(); |
| | | // if (RegisterMng.getInstance().hasOfflineVisitorRegisterData()) { |
| | | // return; |
| | | // } |
| | | // RegisterMng.getInstance().sendOfflineAttenderRegisterToServer(); |
| | | // if (RegisterMng.getInstance().hasOfflineAttenderRegisterData()) { |
| | | // return; |
| | | // } |
| | | //// CheckInMng.getInstance().sendOfflineCheckInToServer(); |
| | | //// if (CheckInMng.getInstance().hasOfflineCheckInData()) { |
| | | //// return; |
| | | //// } |
| | | // SurveillanceMng.getInstance().sendOfflineUnknownToServer(); |
| | | } |
| | | |
| | | |
| | | } |