@Override protected void onResume() { AppUtility.getAppUtilityInstance().checkAndInitializeDatabase(this); super.onResume(); setListAdapter(); mealBreakTimeCounter = TimerUtility.getTimerUtilityInstance().getTimerObjectFromContainer(IAppConstants.TimerManagerConstants.TIMER_UTILITY_MEALBREAK_TIME); if(mealBreakTimeCounter != null) { if(mealBreakTimeCounter.isMealBreakRegistered()) { mealBreakTimeCounter.unregisterMealBreakCounterCallback(); } mealBreakTimeCounter.registerMealBreakCounterCallback(this); headerTimeCounter = TimerUtility.getTimerUtilityInstance().getTimerObjectFromContainer(IAppConstants.TimerManagerConstants.TIMER_UTILITY_HEADER_TIMER_OBJECT); if (headerTimeCounter == null) { headerTimeCounter = new TimeCounter(this, IAppConstants.TimerManagerConstants.TIMER_UTILITY_HEADER_TIMER_OBJECT, false); TimerUtility.getTimerUtilityInstance().addTimerObjectToContainer(IAppConstants.TimerManagerConstants.TIMER_UTILITY_HEADER_TIMER_OBJECT, headerTimeCounter); } headerTimeCounter.registerTimeCounterCallback(this); } /* if(AppConfig.getAppConfigInstance(this).isAppSyncing()) { disableSlider(); } else { enableSlider(); }*/ }
@Override public void updateClockTime(String newtime) { if ((mTimeTrackerTextView != null) && (mTimeTrackerTextView.getVisibility() == View.VISIBLE)) { TimeCounter currentServiceRunningTime = AppUtility.getAppUtilityInstance().getCurrentRunningServiceTimeCounter(); if(currentServiceRunningTime != null && AppUtility.getAppUtilityInstance().isApplicationStartAfterCrash()) { long currentSystemTime = currentServiceRunningTime.getCurrentSystemTime(); long currentSystemTimeMins = currentSystemTime/(60*1000); /*long totalTimeInMins = AppUtility.getAppUtilityInstance().getAccumulatedPauseTime(currentServiceRunningTime.getStartTimeStamp(), AppUtility.getAppUtilityInstance().getCurrentTimeStampWithoutSecs()); currentSystemTimeMins -= totalTimeInMins;*/ Date mCurrentDate = new Date(currentSystemTimeMins*60*1000); final SimpleDateFormat formatterTime = new SimpleDateFormat(IAppConstants.HOUR_MINS_FORMAT); formatterTime.setTimeZone(TimeZone.getTimeZone(IAppConstants.UTC_TIMEZONE)); newtime = formatterTime.format(mCurrentDate); } mTimeTrackerTextView.setText(newtime); } }
@Override protected void onCreate(Bundle savedInstanceState) { getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); super.onCreate(savedInstanceState); loadEnvironment(); loadPresenter(); showBaseScreen(); registerUncaughtExceptionHandler(); mPowerManager = (PowerManager)getSystemService(Context.POWER_SERVICE); mWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, “MyWakeLock”); AppUtility.getAppUtilityInstance().acquireWakeLock(mWakeLock); }
@Override public void unCaughtException(Context context, final String message) { AppUtility.getAppUtilityInstance().showCrashDialog(context, message, (MyApp)getApplication()); }
@Override public void onClick(View v) { switch (v.getId()) { case R.id.timer_layout://Layout made clickable to increase click area. case R.id.menu_header_time_tracker: if(AppUtility.getAppUtilityInstance().isConnectionEstablished()) { AppUtility.getAppUtilityInstance().printTimerLogs(); Intent timerDrawerIntent = new Intent(this, TimeDrawerActivity.class); timerDrawerIntent.putExtra(IAppConstants.IS_APP_ON_PAUSE_STATE, false); timerDrawerIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); Object setResult = v.getTag(R.id.menu_header_time_tracker); if(setResult != null && (setResult instanceof Integer)) { int requestCode = Integer.parseInt(setResult.toString()); if ((requestCode&0xffff0000) == 0) { timerDrawerIntent.putExtra(IAppConstants.StoreVisitSummary.EXTRA_NOTIFY_REFRESH, requestCode ); startActivityForResult(timerDrawerIntent, requestCode); } else { startActivity(timerDrawerIntent); } } else { startActivity(timerDrawerIntent); } }else { AppLogs.d("NavigationDrawerSliderActivity", " connection not established!!"); } break; case R.id.tv_header_subtitle: //Set click listener to subtitle to increase clickable area. case R.id.ll_header_clickable_menubar: if (button.getVisibility() == View.VISIBLE) { if (isToggle) { final ListPopupWindow mPopupMenuWindow = new ListPopupWindow( this); mPopupMenuWindow.setAnchorView(v); mPopupMenuWindow.setHeight(406); mPopupMenuWindow.setWidth(325); mPopupMenuWindow.getListView(); mPopupMenuWindow.setBackgroundDrawable(getResources() .getDrawable(R.drawable.bg_popover_function_nine)); if (menuItems != null) { menuAdapter = new FunctionMenuAdapter(this, menuItems, txtHeaderTypeface); } mPopupMenuWindow.setAdapter(menuAdapter); mPopupMenuWindow.setVerticalOffset(15); mPopupMenuWindow.setHorizontalOffset(-19); mPopupMenuWindow .setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long arg3) { //TODO: Call through Presenter. Currently, the "this" instance is of HomeScreenActivity, hence making local method call. /*mPresenter.*/OnClickSelectedItem(menuItems .get(position).toString()); mPopupMenuWindow.dismiss(); isToggle = !isToggle; } }); mPopupMenuWindow.show(); } isToggle = !isToggle; } break; } }