android.support.v4.util.Pair Java Examples

The following examples show how to use android.support.v4.util.Pair. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AddOrEditContactFragment.java    From BlackList with Apache License 2.0 6 votes vote down vote up
private void addRowsToNumbersList(Bundle data) {
    if (data == null) {
        return;
    }
    // get numbers and types from parameters
    ArrayList<String> numbers = data.getStringArrayList(CONTACT_NUMBERS);
    ArrayList<Integer> types = data.getIntegerArrayList(CONTACT_NUMBER_TYPES);
    if (numbers != null && types != null && numbers.size() == types.size()) {
        // get the set of unique pairs of numbers/types form the current view
        Set<Pair<String, Integer>> numbers2TypeSet = getNumber2TypePairs();
        for (int i = 0; i < numbers.size(); i++) {
            String number = numbers.get(i);
            int type = types.get(i);
            // add to View only rows with unique pair of number/type
            if (numbers2TypeSet.add(new Pair<>(number, type))) {
                addRowToNumbersList(number, type);
            }
        }
    }
}
 
Example #2
Source File: AutoSharedElementCallback.java    From native-navigation with MIT License 6 votes vote down vote up
/**
 * Clears and populates partialMatches with all views from transitionViews that is a partial match
 * with the supplied transition name.
 */
private void findAllPartialMatches(TransitionName tn, List<Pair<View, String>> transitionViews,
    List<View> partialMatches) {
  partialMatches.clear();
  for (Pair<View, String> p : transitionViews) {
    TransitionName tn2 = TransitionName.parse(p.second /* transition name */);
    // If there is no views that perfectly matches the transition name but there is one that is
    // a partial match, we will automatically
    // map it. This will commonly occur when the user is viewing pictures and swipes to a
    // different one.
    if (tn.partialEquals(tn2)) {
      // Partial match
      partialMatches.add(p.first);
    }
  }
}
 
Example #3
Source File: NavigationSceneListenerTests.java    From scene with Apache License 2.0 6 votes vote down vote up
@Test
public void testNavigationListenerRemoveAfterLifecycleDestroy() {
    TestScene rootScene = new TestScene();
    Pair<SceneLifecycleManager<NavigationScene>, NavigationScene> pair = NavigationSourceUtility.createFromInitSceneLifecycleManager(rootScene);
    SceneLifecycleManager sceneLifecycleManager = pair.first;
    NavigationScene navigationScene = pair.second;
    sceneLifecycleManager.onStart();
    sceneLifecycleManager.onResume();

    final TestChildScene child = new TestChildScene();
    navigationScene.push(child);

    final AtomicBoolean called = new AtomicBoolean(false);
    NavigationListener navigationListener = new NavigationListener() {
        @Override
        public void navigationChange(@Nullable Scene from, @NonNull Scene to, boolean isPush) {
            called.set(true);
        }
    };
    navigationScene.addNavigationListener(child, navigationListener);
    navigationScene.remove(child);

    navigationScene.push(TestChildScene.class);
    assertFalse(called.get());
}
 
Example #4
Source File: CategorySelectionFragment.java    From android-topeka with Apache License 2.0 6 votes vote down vote up
private void startQuizActivityWithTransition(Activity activity, View toolbar,
                                             Category category) {

    final Pair[] pairs = TransitionHelper.createSafeTransitionParticipants(activity, false,
            new Pair<>(toolbar, activity.getString(R.string.transition_toolbar)));
    @SuppressWarnings("unchecked")
    ActivityOptionsCompat sceneTransitionAnimation = ActivityOptionsCompat
            .makeSceneTransitionAnimation(activity, pairs);

    // Start the activity with the participants, animating from one to the other.
    final Bundle transitionBundle = sceneTransitionAnimation.toBundle();
    Intent startIntent = QuizActivity.getStartIntent(activity, category);
    ActivityCompat.startActivityForResult(activity,
            startIntent,
            REQUEST_CATEGORY,
            null);
}
 
