當前位置: 首頁>>代碼示例>>Java>>正文


Java Pair類代碼示例

本文整理匯總了Java中android.util.Pair的典型用法代碼示例。如果您正苦於以下問題:Java Pair類的具體用法?Java Pair怎麽用?Java Pair使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Pair類屬於android.util包,在下文中一共展示了Pair類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onProducerFinishWithCancellation

import android.util.Pair; //導入依賴的package包/類
@Override
public synchronized void onProducerFinishWithCancellation(
    String requestId,
    String producerName,
    @Nullable Map<String, String> extraMap) {
  if (FLog.isLoggable(FLog.VERBOSE)) {
    Pair<String, String> mapKey = Pair.create(requestId, producerName);
    Long startTime = mProducerStartTimeMap.remove(mapKey);
    long currentTime = getTime();
    FLog.v(
        TAG,
        "time %d: onProducerFinishWithCancellation: " +
            "{requestId: %s, stage: %s, elapsedTime: %d ms, extraMap: %s}",
        currentTime,
        requestId,
        producerName,
        getElapsedTime(startTime, currentTime),
        extraMap);
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:RequestLoggingListener.java

示例2: onRecorderCanceled

import android.util.Pair; //導入依賴的package包/類
@Override
public void onRecorderCanceled() {
  Vibrator vibrator = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
  vibrator.vibrate(50);
  getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

  ListenableFuture<Pair<Uri, Long>> future = audioRecorder.stopRecording();
  future.addListener(new ListenableFuture.Listener<Pair<Uri, Long>>() {
    @Override
    public void onSuccess(final Pair<Uri, Long> result) {
      new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... params) {
          PersistentBlobProvider.getInstance(ConversationActivity.this).delete(result.first);
          return null;
        }
      }.execute();
    }

    @Override
    public void onFailure(ExecutionException e) {}
  });
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:24,代碼來源:ConversationActivity.java

示例3: openFile

import android.util.Pair; //導入依賴的package包/類
@Override
public android.os.ParcelFileDescriptor openFile(android.net.Uri uri, java.lang.String mode)
        throws java.io.FileNotFoundException {

    Pair<UUID, String> callIdAndAttachmentName = parseCallIdAndAttachmentName(uri);
    if (callIdAndAttachmentName == null) {
        throw new FileNotFoundException();
    }

    try {
        File file = NativeAppCallAttachmentStore.openAttachment(
                callIdAndAttachmentName.first,
                callIdAndAttachmentName.second);

        return ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
    } catch (FileNotFoundException exception) {
        Log.e(TAG, "Got unexpected exception:" + exception);
        throw exception;
    }
}
 
開發者ID:eviltnan,項目名稱:kognitivo,代碼行數:21,代碼來源:FacebookContentProvider.java

示例4: onCreate

import android.util.Pair; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mAdapter = new ChannelSearchDialog.SuggestionsAdapter(this);
    ListSearchView view = new ListSearchView(this, this);
    view.setBackgroundColor(StyledAttributesHelper.getColor(this, R.attr.colorBackgroundFloating, 0));
    view.setSuggestionsAdapter(mAdapter);
    setContentView(view);

    mAdapter.setItemClickListener((int index, Pair<ServerConnectionInfo, String> value) -> {
        Intent intent = new Intent(this, MainActivity.class);
        intent.putExtra(MainActivity.ARG_SERVER_UUID, value.first.getUUID().toString());
        intent.putExtra(MainActivity.ARG_CHANNEL_NAME, value.second);
        intent.putExtra(Intent.EXTRA_TEXT, getIntent().getStringExtra(Intent.EXTRA_TEXT));
        intent.setAction(Intent.ACTION_SEND);
        intent.setType("text/plain");
        startActivity(intent);
        overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
        finish();
    });
}
 
開發者ID:MCMrARM,項目名稱:revolution-irc,代碼行數:23,代碼來源:ShareTargetActivity.java

示例5: setCommand

import android.util.Pair; //導入依賴的package包/類
/**
 * Insert a new {@link CustomCommand} in the {@link DBCustomCommand} synchronising with a basic
 * lock object in a vain attempt to prevent concurrency issues.
 *
 * @param ctx           the application context
 * @param customCommand to be set
 * @return true if the insertion was successful
 */
