当前位置: 首页>>代码示例>>Java>>正文


Java ListenableFutureTask类代码示例

本文整理汇总了Java中org.thoughtcrime.securesms.util.ListenableFutureTask的典型用法代码示例。如果您正苦于以下问题:Java ListenableFutureTask类的具体用法?Java ListenableFutureTask怎么用?Java ListenableFutureTask使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ListenableFutureTask类属于org.thoughtcrime.securesms.util包,在下文中一共展示了ListenableFutureTask类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendMessage

import org.thoughtcrime.securesms.util.ListenableFutureTask; //导入依赖的package包/类
private ListenableFutureTask<Boolean> sendMessage(@NonNull final Recipient recipient,
                                                  @NonNull final SignalServiceCallMessage callMessage)
{
  Callable<Boolean> callable = new Callable<Boolean>() {
    @Override
    public Boolean call() throws Exception {
      try {
        String number = Util.canonicalizeNumber(WebRtcCallService.this, recipient.getNumber());
        messageSender.sendCallMessage(new SignalServiceAddress(number), callMessage);
        return true;
      } catch (InvalidNumberException e) {
        throw new IOException(e);
      }
    }
  };

  ListenableFutureTask<Boolean> listenableFutureTask = new ListenableFutureTask<>(callable, null, serviceExecutor);
  networkExecutor.execute(listenableFutureTask);

  return listenableFutureTask;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:22,代码来源:WebRtcCallService.java

示例2: getMediaMmsMessageRecord

import org.thoughtcrime.securesms.util.ListenableFutureTask; //导入依赖的package包/类
private MediaMmsMessageRecord getMediaMmsMessageRecord(Cursor cursor) {
  long id                 = cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.ID));
  long dateSent           = cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.NORMALIZED_DATE_SENT));
  long dateReceived       = cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.NORMALIZED_DATE_RECEIVED));
  long box                = cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.MESSAGE_BOX));
  long threadId           = cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.THREAD_ID));
  String address          = cursor.getString(cursor.getColumnIndexOrThrow(MmsDatabase.ADDRESS));
  int addressDeviceId     = cursor.getInt(cursor.getColumnIndexOrThrow(MmsDatabase.ADDRESS_DEVICE_ID));
  int receiptCount        = cursor.getInt(cursor.getColumnIndexOrThrow(MmsDatabase.RECEIPT_COUNT));
  DisplayRecord.Body body = getBody(cursor);
  int partCount           = cursor.getInt(cursor.getColumnIndexOrThrow(MmsDatabase.PART_COUNT));
  Recipients recipients   = getRecipientsFor(address);

  ListenableFutureTask<SlideDeck> slideDeck = getSlideDeck(masterSecret, id);

  return new MediaMmsMessageRecord(context, id, recipients, recipients.getPrimaryRecipient(),
                                   addressDeviceId, dateSent, dateReceived, receiptCount,
                                   threadId, body, slideDeck, partCount, box);
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:20,代码来源:MmsDatabase.java

示例3: getCachedSlideDeck

import org.thoughtcrime.securesms.util.ListenableFutureTask; //导入依赖的package包/类
private ListenableFutureTask<SlideDeck> getCachedSlideDeck(final long id) {
  SoftReference<SlideDeck> reference = slideCache.get(id);

  if (reference != null) {
    final SlideDeck slideDeck = reference.get();

    if (slideDeck != null) {
      Callable<SlideDeck> task = new Callable<SlideDeck>() {
        @Override
        public SlideDeck call() throws Exception {
          return slideDeck;
        }
      };

      ListenableFutureTask<SlideDeck> future = new ListenableFutureTask<SlideDeck>(task);
      future.run();

      return future;
    }
  }

  return null;
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:24,代码来源:MmsDatabase.java

示例4: getRecipientDetailsAsync

import org.thoughtcrime.securesms.util.ListenableFutureTask; //导入依赖的package包/类
private @NonNull ListenableFutureTask<RecipientDetails> getRecipientDetailsAsync(final Context context,
                                                                                 final long recipientId,
                                                                                 final @NonNull String number)
{
  Callable<RecipientDetails> task = new Callable<RecipientDetails>() {
    @Override
    public RecipientDetails call() throws Exception {
      return getRecipientDetailsSync(context, recipientId, number);
    }
  };

  ListenableFutureTask<RecipientDetails> future = new ListenableFutureTask<>(task);
  asyncRecipientResolver.submit(future);
  return future;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:16,代码来源:RecipientProvider.java

示例5: getRecipientsPreferencesAsync

import org.thoughtcrime.securesms.util.ListenableFutureTask; //导入依赖的package包/类
private ListenableFutureTask<RecipientsPreferences> getRecipientsPreferencesAsync(final Context context, final long[] recipientIds) {
  ListenableFutureTask<RecipientsPreferences> task = new ListenableFutureTask<>(new Callable<RecipientsPreferences>() {
    @Override
    public RecipientsPreferences call() throws Exception {
      return getRecipientsPreferencesSync(context, recipientIds);
    }
  });

  asyncRecipientResolver.execute(task);

  return task;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:13,代码来源:RecipientProvider.java

示例6: 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();
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:35,代码来源:WebRtcCallService.java

示例7: 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();
    }
  });
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:31,代码来源:WebRtcCallService.java

示例8: retrieveTurnServers