Example #5
Source File: JobServiceConnectionTest.java    From firebase-jobdispatcher-android with Apache License 2.0 6 votes vote down vote up
@Test
public void finishesJobsQueuedAfterUnbind() throws Exception {
  final Queue<Pair<Bundle, Integer>> callbackResults = new ArrayDeque<>();
  noopCallback =
      new IJobCallback.Stub() {
        @Override
        public void jobFinished(Bundle invocationData, @JobService.JobResult int result) {
          callbackResults.offer(Pair.create(invocationData, result));
        }
      };

  connection = new JobServiceConnection(noopCallback, contextMock);
  connection.onServiceConnected(null, binderMock);
  connection.onServiceDisconnected(null);

  assertThat(callbackResults).isEmpty();

  // If the job is queued after the connection has been unbound (regardless of reason) then we
  // should NOT start it and should instead send a retry message via the callback
  connection.startJob(job);

  assertThat(callbackResults).hasSize(1);
  Pair<Bundle, Integer> result = callbackResults.poll();
  assertBundlesEqual(jobData, result.first);
  assertThat(result.second).isEqualTo(Integer.valueOf(JobService.RESULT_FAIL_RETRY));
}
 
Example #6
Source File: AvgAnalysisActivity.java    From Ticket-Analysis with MIT License 6 votes vote down vote up
private List<BarEntry> generateEntry(List<TicketOpenData> list, int codeLength) {
    float[] valuesCount = new float[codeLength];
    for (int j = 0; j < list.size(); j++) {
        Pair<String[], String[]> sPair = translateCodeToList(list.get(j).openCode);
        String[] values = ArrayUtil.concat(sPair.first, sPair.second);
        for (int k = 0; k < codeLength; k++) {
            try {
                valuesCount[k] += Float.valueOf(values[k]);//非数字直接抛异常
            } catch (Exception e) {
                e.printStackTrace();
                valuesCount[k] += 0;
            }
        }
    }
    List<BarEntry> barEntries = new ArrayList<>();
    float count = 0;
    for (int i = 0; i < codeLength - 1; i++) {
        count += valuesCount[i] / list.size();
        barEntries.add(new BarEntry(i, valuesCount[i] / list.size()));
    }
    barEntries.add(new BarEntry(codeLength - 1, count));
    return barEntries;
}
 
Example #7
Source File: GroupSceneTransactionTests.java    From scene with Apache License 2.0 6 votes vote down vote up
@Test
public void testTransactionHide() {
    GroupSceneLifecycleTests.TestEmptyScene testScene = new GroupSceneLifecycleTests.TestEmptyScene();
    GroupSceneLifecycleTests.TestChildScene childScene = new GroupSceneLifecycleTests.TestChildScene();

    Pair<SceneLifecycleManager<NavigationScene>, NavigationScene> pair = NavigationSourceUtility.createFromInitSceneLifecycleManager(testScene);

    testScene.add(testScene.mId, childScene, "childScene");
    assertEquals(View.VISIBLE, childScene.getView().getVisibility());

    testScene.beginTransaction();
    testScene.hide(childScene);
    testScene.commitTransaction();

    assertEquals(State.ACTIVITY_CREATED, childScene.getState());
    assertEquals(View.GONE, childScene.getView().getVisibility());
    assertFalse(testScene.isShow(childScene));
}
 
Example #8
Source File: NavigationStackTests.java    From scene with Apache License 2.0 6 votes vote down vote up
@Test
public void testPushSingleTaskPredicate() {
    final TestScene groupScene = new TestScene();
    Pair<SceneLifecycleManager<NavigationScene>, NavigationScene> pair = NavigationSourceUtility.createFromInitSceneLifecycleManager(groupScene);

    SceneLifecycleManager sceneLifecycleManager = pair.first;
    NavigationScene navigationScene = pair.second;

    sceneLifecycleManager.onStart();
    sceneLifecycleManager.onResume();

    navigationScene.push(TestChildScene.class);

    for (int i = 0; i < 100; i++) {
        navigationScene.push(CountChildScene.class);
    }
    assertEquals(102, navigationScene.getSceneList().size());

    navigationScene.push(TestChildScene.class, null, new PushOptions.Builder().setRemovePredicate(new PushOptions.SingleTaskPredicate(TestChildScene.class)).build());
    assertEquals(102, navigationScene.getSceneList().size());
}
 
