Java 类android.support.v4.util.Pair 实例源码

项目:BlackList    文件:AddOrEditContactFragment.java   
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);
            }
        }
    }
}
项目:FuelUp    文件:CheckPreviousVersionsActivity.java   
@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);
        }
    }
}
项目:android-schedules    文件:ManageItemAdapter.java   
@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);
        }
    });
}
项目:EsperantoRadio    文件:VideoBrowserFragment.java   
@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());
    }
}
项目:LaunchEnr    文件:NotificationListener.java   
@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;
}
项目:RxShell    文件:CmdProcessorTest.java   
@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);
    }
}
项目:NeoTerm    文件:PhoneTabSwitcherLayout.java   
/**
 * 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;
        }

    };
}
项目:Hands-On-Android-UI-Development    文件:ClaimItemAdapter.java   
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);
            }
        }
    });
}
项目:MovieApp    文件:MovieListPresenter.java   
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;
    }
项目:AppTycoon    文件:NewProductReleaseFragment.java   
/**
 * 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;
    }
}
项目:ChromeLikeTabSwitcher    文件:PhoneTabSwitcherLayout.java   
/**
 * 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;
}
项目:Quran    文件:BookmarkModel.java   
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());
}
项目:AndroidOpen    文件:Navigator.java   
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);
}
项目:Quran    文件:PagerActivity.java   
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();
        }
      }));
}
项目:AppTycoon    文件:Product.java   
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();
}
项目:betterHotels    文件:TripsListActivity.java   
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_trips_list);
    initializeToolbar();

    ivHero1 = (ImageView) findViewById(R.id.iv_hero_1);
    trip1Layout = (ViewGroup) findViewById(R.id.trip_1_layout);
    trip1Layout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Pair<View, String> p1 = Pair.create((View) ivHero1, ivHero1.getTransitionName());
            ActivityOptionsCompat options = ActivityOptionsCompat.
                    makeSceneTransitionAnimation((TripsListActivity.this), p1);
            Bundle bundle = options.toBundle();
            Intent i = new Intent(TripsListActivity.this, TripDetailActivity.class);
            startActivity(i, bundle);
        }
    });
}
项目:CryptoVoice    文件:Main.java   
@Override
public Pair<TrustManagerFactory, KeyManagerFactory> getTrustManagerFactory() {
    try {
        KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
        trustStore.load(null);
        InputStream stream = this.getAssets().open("server.crt");
        BufferedInputStream bis = new BufferedInputStream(stream);
        CertificateFactory cf = CertificateFactory.getInstance("X.509");
        while (bis.available() > 0) {
            Certificate cert = cf.generateCertificate(bis);
            trustStore.setCertificateEntry("cert" + bis.available(), cert);
        }
        KeyManagerFactory kmfactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
        kmfactory.init(trustStore, "1234".toCharArray());
        TrustManagerFactory tmf=TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
        tmf.init(trustStore);
        return new Pair<>(tmf, kmfactory);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
项目:ChromeLikeTabSwitcher    文件:AbstractTabSwitcherLayout.java   
/**
 * Calculates the positions of all items, when dragging towards the start.
 *
 * @param dragDistance
 *         The current drag distance in pixels as a {@link Float} value
 */
private void calculatePositionsWhenDraggingToEnd(final float dragDistance) {
    firstVisibleIndex = -1;
    AbstractItemIterator iterator =
            new ItemIterator.Builder(getTabSwitcher(), getTabViewRecycler()).create();
    AbstractItem item;
    boolean abort = false;

    while ((item = iterator.next()) != null && !abort) {
        if (getItemCount() - item.getIndex() > 1) {
            abort = calculatePositionWhenDraggingToEnd(dragDistance, item, iterator.previous());

            if (firstVisibleIndex == -1 && item.getTag().getState() == State.FLOATING) {
                firstVisibleIndex = item.getIndex();
            }
        } else {
            Pair<Float, State> pair = clipPosition(item.getIndex(), item.getTag().getPosition(),
                    iterator.previous());
            item.getTag().setPosition(pair.first);
            item.getTag().setState(pair.second);
        }

        inflateOrRemoveView(item, true);
    }
}
项目:Nimbus    文件:QuizQuestionActivity.java   
@Override
protected void onProgressUpdate(Pair<String, String>... values) {
    String str="";

    if(values[0].first.length()==1){
        str+="0";
    }
    str+=values[0].first+" mins ";

    if(values[0].second.length()==1){
        str+="0";
    }
    str+=values[0].second+" seconds ";

    timer_text.setText(str);

}
项目:NeoTerm    文件:PhoneTabSwitcherLayout.java   
/**
 * Adapts the stack, which is located at the start, when swiping a tab.
 *
 * @param swipedTabItem
 *         The tab item, which corresponds to the swiped tab, as an instance of the class {@link
 *         TabItem}. The tab item may not be null
 * @param successorIndex
 *         The index of the tab, which is located after the swiped tab, as an {@link Integer}
 *         value
 * @param count
 *         The number of tabs, which are contained by the tab switcher, excluding the swiped
 *         tab, as an {@link Integer} value
 */
