Fix dialog crashes in StateDialogActivity

This commit is contained in:
Felix Ableitner 2017-10-20 10:36:53 +09:00
parent da9db849eb
commit d925cbfdde
1 changed files with 4 additions and 6 deletions

View File

@ -3,9 +3,7 @@ package com.nutomic.syncthingandroid.activities;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Intent; import android.content.Intent;
import android.databinding.DataBindingUtil; import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat; import android.support.v4.app.ActivityCompat;
import android.view.View; import android.view.View;
@ -27,15 +25,15 @@ public abstract class StateDialogActivity extends SyncthingActivity {
private AlertDialog mDisabledDialog; private AlertDialog mDisabledDialog;
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onResume() {
super.onCreate(savedInstanceState); super.onResume();
registerOnServiceConnectedListener(() -> registerOnServiceConnectedListener(() ->
getService().registerOnApiChangeListener(this::onApiChange)); getService().registerOnApiChangeListener(this::onApiChange));
} }
@Override @Override
protected void onDestroy() { protected void onPause() {
super.onDestroy(); super.onPause();
if (getService() != null) { if (getService() != null) {
getService().unregisterOnApiChangeListener(this::onApiChange); getService().unregisterOnApiChangeListener(this::onApiChange);
} }