Example #9
Source File: GroupSceneTransactionTests.java    From scene with Apache License 2.0 6 votes vote down vote up
@Test
public void testTransactionShow() {
    GroupSceneLifecycleTests.TestEmptyScene testScene = new GroupSceneLifecycleTests.TestEmptyScene();
    GroupSceneLifecycleTests.TestChildScene childScene = new GroupSceneLifecycleTests.TestChildScene();

    Pair<SceneLifecycleManager<NavigationScene>, NavigationScene> pair = NavigationSourceUtility.createFromInitSceneLifecycleManager(testScene);

    testScene.add(testScene.mId, childScene, "childScene");
    assertEquals(View.VISIBLE, childScene.getView().getVisibility());

    testScene.hide(childScene);
    assertEquals(View.GONE, childScene.getView().getVisibility());

    testScene.beginTransaction();
    testScene.show(childScene);
    testScene.commitTransaction();

    assertEquals(State.ACTIVITY_CREATED, childScene.getState());
    assertEquals(View.VISIBLE, childScene.getView().getVisibility());
    assertTrue(testScene.isShow(childScene));
}
 
Example #10
Source File: NavigationHelperTest.java    From graphhopper-navigation-android with MIT License 6 votes vote down vote up
@Test
public void findUpcomingIntersection_endOfLegReturnsNullIntersection() throws Exception {
  int stepIndex = buildMultiLegRoute().legs().get(1).steps().size() - 1;
  RouteProgress routeProgress = buildMultiLegRouteProgress(0, 0, 0, stepIndex, 1);
  RouteLegProgress legProgress = routeProgress.currentLegProgress();
  RouteStepProgress stepProgress = legProgress.currentStepProgress();
  List<StepIntersection> intersections = stepProgress.intersections();
  List<Pair<StepIntersection, Double>> intersectionDistances = stepProgress.intersectionDistancesAlongStep();
  StepIntersection currentIntersection = NavigationHelper.findCurrentIntersection(
    intersections, intersectionDistances, legProgress.currentStep().distance()
  );

  StepIntersection upcomingIntersection = NavigationHelper.findUpcomingIntersection(
    intersections, legProgress.upComingStep(), currentIntersection
  );

  assertEquals(null, upcomingIntersection);
}
 
Example #11
Source File: MoveStatusExposeEngine.java    From Shield with MIT License 6 votes vote down vote up
protected void dispatchExposeEvent(T item) {

        currentDelayRunnable = null;

        Pair<T, ExposeScope> key = new Pair<>(item, exposeInfo.exposeScope);
        int count = infoHolder.getCount(key);
        if (exposeInfo.maxExposeCount <= count || exposeInfo.exposeDuration + infoHolder.getLastTimeMillis(item) > System.currentTimeMillis()) {
            return;
        }

        if (exposeInfo.agentExposeCallback != null) {
            exposeInfo.agentExposeCallback.onExpose(exposeInfo.data, count, getPath(item));
        }
        infoHolder.setCount(key, count + 1);
        infoHolder.setLastTimeMillis(key, System.currentTimeMillis());
    }
 
Example #12
Source File: ContextUtils.java    From openlauncher with Apache License 2.0 6 votes vote down vote up
/**
 * Get public (accessible) appdata folders
 */
@SuppressWarnings("StatementWithEmptyBody")
public List<Pair<File, String>> getAppDataPublicDirs(boolean internalStorageFolder, boolean sdcardFolders, boolean storageNameWithoutType) {
    List<Pair<File, String>> dirs = new ArrayList<>();
    for (File externalFileDir : ContextCompat.getExternalFilesDirs(_context, null)) {
        if (externalFileDir == null || Environment.getExternalStorageDirectory() == null) {
            continue;
        }
        boolean isInt = externalFileDir.getAbsolutePath().startsWith(Environment.getExternalStorageDirectory().getAbsolutePath());
        boolean add = (internalStorageFolder && isInt) || (sdcardFolders && !isInt);
        if (add) {
            dirs.add(new Pair<>(externalFileDir, getStorageName(externalFileDir, storageNameWithoutType)));
            if (!externalFileDir.exists() && externalFileDir.mkdirs()) ;
        }
    }
    return dirs;
}
 
