Search in sources :

Example 21 with Pair

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);
        }
    });
}
Also used : Status(com.keylesspalace.tusky.entity.Status) StatusViewData(com.keylesspalace.tusky.viewdata.StatusViewData) Pair(android.support.v4.util.Pair)

Example 22 with Pair

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));
}
Also used : PhoneAccountHandle(android.telecom.PhoneAccountHandle) Pair(android.support.v4.util.Pair)

Example 23 with Pair

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);
}
Also used : HourlyForecast(ua.dp.michaellang.weather.data.entity.Forecast.HourlyForecast) ArrayList(java.util.ArrayList) Observable(io.reactivex.Observable) Pair(android.support.v4.util.Pair)

Example 24 with Pair

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());
}
Also used : ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat) Pair(android.support.v4.util.Pair)

Example 25 with Pair

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);
}
Also used : Vertex(net.imagej.ops.geom.geom3d.mesh.Vertex) ValuePair(net.imglib2.util.ValuePair)

Aggregations

Pair (android.support.v4.util.Pair)75 ArrayList (java.util.ArrayList)37 View (android.view.View)26 Pair (org.apache.commons.math3.util.Pair)25 ActivityOptionsCompat (android.support.v4.app.ActivityOptionsCompat)16 Intent (android.content.Intent)15 TextView (android.widget.TextView)14 List (java.util.List)12 ImageView (android.widget.ImageView)10 RecyclerView (android.support.v7.widget.RecyclerView)8 AlertDialog (android.support.v7.app.AlertDialog)7 ByteProcessor (ij.process.ByteProcessor)7 HashMap (java.util.HashMap)7 Map (java.util.Map)7 Pair (mpicbg.trakem2.util.Pair)7 NonNull (android.support.annotation.NonNull)6 OsmandSettings (net.osmand.plus.OsmandSettings)6 DialogInterface (android.content.DialogInterface)5 Transition (android.transition.Transition)4 RealLocalizable (net.imglib2.RealLocalizable)4