Search in sources :

Example 76 with Pair

use of net.imglib2.util.Pair in project LookLook by xinghongfei.

the class Help method createSafeTransitionParticipants.

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()]);
}
Also used : ArrayList(java.util.ArrayList) View(android.view.View) Pair(android.support.v4.util.Pair)

Example 77 with Pair

use of net.imglib2.util.Pair in project LookLook by xinghongfei.

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()]);
}
Also used : ArrayList(java.util.ArrayList) View(android.view.View) Pair(android.support.v4.util.Pair)

Example 78 with Pair

use of net.imglib2.util.Pair in project GDSC-SMLM by aherbert.

the class Gaussian2DFunction method computeValuesAndJacobian.

/*
	 * (non-Javadoc)
	 * 
	 * @see gdsc.smlm.function.ExtendedNonLinearFunction#computeValuesAndJacobian(double[])
	 */
public Pair<double[], double[][]> computeValuesAndJacobian(double[] variables) {
    initialise1(variables);
    final int n = size();
    final double[][] jacobian = new double[n][];
    final double[] values = new double[n];
    forEach(new Gradient1Procedure() {

        int i = 0;

        public void execute(double value, double[] dy_da) {
            values[i] = value;
            jacobian[i++] = dy_da.clone();
        }
    });
    return new Pair<double[], double[][]>(values, jacobian);
}
Also used : Gradient1Procedure(gdsc.smlm.function.Gradient1Procedure) Pair(org.apache.commons.math3.util.Pair)

Example 79 with Pair

use of net.imglib2.util.Pair in project Rocket.Chat.Android by RocketChat.

the class RoomPresenter method sendMessage.

@Override
public void sendMessage(String messageText) {
    final Disposable subscription = getRoomUserPair().flatMap(pair -> messageInteractor.send(pair.first, pair.second, messageText)).subscribeOn(AndroidSchedulers.from(BackgroundLooper.get())).observeOn(AndroidSchedulers.mainThread()).subscribe(success -> {
        if (success) {
            view.onMessageSendSuccessfully();
        }
    }, Logger::report);
    addSubscription(subscription);
}
Also used : Disposable(io.reactivex.disposables.Disposable) User(chat.rocket.core.models.User) Settings(chat.rocket.core.models.Settings) Optional(com.fernandocejas.arrow.optional.Optional) UserRepository(chat.rocket.core.repositories.UserRepository) RoomRepository(chat.rocket.core.repositories.RoomRepository) Logger(chat.rocket.android.helper.Logger) NonNull(android.support.annotation.NonNull) Single(io.reactivex.Single) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) LogIfError(chat.rocket.android.helper.LogIfError) MessageInteractor(chat.rocket.core.interactors.MessageInteractor) Message(chat.rocket.core.models.Message) MethodCallHelper(chat.rocket.android.api.MethodCallHelper) Disposable(io.reactivex.disposables.Disposable) ConnectivityManagerApi(chat.rocket.android.service.ConnectivityManagerApi) Pair(android.support.v4.util.Pair) Room(chat.rocket.core.models.Room) SyncState(chat.rocket.core.SyncState) Nullable(android.support.annotation.Nullable) BackgroundLooper(chat.rocket.android.BackgroundLooper) BasePresenter(chat.rocket.android.shared.BasePresenter) AbsoluteUrlHelper(chat.rocket.android.helper.AbsoluteUrlHelper) Logger(chat.rocket.android.helper.Logger)

Example 80 with Pair

use of net.imglib2.util.Pair in project Rocket.Chat.Android by RocketChat.

the class MainPresenter method subscribeToUnreadCount.

private void subscribeToUnreadCount() {
    final Disposable subscription = Flowable.combineLatest(roomInteractor.getTotalUnreadRoomsCount(), roomInteractor.getTotalUnreadMentionsCount(), (Pair::new)).subscribeOn(AndroidSchedulers.from(BackgroundLooper.get())).observeOn(AndroidSchedulers.mainThread()).subscribe(pair -> view.showUnreadCount(pair.first, pair.second), Logger::report);
    addSubscription(subscription);
}
Also used : Disposable(io.reactivex.disposables.Disposable) Logger(chat.rocket.android.helper.Logger) Pair(android.support.v4.util.Pair)

Aggregations

Pair (android.support.v4.util.Pair)79 ArrayList (java.util.ArrayList)49 Pair (org.apache.commons.math3.util.Pair)38 View (android.view.View)28 List (java.util.List)22 ActivityOptionsCompat (android.support.v4.app.ActivityOptionsCompat)19 Intent (android.content.Intent)18 TextView (android.widget.TextView)15 HashMap (java.util.HashMap)15 Map (java.util.Map)15 Arrays (java.util.Arrays)13 Test (org.junit.Test)12 ImageView (android.widget.ImageView)11 RecyclerView (android.support.v7.widget.RecyclerView)9 Collections (java.util.Collections)9 Person (org.drools.modelcompiler.domain.Person)9 KieSession (org.kie.api.runtime.KieSession)9 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)8 Assertions (org.assertj.core.api.Assertions)7 Cursor (android.database.Cursor)4