Search in sources :

Example 51 with Pair

use of org.apache.commons.math3.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)

Example 52 with Pair

use of org.apache.commons.math3.util.Pair in project LookLook by xinghongfei.

the class Help method createSafeTransitionParticipants.

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));
    }
    return participants.toArray(new Pair[participants.size()]);
}
Also used : ArrayList(java.util.ArrayList) View(android.view.View) Pair(android.support.v4.util.Pair)

Example 53 with Pair

use of org.apache.commons.math3.util.Pair in project LookLook by xinghongfei.

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

Example 54 with Pair

use of org.apache.commons.math3.util.Pair in project Remindy by abicelis.

the class ProgrammedLocationBasedTaskViewHolder method onClick.

@Override
public void onClick(View view) {
    int id = view.getId();
    switch(id) {
        case R.id.item_task_programmed_location_based_container:
            Pair[] pairs = new Pair[1];
            pairs[0] = new Pair<View, String>(mCategoryIcon, mFragment.getResources().getString(R.string.transition_task_list_category));
            //pairs[1] = new Pair<View, String>(mTitle, mFragment.getResources().getString(R.string.transition_task_list_title));
            //pairs[2] = new Pair<View, String>(mDescription, mFragment.getResources().getString(R.string.transition_task_list_description));
            ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(mFragment.getActivity(), pairs);
            Intent openTaskDetailActivity = new Intent(mFragment.getActivity(), TaskDetailActivity.class);
            openTaskDetailActivity.putExtra(TaskDetailActivity.TASK_ID_TO_DISPLAY, mCurrent.getId());
            openTaskDetailActivity.putExtra(TaskDetailActivity.TASK_POSITION, mReminderPosition);
            if (mClickListener != null) {
                mClickListener.onItemClicked(mReminderPosition, openTaskDetailActivity, options.toBundle());
            }
            break;
    }
}
Also used : Intent(android.content.Intent) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat) Pair(android.support.v4.util.Pair)

Example 55 with Pair

use of org.apache.commons.math3.util.Pair in project Remindy by abicelis.

the class ProgrammedRepeatingTaskViewHolder method onClick.

@Override
public void onClick(View view) {
    int id = view.getId();
    switch(id) {
        case R.id.item_task_programmed_repeating_container:
            Pair[] pairs = new Pair[1];
            pairs[0] = new Pair<View, String>(mCategoryIcon, mFragment.getResources().getString(R.string.transition_task_list_category));
            //pairs[1] = new Pair<View, String>(mTitle, mFragment.getResources().getString(R.string.transition_task_list_title));
            //pairs[2] = new Pair<View, String>(mDescription, mFragment.getResources().getString(R.string.transition_task_list_description));
            ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(mFragment.getActivity(), pairs);
            Intent openTaskDetailActivity = new Intent(mFragment.getActivity(), TaskDetailActivity.class);
            openTaskDetailActivity.putExtra(TaskDetailActivity.TASK_ID_TO_DISPLAY, mCurrent.getId());
            openTaskDetailActivity.putExtra(TaskDetailActivity.TASK_POSITION, mReminderPosition);
            if (mClickListener != null) {
                mClickListener.onItemClicked(mReminderPosition, openTaskDetailActivity, options.toBundle());
            }
            break;
    }
}
Also used : Intent(android.content.Intent) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat) Pair(android.support.v4.util.Pair)

Aggregations

Pair (android.support.v4.util.Pair)38 ArrayList (java.util.ArrayList)22 View (android.view.View)16 Collectors (java.util.stream.Collectors)16 IntStream (java.util.stream.IntStream)16 ActivityOptionsCompat (android.support.v4.app.ActivityOptionsCompat)13 Logger (org.apache.logging.log4j.Logger)12 ParamUtils (org.broadinstitute.hellbender.utils.param.ParamUtils)12 Intent (android.content.Intent)11 Pair (org.apache.commons.math3.util.Pair)11 IOException (java.io.IOException)10 java.util (java.util)10 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)10 Pair (org.apache.commons.lang3.tuple.Pair)10 RealMatrix (org.apache.commons.math3.linear.RealMatrix)10 File (java.io.File)9 List (java.util.List)9 Array2DRowRealMatrix (org.apache.commons.math3.linear.Array2DRowRealMatrix)8 UserException (org.broadinstitute.hellbender.exceptions.UserException)8 org.broadinstitute.hellbender.tools.exome (org.broadinstitute.hellbender.tools.exome)8