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;
}
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;
}
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));
}
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);
}
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());
}
Aggregations