private void adaptStackOnSwipe(@NonNull final TabItem swipedTabItem, final int successorIndex,
                               final int count) {
    if (swipedTabItem.getTag().getState() == State.STACKED_START_ATOP &&
            successorIndex < getModel().getCount()) {
        TabItem tabItem = TabItem.create(getTabSwitcher(), viewRecycler, successorIndex);
        State state = tabItem.getTag().getState();

        if (state == State.HIDDEN || state == State.STACKED_START) {
            Pair<Float, State> pair =
                    calculatePositionAndStateWhenStackedAtStart(count, swipedTabItem.getIndex(),
                            (TabItem) null);
            tabItem.getTag().setPosition(pair.first);
            tabItem.getTag().setState(pair.second);
            inflateOrRemoveView(tabItem);
        }
    }
}
项目:Hillffair17    文件:QuizQuestionActivity.java   
@Override
protected Void doInBackground(Void... voids) {

    for(int i=1;i>=0;i--){  // 1 minutes
        for(int j=59;j>=0;j--){ // 59 seconds

            if(isCancelled()){
                Log.v("cancel","called");
                return null;
            }

            //Log.v("timer",i+" mins "+j+" seconds");
            publishProgress(new Pair<String, String>(i+"",j+""));

            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }
    }

    return null;
}
项目:Hillffair17    文件:QuizQuestionActivity.java   
@Override
protected void onProgressUpdate(Pair<String, String>... values) {
    String str="";

    if(values[0].first.length()==1){
        str+="0";
    }
    str+=values[0].first+" mins ";

    if(values[0].second.length()==1){
        str+="0";
    }
    str+=values[0].second+" seconds ";

    timer_text.setText(str);

}
项目:NeoTerm    文件:PhoneTabSwitcherLayout.java   
/**
 * Inflates the view, which is used to visualize a specific tab.
 *
 * @param tabItem
 *         The tab item, which corresponds to the tab, whose view should be inflated, as an
 *         instance of the class {@link TabItem}. The tab item may not be null
 * @param listener
 *         The layout listener, which should be notified, when the view has been inflated, as an
 *         instance of the type {@link OnGlobalLayoutListener} or null, if no listener should be
 *         notified
 * @param params
 *         An array, which contains optional parameters, which should be passed to the view
 *         recycler, which is used to inflate the view, as an array of the type {@link Integer}.
 *         The array may not be null
 */
private void inflateView(@NonNull final TabItem tabItem,
                         @Nullable final OnGlobalLayoutListener listener,
                         @NonNull final Integer... params) {
    Pair<View, Boolean> pair = viewRecycler.inflate(tabItem, params);

    if (listener != null) {
        boolean inflated = pair.second;

        if (inflated) {
            View view = pair.first;
            view.getViewTreeObserver()
                    .addOnGlobalLayoutListener(new LayoutListenerWrapper(view, listener));
        } else {
            listener.onGlobalLayout();
        }
    }
}
项目:whatanime-android    文件:LogicAppImpl.java   
@Override
public void searchAnime(String encoded,
                        String filter,
                        final Callback<SearchAnimeResponse> callback) {
    network.searchWithPhoto(context,
            encoded,
            filter,
            new Callback<Pair<String, SearchDetail>>() {
                @Override
                public void done(Pair<String, SearchDetail> pair) {
                    SearchAnimeResponse response = new SearchAnimeResponse();
                    if (pair.first.isEmpty()) {
                        response.errorMessage = C.EMPTY;
                        response.searchDetail = pair.second;
                    } else {
                        response.errorMessage = pair.first;
                        response.searchDetail = null;
                    }
                    callback.done(response);
                }
            });
}
项目:AndroidOpen    文件:TransitionHelper.java   
/**
 * Create the transition participants required during a activity transition while
 * avoiding glitches with the system UI.
 *
 * @param activity The activity used as start for the transition.
 * @param includeStatusBar If false, the status bar will not be added as the transition
 *        participant.
 * @return All transition participants.
 */
