Search in sources :

Example 31 with Pair

use of mpicbg.trakem2.util.Pair in project Signal-Android by signalapp.

the class PagingMediaLoader method loadInBackground.

@Nullable
@Override
public Pair<Cursor, Integer> loadInBackground() {
    long threadId = DatabaseFactory.getThreadDatabase(getContext()).getThreadIdFor(recipient);
    Cursor cursor = DatabaseFactory.getMediaDatabase(getContext()).getGalleryMediaForThread(threadId);
    while (cursor != null && cursor.moveToNext()) {
        AttachmentId attachmentId = new AttachmentId(cursor.getLong(cursor.getColumnIndexOrThrow(AttachmentDatabase.ATTACHMENT_ID_ALIAS)), cursor.getLong(cursor.getColumnIndexOrThrow(AttachmentDatabase.UNIQUE_ID)));
        Uri attachmentUri = PartAuthority.getAttachmentDataUri(attachmentId);
        if (attachmentUri.equals(uri)) {
            return new Pair<>(cursor, leftIsRecent ? cursor.getPosition() : cursor.getCount() - 1 - cursor.getPosition());
        }
    }
    return null;
}
Also used : Cursor(android.database.Cursor) Uri(android.net.Uri) AttachmentId(org.thoughtcrime.securesms.attachments.AttachmentId) Pair(android.support.v4.util.Pair) Nullable(android.support.annotation.Nullable)

Example 32 with Pair

use of mpicbg.trakem2.util.Pair in project iobserve-analysis by research-iobserve.

the class BehaviorModelTable method toInstances.

/**
 * create an Instances object for clustering.
 *
 * @return instance
 */
public Instances toInstances() {
    final FastVector fastVector = new FastVector();
    // add transitions
    for (int i = 0; i < this.signatures.size(); i++) {
        for (int j = 0; j < this.signatures.size(); j++) {
            if (this.transitions[i][j] > AbstractBehaviorModelTable.TRANSITION_THRESHOLD) {
                final Attribute attribute = new Attribute(AbstractBehaviorModelTable.EDGE_INDICATOR + this.inverseSignatures[i] + AbstractBehaviorModelTable.EDGE_DIVIDER + this.inverseSignatures[j]);
                fastVector.addElement(attribute);
            } else {
                continue;
            }
        }
    }
    // add informations
    this.signatures.values().stream().forEach(pair -> Arrays.stream(pair.getSecond()).forEach(callInformation -> fastVector.addElement(new Attribute(AbstractBehaviorModelTable.INFORMATION_INDICATOR + this.inverseSignatures[pair.getFirst()] + AbstractBehaviorModelTable.INFORMATION_DIVIDER + callInformation.getSignature()))));
    // TODO name
    final Instances instances = new Instances("Test", fastVector, 0);
    final Instance instance = this.toInstance();
    instances.add(instance);
    return instances;
}
Also used : Arrays(java.util.Arrays) Logger(org.slf4j.Logger) FastVector(weka.core.FastVector) Pair(org.apache.commons.math3.util.Pair) SingleOrNoneCollector(org.iobserve.analysis.clustering.SingleOrNoneCollector) Instances(weka.core.Instances) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PayloadAwareEntryCallEvent(org.iobserve.stages.general.data.PayloadAwareEntryCallEvent) EntryCallEvent(org.iobserve.stages.general.data.EntryCallEvent) Instance(weka.core.Instance) List(java.util.List) Map(java.util.Map) Optional(java.util.Optional) Attribute(weka.core.Attribute) Instances(weka.core.Instances) FastVector(weka.core.FastVector) Attribute(weka.core.Attribute) Instance(weka.core.Instance)

Example 33 with Pair

use of mpicbg.trakem2.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 34 with Pair

use of mpicbg.trakem2.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 35 with Pair

use of mpicbg.trakem2.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)

Aggregations

Pair (android.support.v4.util.Pair)79 ArrayList (java.util.ArrayList)39 View (android.view.View)28 Pair (org.apache.commons.math3.util.Pair)20 ActivityOptionsCompat (android.support.v4.app.ActivityOptionsCompat)16 TextView (android.widget.TextView)15 Intent (android.content.Intent)14 List (java.util.List)13 ImageView (android.widget.ImageView)10 ByteProcessor (ij.process.ByteProcessor)9 RecyclerView (android.support.v7.widget.RecyclerView)8 HashMap (java.util.HashMap)8 Map (java.util.Map)8 AlertDialog (android.support.v7.app.AlertDialog)7 Pair (mpicbg.trakem2.util.Pair)7 NonNull (android.support.annotation.NonNull)6 Patch (ini.trakem2.display.Patch)6 OsmandSettings (net.osmand.plus.OsmandSettings)6 DialogInterface (android.content.DialogInterface)5 IOException (java.io.IOException)5