Introduce a DestroyableActivity for UI result handlers

This commit is contained in:
Torsten Grote
2016-09-08 11:25:02 -03:00
parent 49e9ee2b6d
commit af5b246d7b
7 changed files with 13 additions and 13 deletions

View File

@@ -18,7 +18,7 @@ import static android.view.inputmethod.InputMethodManager.SHOW_IMPLICIT;
import static org.briarproject.android.TestingConstants.PREVENT_SCREENSHOTS; import static org.briarproject.android.TestingConstants.PREVENT_SCREENSHOTS;
public abstract class BaseActivity extends AppCompatActivity public abstract class BaseActivity extends AppCompatActivity
implements Destroyable { implements DestroyableActivity {
protected ActivityComponent activityComponent; protected ActivityComponent activityComponent;

View File

@@ -59,7 +59,6 @@ public abstract class BriarActivity extends BaseActivity {
protected void signOut(final boolean removeFromRecentApps) { protected void signOut(final boolean removeFromRecentApps) {
briarController.signOut(new UiResultHandler<Void>(this) { briarController.signOut(new UiResultHandler<Void>(this) {
@Override @Override
public void onResultUi(Void result) { public void onResultUi(Void result) {
if (removeFromRecentApps) startExitActivity(); if (removeFromRecentApps) startExitActivity();

View File

@@ -2,7 +2,9 @@ package org.briarproject.android;
import android.support.annotation.UiThread; import android.support.annotation.UiThread;
public interface Destroyable { public interface DestroyableActivity {
void runOnUiThread(Runnable runnable);
@UiThread @UiThread
boolean hasBeenDestroyed(); boolean hasBeenDestroyed();

View File

@@ -100,7 +100,7 @@ public class FeedFragment extends BaseFragment implements
super.onStart(); super.onStart();
feedController.onStart(); feedController.onStart();
feedController.loadPersonalBlog( feedController.loadPersonalBlog(
new UiResultHandler<Blog>(getActivity()) { new UiResultHandler<Blog>(listener) {
@Override @Override
public void onResultUi(Blog b) { public void onResultUi(Blog b) {
personalBlog = b; personalBlog = b;

View File

@@ -2,14 +2,14 @@ package org.briarproject.android.controller.handler;
import android.support.annotation.UiThread; import android.support.annotation.UiThread;
import org.briarproject.android.fragment.BaseFragment.BaseFragmentListener; import org.briarproject.android.DestroyableActivity;
public abstract class UiResultExceptionHandler<R, E extends Exception> public abstract class UiResultExceptionHandler<R, E extends Exception>
implements ResultExceptionHandler<R, E> { implements ResultExceptionHandler<R, E> {
private final BaseFragmentListener listener; private final DestroyableActivity listener;
protected UiResultExceptionHandler(BaseFragmentListener listener) { protected UiResultExceptionHandler(DestroyableActivity listener) {
this.listener = listener; this.listener = listener;
} }

View File

@@ -2,13 +2,14 @@ package org.briarproject.android.controller.handler;
import android.support.annotation.UiThread; import android.support.annotation.UiThread;
import org.briarproject.android.DestroyableActivity;
import org.briarproject.android.fragment.BaseFragment.BaseFragmentListener; import org.briarproject.android.fragment.BaseFragment.BaseFragmentListener;
public abstract class UiResultHandler<R> implements ResultHandler<R> { public abstract class UiResultHandler<R> implements ResultHandler<R> {
private final BaseFragmentListener listener; private final DestroyableActivity listener;
protected UiResultHandler(BaseFragmentListener listener) { protected UiResultHandler(DestroyableActivity listener) {
this.listener = listener; this.listener = listener;
} }

View File

@@ -7,7 +7,7 @@ import android.support.annotation.UiThread;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import org.briarproject.android.ActivityComponent; import org.briarproject.android.ActivityComponent;
import org.briarproject.android.Destroyable; import org.briarproject.android.DestroyableActivity;
public abstract class BaseFragment extends Fragment { public abstract class BaseFragment extends Fragment {
@@ -46,7 +46,7 @@ public abstract class BaseFragment extends Fragment {
getActivity().supportFinishAfterTransition(); getActivity().supportFinishAfterTransition();
} }
public interface BaseFragmentListener extends Destroyable { public interface BaseFragmentListener extends DestroyableActivity {
@UiThread @UiThread
void showLoadingScreen(boolean isBlocking, int stringId); void showLoadingScreen(boolean isBlocking, int stringId);
@@ -54,8 +54,6 @@ public abstract class BaseFragment extends Fragment {
@UiThread @UiThread
void hideLoadingScreen(); void hideLoadingScreen();
void runOnUiThread(Runnable runnable);
void runOnDbThread(Runnable runnable); void runOnDbThread(Runnable runnable);
@UiThread @UiThread