autodismissing confirm activity.

This commit is contained in:
AdrianLxM 2018-06-27 18:02:10 +02:00
parent 0fe26fda27
commit a283586a3c
2 changed files with 32 additions and 10 deletions

View file

@ -3,6 +3,8 @@ package info.nightscout.androidaps.interaction.actions;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.SystemClock;
import android.support.v4.app.NotificationManagerCompat;
import android.support.wearable.view.DotsPageIndicator;
import android.support.wearable.view.GridPagerAdapter;
import android.support.wearable.view.GridViewPager;
@ -26,11 +28,15 @@ public class AcceptActivity extends ViewSelectorActivity {
String title = "";
String message = "";
String actionstring = "";
private DismissThread dismissThread;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.dismissThread = new DismissThread();
dismissThread.start();
Bundle extras = getIntent().getExtras();
title = extras.getString("title", "");
message = extras.getString("message", "");
@ -106,6 +112,32 @@ public class AcceptActivity extends ViewSelectorActivity {
return view==object;
}
}
@Override
public synchronized void onDestroy(){
super.onDestroy();
if(dismissThread != null){
dismissThread.invalidate();
}
}
private class DismissThread extends Thread{
private boolean valid = true;
public synchronized void invalidate(){
valid = false;
}
@Override
public void run() {
SystemClock.sleep(60 * 1000);
synchronized (this) {
if(valid) {
AcceptActivity.this.finish();
}
}
}
}
}

View file

@ -88,16 +88,6 @@ public class MainMenuActivity extends MenuListActivity {
intent = new Intent(this, FillMenuActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
/*
intent = new Intent(this, AcceptActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Bundle params = new Bundle();
params.putString("heading", "Confirm");
params.putString("text", "dies\nist ein\nhoffentlich\n langer text\n\ndies\nist ein\nhoffentlich\n langer text\n\ndies\nist ein\nhoffentlich\n langer text\n\ndies\nist ein\nhoffentlich\n langer text\n\n");
params.putString("actionstring", "blablubb");
intent.putExtras(params);
startActivity(intent);
*/
} else if ("eCarb".equals(action)) {
intent = new Intent(this, ECarbActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);