public static Pair<Boolean, Long> setCommand(@NonNull final Context ctx, @NonNull final CustomCommand customCommand,
                                             final long rowId) {

    synchronized (lock) {

        final Gson gson = new GsonBuilder().disableHtmlEscaping().create();
        final String gsonString = gson.toJson(customCommand);

        final DBCustomCommand dbCustomCommand = new DBCustomCommand(ctx);

        final Pair<Boolean, Long> duplicatePair;
        if (rowId > -1) {
            duplicatePair = new Pair<>(true, rowId);
        } else {
            duplicatePair = commandExists(dbCustomCommand, customCommand);
        }

        return dbCustomCommand.insertPopulatedRow(customCommand.getKeyphrase(),
                customCommand.getRegex(), gsonString, duplicatePair.first, duplicatePair.second);
    }
}
 
開發者ID:brandall76,項目名稱:Saiy-PS,代碼行數:30,代碼來源:CustomCommandHelper.java

示例6: EasyFirebaseAuth

import android.util.Pair; //導入依賴的package包/類
public EasyFirebaseAuth(GoogleApiClient googleApiClient) {
    mAuth = FirebaseAuth.getInstance();
    this.googleApiClient = googleApiClient;

    mAuthListener = new FirebaseAuth.AuthStateListener() {
        @Override
        public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
            final FirebaseUser user = firebaseAuth.getCurrentUser();
            if (user != null) {
                if (firebaseUserSubscriber != null) {
                    firebaseUserSubscriber.onNext(new Pair<GoogleSignInAccount, FirebaseUser>(googleSignInAccount, user));
                    firebaseUserSubscriber.onCompleted();
                }
                if (loggedSubcriber != null) {
                    loggedSubcriber.onNext(user);
                }
                // User is signed in
                Log.d("TAG", "onAuthStateChanged:signed_in:" + user.getUid());
            } else {
                // User is signed out
                Log.d("TAG", "onAuthStateChanged:signed_out");
            }
        }
    };
}
 
開發者ID:florent37,項目名稱:EasyFirebase,代碼行數:26,代碼來源:EasyFirebaseAuth.java

示例7: readImageSize

import android.util.Pair; //導入依賴的package包/類
/**
 * We get the size from a generic image
 */
