Search in sources :

Example 71 with Pair

use of net.imglib2.util.Pair in project android-topeka by googlesamples.

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.
     */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
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));
    }
    //noinspection unchecked
    return participants.toArray(new Pair[participants.size()]);
}
Also used : ArrayList(java.util.ArrayList) View(android.view.View) Pair(android.support.v4.util.Pair) TargetApi(android.annotation.TargetApi)

Example 72 with Pair

use of net.imglib2.util.Pair in project android by owncloud.

the class FileDataStorageManager method getAvailableOfflineFilesFromEveryAccount.

/**
     * Get a collection with all the files set by the user as available offline, from all the accounts
     * in the device.
     *
     * This is the only method working with a NULL account in {@link #mAccount}. Not something to do often.
     *
     * @return      List with all the files set by the user as available offline.
     */
public List<Pair<OCFile, String>> getAvailableOfflineFilesFromEveryAccount() {
    List<Pair<OCFile, String>> result = new ArrayList<>();
    Cursor cursorOnKeptInSync = null;
    try {
        // query for any favorite file in any OC account
        cursorOnKeptInSync = getContentResolver().query(ProviderTableMeta.CONTENT_URI, null, ProviderTableMeta.FILE_KEEP_IN_SYNC + " = ?", new String[] { String.valueOf(OCFile.AvailableOfflineStatus.AVAILABLE_OFFLINE.getValue()) }, // do NOT get also AVAILABLE_OFFLINE_PARENT: only those SET BY THE USER (files or folders)
        null);
        if (cursorOnKeptInSync != null && cursorOnKeptInSync.moveToFirst()) {
            OCFile file;
            String accountName;
            do {
                file = createFileInstance(cursorOnKeptInSync);
                accountName = cursorOnKeptInSync.getString(cursorOnKeptInSync.getColumnIndex(ProviderTableMeta.FILE_ACCOUNT_OWNER));
                result.add(new Pair<>(file, accountName));
            } while (cursorOnKeptInSync.moveToNext());
        }
    } catch (Exception e) {
        Log_OC.e(TAG, "Exception retrieving all the available offline files", e);
    } finally {
        if (cursorOnKeptInSync != null) {
            cursorOnKeptInSync.close();
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) RemoteException(android.os.RemoteException) IOException(java.io.IOException) OperationApplicationException(android.content.OperationApplicationException) Pair(android.support.v4.util.Pair)

Example 73 with Pair

use of net.imglib2.util.Pair in project android by owncloud.

the class FileObserverService method startObservation.

/**
     * Read from the local database the list of files that must to be kept
     * synchronized and starts observers to monitor local changes on them.
     * 
     * Updates the list of currently observed files if called multiple times.
     */
private void startObservation() {
    Log_OC.d(TAG, "Loading all available offline files from database to start watching them");
    FileDataStorageManager fds = new FileDataStorageManager(// this is dangerous - handle with care
    null, getContentResolver());
    List<Pair<OCFile, String>> availableOfflineFiles = fds.getAvailableOfflineFilesFromEveryAccount();
    OCFile file;
    String accountName;
    Account account;
    for (Pair<OCFile, String> pair : availableOfflineFiles) {
        file = pair.first;
        accountName = pair.second;
        account = new Account(accountName, MainApp.getAccountType());
        if (!AccountUtils.exists(account, this)) {
            continue;
        }
        addObservedFile(file, account);
    }
    // watch for instant uploads
    updateInstantUploadsObservers();
// service does not stopSelf() ; that way it tries to be alive forever
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) Account(android.accounts.Account) FileDataStorageManager(com.owncloud.android.datamodel.FileDataStorageManager) Pair(android.support.v4.util.Pair)

Example 74 with Pair

use of net.imglib2.util.Pair in project GSYVideoPlayer by CarGuo.

the class JumpUtils method goToVideoPlayer.

/**
     * 跳转到视频播放
     *
     * @param activity
     * @param view
     */
public static void goToVideoPlayer(Activity activity, View view) {
    Intent intent = new Intent(activity, PlayActivity.class);
    intent.putExtra(PlayActivity.TRANSITION, true);
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        Pair pair = new Pair<>(view, PlayActivity.IMG_TRANSITION);
        ActivityOptionsCompat activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, pair);
        ActivityCompat.startActivity(activity, intent, activityOptions.toBundle());
    } else {
        activity.startActivity(intent);
        activity.overridePendingTransition(R.anim.abc_fade_in, R.anim.abc_fade_out);
    }
}
Also used : Intent(android.content.Intent) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat) Pair(android.support.v4.util.Pair)

Example 75 with Pair

use of net.imglib2.util.Pair in project hadoop by apache.

the class TestGenericOptionsParser method testEmptyFilenames.

/**
   * Test the case where the libjars, files and archives arguments
   * contains an empty token, which should create an IllegalArgumentException.
   */
@Test
public void testEmptyFilenames() throws Exception {
    List<Pair<String, String>> argsAndConfNames = new ArrayList<Pair<String, String>>();
    argsAndConfNames.add(new Pair<String, String>("-libjars", "tmpjars"));
    argsAndConfNames.add(new Pair<String, String>("-files", "tmpfiles"));
    argsAndConfNames.add(new Pair<String, String>("-archives", "tmparchives"));
    for (Pair<String, String> argAndConfName : argsAndConfNames) {
        String arg = argAndConfName.getFirst();
        File tmpFileOne = new File(testDir, "tmpfile1");
        Path tmpPathOne = new Path(tmpFileOne.toString());
        File tmpFileTwo = new File(testDir, "tmpfile2");
        Path tmpPathTwo = new Path(tmpFileTwo.toString());
        localFs.create(tmpPathOne);
        localFs.create(tmpPathTwo);
        String[] args = new String[2];
        args[0] = arg;
        // create an empty path in between two valid files,
        // which prior to HADOOP-10820 used to result in the
        // working directory being added to "tmpjars" (or equivalent)
        args[1] = String.format("%s,,%s", tmpFileOne.toURI().toString(), tmpFileTwo.toURI().toString());
        try {
            new GenericOptionsParser(conf, args);
            fail("Expected exception for empty filename");
        } catch (IllegalArgumentException e) {
            // expect to receive an IllegalArgumentException
            GenericTestUtils.assertExceptionContains("File name can't be" + " empty string", e);
        }
        // test zero file list length - it should create an exception
        args[1] = ",,";
        try {
            new GenericOptionsParser(conf, args);
            fail("Expected exception for zero file list length");
        } catch (IllegalArgumentException e) {
            // expect to receive an IllegalArgumentException
            GenericTestUtils.assertExceptionContains("File name can't be" + " empty string", e);
        }
        // test filename with space character
        // it should create exception from parser in URI class
        // due to URI syntax error
        args[1] = String.format("%s, ,%s", tmpFileOne.toURI().toString(), tmpFileTwo.toURI().toString());
        try {
            new GenericOptionsParser(conf, args);
            fail("Expected exception for filename with space character");
        } catch (IllegalArgumentException e) {
            // expect to receive an IllegalArgumentException
            GenericTestUtils.assertExceptionContains("URISyntaxException", e);
        }
    }
}
Also used : Path(org.apache.hadoop.fs.Path) ArrayList(java.util.ArrayList) File(java.io.File) Pair(org.apache.commons.math3.util.Pair) Test(org.junit.Test)

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