Java 类android.util.Pair 实例源码

项目:Phial    文件:HomeActivity.java   
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();
}
项目:OpenYOLO-Android    文件:CollectionConverter.java   
/**
 * Converts all the values in the provided collection, and adds them to a new map.
 */
@NonNull
public static <T, U, V> Map<U, V> toMap(
        @Nullable Collection<T> values,
        @NonNull ValueConverter<T, Pair<U, V>> valueConverter) {
    if (values == null) {
        return Collections.emptyMap();
    }

    Map<U, V> result = createMap(values.size());
    for (T value : values) {
        Pair<U, V> converted = valueConverter.convert(value);
        result.put(converted.first, converted.second);
    }

    return result;
}
项目:Exoplayer2Radio    文件:AtomParsers.java   
/**
 * Parses encryption data from an audio/video sample entry, populating {@code out} and returning
 * the unencrypted atom type, or 0 if no common encryption sinf atom was present.
 */
private static int parseSampleEntryEncryptionData(ParsableByteArray parent, int position,
    int size, StsdData out, int entryIndex) {
  int childPosition = parent.getPosition();
  while (childPosition - position < size) {
    parent.setPosition(childPosition);
    int childAtomSize = parent.readInt();
    Assertions.checkArgument(childAtomSize > 0, "childAtomSize should be positive");
    int childAtomType = parent.readInt();
    if (childAtomType == Atom.TYPE_sinf) {
      Pair<Integer, TrackEncryptionBox> result = parseSinfFromParent(parent, childPosition,
          childAtomSize);
      if (result != null) {
        out.trackEncryptionBoxes[entryIndex] = result.second;
        return result.first;
      }
    }
    childPosition += childAtomSize;
  }
  // This enca/encv box does not have a data format so return an invalid atom type.
  return 0;
}
项目:weex-uikit    文件:WXAnimationBean.java   
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 parsePivot(Arrays.asList(WXAnimationBean.Style.CENTER,
                                  WXAnimationBean.Style.CENTER), width, height,viewportW);
}
项目:prebid-mobile-android    文件:BidManagerTest.java   
@Test
public void testKeywordString() throws Exception {
    //Registering a list of adUnits test
    ArrayList<BidResponse> bids = new ArrayList<>();
    BidResponse testBid = new BidResponse(TestConstants.cpm3, ServerResponses.ut_url);
    testBid.addCustomKeyword("pb_cache_id", "14y3834yq5iu5");
    testBid.addCustomKeyword("hb_pb", "0.54");
    testBid.addCustomKeyword("hb_bidder", "mock_bidder");
    bids.add(testBid);
    MockServer.addTestSetup(TestConstants.configID1, bids);
    ArrayList<AdUnit> adUnits = new ArrayList<AdUnit>();
    adUnits.add(adUnit1);
    Prebid.init(activity.getApplicationContext(), adUnits, TestConstants.accountId);
    Robolectric.flushBackgroundThreadScheduler();
    Robolectric.flushForegroundThreadScheduler();
    ArrayList<Pair<String, String>> keywords = BidManager.getKeywordsForAdUnit(adUnit1.getCode(), activity.getApplicationContext());
    for (Pair keywordPair : keywords) {
        if ("pb_cache_id".equals(keywordPair.first)) {
            assertEquals("14y3834yq5iu5", keywordPair.second);
        } else if ("hb_pb".equals(keywordPair.first)) {
            assertEquals("0.54", keywordPair.second);
        } else if ("hb_bidder".equals(keywordPair.first)) {
            assertEquals("mock_bidder", keywordPair.second);
        }
    }
}
项目:Exoplayer2Radio    文件:CodecSpecificDataUtil.java   
/**
 * Parses an AudioSpecificConfig, as defined in ISO 14496-3 1.6.2.1
 *
 * @param audioSpecificConfig The AudioSpecificConfig to parse.
 * @return A pair consisting of the sample rate in Hz and the channel count.
 */
