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 Project: trust-wallet-android-source   Author: trustwallet   File: ImportWalletActivity.java    License: 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 #2
Source Project: scene   Author: bytedance   File: GroupSceneManager.java    License: 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 #3
Source Project: openlauncher   Author: OpenLauncherTeam   File: ContextUtils.java    License: 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 #4
Source Project: scene   Author: bytedance   File: NavigationStackTests.java    License: 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 #5
Source Project: Ticket-Analysis   Author: xiaolongonly   File: AvgAnalysisActivity.java    License: 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 #6
Source Project: scene   Author: bytedance   File: GroupSceneTransactionTests.java    License: 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 #7
Source Project: scene   Author: bytedance   File: GroupSceneTransactionTests.java    License: 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 #8
Source Project: scene   Author: bytedance   File: ScenePlaceHolderViewTests.java    License: 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 #9
Source Project: scene   Author: bytedance   File: NavigationSceneListenerTests.java    License: 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 #10
Source Project: native-navigation   Author: airbnb   File: AutoSharedElementCallback.java    License: 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 #11
Source Project: android-topeka   Author: googlearchive   File: CategorySelectionFragment.java    License: 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 #12
Source Project: firebase-jobdispatcher-android   Author: googlearchive   File: JobServiceConnectionTest.java    License: 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 #13
Source Project: graphhopper-navigation-android   Author: graphhopper   File: NavigationHelperTest.java    License: 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 #14
Source Project: Shield   Author: Meituan-Dianping   File: MoveStatusExposeEngine.java    License: 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 #15
Source Project: IdeaTrackerPlus   Author: IdeaTrackerPlus   File: DatabaseHelper.java    License: 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 #16
Source Project: Orin   Author: aliumujib   File: SearchAdapter.java    License: 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 #17
Source Project: BlackList   Author: kaliturin   File: AddOrEditContactFragment.java    License: 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 #18
Source Project: Tok-Android   Author: InsightIM   File: BasePageJump.java    License: GNU General Public License v3.0 5 votes vote down vote up
protected static void jumpWithTransition(Context context, Intent intent,
    Pair<View, String>... sharedElements) {
    if (context instanceof Activity
        && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1
        && sharedElements != null
        && sharedElements.length > 0) {
        ActivityOptionsCompat compat =
            ActivityOptionsCompat.makeSceneTransitionAnimation((Activity) context,
                sharedElements);
        ActivityCompat.startActivity(context, intent, compat.toBundle());
    } else {
        jump(context, intent);
    }
}
 
Example #19
Source Project: scene   Author: bytedance   File: SharedElementUtils.java    License: 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 #20
Source Project: scene   Author: bytedance   File: ViewAnimationBuilder.java    License: Apache License 2.0 5 votes vote down vote up
private void animatePropertyBy(int constantName, float fromValue, float deltaValue) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        if (constantName == TRANSLATION_Z || constantName == Z) {
            return;
        }
    }
    hashMap.put(propertySparseArrayCompat.get(constantName), new Pair<>(fromValue, deltaValue));
}
 
Example #21
Source Project: scene   Author: bytedance   File: InteractionAnimationBuilder.java    License: Apache License 2.0 5 votes vote down vote up
private void animatePropertyBy(int constantName, float fromValue, float deltaValue) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        if (constantName == TRANSLATION_Z || constantName == Z) {
            return;
        }
    }
    hashMap.put(propertySparseArrayCompat.get(constantName), new Pair<>(fromValue, deltaValue));
}
 
Example #22
Source Project: droidconat-2016   Author: Nilhcem   File: ScheduleDayFragmentAdapterAllSessions.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(ScheduleDayEntry holder, int position) {
    Pair<Session, ScheduleSlot> pair = sessions.get(position);
    Session session = pair.first;
    ScheduleSlot slot = pair.second;

    if (session.getRoom().equals(Room.NONE.label)) {
        holder.bindBreakSlot(slot, session, shouldShowTime(slot, position));
    } else {
        holder.bindSelectedSession(slot, session, shouldShowTime(slot, position), selectedSessionsMemory.isSelected(session));
    }
}
 
Example #23
Source Project: eternity   Author: ashdavies   File: MessageViewHolder.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void bind(Pair<Message, MessageState> pair) {
  Message message = pair.first;

  if (message.original() != null) {
    reposted.setText(resolver.get(R.string.label_reposted, message.author().name()));
    reposted.setVisibility(View.VISIBLE);

    message = message.original();
  }

  Picasso.with(getContext())
      .load(message.author().avatar())
      .transform(new CircleTransform(12))
      .into(avatar);

  favourite.setChecked(pair.second.favourite());
  favourite.setVisibility(listener.favouriteEnabled() ? View.VISIBLE : View.GONE);

  author.setText(message.author().name());
  text.setText(message.text());

  repost.setOnClickListener(new RepostClickListener(listener, message));
  repost.setVisibility(listener.repostEnabled() ? View.VISIBLE : View.GONE);

  favourite.setOnClickListener(new FavouriteClickListener(listener, message));

  ago.setText(formatter.format(message.created()));
}
 