public static Pair<View, String>[] createSafeTransitionParticipants(@NonNull Activity activity,
                                                      boolean includeStatusBar, @Nullable Pair... otherParticipants) {
    // Avoid system UI glitches as described here:
    // https://plus.google.com/+AlexLockwood/posts/RPtwZ5nNebb
    View decor = activity.getWindow().getDecorView();
    View statusBar = null;
    if (includeStatusBar) {
        statusBar = decor.findViewById(android.R.id.statusBarBackground);
    }
    View navBar = decor.findViewById(android.R.id.navigationBarBackground);

    // Create pair of transition participants.
    List<Pair> participants = new ArrayList<>(3);
    addNonNullViewToTransitionParticipants(statusBar, participants);
    addNonNullViewToTransitionParticipants(navBar, participants);
    // only add transition participants if there's at least one none-null element
    if (otherParticipants != null && !(otherParticipants.length == 1
            && otherParticipants[0] == null)) {
        participants.addAll(Arrays.asList(otherParticipants));
    }
    return participants.toArray(new Pair[participants.size()]);
}
项目:AndiCar    文件:DBAdapter.java   
@Nullable
public ArrayList<Pair<Long, String>> getFuelTypesForCar(long carID) {
    ArrayList<Pair<Long, String>> retVal = null;
    String selectSql;
    Cursor selectCursor;
    selectSql = "SELECT " + DBAdapter.COL_NAME_GEN_ROWID + ", " + DBAdapter.COL_NAME_GEN_NAME +
            " FROM " + TABLE_NAME_EXPENSECATEGORY +
                " WHERE EXISTS" +
                    " (SELECT * " +
                        "FROM " + DBAdapter.TABLE_NAME_REFUEL +
                        " WHERE " +
                                sqlConcatTableColumn(DBAdapter.TABLE_NAME_REFUEL, DBAdapter.COL_NAME_REFUEL__CAR_ID) +
                                    " = " + carID +
            " AND " + sqlConcatTableColumn(DBAdapter.TABLE_NAME_REFUEL, DBAdapter.COL_NAME_REFUEL__EXPENSECATEGORY_ID) +
            " = " + sqlConcatTableColumn(DBAdapter.TABLE_NAME_EXPENSECATEGORY, DBAdapter.COL_NAME_GEN_ROWID) + ") ";

    selectCursor = execSelectSql(selectSql, null);
    if(selectCursor.getCount() > 0){
        retVal = new ArrayList<>();
        while (selectCursor.moveToNext())
            { retVal.add(new Pair<>(selectCursor.getLong(0), selectCursor.getString(1))); }
    }

    selectCursor.close();
    return retVal;
}
项目:DailyStudy    文件:ViewerActivity.java   
public static void launch(AppCompatActivity activity, View transitionView, int resId) {
//        Intent intent = new Intent(activity, ViewerActivity.class);
//
//
//        ActivityOptionsCompat options = ActivityOptionsCompat
//                .makeSceneTransitionAnimation(activity, transitionView, "image");
//
//        ActivityCompat.startActivity(activity, intent, options.toBundle());


        Pair squareParticipant = new Pair<>(transitionView, ViewCompat.getTransitionName(transitionView));
        ActivityOptionsCompat transitionActivityOptions =
                ActivityOptionsCompat.makeSceneTransitionAnimation(
                        activity, squareParticipant);
        Intent intent = new Intent(
                activity, ViewerActivity.class);
        intent.putExtra("resId", resId);
        activity.startActivity(intent, transitionActivityOptions.toBundle());
    }
项目:Hands-On-Android-UI-Development    文件:ClaimItemAdapter.java   
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);
            }
        }
    });
}
项目:MusicX-music-player    文件:BitmapPalette.java   
private void crossfadeTargetBackground(PaletteTarget target, Pair<View, Integer> t, int newColor) {

        final Drawable oldColor = t.first.getBackground();
        final Drawable[] drawables = new Drawable[2];

        drawables[0] = oldColor != null ? oldColor : new ColorDrawable(t.first.getSolidColor());
        drawables[1] = new ColorDrawable(newColor);
        TransitionDrawable transitionDrawable = new TransitionDrawable(drawables);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            t.first.setBackground(transitionDrawable);
        } else {
            //noinspection deprecation
            t.first.setBackgroundDrawable(transitionDrawable);
        }
        transitionDrawable.startTransition(target.targetCrossfadeSpeed);
    }