Example #13
Source File: SearchAdapter.java    From Orin with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onClick(View view) {
    Object item = dataSet.get(getAdapterPosition());
    switch (getItemViewType()) {
        case ALBUM:
            NavigationUtil.goToAlbum(activity,
                    ((Album) item).getId(),
                    Pair.create(image,
                            activity.getResources().getString(R.string.transition_album_art)
                    ));
            break;
        case ARTIST:
            NavigationUtil.goToArtist(activity,
                    ((Artist) item).getId(),
                    Pair.create(image,
                            activity.getResources().getString(R.string.transition_artist_image)
                    ));
            break;
        case SONG:
            ArrayList<Song> playList = new ArrayList<>();
            playList.add((Song) item);
            MusicPlayerRemote.openQueue(playList, 0, true);
            break;
    }
}
 
Example #14
Source File: ScenePlaceHolderViewTests.java    From scene with Apache License 2.0 6 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void test_parent_no_id() {
    final AtomicBoolean called = new AtomicBoolean();
    GroupScene groupScene = new GroupScene() {
        @NonNull
        @Override
        public ViewGroup onCreateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container, @Nullable Bundle savedInstanceState) {
            return (ViewGroup) inflater.inflate(TestResources.getLayout(this, "layout_place_holder_view_crash_parent_no_id"), container, false);
        }
    };

    Pair<SceneLifecycleManager<NavigationScene>, NavigationScene> pair = NavigationSourceUtility.createFromInitSceneLifecycleManager(groupScene);
    SceneLifecycleManager sceneLifecycleManager = pair.first;
    NavigationScene navigationScene = pair.second;
    sceneLifecycleManager.onStart();
    sceneLifecycleManager.onResume();
    assertTrue(called.get());
}
 
Example #15
Source File: GroupSceneManager.java    From scene with Apache License 2.0 6 votes vote down vote up
private void beginTrackSceneStateChange(@NonNull Scene scene) {
    for (Pair<Scene, String> pair : this.mCurrentTrackMoveStateSceneSet) {
        if (pair.first == scene) {
            throw new SceneInternalException("Target scene " + scene.getClass().getCanonicalName() + " is already tracked");
        }
    }
    //forbid NavigationScene execute navigation stack operation immediately, otherwise GroupScene may sync lifecycle to child,
    //then throw SceneInternalException("Target scene is already tracked")
    NavigationScene navigationScene = mGroupScene.getNavigationScene();
    String suppressTag = null;
    if (navigationScene != null) {
        suppressTag = navigationScene.beginSuppressStackOperation(scene.toString());
    } else {
        //execute GroupScene operations before GroupScene attached or after detached
        suppressTag = null;
    }
    this.mCurrentTrackMoveStateSceneSet.add(Pair.create(scene, suppressTag));
}
 
Example #16
Source File: ImportWalletActivity.java    From trust-wallet-android-source with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    AndroidInjection.inject(this);

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_import_wallet);
    toolbar();

    pages.add(KEYSTORE_FORM_INDEX, new Pair<>(getString(R.string.tab_keystore), ImportKeystoreFragment.create()));
    pages.add(PRIVATE_KEY_FORM_INDEX, new Pair<>(getString(R.string.tab_private_key), ImportPrivateKeyFragment.create()));
    ViewPager viewPager = findViewById(R.id.viewPager);
    viewPager.setAdapter(new TabPagerAdapter(getSupportFragmentManager(), pages));
    TabLayout tabLayout = findViewById(R.id.tabLayout);
    tabLayout.setupWithViewPager(viewPager);

    importWalletViewModel = ViewModelProviders.of(this, importWalletViewModelFactory)
            .get(ImportWalletViewModel.class);
    importWalletViewModel.progress().observe(this, this::onProgress);
    importWalletViewModel.error().observe(this, this::onError);
    importWalletViewModel.wallet().observe(this, this::onWallet);
}
 