Example #24
Source Project: droidddle   Author: goodev   File: UiUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static void launchUser(Activity activity, User data, View view) {
    //new Pair<View, String>(mUserNameView, Scene.USER_NAME)
    ActivityOptionsCompat opts = ActivityOptionsCompat.makeSceneTransitionAnimation(activity,
            new Pair<View, String>(view, Scene.USER_IMAGE));
    Intent intent = new Intent(activity, UserActivity.class);
    intent.putExtra(UiUtils.ARG_USER, data);
    ActivityCompat.startActivity(activity, intent, opts.toBundle());
    //        activity.startActivity(intent);
}
 
Example #25
Source Project: AndroidUtilCode   Author: Blankj   File: ActivityUtils.java    License: Apache License 2.0 5 votes vote down vote up
private static Bundle getOptionsBundle(final Activity activity,
                                       final View[] sharedElements) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return null;
    if (sharedElements == null) return null;
    int len = sharedElements.length;
    if (len <= 0) return null;
    @SuppressWarnings("unchecked")
    Pair<View, String>[] pairs = new Pair[len];
    for (int i = 0; i < len; i++) {
        pairs[i] = Pair.create(sharedElements[i], sharedElements[i].getTransitionName());
    }
    return ActivityOptionsCompat.makeSceneTransitionAnimation(activity, pairs).toBundle();
}
 
Example #26
Source Project: scene   Author: bytedance   File: NavigationStackTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testPushClearTaskPredicate() {
    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();

    TestChildScene secondScene = new TestChildScene();

    navigationScene.push(secondScene);

    assertEquals(secondScene.getState(), State.RESUMED);
    assertEquals(groupScene.getState(), State.ACTIVITY_CREATED);
    assertEquals(2, navigationScene.getSceneList().size());

    TestChild0Scene thirdScene = new TestChild0Scene();
    navigationScene.push(thirdScene, new PushOptions.Builder().setRemovePredicate(new PushOptions.ClearTaskPredicate()).build());
    assertEquals(thirdScene.getState(), State.RESUMED);
    assertEquals(secondScene.getState(), State.NONE);
    assertEquals(groupScene.getState(), State.NONE);
    assertEquals(1, navigationScene.getSceneList().size());
    assertEquals(thirdScene, navigationScene.getCurrentScene());

    navigationScene.push(groupScene, new PushOptions.Builder().setRemovePredicate(new PushOptions.ClearTaskPredicate()).build());
    assertEquals(1, navigationScene.getSceneList().size());
    assertEquals(groupScene, navigationScene.getCurrentScene());
}
 
Example #27
Source Project: RHub   Author: apptik   File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    ToggleButton btnLight = (ToggleButton) findViewById(R.id.btnLight);
    ToggleButton btnAcc = (ToggleButton) findViewById(R.id.btnAcc);

    shield.addActionEvent(RxCompoundButton.checkedChanges(btnLight).map(aBoolean -> {
        if (aBoolean) return new Pair<>(LightOn,btnLight.getContext());
        else return new Pair<>(LightOff,btnLight.getContext());
    }));
    shield.addActionEvent(RxCompoundButton.checkedChanges(btnAcc).map(aBoolean -> {
        if (aBoolean) return new Pair<>(AccOn,btnAcc.getContext());
        else return new Pair<>(AccOff,btnAcc.getContext());
    }));
}
 
Example #28
Source Project: Orin   Author: aliumujib   File: CustomPlaylistSongAdapter.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
protected boolean onSongMenuItemClick(MenuItem item) {
    if (item.getItemId() == R.id.action_go_to_album) {
        Pair[] albumPairs = new Pair[]{
                Pair.create(image, activity.getString(R.string.transition_album_art))
        };
        NavigationUtil.goToAlbum(activity, dataSet.get(getAdapterPosition()).albumId, albumPairs);
        return true;
    }
    return super.onSongMenuItemClick(item);
}
 
Example #29
Source Project: OneTapVideoDownload   Author: Ashish-Bansal   File: DownloadManager.java    License: GNU General Public License v3.0 5 votes vote down vote up
public int getDownloadCountByStatus(DownloadInfo.Status status) {
    Integer count = 0;
    for (Pair<Long, DownloadHandler> p : mDownloadHandlers) {
        if (p.second.getStatus() == status) {
            count++;
        }
    }
    return count;
}
 
Example #30
Source Project: RetroMusicPlayer   Author: deepshooter   File: PlaylistSongAdapter.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
protected boolean onSongMenuItemClick(MenuItem item) {
    if (item.getItemId() == R.id.action_go_to_album) {
        Pair[] albumPairs = new Pair[]{
                Pair.create(image, activity.getString(R.string.transition_album_art))
        };
        NavigationUtil.goToAlbum(activity, dataSet.get(getAdapterPosition() - 1).albumId, albumPairs);
        return true;
    }
    return super.onSongMenuItemClick(item);
}