private Pair<Integer, Integer> readImageSize() {
  InputStream inputStream = null;
  Pair<Integer, Integer> dimensions = null;
  try {
    inputStream = getInputStream();
    dimensions = BitmapUtil.decodeDimensions(inputStream);
    if (dimensions != null) {
      mWidth = dimensions.first;
      mHeight = dimensions.second;
    }
  }finally {
    if (inputStream != null) {
      try {
        inputStream.close();
      } catch (IOException e) {
        // Head in the sand
      }
    }
  }
  return dimensions;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:25,代碼來源:EncodedImage.java

示例8: parseCallIdAndAttachmentName

import android.util.Pair; //導入依賴的package包/類
Pair<UUID, String> parseCallIdAndAttachmentName(Uri uri) {
    try {
        // We don't do explicit format checking here. Malformed URIs may generate NullPointerExceptions or
        // array bounds exceptions, which we'll catch and return null. All of these will result in a
        // FileNotFoundException being thrown in openFile.
        String callIdAndAttachmentName = uri.getPath().substring(1);
        String [] parts = callIdAndAttachmentName.split("/");

        String callIdString = parts[0];
        String attachmentName = parts[1];
        UUID callId = UUID.fromString(callIdString);

        return new Pair<UUID, String>(callId, attachmentName);
    } catch (Exception exception) {
        return null;
    }
}
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:18,代碼來源:NativeAppCallContentProvider.java

示例9: deleteList

import android.util.Pair; //導入依賴的package包/類
public boolean deleteList(List<Pair<String, String[]>> where) {
    long start = System.currentTimeMillis();
    lock.lock();
    try {
        database.beginTransaction();
        for (Pair<String, String[]> pair : where) {
            database.delete(getTableName(), pair.first, pair.second);
        }
        database.setTransactionSuccessful();
        return true;
    } catch (Exception e) {
        OkLogger.printStackTrace(e);
    } finally {
        database.endTransaction();
        lock.unlock();
        OkLogger.v(TAG, System.currentTimeMillis() - start + " deleteList");
    }
    return false;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:20,代碼來源:BaseDao.java

示例10: parsePivot

import android.util.Pair; //導入依賴的package包/類
private static Pair<Float, Float> parsePivot(@Nullable String transformOrigin,
                                             int width, int height,int viewportW) {
  if (!TextUtils.isEmpty(transformOrigin)) {
    int firstSpace = transformOrigin.indexOf(FunctionParser.SPACE);
    if (firstSpace != -1) {
      int i = firstSpace;
      for (; i < transformOrigin.length(); i++) {
        if (transformOrigin.charAt(i) != FunctionParser.SPACE) {
          break;
        }
      }
      if (i < transformOrigin.length() && transformOrigin.charAt(i) != FunctionParser.SPACE) {
        List<String> list = new ArrayList<>(2);
        list.add(transformOrigin.substring(0, firstSpace).trim());
        list.add(transformOrigin.substring(i, transformOrigin.length()).trim());
        return parsePivot(list, width, height,viewportW);
      }
    }
  }
  return null;
}
 
開發者ID:weexext,項目名稱:ucar-weex-core,代碼行數:22,代碼來源:WXAnimationBean.java

示例11: loadConversationList

import android.util.Pair; //導入依賴的package包/類
/**
 * load conversation list
 * 
 * @return
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    +    */
protected List<EMConversation> loadConversationList(){
    // get all conversations
    Map<String, EMConversation> conversations = EMClient.getInstance().chatManager().getAllConversations();
    List<Pair<Long, EMConversation>> sortList = new ArrayList<Pair<Long, EMConversation>>();
    /**
     * lastMsgTime will change if there is new message during sorting
     * so use synchronized to make sure timestamp of last message won't change.
     */
    synchronized (conversations) {
        for (EMConversation conversation : conversations.values()) {
            if (conversation.getAllMessages().size() != 0) {
                sortList.add(new Pair<Long, EMConversation>(conversation.getLastMessage().getMsgTime(), conversation));
            }
        }
    }
    try {
        // Internal is TimSort algorithm, has bug
        sortConversationByLastChatTime(sortList);
    } catch (Exception e) {
        e.printStackTrace();
    }
    List<EMConversation> list = new ArrayList<EMConversation>();
    for (Pair<Long, EMConversation> sortItem : sortList) {
        list.add(sortItem.second);
    }
    return list;
}
 
開發者ID:turoDog,項目名稱:KTalk,代碼行數:33,代碼來源:EaseConversationListFragment.java

示例12: decodeDimensions

import android.util.Pair; //導入依賴的package包/類
public static Pair<Integer, Integer> decodeDimensions(FileDescriptor fd) {
    if (fd == null)
        return null;
    BitmapFactory.Options options = CompressKit.getDefaultDecodeBoundsOptions();
    BitmapFactory.decodeFileDescriptor(fd, null, options);
    return (options.outWidth == -1 || options.outHeight == -1) ?
            null : Pair.create(options.outWidth, options.outHeight);
}
 
開發者ID:tangqipeng,項目名稱:tiny,代碼行數:9,代碼來源:BitmapKit.java

示例13: DynamicStickerBase

import android.util.Pair; //導入依賴的package包/類
public DynamicStickerBase(DstickerDataBean parama, String paramString1, String paramString2, String paramString3) {
    super(paramString2, paramString3);
    this.cE = paramString1;
    this.cF = parama;
    this.bh = this.cF.name;

    String str = this.cE.substring("file://".length());
    Pair localPair = MResFileReaderBase.tryGetMergeFile(str);
    if (null != localPair) {
        this.cG = new MResFileIndexReader(str + "/" + (String) localPair.first, str + "/" + (String) localPair.second);
    }
}
 
開發者ID:zhangyaqiang,項目名稱:Fatigue-Detection,代碼行數:13,代碼來源:DynamicStickerBase.java

示例14: onPageFinished

import android.util.Pair; //導入依賴的package包/類
@Override
public void onPageFinished(WebView view, String url) {
    mWebView = view;
    setUpWebView(view);
    while (!mToInjectJavaScripts.isEmpty()) {
        Pair<String, ValueCallback<String>> pair = mToInjectJavaScripts.poll();
        inject(view, pair.first, pair.second);
    }
    super.onPageFinished(view, url);
}
 
開發者ID:feifadaima,項目名稱:https-github.com-hyb1996-NoRootScriptDroid,代碼行數:11,代碼來源:InjectableWebClient.java

示例15: showFragmentById

import android.util.Pair; //導入依賴的package包/類
private void showFragmentById(int id) {
    final Class<? extends Fragment> target = FRAGMENTS.get(id);

    final Fragment fragment = Fragment.instantiate(this, target.getName());

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setupFragmentTransition(fragment);
    }

    final FragmentTransaction transaction = getSupportFragmentManager().beginTransaction()
            .replace(R.id.content_frame, fragment);

    for (Pair<View, String> sharedElement : sharedElements) {
        transaction.addSharedElement(sharedElement.first, sharedElement.second);
    }

    sharedElements = new ArrayList<>();

    transaction.commit();
}
 
開發者ID:roshakorost,項目名稱:Phial,代碼行數:21,代碼來源:HomeActivity.java


注:本文中的android.util.Pair類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。