项目:ConnectU    文件:ProfesoresActivity.java   
@Override
public void onItemClick(int item, ProfesoresAdapter.ViewHolder view) {

    View imageView = view.profile;
    Intent intent = new Intent(ProfesoresActivity.this, ProfesoresViewActivity.class);
    Gson gson = new Gson();
    intent.putExtra("JDATA", gson.toJson(teachers.get(item)));
    overridePendingTransition(R.anim.fade_in,R.anim.fade_out);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Pair<View, String> pair1 = Pair.create(imageView, getString(R.string.activity_profesores_image_trans));
        ActivityOptionsCompat options = ActivityOptionsCompat.
                makeSceneTransitionAnimation(ProfesoresActivity.this, pair1);
        startActivity(intent, options.toBundle());
    }
    else {
        startActivity(intent);
    }

}
项目:Hands-On-Android-UI-Development    文件:AllowanceOverviewPresenter.java   
Pair<Date, Date> getToday() {
    final GregorianCalendar today = new GregorianCalendar();
    today.set(Calendar.HOUR_OF_DAY, today.getActualMaximum(Calendar.HOUR_OF_DAY));
    today.set(Calendar.MINUTE, today.getActualMaximum(Calendar.MINUTE));
    today.set(Calendar.SECOND, today.getActualMaximum(Calendar.SECOND));
    today.set(Calendar.MILLISECOND, today.getActualMaximum(Calendar.MILLISECOND));

    final Date end = today.getTime();
    today.add(Calendar.DATE, -1);
    today.set(Calendar.HOUR_OF_DAY, 0);
    today.set(Calendar.MINUTE, 0);
    today.set(Calendar.SECOND, 0);
    today.set(Calendar.MILLISECOND, 0);

    return new Pair<>(today.getTime(), end);
}
项目:Hands-On-Android-UI-Development    文件:AllowanceOverviewPresenter.java   
Pair<Date, Date> getThisWeek() {
    final GregorianCalendar today = new GregorianCalendar();
    today.set(Calendar.HOUR_OF_DAY, today.getActualMaximum(Calendar.HOUR_OF_DAY));
    today.set(Calendar.MINUTE, today.getActualMaximum(Calendar.MINUTE));
    today.set(Calendar.SECOND, today.getActualMaximum(Calendar.SECOND));
    today.set(Calendar.MILLISECOND, today.getActualMaximum(Calendar.MILLISECOND));

    final Date end = today.getTime();
    today.add(Calendar.DATE, -(today.get(Calendar.DAY_OF_WEEK) - Calendar.SUNDAY));

    today.set(Calendar.HOUR_OF_DAY, 0);
    today.set(Calendar.MINUTE, 0);
    today.set(Calendar.SECOND, 0);
    today.set(Calendar.MILLISECOND, 0);

    return new Pair<>(today.getTime(), end);
}
项目:Hands-On-Android-UI-Development    文件:AllowanceOverviewPresenter.java   
Pair<Date, Date> getToday() {
    final GregorianCalendar today = new GregorianCalendar();
    today.set(Calendar.HOUR_OF_DAY, today.getActualMaximum(Calendar.HOUR_OF_DAY));
    today.set(Calendar.MINUTE, today.getActualMaximum(Calendar.MINUTE));
    today.set(Calendar.SECOND, today.getActualMaximum(Calendar.SECOND));
    today.set(Calendar.MILLISECOND, today.getActualMaximum(Calendar.MILLISECOND));

    final Date end = today.getTime();
    today.add(Calendar.DATE, -1);
    today.set(Calendar.HOUR_OF_DAY, 0);
    today.set(Calendar.MINUTE, 0);
    today.set(Calendar.SECOND, 0);
    today.set(Calendar.MILLISECOND, 0);

    return new Pair<>(today.getTime(), end);
}
项目:Hands-On-Android-UI-Development    文件:AllowanceOverviewPresenter.java   
Pair<Date, Date> getToday() {
    final GregorianCalendar today = new GregorianCalendar();
    today.set(Calendar.HOUR_OF_DAY, today.getActualMaximum(Calendar.HOUR_OF_DAY));
    today.set(Calendar.MINUTE, today.getActualMaximum(Calendar.MINUTE));
    today.set(Calendar.SECOND, today.getActualMaximum(Calendar.SECOND));
    today.set(Calendar.MILLISECOND, today.getActualMaximum(Calendar.MILLISECOND));

    final Date end = today.getTime();
    today.add(Calendar.DATE, -1);
    today.set(Calendar.HOUR_OF_DAY, 0);
    today.set(Calendar.MINUTE, 0);
    today.set(Calendar.SECOND, 0);
    today.set(Calendar.MILLISECOND, 0);

    return new Pair<>(today.getTime(), end);
}
项目:eternity    文件:ChatPresenter.java   
private void initMessages(View view) {
  Disposable disposable = messages.getAll()
      .doOnNext(reporting)
      .doOnNext(indexer)
      .subscribe(message -> {
        view.add(new Pair<>(message, storage.get(message.uuid())));
        view.collapseActions();
        view.scrollToTop();
      }, new AbstractViewError<>(view));

  disposables.add(disposable);
}
项目:GitHub    文件:BaseMailsFragment.java   
@Override public void onMailClicked(MailsAdapterHolders.MailViewHolder vh, Mail mail) {

    ActivityOptionsCompat options =
        ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(),
            Pair.create((View) vh.senderPic, getString(R.string.shared_mail_sender_pic)),
            Pair.create((View) vh.subject, getString(R.string.shared_mail_subject)),
            Pair.create((View) vh.date, getString(R.string.shared_mail_date)),
            Pair.create((View) vh.star, getString(R.string.shared_mail_star)),
            Pair.create(getActivity().findViewById(R.id.toolbar),
                getString(R.string.shared_mail_toolbar)));

    intentStarter.showMailDetails(getActivity(), mail, options.toBundle());
  }