Example #17
Source File: DatabaseHelper.java    From IdeaTrackerPlus with MIT License 6 votes vote down vote up
public void moveAllToTab(int tabNumber, ArrayList<Pair<Integer, String>> ideas) {
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues values = new ContentValues();

    switch (tabNumber) {
        case 1: //NOW
            values.put(DataEntry.COLUMN_NAME_DONE, false);
            values.put(DataEntry.COLUMN_NAME_LATER, false);
            break;

        case 2: //LATER
            values.put(DataEntry.COLUMN_NAME_DONE, false);
            values.put(DataEntry.COLUMN_NAME_LATER, true);
            break;

        case 3: //DONE
            values.put(DataEntry.COLUMN_NAME_LATER, false);
            values.put(DataEntry.COLUMN_NAME_DONE, true);
            break;
    }

    for (Pair<Integer, String> idea : ideas) {
        db.update(DataEntry.TABLE_NAME, values, "_id=" + idea.first, null);
    }
    notifyAllLists();
}
 
Example #18
Source File: NavigationSourceUtility.java    From scene with Apache License 2.0 5 votes vote down vote up
public static NavigationScene createFromSceneLifecycleManager(final Scene rootScene) {
    Pair<SceneLifecycleManager<NavigationScene>, NavigationScene> pair = createFromInitSceneLifecycleManager(rootScene);
    SceneLifecycleManager sceneLifecycleManager = pair.first;
    sceneLifecycleManager.onStart();
    sceneLifecycleManager.onResume();
    return pair.second;
}
 
Example #19
Source File: AutoSharedElementCallback.java    From native-navigation with MIT License 5 votes vote down vote up
/**
 * Walks the given view group and adds all view with a set transition name to the fragment
 * transaction.
 */
public static void addSharedElementsToFragmentTransaction(
        FragmentTransaction ft, ViewGroup viewGroup) {
  List<Pair<View, String>> transitionViews = new ArrayList<>();
  ViewUtils.findTransitionViews(viewGroup, transitionViews);

  for (Pair<View, String> tv : transitionViews) {
    ft.addSharedElement(tv.first, tv.second);
  }
}
 
Example #20
Source File: BaseActivityLauncher.java    From SmartGo with Apache License 2.0 5 votes vote down vote up
protected <T extends BaseActivityLauncher> T animate(final T son,
                                                     @NonNull Pair<View, String>... sharedElements){
    if(mFrom instanceof Activity) {
        ActivityAnimate.animate((Activity) mFrom, mActivityOptionsBox, sharedElements);
        return son;
    }else {
        throw new IllegalArgumentException("this method needs Activity context,not : " + mFrom);
    }
}
 
Example #21
Source File: NavigationHelperTest.java    From graphhopper-navigation-android with MIT License 5 votes vote down vote up
@Test
public void findCurrentIntersection_beginningOfStepReturnsFirstIntersection() throws Exception {
  RouteProgress routeProgress = buildMultiLegRouteProgress();
  RouteLegProgress legProgress = routeProgress.currentLegProgress();
  RouteStepProgress stepProgress = legProgress.currentStepProgress();
  List<StepIntersection> intersections = stepProgress.intersections();
  List<Pair<StepIntersection, Double>> intersectionDistances = stepProgress.intersectionDistancesAlongStep();

  StepIntersection currentIntersection = NavigationHelper.findCurrentIntersection(
    intersections, intersectionDistances, 0
  );

  assertTrue(currentIntersection.equals(intersections.get(0)));
}
 
Example #22
Source File: SmsParser.java    From fingen with Apache License 2.0 5 votes vote down vote up
private Pair<Integer, Integer> checkBorders(Pair<Integer, Integer> pair) {
    int first = 0;
    int second = 0;
    if (pair.first > 0) {
        first = pair.first;
    }
    if (pair.second > 0) {
        second = pair.second;
    }

    return new Pair<>(first, second);
}
 
