mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-26 03:40:56 +01:00
Join group via invite link.
This commit is contained in:
@@ -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));
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user