Example usage for android.support.v4.util Pair create

List of usage examples for android.support.v4.util Pair create

Introduction

In this page you can find the example usage for android.support.v4.util Pair create.

Prototype

public static <A, B> Pair<A, B> create(A a, B b) 

Source Link

Usage

From source file:Main.java

private static Bundle getOptionsBundle(final Activity activity, final View[] sharedElements) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        int len = sharedElements.length;
        @SuppressWarnings("unchecked")
        Pair<View, String>[] pairs = new Pair[len];
        for (int i = 0; i < len; i++) {
            pairs[i] = Pair.create(sharedElements[i], sharedElements[i].getTransitionName());
        }//  w  ww .j a  va  2s  .c om
        return ActivityOptionsCompat.makeSceneTransitionAnimation(activity, pairs).toBundle();
    }
    return ActivityOptionsCompat.makeSceneTransitionAnimation(activity, null, null).toBundle();
}

From source file:Main.java

private static Bundle getOptionsBundle(final Activity activity, final View[] sharedElements) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
        return null;
    if (sharedElements == null)
        return null;
    int len = sharedElements.length;
    if (len <= 0)
        return null;
    @SuppressWarnings("unchecked")
    Pair<View, String>[] pairs = new Pair[len];
    for (int i = 0; i < len; i++) {
        pairs[i] = Pair.create(sharedElements[i], sharedElements[i].getTransitionName());
    }//from ww  w.  ja  v a2 s.  c  o  m
    return ActivityOptionsCompat.makeSceneTransitionAnimation(activity, pairs).toBundle();
}

From source file:com.google.android.apps.forscience.whistlepunk.TransitionUtils.java

public static Pair<View, String>[] getTransitionPairs(Activity activity, View v, String transitionName) {
    ArrayList<Pair<View, String>> list = new ArrayList<>();
    list.add(Pair.create(v, transitionName));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        View statusBar = activity.findViewById(android.R.id.statusBarBackground);
        if (statusBar != null) {
            list.add(Pair.create(statusBar, Window.STATUS_BAR_BACKGROUND_TRANSITION_NAME));
        }/*w  w w . java  2 s  .com*/
        View navigationBar = activity.findViewById(android.R.id.navigationBarBackground);
        if (navigationBar != null) {
            list.add(Pair.create(navigationBar, Window.NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME));
        }
    }
    return list.toArray(new Pair[list.size()]);
}

From source file:io.github.guaidaodl.pomodorotimer.utils.DateUtils.java

public static Pair<Long, Long> getTodayTime() {
    Calendar calendar = getTodayStartCalendar();

    long startMilliSecondOfToday = calendar.getTimeInMillis();
    long endMilliSecondOfToday = startMilliSecondOfToday + 24L * 60L * 60L * 1000L;
    return Pair.create(startMilliSecondOfToday, endMilliSecondOfToday);
}

From source file:io.github.guaidaodl.pomodorotimer.utils.DateUtils.java

/**
 * ?. ./*from  w ww  .  j av  a 2s  .c  om*/
 *  Calendar 00:00:00;
 */
@VisibleForTesting
static Pair<Long, Long> getWeekTime(Calendar calendar) {
    int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
    calendar.add(Calendar.DAY_OF_MONTH, -dayOfWeek + 1);

    long startMilliSecondOfToday = calendar.getTimeInMillis();
    long endMilliSecondOfToday = startMilliSecondOfToday + 7L * 24L * 60L * 60L * 1000L;

    return Pair.create(startMilliSecondOfToday, endMilliSecondOfToday);
}

From source file:com.pileproject.drive.util.broadcast.RxBroadcastReceiver.java

/**
 * Creates {@link Observable} which will produce a stream
 * when the events which are specified by {@link IntentFilter} have been issued.
 *
 * @param context a {@link Context} of the application
 * @param intentFilter an intent filter that will be passed to
 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)}
 * @return an {@link Observable}/*from  ww w.  ja  v a  2s  . co  m*/
 */
public static Observable<Pair<Context, Intent>> create(final Context context, final IntentFilter intentFilter) {
    return Observable.create(new rx.Observable.OnSubscribe<Pair<Context, Intent>>() {

        @Override
        public void call(final Subscriber<? super Pair<Context, Intent>> subscriber) {
            final BroadcastReceiver receiver = new BroadcastReceiver() {

                @Override
                public void onReceive(Context context, Intent intent) {
                    subscriber.onNext(Pair.create(context, intent));
                }
            };

            context.registerReceiver(receiver, intentFilter);

            subscriber.add(Subscriptions.create(new Action0() {

                @Override
                public void call() {
                    // this line is called when the subscribers un-subscribe this Observable
                    context.unregisterReceiver(receiver);
                }
            }));

        }
    });
}

From source file:org.fs.todo.commons.modules.ProviderActivityModule.java

@Provides
@ForActivity//  ww  w  .ja va 2 s .  c  o m
public List<Pair<Integer, String>> provideTaskStateDataSet(Context context) {
    final List<Pair<Integer, String>> dataSet = new ArrayList<>();
    dataSet.add(Pair.create(DisplayOptions.ALL, context.getString(R.string.str_all_title)));
    dataSet.add(Pair.create(DisplayOptions.ACTIVE, context.getString(R.string.str_active_title)));
    dataSet.add(Pair.create(DisplayOptions.INACTIVE, context.getString(R.string.str_inactive_title)));
    return dataSet;
}

From source file:org.mariotaku.twidere.util.RegexMatcher.java

public void addPattern(String pattern, int code) {
    patternsList.add(Pair.create(Pattern.compile(pattern), code));
}

From source file:codingpractice.renard314.com.products.ui.util.PaletteExtractor.java

@Override
public Bitmap transform(Bitmap source) {
    Pair<Integer, Integer> colors;
    synchronized (mColorCache) {
        Log.i(TAG, "extract color from " + mBitmapName + " cache hit.");
        colors = mColorCache.get(mBitmapName);
    }//  w ww  .  j  ava 2s  .  com
    if (colors == null) {
        final Palette palette = Palette.generate(source);
        if (palette.getMutedSwatch() != null) {
            colors = Pair.create(palette.getMutedSwatch().getRgb(),
                    palette.getMutedSwatch().getTitleTextColor());
            synchronized (mColorCache) {
                mColorCache.put(mBitmapName, colors);
            }
            Log.i(TAG, "extract color from " + mBitmapName + " rgb = "
                    + String.format("%06X", colors.first & 0xFFFFFF));
        } else {
            Log.i(TAG, "extract color from " + mBitmapName + " failed.");
        }

    }
    return source;

}

From source file:io.github.guaidaodl.pomodorotimer.utils.DateUtils.java

/**
 * ./*from ww w .j  a  v a  2 s.  c o m*/
 *
 * Calendar  00:00:00
 */
@VisibleForTesting
static Pair<Long, Long> getMonthTime(Calendar calendar) {
    calendar.set(Calendar.DAY_OF_MONTH, 1);

    int dayCount = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
    long startMilliSecondOfToday = calendar.getTimeInMillis();
    long endMilliSecondOfToday = startMilliSecondOfToday + dayCount * 24L * 60L * 60L * 1000L;

    return Pair.create(startMilliSecondOfToday, endMilliSecondOfToday);
}