Introduce Exception handler for when no result needs to be returned

Also add NotNull annotation to classes that were touched
This commit is contained in:
Torsten Grote
2016-11-11 10:01:20 -02:00
parent ade7e50f65
commit 563d897651
26 changed files with 135 additions and 106 deletions

View File

@@ -5,6 +5,7 @@ import android.support.annotation.UiThread;
import org.briarproject.android.DestroyableContext;
import org.briarproject.android.controller.ActivityLifecycleController;
import org.briarproject.android.controller.handler.ExceptionHandler;
import org.briarproject.android.controller.handler.ResultExceptionHandler;
import org.briarproject.api.clients.NamedGroup;
import org.briarproject.api.clients.PostHeader;
@@ -31,7 +32,7 @@ public interface ThreadListController<G extends NamedGroup, I extends ThreadItem
void createAndStoreMessage(String body, @Nullable I parentItem,
ResultExceptionHandler<I, DbException> handler);
void deleteNamedGroup(ResultExceptionHandler<Void, DbException> handler);
void deleteNamedGroup(ExceptionHandler<DbException> handler);
interface ThreadListListener<H> extends DestroyableContext {
@UiThread

View File

@@ -5,11 +5,12 @@ import android.support.annotation.CallSuper;
import org.briarproject.android.api.AndroidNotificationManager;
import org.briarproject.android.controller.DbControllerImpl;
import org.briarproject.android.controller.handler.ExceptionHandler;
import org.briarproject.android.controller.handler.ResultExceptionHandler;
import org.briarproject.android.threaded.ThreadListController.ThreadListListener;
import org.briarproject.api.clients.ThreadedMessage;
import org.briarproject.api.clients.NamedGroup;
import org.briarproject.api.clients.PostHeader;
import org.briarproject.api.clients.ThreadedMessage;
import org.briarproject.api.crypto.CryptoExecutor;
import org.briarproject.api.db.DatabaseExecutor;
import org.briarproject.api.db.DbException;
@@ -265,8 +266,7 @@ public abstract class ThreadListControllerImpl<G extends NamedGroup, I extends T
protected abstract H addLocalMessage(M message) throws DbException;
@Override
public void deleteNamedGroup(
final ResultExceptionHandler<Void, DbException> handler) {
public void deleteNamedGroup(final ExceptionHandler<DbException> handler) {
runOnDbThread(new Runnable() {
@Override
public void run() {
@@ -277,8 +277,6 @@ public abstract class ThreadListControllerImpl<G extends NamedGroup, I extends T
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Removing group took " + duration + " ms");
//noinspection ConstantConditions
handler.onResult(null);
} catch (DbException e) {
if (LOG.isLoggable(WARNING))
LOG.log(WARNING, e.toString(), e);