import org.thoughtcrime.securesms.util.ListenableFutureTask; //导入依赖的package包/类
private ListenableFutureTask<List<PeerConnection.IceServer>> retrieveTurnServers() {
  Callable<List<PeerConnection.IceServer>> callable = new Callable<List<PeerConnection.IceServer>>() {
    @Override
    public List<PeerConnection.IceServer> call() {
      LinkedList<PeerConnection.IceServer> results = new LinkedList<>();

      try {
        TurnServerInfo turnServerInfo = accountManager.getTurnServerInfo();

        for (String url : turnServerInfo.getUrls()) {
          if (url.startsWith("turn")) {
            results.add(new PeerConnection.IceServer(url, turnServerInfo.getUsername(), turnServerInfo.getPassword()));
          } else {
            results.add(new PeerConnection.IceServer(url));
          }
        }

      } catch (IOException e) {
        Log.w(TAG, e);
      }

      return results;
    }
  };

  ListenableFutureTask<List<PeerConnection.IceServer>> futureTask = new ListenableFutureTask<>(callable, null, serviceExecutor);
  networkExecutor.execute(futureTask);

  return futureTask;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:31,代码来源:WebRtcCallService.java

示例9: get

import org.thoughtcrime.securesms.util.ListenableFutureTask; //导入依赖的package包/类
public ListenableFutureTask<Bitmap> get() {
  Util.assertMainThread();

  if (bitmapReference != null && bitmapReference.get() != null) {
    return new ListenableFutureTask<>(bitmapReference.get());
  } else if (task != null) {
    return task;
  } else {
    Callable<Bitmap> callable = new Callable<Bitmap>() {
      @Override public Bitmap call() throws Exception {
        try {
          Log.w(TAG, "loading page " + model.getSprite());
          return loadPage();
        } catch (IOException ioe) {
          Log.w(TAG, ioe);
        }
        return null;
      }
    };
    task = new ListenableFutureTask<>(callable);
    new AsyncTask<Void, Void, Void>() {
      @Override protected Void doInBackground(Void... params) {
        task.run();
        return null;
      }

      @Override protected void onPostExecute(Void aVoid) {
        task = null;
      }
    }.execute();
  }
  return task;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:34,代码来源:EmojiPageBitmap.java

示例10: 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();
  }
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:35,代码来源:WebRtcCallService.java

示例11: 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();
    }
  });
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:33,代码来源:WebRtcCallService.java

示例12: getSlideDeck

import org.thoughtcrime.securesms.util.ListenableFutureTask; //导入依赖的package包/类
private ListenableFutureTask<SlideDeck> getSlideDeck(final MasterSecret masterSecret,
                                                     final long id)
{
  ListenableFutureTask<SlideDeck> future = getCachedSlideDeck(id);

  if (future != null) {
    return future;
  }

  Callable<SlideDeck> task = new Callable<SlideDeck>() {
    @Override
    public SlideDeck call() throws Exception {
      if (masterSecret == null)
        return null;

      PartDatabase partDatabase = DatabaseFactory.getPartDatabase(context);
      PduBody      body         = getPartsAsBody(partDatabase.getParts(id));
      SlideDeck    slideDeck    = new SlideDeck(context, masterSecret, body);

      if (!body.containsPushInProgress()) {
        slideCache.put(id, new SoftReference<SlideDeck>(slideDeck));
      }

      return slideDeck;
    }
  };

  future = new ListenableFutureTask<SlideDeck>(task);
  slideResolver.execute(future);

  return future;
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:33,代码来源:MmsDatabase.java

示例13: MediaMmsMessageRecord

import org.thoughtcrime.securesms.util.ListenableFutureTask; //导入依赖的package包/类
public MediaMmsMessageRecord(Context context, long id, Recipients recipients,
                             Recipient individualRecipient, int recipientDeviceId,
                             long dateSent, long dateReceived, int deliveredCount,
                             long threadId, Body body,
                             ListenableFutureTask<SlideDeck> slideDeck,
                             int partCount, long mailbox)
{
  super(context, id, body, recipients, individualRecipient, recipientDeviceId,
        dateSent, dateReceived, threadId, DELIVERY_STATUS_NONE, deliveredCount, mailbox);

  this.context             = context.getApplicationContext();
  this.partCount           = partCount;
  this.slideDeckFutureTask = slideDeck;
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:15,代码来源:MediaMmsMessageRecord.java

示例14: 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);
    }
  });
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:38,代码来源:Recipient.java

示例15: getAsynchronousRecipient

import org.thoughtcrime.securesms.util.ListenableFutureTask; //导入依赖的package包/类
private Recipient getAsynchronousRecipient(final Context context, final long recipientId) {
  Log.w("RecipientProvider", "Cache miss [ASYNC]!");

  final String number = CanonicalAddressDatabase.getInstance(context).getAddressFromId(recipientId);
  final boolean isGroupRecipient = GroupUtil.isEncodedGroup(number);

  Callable<RecipientDetails> task = new Callable<RecipientDetails>() {
    @Override
    public RecipientDetails call() throws Exception {
      if (isGroupRecipient) return getGroupRecipientDetails(context, number);
      else                  return getRecipientDetails(context, number);
    }
  };

  ListenableFutureTask<RecipientDetails> future = new ListenableFutureTask<RecipientDetails>(task);

  asyncRecipientResolver.submit(future);

  Bitmap contactPhoto;
  Bitmap contactPhotoCropped;

  if (isGroupRecipient) {
    contactPhoto        = ContactPhotoFactory.getDefaultGroupPhoto(context);
    contactPhotoCropped = ContactPhotoFactory.getDefaultGroupPhotoCropped(context);
  } else {
    contactPhoto        = ContactPhotoFactory.getDefaultContactPhoto(context);
    contactPhotoCropped = ContactPhotoFactory.getDefaultContactPhotoCropped(context);
  }

  Recipient recipient = new Recipient(number, contactPhoto, contactPhotoCropped, recipientId, future);
  recipientCache.put(recipientId, recipient);

  return recipient;
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:35,代码来源:RecipientProvider.java


注:本文中的org.thoughtcrime.securesms.util.ListenableFutureTask类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。