Search in sources :

Example 26 with Pair

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)));
}
Also used : Clip(org.odk.collect.audioclips.Clip) SelectChoice(org.javarosa.core.model.SelectChoice) MockFormEntryPromptBuilder(org.odk.collect.android.support.MockFormEntryPromptBuilder) AudioButton(org.odk.collect.android.audio.AudioButton) Pair(androidx.core.util.Pair) GeneralSelectMultiWidgetTest(org.odk.collect.android.widgets.base.GeneralSelectMultiWidgetTest) Test(org.junit.Test)

Example 27 with Pair

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);
        }
    }
}
Also used : SSLContext(javax.net.ssl.SSLContext) Context(android.content.Context) HashMap(java.util.HashMap) AppPreferences(com.nextcloud.client.preferences.AppPreferences) ArrayList(java.util.ArrayList) SyncedFolderProvider(com.owncloud.android.datamodel.SyncedFolderProvider) StoragePoint(com.owncloud.android.datastorage.StoragePoint) SuppressLint(android.annotation.SuppressLint) SyncedFolder(com.owncloud.android.datamodel.SyncedFolder) Pair(androidx.core.util.Pair)

Example 28 with Pair

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);
}
Also used : FormSourceException(org.odk.collect.forms.FormSourceException) ServerFormDetails(org.odk.collect.android.formmanagement.ServerFormDetails) Pair(androidx.core.util.Pair)

Example 29 with Pair

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);
}
Also used : HorizontalScrollView(android.widget.HorizontalScrollView) View(android.view.View) TextView(android.widget.TextView) Pair(androidx.core.util.Pair)

Example 30 with Pair

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);
}
Also used : SgEpisode2UpdateByNumber(com.battlelancer.seriesguide.provider.SgEpisode2UpdateByNumber) Pair(androidx.core.util.Pair) Nullable(androidx.annotation.Nullable)

Aggregations

Pair (androidx.core.util.Pair)31 ArrayList (java.util.ArrayList)9 EpisodeAction (de.danoeh.antennapod.net.sync.model.EpisodeAction)7 ReferenceManager (org.javarosa.core.reference.ReferenceManager)6 Test (org.junit.Test)6 AppDependencyModule (org.odk.collect.android.injection.config.AppDependencyModule)6 CollectHelpers.setupFakeReferenceManager (org.odk.collect.android.support.CollectHelpers.setupFakeReferenceManager)6 MockFormEntryPromptBuilder (org.odk.collect.android.support.MockFormEntryPromptBuilder)6 Date (java.util.Date)5 ImageView (android.widget.ImageView)4 SimpleDateFormat (java.text.SimpleDateFormat)4 RandomString (net.bytebuddy.utility.RandomString)4 BitmapDrawable (android.graphics.drawable.BitmapDrawable)3 Drawable (android.graphics.drawable.Drawable)3 Uri (android.net.Uri)3 View (android.view.View)3 Nullable (androidx.annotation.Nullable)3 FileWidgetTest (org.odk.collect.android.widgets.base.FileWidgetTest)3 SynchronousImageLoader (org.odk.collect.android.widgets.support.SynchronousImageLoader)3 ImageLoader (org.odk.collect.imageloader.ImageLoader)3