@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.navigation_drawer_layout); checkUser(); initNavigationDrawer(); ObservableScrollView observableScrollView = (ObservableScrollView) findViewById(R.id.cameras_scroll_view); observableScrollView.setScrollViewCallbacks(this); setUpActionButtons(); initDataCollectionObjects(); activity = this; /** * Use Handler here because we want the title bar/menu get loaded first. When the app starts, it * will load cameras to grid view twice: 1. Load cameras that saved locally without image * (disabled load image from cache because it blocks UI.) 2. When camera list returned from * Evercam, show them on screen with thumbnails, then request for snapshots in background * separately. * * <p>TODO: Check is it really necessary to keep the post delay handler here See if refresh icon * stop animating or not. */ new Handler() .postDelayed( new Runnable() { @Override public void run() { /** * Sometimes Evercam returns the list less than 0.1 sec? so check it's returned or * not before the first load to avoid loading it twice. */ io.evercam.androidapp.custom.FlowLayout camsLineView = (io.evercam.androidapp.custom.FlowLayout) CamerasActivity.this.findViewById(R.id.cameras_flow_layout); if (!(camsLineView.getChildCount() > 0)) { addAllCameraViews(false, false); if (camsLineView.getChildCount() > 0 && databaseLoadTime == 0 && startTime != null) { databaseLoadTime = Commons.calculateTimeDifferenceFrom(startTime); } } } }, 1); // Start loading camera list after menu created(because need the menu // showing as animation) new CamerasCheckInternetTask(CamerasActivity.this, InternetCheckType.START) .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Fabric.with(this, new Crashlytics()); setContentView(R.layout.main_activity_layout); launch(); }
@Override public void onStop() { super.onStop(); if (AppData.defaultUser != null) { usernameOnStop = AppData.defaultUser.getUsername(); } showOfflineOnStop = PrefsManager.showOfflineCameras(this); }
@Override public void onRestart() { super.onRestart(); if (MainActivity.isUserLogged(this)) { // Reload camera list if default user has been changed, or offline settings has been changed if (isUserChanged() || isOfflineSettingChanged()) { new CamerasCheckInternetTask(CamerasActivity.this, InternetCheckType.START) .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else { try { new CamerasCheckInternetTask(CamerasActivity.this, InternetCheckType.RESTART) .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } catch (RejectedExecutionException e) { EvercamPlayApplication.sendCaughtExceptionNotImportant(activity, e); } } usernameOnStop = ""; } else { startActivity(new Intent(this, SlideActivity.class)); finish(); } }
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); mDrawerToggle.onConfigurationChanged(newConfig); resizeCameras(); }
@Override protected void onDestroy() { super.onDestroy(); activity = null; removeAllCameraViews(); }
@Override protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); // Sync the toggle state after onRestoreInstanceState has occurred. mDrawerToggle.syncState(); }
@Override protected void onRestart() { super.onRestart(); launch(); }