use of org.apache.commons.math3.util.Pair in project cassandra by apache.
the class SampledOpDistributionFactory method get.
public OpDistribution get(boolean isWarmup, MeasurementSink sink) {
PartitionGenerator generator = newGenerator();
List<Pair<Operation, Double>> operations = new ArrayList<>();
for (Map.Entry<T, Double> ratio : ratios.entrySet()) {
List<? extends Operation> ops = get(new Timer(ratio.getKey().toString(), sink), generator, ratio.getKey(), isWarmup);
for (Operation op : ops) operations.add(new Pair<>(op, ratio.getValue() / ops.size()));
}
return new SampledOpDistribution(new EnumeratedDistribution<>(operations), clustering.get());
}
use of org.apache.commons.math3.util.Pair in project Material-Animations by lgvalle.
the class BaseDetailActivity method transitionTo.
@SuppressWarnings("unchecked")
void transitionTo(Intent i) {
final Pair<View, String>[] pairs = TransitionHelper.createSafeTransitionParticipants(this, true);
ActivityOptionsCompat transitionActivityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(this, pairs);
startActivity(i, transitionActivityOptions.toBundle());
}
use of org.apache.commons.math3.util.Pair in project Material-Animations by lgvalle.
the class TransitionHelper method createSafeTransitionParticipants.
/**
* 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()]);
}
use of org.apache.commons.math3.util.Pair in project android-topeka by googlesamples.
the class CategorySelectionFragment method startQuizActivityWithTransition.
private void startQuizActivityWithTransition(Activity activity, View toolbar, Category category) {
final Pair[] pairs = TransitionHelper.createSafeTransitionParticipants(activity, false, new Pair<>(toolbar, activity.getString(R.string.transition_toolbar)));
@SuppressWarnings("unchecked") ActivityOptionsCompat sceneTransitionAnimation = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, pairs);
// Start the activity with the participants, animating from one to the other.
final Bundle transitionBundle = sceneTransitionAnimation.toBundle();
Intent startIntent = QuizActivity.getStartIntent(activity, category);
ActivityCompat.startActivityForResult(activity, startIntent, REQUEST_CATEGORY, transitionBundle);
}
use of org.apache.commons.math3.util.Pair in project android-page-transition by xmuSistone.
the class CommonFragment method gotoDetail.
@Override
public void gotoDetail() {
Activity activity = (Activity) getContext();
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, new Pair(imageView, DetailActivity.IMAGE_TRANSITION_NAME), new Pair(address1, DetailActivity.ADDRESS1_TRANSITION_NAME), new Pair(address2, DetailActivity.ADDRESS2_TRANSITION_NAME), new Pair(address3, DetailActivity.ADDRESS3_TRANSITION_NAME), new Pair(address4, DetailActivity.ADDRESS4_TRANSITION_NAME), new Pair(address5, DetailActivity.ADDRESS5_TRANSITION_NAME), new Pair(ratingBar, DetailActivity.RATINGBAR_TRANSITION_NAME), new Pair(head1, DetailActivity.HEAD1_TRANSITION_NAME), new Pair(head2, DetailActivity.HEAD2_TRANSITION_NAME), new Pair(head3, DetailActivity.HEAD3_TRANSITION_NAME), new Pair(head4, DetailActivity.HEAD4_TRANSITION_NAME));
Intent intent = new Intent(activity, DetailActivity.class);
intent.putExtra(DetailActivity.EXTRA_IMAGE_URL, imageUrl);
ActivityCompat.startActivity(activity, intent, options.toBundle());
}
Aggregations