use of net.imglib2.util.Pair in project Tusky by tuskyapp.
the class TimelineFragment method onFavourite.
@Override
public void onFavourite(final boolean favourite, final int position) {
final Status status = statuses.get(position).getAsRight();
timelineCases.favouriteWithCallback(status, favourite, new Callback<Status>() {
@Override
public void onResponse(@NonNull Call<Status> call, @NonNull Response<Status> response) {
if (response.isSuccessful()) {
status.setFavourited(favourite);
if (status.getReblog() != null) {
status.getReblog().setFavourited(favourite);
}
Pair<StatusViewData.Concrete, Integer> actual = findStatusAndPosition(position, status);
if (actual == null)
return;
StatusViewData newViewData = new StatusViewData.Builder(actual.first).setFavourited(favourite).createStatusViewData();
statuses.setPairedItem(actual.second, newViewData);
adapter.changeItem(actual.second, newViewData, false);
}
}
@Override
public void onFailure(@NonNull Call<Status> call, @NonNull Throwable t) {
Log.d(TAG, "Failed to favourite status " + status.getId(), t);
}
});
}
use of net.imglib2.util.Pair in project android_packages_apps_Dialer by MoKee.
the class DefaultVoicemailNotifier method getNotificationInfo.
/**
* Determines which ringtone Uri and Notification defaults to use when updating the notification
* for the given call.
*/
private Pair<Uri, Integer> getNotificationInfo(@Nullable NewCall callToNotify) {
Log.v(TAG, "getNotificationInfo");
if (callToNotify == null) {
Log.i(TAG, "callToNotify == null");
return new Pair<>(null, 0);
}
PhoneAccountHandle accountHandle = null;
if (callToNotify.accountComponentName == null || callToNotify.accountId == null) {
Log.v(TAG, "accountComponentName == null || callToNotify.accountId == null");
accountHandle = TelecomUtil.getDefaultOutgoingPhoneAccount(mContext, PhoneAccount.SCHEME_TEL);
if (accountHandle == null) {
Log.i(TAG, "No default phone account found, using default notification ringtone");
return new Pair<>(null, Notification.DEFAULT_ALL);
}
} else {
accountHandle = new PhoneAccountHandle(ComponentName.unflattenFromString(callToNotify.accountComponentName), callToNotify.accountId);
}
if (accountHandle.getComponentName() != null) {
Log.v(TAG, "PhoneAccountHandle.ComponentInfo:" + accountHandle.getComponentName());
} else {
Log.i(TAG, "PhoneAccountHandle.ComponentInfo: null");
}
return new Pair<>(TelephonyManagerCompat.getVoicemailRingtoneUri(getTelephonyManager(), accountHandle), getNotificationDefaults(accountHandle));
}
use of net.imglib2.util.Pair in project WeatherApp by Cilestal.
the class WeatherRepositoryImpl method getCurrentCitiesWeather.
@Override
public Observable<Pair<String, HourlyForecast>> getCurrentCitiesWeather(Iterable<String> locationKeys, @Nullable String language, @Nullable Boolean details) {
// записываем все Observable в List
List<Observable<Pair<String, HourlyForecast>>> lst = new ArrayList<>();
for (final String locationKey : locationKeys) {
// сохраняем результат в виде ключ-значение
Observable<Pair<String, HourlyForecast>> observable = mService.getOneHourForecast(locationKey, language, details).map(response -> {
HourlyForecast hourlyForecast = response.body().get(0);
return new Pair<>(locationKey, hourlyForecast);
});
lst.add(observable);
}
return Observable.merge(lst);
}
use of net.imglib2.util.Pair in project mvpanimation by androidMVP.
the class ExpandingAdapter method startActivity.
private void startActivity(Context context, Intent intent, ViewHolder viewHolder) {
final Pair<View, String>[] pairs = createSafeTransitionParticipants((Activity) context, false, new Pair<>(viewHolder.avatar1, "avatar1"), new Pair<>(viewHolder.avatar2, "avatar2"), new Pair<>(viewHolder.mImageView, "image"));
ActivityOptionsCompat transitionActivityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation((Activity) context, pairs);
context.startActivity(intent, transitionActivityOptions.toBundle());
}
use of net.imglib2.util.Pair in project imagej-ops by imagej.
the class DefaultConvexHull3D method computeMinMax.
/**
* Finds for each dimension the min and max vertex.
*
* @return min and max vertices of each dimension
*/
private Pair<Double, Vertex[]> computeMinMax(final Set<Vertex> vertices) {
Vertex[] minMax = new Vertex[6];
double maxX, maxY, maxZ;
double minX, minY, minZ;
Iterator<Vertex> it = vertices.iterator();
Vertex initPoint = it.next();
for (int i = 0; i < minMax.length; i++) {
minMax[i] = initPoint;
}
minX = maxX = initPoint.getX();
minY = maxY = initPoint.getY();
minZ = maxZ = initPoint.getZ();
while (it.hasNext()) {
Vertex v = it.next();
if (v.getX() > maxX) {
maxX = v.getX();
minMax[3] = v;
} else if (v.getX() < minX) {
minX = v.getX();
minMax[0] = v;
}
if (v.getY() > maxY) {
maxY = v.getY();
minMax[4] = v;
} else if (v.getY() < minY) {
minY = v.getY();
minMax[2] = v;
}
if (v.getZ() > maxZ) {
maxZ = v.getZ();
minMax[5] = v;
} else if (v.getZ() < minZ) {
minZ = v.getZ();
minMax[3] = v;
}
}
// This epsilon formula comes from John Lloyd's quickhull
// implementation http://www.cs.ubc.ca/~lloyd/java/quickhull3d.html
final double epsilon = 3 * DOUBLE_PREC * (Math.max(Math.abs(maxX), Math.abs(minX)) + Math.max(Math.abs(maxY), Math.abs(minY)) + Math.max(Math.abs(maxZ), Math.abs(minZ)));
return new ValuePair<>(epsilon, minMax);
}
Aggregations