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


Java Pair类代码示例

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


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

示例1: addRowsToNumbersList

import android.support.v4.util.Pair; //导入依赖的package包/类
private void addRowsToNumbersList(Bundle data) {
    if (data == null) {
        return;
    }
    // get numbers and types from parameters
    ArrayList<String> numbers = data.getStringArrayList(CONTACT_NUMBERS);
    ArrayList<Integer> types = data.getIntegerArrayList(CONTACT_NUMBER_TYPES);
    if (numbers != null && types != null && numbers.size() == types.size()) {
        // get the set of unique pairs of numbers/types form the current view
        Set<Pair<String, Integer>> numbers2TypeSet = getNumber2TypePairs();
        for (int i = 0; i < numbers.size(); i++) {
            String number = numbers.get(i);
            int type = types.get(i);
            // add to View only rows with unique pair of number/type
            if (numbers2TypeSet.add(new Pair<>(number, type))) {
                addRowToNumbersList(number, type);
            }
        }
    }
}
 
开发者ID:kaliturin,项目名称:BlackList,代码行数:21,代码来源:AddOrEditContactFragment.java

示例2: onCheckPreviousAppInstalledTaskPostExecute

import android.support.v4.util.Pair; //导入依赖的package包/类
@Override
public void onCheckPreviousAppInstalledTaskPostExecute(Pair<JSONObject, Set<String>> result) {
    JSONObject json = result.first;
    if (json == null) {
        setAccountAndFinish();

    } else {
        List<String> vehicles = getVehiclesFromJsonOrShowErrorToast(json);
        if (vehicles.isEmpty()) {   // previous version exists but is empty
            setAccountAndFinish();

        } else {
            this.json = json;
            loader.setVisibility(View.GONE);
            chooseVehiclesLayout.setVisibility(View.VISIBLE);
            nextBtn.setVisibility(View.VISIBLE);
            if (adapter == null)
                adapter = new ListVehiclesRestoreAdapter(this, this, vehicles, result.second);
            vehiclesList.setAdapter(adapter);
        }
    }
}
 
开发者ID:piskula,项目名称:FuelUp,代码行数:23,代码来源:CheckPreviousVersionsActivity.java

示例3: onBindViewHolder

import android.support.v4.util.Pair; //导入依赖的package包/类
@Override
public void onBindViewHolder(final ManageItemViewHolder holder, final int position) {
    super.onBindViewHolder(holder, position);

    final Schedule schedule = mItemList.get(position).second;

    holder.txtLabel.setText(schedule.getCode());
    holder.cbxEnabled.setChecked(schedule.isEnabled());
    holder.itemView.setTag(mItemList.get(position));

    holder.cbxEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            schedule.setEnabled(b);
            mItemList.set(position, new Pair<>((long) position, schedule));
        }
    });

    holder.btnDelete.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            listener.onScheduleDelete(holder, schedule);
        }
    });
}
 
开发者ID:linklux,项目名称:android-schedules,代码行数:26,代码来源:ManageItemAdapter.java

示例4: itemClicked