public static Pair<Integer, Integer> parseAacAudioSpecificConfig(byte[] audioSpecificConfig) {
  ParsableBitArray bitArray = new ParsableBitArray(audioSpecificConfig);
  int audioObjectType = getAacAudioObjectType(bitArray);
  int sampleRate = getAacSamplingFrequency(bitArray);
  int channelConfiguration = bitArray.readBits(4);
  if (audioObjectType == AUDIO_OBJECT_TYPE_SBR || audioObjectType == AUDIO_OBJECT_TYPE_PS) {
    // For an AAC bitstream using spectral band replication (SBR) or parametric stereo (PS) with
    // explicit signaling, we return the extension sampling frequency as the sample rate of the
    // content; this is identical to the sample rate of the decoded output but may differ from
    // the sample rate set above.
    // Use the extensionSamplingFrequencyIndex.
    sampleRate = getAacSamplingFrequency(bitArray);
    audioObjectType = getAacAudioObjectType(bitArray);
    if (audioObjectType == AUDIO_OBJECT_TYPE_ER_BSAC) {
      // Use the extensionChannelConfiguration.
      channelConfiguration = bitArray.readBits(4);
    }
  }
  int channelCount = AUDIO_SPECIFIC_CONFIG_CHANNEL_COUNT_TABLE[channelConfiguration];
  Assertions.checkArgument(channelCount != AUDIO_SPECIFIC_CONFIG_CHANNEL_CONFIGURATION_INVALID);
  return Pair.create(sampleRate, channelCount);
}
项目:aosp_nav_bar_ex    文件:NavBarEntryAdapter.java   
@Override
public View getView(final int position, View convertView, ViewGroup parent)
{
    View resultView = convertView;

    ViewHolder holder;

    if (resultView == null)
    {
        resultView = inflater.inflate(android.R.layout.simple_list_item_1, null);
        holder = new ViewHolder((TextView) resultView.findViewById(android.R.id.text1));

        resultView.setTag(holder);
    }
    else
    {
        holder = (ViewHolder) resultView.getTag();
    }

    Pair<String /* uuid */, NavBarEntry> entry = getItem(position);
    fillViews(holder, entry);

    return resultView;
}
项目:easyfilemanager    文件:MultiSelectionUtil.java   
private void tryRestoreInstanceState(HashSet<Long> idsToCheckOnRestore) {
    if (idsToCheckOnRestore == null || mListView.getAdapter() == null) {
        return;
    }
    boolean idsFound = false;
    Adapter adapter = mListView.getAdapter();
    for (int pos = adapter.getCount() - 1; pos >= 0; pos--) {
        if (idsToCheckOnRestore.contains(adapter.getItemId(pos))) {
            idsFound = true;
            if (mItemsToCheck == null) {
                mItemsToCheck = new HashSet<Pair<Integer, Long>>();
            }
            mItemsToCheck.add(new Pair<Integer, Long>(pos, adapter.getItemId(pos)));
        }
    }
    if (idsFound) {
        // We found some IDs that were checked. Let's now restore the multi-selection
        // state.
        mActionMode = mActivity.startSupportActionMode(mCallbacks);
    }
}
项目:streaminglib    文件:RtspClientSession.java   
private Pair<Integer, Integer> getNewInterleavedChannels() {
    // Determine which RTP channels are used
    List<Integer> takenRtpChannels = new ArrayList<>();
    for (RtpStream s : streams) {
        if (s.getRtpProtocol() == RtpStream.RtpProtocol.TCP) {
            Pair<Integer, Integer> i = s.getInterleavedRtpChannels();
            if (i != null) takenRtpChannels.add(i.first);
        }
    }

    // Determine the lowest available RTP channels
    Integer rtpChannel = null, rtcpChannel = null;
    for (int i = 0; i < Integer.MAX_VALUE; i += 2) {
        if (!takenRtpChannels.contains(i)) {
            rtpChannel = i;
            rtcpChannel = i + 1;
        }
    }
    return new Pair<>(rtpChannel, rtcpChannel);
}
项目:Saiy-PS    文件:BingTranslate.java   
/**
 * Execute the translation request
 *
 * @param ctx               the application context
 * @param language          the {@link TranslationLanguageBing}
 * @param translationString the content to translate
 * @return the translation result {@link Pair} with the first parameter denoting success
 */
