reset idle timer each time a new swap screen is loaded

This means that as long as the user is using swap, it'll stay running.
This commit is contained in:
Hans-Christoph Steiner 2019-05-23 10:44:15 +02:00
parent e02bc4134a
commit 74c3c24f0a
2 changed files with 7 additions and 1 deletions

View File

@ -484,7 +484,11 @@ public class SwapService extends Service {
} }
} }
private void initTimer() { /**
* Sets or resets the idel timer for {@link #TIMEOUT}ms, once the timer
* expires, this service and all things that rely on it will be stopped.
*/
public void initTimer() {
if (timer != null) { if (timer != null) {
Utils.debugLog(TAG, "Cancelling existing timeout timer so timeout can be reset."); Utils.debugLog(TAG, "Cancelling existing timeout timer so timeout can be reset.");
timer.cancel(); timer.cancel();

View File

@ -472,6 +472,8 @@ public class SwapWorkflowActivity extends AppCompatActivity {
} }
public void inflateSwapView(@LayoutRes int viewRes) { public void inflateSwapView(@LayoutRes int viewRes) {
getSwapService().initTimer();
container.removeAllViews(); container.removeAllViews();
View view = ((LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE)).inflate(viewRes, container, false); View view = ((LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE)).inflate(viewRes, container, false);
currentView = (SwapView) view; currentView = (SwapView) view;