Only show RSS Feed Import Failed Dialog when Activity lives

This commit is contained in:
Torsten Grote
2016-09-02 11:12:24 -03:00
parent 387e44d114
commit 0deac1d1b6
3 changed files with 22 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ package org.briarproject.android;
import android.os.Bundle;
import android.os.IBinder;
import android.support.annotation.UiThread;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
@@ -16,12 +17,14 @@ import static android.view.inputmethod.InputMethodManager.SHOW_FORCED;
import static android.view.inputmethod.InputMethodManager.SHOW_IMPLICIT;
import static org.briarproject.android.TestingConstants.PREVENT_SCREENSHOTS;
public abstract class BaseActivity extends AppCompatActivity {
public abstract class BaseActivity extends AppCompatActivity
implements Destroyable {
protected ActivityComponent activityComponent;
private final List<ActivityLifecycleController> lifecycleControllers =
new ArrayList<>();
private boolean destroyed = false;
public abstract void injectActivity(ActivityComponent component);
@@ -78,11 +81,17 @@ public abstract class BaseActivity extends AppCompatActivity {
@Override
protected void onDestroy() {
super.onDestroy();
destroyed = true;
for (ActivityLifecycleController alc : lifecycleControllers) {
alc.onActivityDestroy();
}
}
@UiThread
public boolean hasBeenDestroyed() {
return destroyed;
}
public void showSoftKeyboardForced(View view) {
Object o = getSystemService(INPUT_METHOD_SERVICE);
((InputMethodManager) o).showSoftInput(view, SHOW_FORCED);

View File

@@ -0,0 +1,10 @@
package org.briarproject.android;
import android.support.annotation.UiThread;
interface Destroyable {
@UiThread
boolean hasBeenDestroyed();
}

View File

@@ -151,6 +151,8 @@ public class RssFeedImportActivity extends BriarActivity {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (RssFeedImportActivity.this.hasBeenDestroyed()) return;
// hide progress bar, show publish button
progressBar.setVisibility(GONE);
importButton.setVisibility(VISIBLE);