public static Pair<Boolean, String> execute(@NonNull final Context ctx,
                                            @NonNull final TranslationLanguageBing language,
                                            @NonNull final String translationString) {

    if (BingCredentials.isTokenValid(ctx)) {
        if (DEBUG) {
            MyLog.i(CLS_NAME, "execute: token valid");
        }
        return new BingTranslateAPI().execute(ctx, SPH.getBingToken(ctx), translationString,
                TranslationLanguageBing.AUTO_DETECT, language);
    } else {
        if (DEBUG) {
            MyLog.i(CLS_NAME, "execute: token invalid");
        }
        if (new BingOAuth().execute(ctx, true)) {
            return new BingTranslateAPI().execute(ctx, SPH.getBingToken(ctx), translationString,
                    TranslationLanguageBing.AUTO_DETECT, language);
        } else {
            if (DEBUG) {
                MyLog.w(CLS_NAME, "execute: refreshing token failed");
            }
            return new Pair<>(false, null);
        }
    }
}
项目:RoomDemo2017    文件:ListFragment.java   
public void startDetailActivity(String itemId, View viewRoot) {
    Activity container = getActivity();
    Intent i = new Intent(container, DetailActivity.class);
    i.putExtra(EXTRA_ITEM_ID, itemId);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        container.getWindow().setEnterTransition(new Fade(Fade.IN));
        container.getWindow().setEnterTransition(new Fade(Fade.OUT));

        ActivityOptions options = ActivityOptions
                .makeSceneTransitionAnimation(container,
                        new Pair<>(viewRoot.findViewById(R.id.imv_list_item_circle),
                                getString(R.string.transition_drawable)),
                        new Pair<>(viewRoot.findViewById(R.id.lbl_message),
                                getString(R.string.transition_message)),
                        new Pair<>(viewRoot.findViewById(R.id.lbl_date_and_time),
                                getString(R.string.transition_time_and_date)));

        startActivity(i, options.toBundle());

    } else {
        startActivity(i);
    }
}
项目:SciChart.Android.Examples    文件:SearchResultsDataAdapter.java   
private static List<Pair<Integer, Integer>> getRanges(List<Integer> list) {
    if (list.size() < 1) return null;
    final List<List<Integer>> indexesList = new ArrayList<>();
    List<Integer> someList = new ArrayList<>();
    for (int i = 0; i < list.size() - 1; i++) {
        someList.add(list.get(i));
        if (list.get(i + 1) - list.get(i) > 1) {
            indexesList.add(someList);
            someList = new ArrayList<>();
        }
    }
    someList.add(list.get(list.size() - 1));
    indexesList.add(someList);

    final List<Pair<Integer, Integer>> result = new ArrayList<>();
    for (List<Integer> indexList : indexesList) {
        result.add(new Pair<>(indexList.get(0), indexList.size()));
    }

    return result;
}
项目:GitHub    文件:DelegateAdapter.java   
public void clear() {
    mTotal = 0;
    mIndex = 0;
    if (mIndexGen != null) {
        mIndexGen.set(0);
    }
    mLayoutManager.setLayoutHelpers(null);

    for (Pair<AdapterDataObserver, Adapter> p : mAdapters) {
        p.second.unregisterAdapterDataObserver(p.first);
    }


    mItemTypeAry.clear();
    mAdapters.clear();
    mIndexAry.clear();
}
项目:GitHub    文件:RequestLoggingListener.java   
@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);
  }
}
项目:Cable-Android    文件:ConversationActivity.java   
@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) {}
  });
}
项目:kognitivo    文件:FacebookContentProvider.java   
@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;
    }
}
项目:revolution-irc    文件:ShareTargetActivity.java   
@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();
    });
}
项目:Saiy-PS    文件:CustomCommandHelper.java   
/**
 * 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);
    }
}
项目:EasyFirebase    文件:EasyFirebaseAuth.java   
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");
            }
        }
    };
}
项目:GitHub    文件:EncodedImage.java   
/**
 * 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;
}
项目:AndroidBackendlessChat    文件:NativeAppCallContentProvider.java   
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;
    }
}
项目:GitHub    文件:BaseDao.java   
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;
}
项目:ucar-weex-core    文件:WXAnimationBean.java   
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;
}
项目:KTalk    文件:EaseConversationListFragment.java   
/**
 * 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;
}
项目:tiny    文件:BitmapKit.java   
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);
}
项目:Fatigue-Detection    文件:DynamicStickerBase.java   
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);
    }
}
项目:https-github.com-hyb1996-NoRootScriptDroid    文件:InjectableWebClient.java   
@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);
}
项目:starcor.xul    文件:XulBindingSelector.java   
@Override
boolean apply(IXulDataSelectContext dataCtx, ArrayList<XulDataNode> ctx) {
    HashSet<Integer> keepPositions = new HashSet<Integer>();

    int orgSize = ctx.size();
    for (int i1 = 0; i1 < _ranges.size(); i1++) {
        Pair<Integer, Integer> range = _ranges.get(i1);
        int begin = range.first;
        int end = range.second;
        if (begin < 0) {
            begin += orgSize;
        }
        if (end < 0) {
            end += orgSize;
        }
        if (end < 0 || begin < 0) {
            // invalid range
            continue;
        }
        if (end > orgSize) {
            end = orgSize;
        }
        for (int i = begin; i <= end; ++i) {
            keepPositions.add(i);
        }
    }
    while (orgSize > 0) {
        --orgSize;
        if (!keepPositions.contains(orgSize)) {
            ctx.remove(orgSize);
        }
    }
    return true;
}
项目:RecyclerViewInjectorAdapter    文件:RecyclerViewInjectorAdapterAndroidTest.java   
private List<String> getChildAdapterDataStringList(List<Pair<String, Integer>> list) {
    List<String> result = new ArrayList<>(list.size());
    for (Pair<String, Integer> item : list) {
        result.add(item.first);
    }
    return result;
}
项目:Mire    文件:ActivitySetWallpapers.java   
private void OnWallpaperLoaded(final Palette palette)
{
       progress.setVisibility(View.GONE);
    apply.startAnimation(anim);
    apply.setVisibility(View.VISIBLE);

    apply.setImageDrawable(DrawableHelper.getTintedDrawable(ActivitySetWallpapers.this, R.drawable.ic_more_vert_accent_24dp, MirePaletteUtils.getColor(palette, Preferences.getAttributeColor(ActivitySetWallpapers.this, R.attr.colorAccent))));
    apply.setOnClickListener(new View.OnClickListener()
    {
        @Override
        public void onClick(View view)
        {
            final int defaultColor = Preferences.getAttributeColor(ActivitySetWallpapers.this, R.attr.colorAccent);
            final int colorInt = MirePaletteUtils.getColor(palette, defaultColor);

            Intent intent = new Intent(ActivitySetWallpapers.this, ActivityDialogWallpaperChoiceOptions.class);
            intent.putExtra(URL, image);
            intent.putExtra(NAME, title);
            intent.putExtra(TEXT, text);
            intent.putExtra(COLOR, colorInt);

            int src = DrawableHelper.getDrawableInt(ActivitySetWallpapers.this, R.drawable.ic_more_vert_accent_24dp, MirePaletteUtils.getColor(palette, Preferences.getAttributeColor(ActivitySetWallpapers.this, R.attr.colorAccent))); // Does not Work :'(
            CircularRevealTransformEnter.addExtras(intent, src);

            Pair<View, String> pair = (Pair<View, String>)Pair.create((View)findViewById(R.id.id_apply), "transition_dialog");

            ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(ActivitySetWallpapers.this, pair);

            startActivity(intent, options.toBundle());
        }
    });
   }
项目:Saiy-PS    文件:Hotword.java   
/**
 * Used by the {@link Callable} in {@link Callable#call()}
 *
 * @return an array list containing {@link Pair} of {@link CC} and {@link Float} confidence scores
 */
