public void buttonTimerClicked(View view) { if (!isTimerRunning()) { setTimerRunning(true); mTimeElapsed = System.currentTimeMillis(); start_time = mTimeElapsed; Calendar cal = Calendar.getInstance(); // cal.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles")); Calendar dt = Calendar.getInstance(); dt.clear(); dt.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DATE)); day = dt.getTime(); System.out.println("Date: " + day); mHandler.postDelayed(mRunnable, 1000L); mSpinnerDropdown.setEnabled(false); } else { end_time = System.currentTimeMillis(); setTimerRunning(false); resetTimer(); System.out.println("start time: " + start_time); System.out.println("end time: " + end_time); System.out.println("Button updated"); TLApp.addTimeLog(pid, aid, start_time, end_time, day); } updateTimerButton(); }
/** * ATTENTION: This was auto-generated to implement the App Indexing API. See * https://g.co/AppIndexing/AndroidStudio for more information. */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SharedPreferences shared = getSharedPreferences(TLApp.USER_SHARED_PREFS, MODE_PRIVATE); pid = (shared.getString("pid", "")); System.out.println("PID: " + pid); setContentView(R.layout.time_logger); if (TLApp.alert == 1) { System.out.println("fired fetching"); TLApp.alert = 0; TLApp.getActivities(pid); finish(); } Intent intent = new Intent(this, TLTimeLoggerService.class); startService(intent); initComponents(); }