Example #23
Source File: AppFragment.java    From apkextractor with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onItemClicked(AppItem appItem, RecyclerViewAdapter.ViewHolder viewHolder, int position) {
    if(getActivity()==null)return;
    Intent intent=new Intent(getActivity(), AppDetailActivity.class);
    intent.putExtra(BaseActivity.EXTRA_PACKAGE_NAME,appItem.getPackageName());
    ActivityOptionsCompat compat = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(),new Pair<View, String>(viewHolder.icon,"icon"));
    try{
        ActivityCompat.startActivity(getActivity(), intent, compat.toBundle());
    }catch (Exception e){e.printStackTrace();}
}
 
Example #24
Source File: OptionsCompatDemoActivity.java    From AndroidStudyDemo with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 这里可以用多个元素或者是单个元素进行动画,这里用了多个元素。为了保证动画效果,这里进行了渐变操作,
 * 在handle中进行了恢复操作,这样让动画看起来平滑了很多
 * @param views
 */
private void screenTransitAnimByPair(Pair<View, Integer>... views) {
    sIsSceneAnim = true;
    if (mTestSwitch) {
        Pair<View, String>[] tViews = new Pair[views.length];
        int i = 0;
        for (Pair<View, Integer> view : views) {
            tViews[i] = new Pair<>(view.first, view.second.toString());
            i++;
        }
        ActivityOptionsCompat optionsCompat
                = ActivityOptionsCompat.makeSceneTransitionAnimation(
                OptionsCompatDemoActivity.this,
                tViews
        );
        ActivityCompat.startActivity(
                OptionsCompatDemoActivity.this,
                mIntent,
                optionsCompat.toBundle()
        );
    } else {
        ActivityOptionsCompatICS optionsCompatICS
                = ActivityOptionsCompatICS.makeSceneTransitionAnimation(
                OptionsCompatDemoActivity.this,
                views
        );
        ActivityCompatICS.startActivity(
                OptionsCompatDemoActivity.this,
                mIntent,
                optionsCompatICS.toBundle()
        );
    }
}
 
Example #25
Source File: ViewUtilityTests.java    From scene with Apache License 2.0 5 votes vote down vote up
@Test
public void testActivityContext() {
    final TestScene2 testScene = new TestScene2();

    Pair<SceneLifecycleManager<NavigationScene>, NavigationScene> pair = NavigationSourceUtility.createFromInitSceneLifecycleManager(testScene);
    View view = testScene.requireView();
    assertEquals(ViewUtility.findSceneByView(view), testScene);

    FrameLayout frameLayout = (FrameLayout) view;
    View childView = new View(testScene.requireSceneContext());
    frameLayout.addView(childView);
    assertEquals(ViewUtility.findSceneByView(childView), testScene);
}
 
Example #26
Source File: SharedElementUtils.java    From scene with Apache License 2.0 5 votes vote down vote up
private static HashMap<String, Pair<View, View>> getShareView(View fromView, View toView, List<String> share) {
    HashMap<String, View> fromList = getTransitionViewList(fromView, share, true);
    HashMap<String, View> toList = getTransitionViewList(toView, share, true);

    HashMap<String, Pair<View, View>> hashMap = new HashMap<>();
    for (Map.Entry<String, View> entry : fromList.entrySet()) {
        String key = entry.getKey();
        View toTargetView = toList.get(key);
        if (toTargetView != null) {
            hashMap.put(key, Pair.create(entry.getValue(), toTargetView));
        }
    }
    return hashMap;
}
 