public ArrayList<Pair<CC, Float>> detectCallable() {

    switch (sl) {

        case ENGLISH:
            return ((Hotword_en) hotword).detectCallable();
        case ENGLISH_US:
            return ((Hotword_en) hotword).detectCallable();
        default:
            return ((Hotword_en) hotword).detectCallable();
    }
}
项目:atlas    文件:BundleInstaller.java   
public static void startDelayInstall(final String location,InstallListener listener)
{
    createIdleInstallerIfNeed();
    if(location!=null){
        BundleImpl impl = (BundleImpl)Atlas.getInstance().getBundle(location);
        if(impl==null || !impl.checkValidate()){
            sDelayInstallBundles.add(new Pair<String, InstallListener>(location,listener));
        }
    }
}
项目:chromium-net-for-android    文件:CronetHttpURLConnection.java   
/**
 * Returns the index of request header in {@link #mRequestHeaders} or
 * -1 if not found.
 */
private int findRequestProperty(String key) {
    for (int i = 0; i < mRequestHeaders.size(); i++) {
        Pair<String, String> entry = mRequestHeaders.get(i);
        if (entry.first.equalsIgnoreCase(key)) {
            return i;
        }
    }
    return -1;
}
项目:streaminglib    文件:RtpStream.java   
public void configureUdp(Pair<Integer, Integer> remoteRtpPorts, InetAddress host) throws IllegalStateException {
    validateState(RtpStreamState.CONFIGURED, RtpStreamState.INITIALIZED);
    validateRtpProtocol(RtpProtocol.UDP);
    this.remoteRtpPorts = remoteRtpPorts;

    rtpPacket = new DatagramPacket(new byte[]{}, 0, host, remoteRtpPorts.first);
    rtcpPacket = new DatagramPacket(new byte[]{}, 0, host, remoteRtpPorts.second);

    state = RtpStreamState.CONFIGURED;

    startListening();
}
项目:AOSP-Kayboard-7.1.2    文件:EmojiCategory.java   
public Pair<Integer, Integer> getCategoryIdAndPageIdFromPagePosition(final int position) {
    int sum = 0;
    for (final CategoryProperties properties : mShownCategories) {
        final int temp = sum;
        sum += properties.mPageCount;
        if (sum > position) {
            return new Pair<>(properties.mCategoryId, position - temp);
        }
    }
    return null;
}
项目:SimpleRssReader    文件:RoundedCornersBackgroundSpan.java   
private RoundedCornersBackgroundSpan(@NonNull Builder builder) {
    mPaint.setAntiAlias(true);
    mRadius = builder.mRadius;
    mPadding = builder.mPadding;
    mSeparatorWidth = builder.mSeparatorWidth;
    mTextAlignment = builder.mTextAlignment;
    for (final Pair<CharSequence, BackgroundHolder> textPart : builder.mTextParts) {
        if (textPart.second != null) {
            mBackgroundHolders.add(textPart.second);
        }
    }
    final char firstChar = builder.mTextParts.get(0).first.charAt(0);
    mRtlText = firstChar >= 0x5D0 && firstChar <= 0x6ff;
}
项目:Saiy-PS    文件:BVCredentials.java   
/**
 * Convenience method to check if the most recent access token remains valid and automatically
 * request one if required.
 *
 * @param ctx    the application context
 * @param apiKey the API key
 * @return an {@link Pair} of which the first parameter will denote success and the second an
 * {@link BVCredentials} object, containing the token credentials. If the request was unsuccessful,
 * the second parameter may be null.
 */
