当前位置: 首页>>代码示例>>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;未经允许,请勿转载。