Join group via invite link.

This commit is contained in:
Alan Evans
2020-08-26 12:51:25 -03:00
committed by GitHub
parent b58376920f
commit 860f06ec9e
45 changed files with 2488 additions and 271 deletions

View File

@@ -0,0 +1,64 @@
package org.thoughtcrime.securesms.util;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
public final class AsynchronousCallback {
/**
* Use to call back from a asynchronous repository call, e.g. a load operation.
* <p>
* Using the original thread used for operation to invoke the callback methods.
* <p>
* The contract is that exactly one method on the callback will be called, exactly once.
*
* @param <R> Result type
* @param <E> Error type
*/
public interface WorkerThread<R, E> {
@androidx.annotation.WorkerThread
void onComplete(@Nullable R result);
@androidx.annotation.WorkerThread
void onError(@Nullable E error);
}
/**
* Use to call back from a asynchronous repository call, e.g. a load operation.
* <p>
* Using the main thread used for operation to invoke the callback methods.
* <p>
* The contract is that exactly one method on the callback will be called, exactly once.
*
* @param <R> Result type
* @param <E> Error type
*/
public interface MainThread<R, E> {
@androidx.annotation.MainThread
void onComplete(@Nullable R result);
@androidx.annotation.MainThread
void onError(@Nullable E error);
/**
* If you have a callback that is only suitable for running on the main thread, this will
* decorate it to make it suitable to pass as a worker thread callback.
*/
default @NonNull WorkerThread<R, E> toWorkerCallback() {
return new WorkerThread<R, E>() {
@Override
public void onComplete(@Nullable R result) {
Util.runOnMain(() -> MainThread.this.onComplete(result));
}
@Override
public void onError(@Nullable E error) {
Util.runOnMain(() -> MainThread.this.onError(error));
}
};
}
}
}

View File

@@ -112,9 +112,7 @@ public class CommunicationActions {
@Override
protected void onPostExecute(Long threadId) {
Intent intent = new Intent(context, ConversationActivity.class);
intent.putExtra(ConversationActivity.RECIPIENT_EXTRA, recipient.getId());
intent.putExtra(ConversationActivity.THREAD_ID_EXTRA, threadId);
Intent intent = ConversationActivity.buildIntent(context, recipient.getId(), threadId);
if (!TextUtils.isEmpty(text)) {
intent.putExtra(ConversationActivity.TEXT_EXTRA, text);

View File

@@ -1,6 +1,7 @@
package org.thoughtcrime.securesms.util;
import android.os.Handler;
import android.os.Looper;
/**
* A class that will throttle the number of runnables executed to be at most once every specified
@@ -21,7 +22,7 @@ public class Debouncer {
* {@code threshold} milliseconds.
*/
public Debouncer(long threshold) {
this.handler = new Handler();
this.handler = new Handler(Looper.getMainLooper());
this.threshold = threshold;
}