| | |
| | | |
| | | 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.PlaceMng; |
| | | import cn.com.basic.face.service.VisitorTypeMng; |
| | | 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; |
| | | import com.lzy.okhttputils.model.HttpHeaders; |
| | | import com.lzy.okhttputils.model.HttpParams; |
| | | |
| | | import org.xutils.x; |
| | | |
| | | import cn.com.basic.face.discern.entity.Place; |
| | | |
| | | /** |
| | | * Created by zhangbo on 2017/2/15. |
| | | */ |
| | | |
| | | public class BaseApplication extends Application{ |
| | | |
| | |
| | | return application; |
| | | } |
| | | |
| | | private Place place; |
| | | private Device androidDevice; |
| | | private Device camera1; |
| | | private Device camera2; |
| | | |
| | | public void setPlace(Place place) { |
| | | this.place = place; |
| | | |
| | | public static boolean deviceAvailable = false; |
| | | |
| | | public void setAndroidDevice(Device device) { |
| | | this.androidDevice = device; |
| | | if (device != null && device.getDeviceId() != null && !"".equals(device.getDeviceId())) { |
| | | deviceAvailable = true; |
| | | DictionaryMng.getInstance().loadAllDictionaryData(); |
| | | } |
| | | } |
| | | |
| | | public Place getPlace() { |
| | | if (place == null) { |
| | | place = new Place(); |
| | | public void setCamera1(Device camera1) { |
| | | this.camera1 = camera1; |
| | | if (camera1 != null && camera1.getDeviceId() != null && !"".equals(camera1.getDeviceId())) { |
| | | DictionaryMng.getInstance().loadAllDictionaryData(); |
| | | } |
| | | return place; |
| | | } |
| | | |
| | | 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; |
| | | PlaceMng.getInstance().findPlace(); |
| | | DictionaryMng.getInstance().loadAllDictionaryData(); |
| | | VisitorTypeMng.getInstance().loadAll(); |
| | | |
| | | } |
| | | |
| | | 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(); |
| | | } |
| | | |
| | | |
| | | } |