import android.support.v4.util.Pair; //导入依赖的package包/类
@Override
public void itemClicked(View view, MediaInfo item, int position) {
    if (view instanceof ImageButton) {
        Utils.showQueuePopup(getActivity(), view, item);
    } else {
        String transitionName = getString(R.string.transition_image);
        VideoListAdapter.ViewHolder viewHolder =
                (VideoListAdapter.ViewHolder) mRecyclerView.findViewHolderForPosition(position);
        Pair<View, String> imagePair = Pair
                .create((View) viewHolder.getImageView(), transitionName);
        ActivityOptionsCompat options = ActivityOptionsCompat
                .makeSceneTransitionAnimation(getActivity(), imagePair);

        Intent intent = new Intent(getActivity(), LocalPlayerActivity.class);
        intent.putExtra("media", item);
        intent.putExtra("shouldStart", false);
        ActivityCompat.startActivity(getActivity(), intent, options.toBundle());
    }
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:20,代码来源:VideoBrowserFragment.java

示例5: handleMessage

import android.support.v4.util.Pair; //导入依赖的package包/类
@Override
public boolean handleMessage(Message message) {
    switch (message.what) {
        case MSG_NOTIFICATION_POSTED:
            if (sNotificationsChangedListener != null) {
                NotificationPostedMsg msg = (NotificationPostedMsg) message.obj;
                sNotificationsChangedListener.onNotificationPosted(msg.packageUserKey,
                        msg.notificationKey, msg.shouldBeFilteredOut);
            }
            break;
        case MSG_NOTIFICATION_REMOVED:
            if (sNotificationsChangedListener != null) {
                Pair<PackageUserKey, NotificationKeyData> pair
                        = (Pair<PackageUserKey, NotificationKeyData>) message.obj;
                sNotificationsChangedListener.onNotificationRemoved(pair.first, pair.second);
            }
            break;
        case MSG_NOTIFICATION_FULL_REFRESH:
            if (sNotificationsChangedListener != null) {
                sNotificationsChangedListener.onNotificationFullRefresh(
                        (List<StatusBarNotification>) message.obj);
            }
            break;
    }
    return true;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:27,代码来源:NotificationListener.java

示例6: testCommand_callback_sync

import android.support.v4.util.Pair; //导入依赖的package包/类
@Test
public void testCommand_callback_sync() throws IOException, InterruptedException {
    processor.attach(session);

    int cnt = 100;
    List<Pair<TestObserver<Cmd.Result>, TestSubscriber<String>>> testSubscribers = new ArrayList<>();
    for (int j = 0; j < cnt; j++) {
        List<String> cmds = new ArrayList<>();
        for (int i = 0; i < 10; i++) cmds.add("echo " + i);
        cmds.add("echo " + j);

        PublishProcessor<String> outputListener = PublishProcessor.create();
        TestSubscriber<String> outputObserver = outputListener.doOnEach(stringNotification -> TestHelper.sleep(1)).test();
        final Cmd cmd = Cmd.builder(cmds).outputProcessor(outputListener).build();
        final TestObserver<Cmd.Result> resultObserver = processor.submit(cmd).subscribeOn(Schedulers.newThread()).test();
        testSubscribers.add(new Pair<>(resultObserver, outputObserver));
    }
    for (Pair<TestObserver<Cmd.Result>, TestSubscriber<String>> pair : testSubscribers) {
        pair.first.awaitDone(5, TimeUnit.SECONDS).assertNoTimeout().assertComplete();
        pair.second.awaitDone(5, TimeUnit.SECONDS).assertNoTimeout().assertValueCount(11);
    }
}
 
开发者ID:d4rken,项目名称:RxShell,代码行数:23,代码来源:CmdProcessorTest.java

示例7: createHideSwitcherAnimationListener

import android.support.v4.util.Pair; //导入依赖的package包/类
/**
 * Creates and returns an animation listener, which allows to inflate or remove the views, which
 * are used to visualize tabs, when an animation, which is used to hide the tab switcher,
 * has been finished.
 *
 * @return The animation listener, which has been created, as an instance of the type {@link
 * AnimatorListener}. The listener may not be null
 */
@NonNull
private AnimatorListener createHideSwitcherAnimationListener() {
    return new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(final Animator animation) {
            super.onAnimationEnd(animation);
            AbstractTabItemIterator iterator =
                    new TabItemIterator.Builder(getTabSwitcher(), viewRecycler).create();
            TabItem tabItem;

            while ((tabItem = iterator.next()) != null) {
                if (tabItem.getTab() == getModel().getSelectedTab()) {
                    Pair<View, Boolean> pair = viewRecycler.inflate(tabItem);
                    View view = pair.first;
                    FrameLayout.LayoutParams layoutParams =
                            (FrameLayout.LayoutParams) view.getLayoutParams();
                    view.setAlpha(1f);
                    getArithmetics().setScale(Axis.DRAGGING_AXIS, view, 1);
                    getArithmetics().setScale(Axis.ORTHOGONAL_AXIS, view, 1);
                    view.setX(layoutParams.leftMargin);
                    view.setY(layoutParams.topMargin);
                } else {
                    viewRecycler.remove(tabItem);
                }
            }

            viewRecycler.clearCache();
            recyclerAdapter.clearCachedPreviews();
            tabViewBottomMargin = -1;
        }

    };
}
 
开发者ID:NeoTerm,项目名称:NeoTerm,代码行数:43,代码来源:PhoneTabSwitcherLayout.java

示例8: ClaimItemAdapter

import android.support.v4.util.Pair; //导入依赖的package包/类
public ClaimItemAdapter(
        final Context context,
        final LifecycleOwner owner,
        final LiveData<List<ClaimItem>> liveItems) {

    this.layoutInflater = LayoutInflater.from(context);
    this.itemPresenter = new ItemPresenter(context);

    liveItems.observe(owner, new Observer<List<ClaimItem>>() {
        @Override
        public void onChanged(final List<ClaimItem> claimItems) {
            if (!items.isEmpty()) {
                updateCommand.exec(Pair.create(items, claimItems));
            } else {
                createDisplayListCommand.exec(claimItems);
            }
        }
    });
}
 
开发者ID:PacktPublishing,项目名称:Hands-On-Android-UI-Development,代码行数:20,代码来源:ClaimItemAdapter.java

示例9: getBoxOfficeMovieDetail

import android.support.v4.util.Pair; //导入依赖的package包/类
private MovieListResult getBoxOfficeMovieDetail(Pair pair) {

        TmdbMovieDetail movieDetail = (TmdbMovieDetail) pair.first;
        BoxOffice boxOffice = (BoxOffice) pair.second;

        realm = Realm.getDefaultInstance();
        MovieListResult movieListResult = new MovieListResult();
        Result result = createResult(movieDetail);

        MovieStatus status = findInRealmMovieStatus(realm, movieDetail.getId());
        if (status == null) {
            movieListResult.setResult(result);
            movieListResult.setRevenue(boxOffice.getRevenue());
            movieListResult.setAddedToWatchlist(false);
            movieListResult.setMarkedAsFavorite(false);
        } else {
            movieListResult.setResult(result);
            movieListResult.setRevenue(boxOffice.getRevenue());
            movieListResult.setAddedToWatchlist(status.isAddedToWatchList());
            movieListResult.setMarkedAsFavorite(status.isMarkedAsFavorite());
        }
        realm.close();

        return movieListResult;
    }
 
开发者ID:prakh25,项目名称:MovieApp,代码行数:26,代码来源:MovieListPresenter.java

示例10: getItemViewType

import android.support.v4.util.Pair; //导入依赖的package包/类
/**
 * Determine if the feature is new/upgraded/unchanged.
 *
 * @param position Position of the view in the adapter.
 * @return The type constant of the view in this position (NEW/UPGRADED/UNCHANGED)
 */
@Override
public int getItemViewType(int position) {
    // The current feature and its level
    Pair<ProductFeature, Integer> pair = mProduct.getFeatures().get(position);
    int featureId = pair.first.getFeatureId();
    int level = pair.second;

    Pair<ProductFeature, Integer> prevPair = mProduct.getReleasedVersion().getFeature(featureId);

    if (prevPair == null) {
        // If prevPair is null, the previous version did not have this, so this is a NEW feature.
        return NEW;
    } else if (level > prevPair.second) {
        // The previous version had this, but the level was lower, so this is an UPGRADED feature.
        return UPGRADED;
    } else {
        // The previous version had this feature, and it was of equal or lower level.
        // This is considered UNCHANGED. Downgrading features is not possible.
        return UNCHANGED;
    }
}
 
开发者ID:zak0,项目名称:AppTycoon,代码行数:28,代码来源:NewProductReleaseFragment.java

示例11: relocateWhenAddingHiddenTabs

import android.support.v4.util.Pair; //导入依赖的package包/类
/**
 * Calculates the position and state of hidden tabs, which have been added to the tab switcher.
 *
 * @param addedItems
 *         An array, which contains the items, which correspond to the tabs, which have been
 *         added, as an array of the type {@link AbstractItem}. The array may not be null
 * @param referenceItem
 *         The item, which corresponds to the tab, which is used as a reference, as an instance
 *         of the class {@link AbstractItem}. The item may not be null
 * @return An array, which contains the items, which correspond to the tabs, which have been
 * added, as an array of the type {@link AbstractItem}. The array may not be null
 */
@NonNull
private AbstractItem[] relocateWhenAddingHiddenTabs(@NonNull final AbstractItem[] addedItems,
                                                    @NonNull final AbstractItem referenceItem) {
    boolean stackedAtStart = isStackedAtStart(referenceItem.getIndex());

    for (AbstractItem item : addedItems) {
        Pair<Float, State> pair;

        if (stackedAtStart) {
            AbstractItem predecessor = item.getIndex() > 0 ?
                    TabItem.create(getTabSwitcher(), tabViewRecycler, item.getIndex() - 1) :
                    null;
            pair = calculatePositionAndStateWhenStackedAtStart(getModel().getCount(),
                    item.getIndex(), predecessor);
        } else {
            pair = calculatePositionAndStateWhenStackedAtEnd(item.getIndex());
        }

        Tag tag = item.getTag();
        tag.setPosition(pair.first);
        tag.setState(pair.second);
    }

    return addedItems;
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:38,代码来源:PhoneTabSwitcherLayout.java

示例12: removeItemsObservable

import android.support.v4.util.Pair; //导入依赖的package包/类
public Completable removeItemsObservable(
    final List<QuranRow> itemsToRemoveRef) {
  return Completable.fromCallable(() -> {
    List<Long> tagsToDelete = new ArrayList<>();
    List<Long> bookmarksToDelete = new ArrayList<>();
    List<Pair<Long, Long>> untag = new ArrayList<>();
    for (int i = 0, size = itemsToRemoveRef.size(); i < size; i++) {
      QuranRow row = itemsToRemoveRef.get(i);
      if (row.isBookmarkHeader() && row.tagId > 0) {
        tagsToDelete.add(row.tagId);
      } else if (row.isBookmark() && row.bookmarkId > 0) {
        if (row.tagId > 0) {
          untag.add(new Pair<>(row.bookmarkId, row.tagId));
        } else {
          bookmarksToDelete.add(row.bookmarkId);
        }
      }
    }
    bookmarksDBAdapter.bulkDelete(tagsToDelete, bookmarksToDelete, untag);
    return null;
  }).subscribeOn(Schedulers.io());
}
 
开发者ID:Elias33,项目名称:Quran,代码行数:23,代码来源:BookmarkModel.java

示例13: launchDetail

import android.support.v4.util.Pair; //导入依赖的package包/类
public static void launchDetail(MainActivity fromActivity, View fromView, Thing item, View backgroundView) {
    ViewCompat.setTransitionName(fromView, "detail_element");
    ViewCompat.setTransitionName(fromActivity.findViewById(R.id.fab), "fab");
    ActivityOptionsCompat options =
            TransitionHelper.makeOptionsCompat(
                    fromActivity,
                    Pair.create(fromView, "detail_element"),
                    Pair.create(fromActivity.findViewById(R.id.fab), "fab")
            );
    Intent intent = new Intent(fromActivity, MainActivity.class);
    intent.putExtra("item_text", item.text);
    intent.putExtra("fragment_resource_id", R.layout.fragment_thing_detail);

    if (backgroundView != null) BitmapUtil.storeBitmapInIntent(BitmapUtil.createBitmap(backgroundView), intent);

    ActivityCompat.startActivity(fromActivity, intent, options.toBundle());

    fromActivity.overridePendingTransition(R.anim.slide_up, R.anim.scale_down);
}
 
开发者ID:shenhuanet,项目名称:AndroidOpen,代码行数:20,代码来源:Navigator.java

示例14: checkIfPageIsBookmarked

import android.support.v4.util.Pair; //导入依赖的package包/类
private void checkIfPageIsBookmarked(Integer... pages) {
  compositeDisposable.add(bookmarkModel.getIsBookmarkedObservable(pages)
      .observeOn(AndroidSchedulers.mainThread())
      .subscribeWith(new DisposableObserver<Pair<Integer, Boolean>>() {

        @Override
        public void onNext(Pair<Integer, Boolean> result) {
          bookmarksCache.put(result.first, result.second);
        }

        @Override
        public void onError(Throwable e) {
        }

        @Override
        public void onComplete() {
          supportInvalidateOptionsMenu();
        }
      }));
}
 
开发者ID:Elias33,项目名称:Quran,代码行数:21,代码来源:PagerActivity.java

示例15: Product

import android.support.v4.util.Pair; //导入依赖的package包/类
public Product(String name, ProductType type) {
    mName = name;
    mType = type;
    mReleaseCount = 0;
    mComplexity = 0;
    mQuality = 0;

    mUnitPrice = 0;
    mDownloads = 0;
    mTotalEarnings = 0;
    mUsers = 1288; // TODO: Set to something for dev purposes

    mFeatures = new ArrayList<>();
    mFeatureIncomes = new SparseArray<>();
    mSubProducts = new ArrayList<>();

    // Every product has the "Core functionality" feature. So, we add it here.
    ProductFeature coreFeatures = ProductFeature.getFeature(ProductFeature.PRODUCT_FEATURE_CORE_FEATURES);
    mFeatures.add(new Pair<>(coreFeatures, 1));

    calculateComplexity();
}
 
开发者ID:zak0,项目名称:AppTycoon,代码行数:23,代码来源:Product.java


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