本文整理汇总了Java中org.thoughtcrime.securesms.util.ListenableFutureTask.addListener方法的典型用法代码示例。如果您正苦于以下问题:Java ListenableFutureTask.addListener方法的具体用法?Java ListenableFutureTask.addListener怎么用?Java ListenableFutureTask.addListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.thoughtcrime.securesms.util.ListenableFutureTask
的用法示例。
在下文中一共展示了ListenableFutureTask.addListener方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleResponseMessage
import org.thoughtcrime.securesms.util.ListenableFutureTask; //导入方法依赖的package包/类
private void handleResponseMessage(Intent intent) {
try {
Log.w(TAG, "Got response: " + intent.getStringExtra(EXTRA_REMOTE_DESCRIPTION));
if (callState != CallState.STATE_DIALING || !getRemoteRecipient(intent).equals(recipient) || !Util.isEquals(this.callId, getCallId(intent))) {
Log.w(TAG, "Got answer for recipient and call id we're not currently dialing: " + getCallId(intent) + ", " + getRemoteRecipient(intent));
return;
}
if (peerConnection == null || pendingIceUpdates == null) {
throw new AssertionError("assert");
}
if (!pendingIceUpdates.isEmpty()) {
ListenableFutureTask<Boolean> listenableFutureTask = sendMessage(recipient, SignalServiceCallMessage.forIceUpdates(pendingIceUpdates));
listenableFutureTask.addListener(new FailureListener<Boolean>(callState, callId) {
@Override
public void onFailureContinue(Throwable error) {
Log.w(TAG, error);
sendMessage(WebRtcViewModel.State.NETWORK_FAILURE, recipient, localVideoEnabled, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled);
terminate();
}
});
}
this.peerConnection.setRemoteDescription(new SessionDescription(SessionDescription.Type.ANSWER, intent.getStringExtra(EXTRA_REMOTE_DESCRIPTION)));
this.pendingIceUpdates = null;
} catch (PeerConnectionException e) {
Log.w(TAG, e);
terminate();
}
}
示例2: handleLocalIceCandidate
import org.thoughtcrime.securesms.util.ListenableFutureTask; //导入方法依赖的package包/类
private void handleLocalIceCandidate(Intent intent) {
if (callState == CallState.STATE_IDLE || !Util.isEquals(this.callId, getCallId(intent))) {
Log.w(TAG, "State is now idle, ignoring ice candidate...");
}
if (recipient == null || callId == null) {
throw new AssertionError("assert: " + callState + ", " + callId);
}
IceUpdateMessage iceUpdateMessage = new IceUpdateMessage(this.callId, intent.getStringExtra(EXTRA_ICE_SDP_MID),
intent.getIntExtra(EXTRA_ICE_SDP_LINE_INDEX, 0),
intent.getStringExtra(EXTRA_ICE_SDP));
if (pendingIceUpdates != null) {
this.pendingIceUpdates.add(iceUpdateMessage);
return;
}
ListenableFutureTask<Boolean> listenableFutureTask = sendMessage(recipient, SignalServiceCallMessage.forIceUpdate(iceUpdateMessage));
listenableFutureTask.addListener(new FailureListener<Boolean>(callState, callId) {
@Override
public void onFailureContinue(Throwable error) {
Log.w(TAG, error);
sendMessage(WebRtcViewModel.State.NETWORK_FAILURE, recipient, localVideoEnabled, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled);
terminate();
}
});
}
示例3: handleResponseMessage
import org.thoughtcrime.securesms.util.ListenableFutureTask; //导入方法依赖的package包/类
private void handleResponseMessage(Intent intent) {
try {
Log.w(TAG, "Got response: " + intent.getStringExtra(EXTRA_REMOTE_DESCRIPTION));
if (callState != CallState.STATE_DIALING || !getRemoteRecipient(intent).equals(recipient) || !Util.isEquals(this.callId, getCallId(intent))) {
Log.w(TAG, "Got answer for recipient and call id we're not currently dialing: " + getCallId(intent) + ", " + getRemoteRecipient(intent));
return;
}
if (peerConnection == null || pendingOutgoingIceUpdates == null) {
throw new AssertionError("assert");
}
if (!pendingOutgoingIceUpdates.isEmpty()) {
ListenableFutureTask<Boolean> listenableFutureTask = sendMessage(recipient, SignalServiceCallMessage.forIceUpdates(pendingOutgoingIceUpdates));
listenableFutureTask.addListener(new FailureListener<Boolean>(callState, callId) {
@Override
public void onFailureContinue(Throwable error) {
Log.w(TAG, error);
sendMessage(WebRtcViewModel.State.NETWORK_FAILURE, recipient, localVideoEnabled, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled);
terminate();
}
});
}
this.peerConnection.setRemoteDescription(new SessionDescription(SessionDescription.Type.ANSWER, intent.getStringExtra(EXTRA_REMOTE_DESCRIPTION)));
this.pendingOutgoingIceUpdates = null;
} catch (PeerConnectionException e) {
Log.w(TAG, e);
terminate();
}
}
示例4: handleLocalIceCandidate
import org.thoughtcrime.securesms.util.ListenableFutureTask; //导入方法依赖的package包/类
private void handleLocalIceCandidate(Intent intent) {
if (callState == CallState.STATE_IDLE || !Util.isEquals(this.callId, getCallId(intent))) {
Log.w(TAG, "State is now idle, ignoring ice candidate...");
return;
}
if (recipient == null || callId == null) {
throw new AssertionError("assert: " + callState + ", " + callId);
}
IceUpdateMessage iceUpdateMessage = new IceUpdateMessage(this.callId, intent.getStringExtra(EXTRA_ICE_SDP_MID),
intent.getIntExtra(EXTRA_ICE_SDP_LINE_INDEX, 0),
intent.getStringExtra(EXTRA_ICE_SDP));
if (pendingOutgoingIceUpdates != null) {
Log.w(TAG, "Adding to pending ice candidates...");
this.pendingOutgoingIceUpdates.add(iceUpdateMessage);
return;
}
ListenableFutureTask<Boolean> listenableFutureTask = sendMessage(recipient, SignalServiceCallMessage.forIceUpdate(iceUpdateMessage));
listenableFutureTask.addListener(new FailureListener<Boolean>(callState, callId) {
@Override
public void onFailureContinue(Throwable error) {
Log.w(TAG, error);
sendMessage(WebRtcViewModel.State.NETWORK_FAILURE, recipient, localVideoEnabled, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled);
terminate();
}
});
}
示例5: Recipient
import org.thoughtcrime.securesms.util.ListenableFutureTask; //导入方法依赖的package包/类
Recipient(String number, Bitmap contactPhoto, Bitmap circleCroppedContactPhoto,
long recipientId, ListenableFutureTask<RecipientDetails> future)
{
this.number = number;
this.circleCroppedContactPhoto = circleCroppedContactPhoto;
this.contactPhoto = contactPhoto;
this.recipientId = recipientId;
this.generatedAvatar = null;
future.addListener(new FutureTaskListener<RecipientDetails>() {
@Override
public void onSuccess(RecipientDetails result) {
if (result != null) {
HashSet<RecipientModifiedListener> localListeners;
synchronized (Recipient.this) {
Recipient.this.name = result.name;
Recipient.this.number = result.number;
Recipient.this.contactUri = result.contactUri;
Recipient.this.contactPhoto = result.avatar;
Recipient.this.circleCroppedContactPhoto = result.croppedAvatar;
localListeners = (HashSet<RecipientModifiedListener>) listeners.clone();
listeners.clear();
}
for (RecipientModifiedListener listener : localListeners)
listener.onModified(Recipient.this);
}
}
@Override
public void onFailure(Throwable error) {
Log.w("Recipient", error);
}
});
}
示例6: Recipient
import org.thoughtcrime.securesms.util.ListenableFutureTask; //导入方法依赖的package包/类
Recipient(long recipientId,
@NonNull String number,
@Nullable Recipient stale,
@NonNull ListenableFutureTask<RecipientDetails> future)
{
this.recipientId = recipientId;
this.number = number;
this.contactPhoto = ContactPhotoFactory.getLoadingPhoto();
this.color = null;
this.resolving = true;
if (stale != null) {
this.name = stale.name;
this.contactUri = stale.contactUri;
this.contactPhoto = stale.contactPhoto;
this.color = stale.color;
}
future.addListener(new FutureTaskListener<RecipientDetails>() {
@Override
public void onSuccess(RecipientDetails result) {
if (result != null) {
synchronized (Recipient.this) {
Recipient.this.name = result.name;
Recipient.this.number = result.number;
Recipient.this.contactUri = result.contactUri;
Recipient.this.contactPhoto = result.avatar;
Recipient.this.color = result.color;
Recipient.this.resolving = false;
}
notifyListeners();
}
}
@Override
public void onFailure(ExecutionException error) {
Log.w(TAG, error);
}
});
}
示例7: Recipients
import org.thoughtcrime.securesms.util.ListenableFutureTask; //导入方法依赖的package包/类
Recipients(@NonNull List<Recipient> recipients,
@Nullable Recipients stale,
@NonNull ListenableFutureTask<RecipientsPreferences> preferences)
{
this.recipients = recipients;
if (stale != null) {
ringtone = stale.ringtone;
mutedUntil = stale.mutedUntil;
vibrate = stale.vibrate;
blocked = stale.blocked;
expireMessages = stale.expireMessages;
}
preferences.addListener(new FutureTaskListener<RecipientsPreferences>() {
@Override
public void onSuccess(RecipientsPreferences result) {
if (result != null) {
Set<RecipientsModifiedListener> localListeners;
synchronized (Recipients.this) {
ringtone = result.getRingtone();
mutedUntil = result.getMuteUntil();
vibrate = result.getVibrateState();
blocked = result.isBlocked();
expireMessages = result.getExpireMessages();
localListeners = new HashSet<>(listeners);
}
for (RecipientsModifiedListener listener : localListeners) {
listener.onModified(Recipients.this);
}
}
}
@Override
public void onFailure(ExecutionException error) {
Log.w(TAG, error);
}
});
}
示例8: Recipient
import org.thoughtcrime.securesms.util.ListenableFutureTask; //导入方法依赖的package包/类
Recipient(long recipientId,
@NonNull String number,
@Nullable Recipient stale,
@NonNull ListenableFutureTask<RecipientDetails> future)
{
this.recipientId = recipientId;
this.number = number;
this.contactPhoto = ContactPhotoFactory.getLoadingPhoto();
this.color = null;
this.resolving = true;
if (stale != null) {
this.name = stale.name;
this.contactUri = stale.contactUri;
this.contactPhoto = stale.contactPhoto;
this.color = stale.color;
this.customLabel = stale.customLabel;
}
future.addListener(new FutureTaskListener<RecipientDetails>() {
@Override
public void onSuccess(RecipientDetails result) {
if (result != null) {
synchronized (Recipient.this) {
Recipient.this.name = result.name;
Recipient.this.number = result.number;
Recipient.this.contactUri = result.contactUri;
Recipient.this.contactPhoto = result.avatar;
Recipient.this.color = result.color;
Recipient.this.customLabel = result.customLabel;
Recipient.this.resolving = false;
}
notifyListeners();
}
}
@Override
public void onFailure(ExecutionException error) {
Log.w(TAG, error);
}
});
}