use of androidx.core.util.Pair in project collect by opendatakit.
the class SelectMultiWidgetTest method whenChoicesHaveAudio_audioButtonUsesIndexAsClipID.
@Test
public void whenChoicesHaveAudio_audioButtonUsesIndexAsClipID() throws Exception {
formEntryPrompt = new MockFormEntryPromptBuilder().withIndex("i am index").withSelectChoices(asList(new SelectChoice("1", "1"), new SelectChoice("2", "2"))).withSpecialFormSelectChoiceText(asList(new Pair<>(FormEntryCaption.TEXT_FORM_AUDIO, REFERENCES.get(0).first), new Pair<>(FormEntryCaption.TEXT_FORM_AUDIO, REFERENCES.get(1).first))).build();
populateRecyclerView(getWidget());
verify(audioHelper).setAudio(any(AudioButton.class), eq(new Clip("i am index 0", REFERENCES.get(0).second)));
verify(audioHelper).setAudio(any(AudioButton.class), eq(new Clip("i am index 1", REFERENCES.get(1).second)));
}
use of androidx.core.util.Pair in project android by nextcloud.
the class MainApp method cleanOldEntries.
private static void cleanOldEntries(Clock clock) {
// previous versions of application created broken entries in the SyncedFolderProvider
// database, and this cleans all that and leaves 1 (newest) entry per synced folder
Context context = getAppContext();
AppPreferences preferences = AppPreferencesImpl.fromContext(context);
if (!preferences.isLegacyClean()) {
SyncedFolderProvider syncedFolderProvider = new SyncedFolderProvider(context.getContentResolver(), preferences, clock);
List<SyncedFolder> syncedFolderList = syncedFolderProvider.getSyncedFolders();
Map<Pair<String, String>, Long> syncedFolders = new HashMap<>();
ArrayList<Long> ids = new ArrayList<>();
for (SyncedFolder syncedFolder : syncedFolderList) {
Pair<String, String> checkPair = new Pair<>(syncedFolder.getAccount(), syncedFolder.getLocalPath());
if (syncedFolders.containsKey(checkPair)) {
if (syncedFolder.getId() > syncedFolders.get(checkPair)) {
syncedFolders.put(checkPair, syncedFolder.getId());
}
} else {
syncedFolders.put(checkPair, syncedFolder.getId());
}
}
ids.addAll(syncedFolders.values());
if (ids.size() > 0) {
int deletedCount = syncedFolderProvider.deleteSyncedFoldersNotInList(ids);
if (deletedCount > 0) {
preferences.setLegacyClean(true);
}
} else {
preferences.setLegacyClean(true);
}
}
}
use of androidx.core.util.Pair in project collect by opendatakit.
the class DownloadFormListTask method doInBackground.
@Override
protected Pair<List<ServerFormDetails>, FormSourceException> doInBackground(Void... values) {
if (webCredentialsUtils != null) {
setTemporaryCredentials();
}
List<ServerFormDetails> formList = null;
FormSourceException exception = null;
try {
formList = serverFormsDetailsFetcher.fetchFormDetails();
} catch (FormSourceException e) {
exception = e;
} finally {
if (webCredentialsUtils != null) {
clearTemporaryCredentials();
}
}
return new Pair<>(formList, exception);
}
use of androidx.core.util.Pair in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class PagerSlidingTabStrip method getIndicatorCoordinates.
public Pair<Float, Float> getIndicatorCoordinates() {
// default: line below current tab
View currentTab = mTabsContainer.getChildAt(mCurrentPosition);
float lineLeft = currentTab.getLeft();
float lineRight = currentTab.getRight();
// if there is an offset, start interpolating left and right coordinates between current and next tab
if (mCurrentPositionOffset > 0f && mCurrentPosition < mTabCount - 1) {
View nextTab = mTabsContainer.getChildAt(mCurrentPosition + 1);
final float nextTabLeft = nextTab.getLeft();
final float nextTabRight = nextTab.getRight();
lineLeft = (mCurrentPositionOffset * nextTabLeft + (1f - mCurrentPositionOffset) * lineLeft);
lineRight = (mCurrentPositionOffset * nextTabRight + (1f - mCurrentPositionOffset) * lineRight);
}
return new Pair<>(lineLeft, lineRight);
}
use of androidx.core.util.Pair in project SeriesGuide by UweTrottmann.
the class HexagonEpisodeSync method buildSgEpisodeUpdate.
@Nullable
private Pair<SgEpisode2UpdateByNumber, Long> buildSgEpisodeUpdate(Integer watchedFlag, Integer plays, Boolean isInCollection, DateTime updatedAt, int episodeNumber, int seasonNumber, long showId, Long lastWatchedMs) {
Integer watchedFlagOrNull = null;
Integer playsOrNull = null;
if (watchedFlag != null && watchedFlag != EpisodeFlags.UNWATCHED) {
// Watched or skipped.
watchedFlagOrNull = watchedFlag;
if (watchedFlag == EpisodeFlags.WATCHED) {
// Note: plays may be null for legacy data. Protect against invalid data.
if (plays != null && plays >= 1) {
playsOrNull = plays;
} else {
playsOrNull = 1;
}
}
// record last watched time by taking latest updatedAt of watched/skipped
if (updatedAt != null) {
long lastWatchedMsNew = updatedAt.getValue();
if (lastWatchedMs == null || lastWatchedMs < lastWatchedMsNew) {
lastWatchedMs = lastWatchedMsNew;
}
}
}
boolean inCollection = isInCollection != null && isInCollection;
if (watchedFlag == null && !inCollection) {
// skip if episode has no watched flag and is not in collection
return null;
}
return new Pair<>(new SgEpisode2UpdateByNumber(showId, episodeNumber, seasonNumber, watchedFlagOrNull, playsOrNull, isInCollection), lastWatchedMs);
}
Aggregations