public static Pair<Boolean, BVCredentials> refreshTokenIfRequired(@NonNull final Context ctx,
                                                                  @NonNull final String apiKey) {
    final BVCredentials bvCredentials = getLastToken(ctx);

    if (isTokenValid(bvCredentials)) {
        return new Pair<>(true, bvCredentials);
    } else {
        return new BVAuthRequest(ctx.getApplicationContext(), apiKey).getToken();
    }
}
项目:RIBs    文件:LoggedOutView.java   
@Override
public Observable<Pair<String, String>> playerNames() {
  return RxView.clicks(findViewById(R.id.login_button))
      .map(
          new Function<Object, Pair<String, String>>() {
            @Override
            public Pair<String, String> apply(Object irrelevant) throws Exception {
              return new Pair<>(
                  playerOneEditText.getText().toString(), playerTwoEditText.getText().toString());
            }
          });
}
项目:revolution-irc    文件:ChannelSearchDialog.java   
@Override
public void bind(Pair<ServerConnectionInfo, String> item) {
    String name = item.first.getName();
    String channel = item.second;
    int iof = channel.indexOf(mHighlightQuery);
    SpannableString str = new SpannableString(channel + "  " + name);
    str.setSpan(new ForegroundColorSpan(mHighlightTextColor), iof, iof + mHighlightQuery.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    str.setSpan(new ForegroundColorSpan(mSecondaryTextColor), channel.length() + 2, channel.length() + 2 + name.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    mText.setText(str);
}
项目:fuckView    文件:Hook.java   
private Pair<Boolean, Integer> isBlockDialog(ArrayList<BlockModel> mBlockList, View view) {
    final String pkg = view.getContext().getPackageName();
    final int len = mBlockList.size();
    for (int i = 0; i < len; i++) {
        BlockModel model = mBlockList.get(i);
        if (!model.packageName.equals(pkg) || !model.className.equals(DIALOG_VIRTUAL_CLASSNAME)) {
            continue;
        }
        if (model.record.equals(getAllText(view))) {
            return new Pair<>(model.enable, i);
        }
    }
    return new Pair<>(false, -1);
}