项目:Hands-On-Android-UI-Development    文件:AllowanceOverviewPresenter.java   
public SpendingStats onBackground(final List<ClaimItem> items) {
    final Pair<Date, Date> today = getToday();
    final Pair<Date, Date> thisWeek = getThisWeek();

    double spentTotal = 0;
    double spentToday = 0;
    double spentThisWeek = 0;

    for (int i = 0; i < items.size(); i++) {
        final ClaimItem item = items.get(i);

        spentTotal += item.amount;

        if (item.getTimestamp().compareTo(thisWeek.first) >= 0
                && item.getTimestamp().compareTo(thisWeek.second) <= 0) {

            spentThisWeek += item.amount;
        }

        if (item.getTimestamp().compareTo(today.first) >= 0
                && item.getTimestamp().compareTo(today.second) <= 0) {

            spentToday += item.amount;
        }
    }

    // for stats we round everything to integers
    return new SpendingStats(
            (int) spentTotal,
            (int) spentToday,
            (int) spentThisWeek
    );
}
项目:AmenEye    文件:TecNewsFragment.java   
@Override
public void onItemClick(int position, BaseItem data, View view) {
    //跳转到其他界面
    NewsBean topNews = (NewsBean) data.getData();
    Bundle bundle = new Bundle();
    Intent intent = new Intent(TecNewsFragment.this.getActivity(), TopNewsInfoActivity.class);
    bundle.putString(Constants.BUNDLE_KEY_TITLE, topNews.getTitle());
    bundle.putString(Constants.BUNDLE_KEY_ID, topNews.getDocid());
    bundle.putString(Constants.BUNDLE_KEY_IMG_URL, topNews.getImgsrc());
    intent.putExtras(bundle);
    String transitionName = getString(R.string.top_news_img);
    Pair pairImg = new Pair<>(view.findViewById(R.id.news_image), transitionName);
    ActivityOptionsCompat transitionActivityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(), pairImg);
    startActivity(intent, transitionActivityOptions.toBundle());
}
项目:RxShell    文件:RxCmdShell.java   
/**
 * @see #shellEnvironment(String, String)
 */
public Builder shellEnvironment(Collection<Pair<String, String>> vars) {
    for (Pair<String, String> pair : vars) {
        shellEnvironment(pair.first, pair.second);
    }
    return this;
}
项目:ChromeLikeTabSwitcher    文件:PhoneTabSwitcherLayout.java   
@Nullable
@Override
protected final Pair<Integer, Float> onDetachLayout(final boolean tabsOnly) {
    Pair<Integer, Float> result = null;

    if (getTabSwitcher().isSwitcherShown() && getFirstVisibleIndex() != -1) {
        TabItem tabItem =
                TabItem.create(getModel(), getTabViewRecycler(), getFirstVisibleIndex());
        Tag tag = tabItem.getTag();

        if (tag.getState() != State.HIDDEN) {
            float position = tag.getPosition();
            float draggingAxisSize =
                    getArithmetics().getTabContainerSize(Axis.DRAGGING_AXIS, false);
            float orthogonalAxisSize =
                    getArithmetics().getTabContainerSize(Axis.ORTHOGONAL_AXIS, false);
            result = Pair.create(getFirstVisibleIndex(),
                    position / Math.max(draggingAxisSize, orthogonalAxisSize));
        }
    }

    contentViewRecycler.removeAll();
    contentViewRecycler.clearCache();
    tabRecyclerAdapter.clearCachedPreviews();
    detachEmptyView();

    if (!tabsOnly) {
        getModel().removeListener(tabRecyclerAdapter);
    }

    return result;
}