Skip to content

Commit

Permalink
Small fixes to behaviour upon restoring instance state.
Browse files Browse the repository at this point in the history
Still bugged
  • Loading branch information
Billsong19 committed Jun 24, 2020
1 parent 3fd90cf commit d95732d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
25 changes: 25 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 10 additions & 13 deletions app/src/main/java/com/example/sleeplog/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,13 @@ protected void onCreate(Bundle savedInstanceState) {
settingsButton = (Button)findViewById(R.id.Settings);
sleepLogButton = (Button)findViewById(R.id.SleepLog);

if(savedInstanceState != null){
String previousStartTime = savedInstanceState.getString("Start Time");
_timerPaused = savedInstanceState.getBoolean("Timer Paused");
_sleepSession = new SleepSession(previousStartTime);
if (_timerPaused){
Log.d(TAG, "onCreate: Start Time " + previousStartTime + " restored in paused state");
}
Log.d(TAG, "onCreate: Start Time " + previousStartTime + "restored in unpaused state");

}
handler = new Handler() ;

if (!_timerPaused)
{
finishedSleepingButton.setEnabled(false);
}
handler = new Handler() ;


startButton.setOnClickListener(new View.OnClickListener() {
@Override
Expand Down Expand Up @@ -156,11 +147,17 @@ public void onRestoreInstanceState(Bundle savedInstanceState) {

String previousStartTime = savedInstanceState.getString("Start Time");
_timerPaused = savedInstanceState.getBoolean("Timer Paused");
_sleepSession = new SleepSession(previousStartTime);
if (previousStartTime!=null) {
_sleepSession = new SleepSession(previousStartTime);
handler.postDelayed(runnable, 0);
}
if (_timerPaused){
Log.d(TAG, "onRestoreInstanceState: Start Time " + previousStartTime + " restored in paused state");
}
Log.d(TAG, "onRestoreInstanceState: Start Time " + previousStartTime + "restored in unpaused state");
else {
Log.d(TAG, "onRestoreInstanceState: Start Time " + previousStartTime + "restored in unpaused state");

}
super.onRestoreInstanceState(savedInstanceState);
}

Expand Down

0 comments on commit d95732d

Please sign in to comment.