Example #27
Source File: NavigationSourceUtility.java    From scene with Apache License 2.0 5 votes vote down vote up
public static Pair<SceneLifecycleManager<NavigationScene>, NavigationScene> createFromInitSceneLifecycleManager(final Scene rootScene) {
    ActivityController<TestActivity> controller = Robolectric.buildActivity(TestActivity.class).create().start().resume();
    TestActivity testActivity = controller.get();
    NavigationScene navigationScene = new NavigationScene();
    NavigationSceneOptions options = new NavigationSceneOptions(rootScene.getClass());
    navigationScene.setArguments(options.toBundle());

    Scope.RootScopeFactory rootScopeFactory = new Scope.RootScopeFactory() {
        @Override
        public Scope getRootScope() {
            return Scope.DEFAULT_ROOT_SCOPE_FACTORY.getRootScope();
        }
    };

    SceneComponentFactory sceneComponentFactory = new SceneComponentFactory() {
        @Override
        public Scene instantiateScene(ClassLoader cl, String className, Bundle bundle) {
            if (className.equals(rootScene.getClass().getName())) {
                return rootScene;
            }
            return null;
        }
    };

    navigationScene.setDefaultNavigationAnimationExecutor(new NoAnimationExecutor());
    navigationScene.setRootSceneComponentFactory(sceneComponentFactory);

    SceneLifecycleManager<NavigationScene> sceneLifecycleManager = new SceneLifecycleManager<>();
    sceneLifecycleManager.onActivityCreated(testActivity, testActivity.mFrameLayout,
            navigationScene, rootScopeFactory,
            false, null);
    return Pair.create(sceneLifecycleManager, navigationScene);
}
 
Example #28
Source File: ToDayAdapter.java    From ToDay with MIT License 5 votes vote down vote up
/**
 * Binds events for given day, each event should either
 * start and end within the day,
 * or starts before and end within of after the day.
 * Bound cursor should be deactivated via {@link #deactivate()} when appropriate
 * @param timeMillis    time in millis that represents day in agenda
 * @param cursor        {@link CalendarContract.Events} cursor wrapper
 * @see {@link #loadEvents(long)}
 * @see {@link #deactivate()}
 */
public final void bindEvents(long timeMillis, EventCursor cursor) {
    if (mLock) {
        return;
    }
    Pair<EventGroup, Integer> pair = findGroup(timeMillis);
    if (pair != null) {
        pair.first.setCursor(cursor, mEventObserver);
        notifyEventsChanged(pair.first, pair.second);
    }
}
 
Example #29
Source File: CodeBaseAdapter.java    From Ticket-Analysis with MIT License 5 votes vote down vote up
public void setData(final Pair<Integer, Integer> data, int size, boolean isSpecial, int position, int type) {
    List<String> numberList;
    if (!isSpecial) {
        numberList = generateNumberList(data.first, data.second);
        tvCodeColor.setText("红球" + (position + 1));
    } else {
        tvCodeColor.setText("特别码");
        if (specialCode != null && specialCode.size() > 0) {
            numberList = specialCode;
        } else {
            numberList = generateNumberList(data.first, data.second);
        }
    }
    if (selectedList.size() <= position) {
        selectedList.add(new ArrayList<>());
    }
    tvHint.setText("可选0~" + size + "个码");
    rvCodes.setLayoutManager(new GridLayoutManager(mContext, 7));
    CodeForChooseAdapter codeForChooseAdapter;
    if (type == TYPE_NORMAL_WITH_SPECIAL && codeDis.size() <= 1) {
        codeForChooseAdapter = new CodeForChooseAdapter(mContext, numberList, isSpecial, size, position, selectedList);
        codeForChooseAdapter.setOnClickListener(v -> {
            for (int i = 0; i < mCodeForChooseAdapters.size(); i++) {
                mCodeForChooseAdapters.get(i).notifyDataSetChanged();
            }
        });
    } else {
        codeForChooseAdapter = new CodeForChooseAdapter(mContext, numberList, isSpecial, size, selectedList.get(position));
    }

    mCodeForChooseAdapters.add(codeForChooseAdapter);
    rvCodes.setAdapter(codeForChooseAdapter);
}
 
Example #30
Source File: MainActivity.java    From RetroMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
NavigationItemsAdapter() {
    mList.add(new Pair<>(R.drawable.ic_home_white_24dp, R.string.home));
    mList.add(new Pair<>(R.drawable.ic_library_add_white_24dp, R.string.library));
    mList.add(new Pair<>(R.drawable.ic_folder_white_24dp, R.string.folders));
    mList.add(new Pair<>(R.drawable.ic_favorite_white_24dp, R.string.support_development));
    mList.add(new Pair<>(R.drawable.ic_settings_white_24dp, R.string.action_settings));
    mList.add(new Pair<>(R.drawable.ic_help_white_24dp, R.string.action_about));
}