@Test public void testSort() { Intent intent = new Intent(); intent.putExtra(SearchManager.QUERY, "filter"); controller = Robolectric.buildActivity(SearchActivity.class, intent); controller.create().postCreate(null).start().resume().visible(); activity = controller.get(); assertTrue(AlgoliaClient.sSortByTime); activity.onOptionsItemSelected(shadowOf(activity).getOptionsMenu() .findItem(R.id.menu_sort_recent)); activity.onOptionsItemSelected(shadowOf(activity).getOptionsMenu() .findItem(R.id.menu_sort_popular)); assertFalse(AlgoliaClient.sSortByTime); verify(itemManager, times(2)).getStories(any(), eq(ItemManager.MODE_DEFAULT)); }
private void sort(boolean byTime) { if (AlgoliaClient.sSortByTime == byTime) { return; } AlgoliaClient.sSortByTime = byTime; Preferences.setSortByRecent(this, byTime); ListFragment listFragment = (ListFragment) getSupportFragmentManager() .findFragmentByTag(LIST_FRAGMENT_TAG); if (listFragment != null) { listFragment.filter(mQuery); } }
SearchActivity extends BaseListActivity { private void sort(boolean byTime) { if (AlgoliaClient.sSortByTime == byTime) { return; } AlgoliaClient.sSortByTime = byTime; Preferences.setSortByRecent(this, byTime); ListFragment listFragment = (ListFragment) getSupportFragmentManager() .findFragmentByTag(LIST_FRAGMENT_TAG); if (listFragment != null) { listFragment.filter(mQuery); } } }
SearchActivity extends BaseListActivity { private void sort(boolean byTime) { if (AlgoliaClient.sSortByTime == byTime) { return; } AlgoliaClient.sSortByTime = byTime; Preferences.setSortByRecent(this, byTime); ListFragment listFragment = (ListFragment) getSupportFragmentManager() .findFragmentByTag(LIST_FRAGMENT_TAG); if (listFragment != null) { listFragment.filter(mQuery); } }  }
SearchActivity extends BaseListActivity { private void sort(boolean byTime) { if (AlgoliaClient.sSortByTime == byTime) { return; } AlgoliaClient.sSortByTime = byTime; Preferences.setSortByRecent(this, byTime); ListFragment listFragment = (ListFragment) getSupportFragmentManager() .findFragmentByTag(LIST_FRAGMENT_TAG); if (listFragment != null) { listFragment.filter(mQuery); } }  @Override boolean onCreateOptionsMenu(Menu menu); @Override boolean onPrepareOptionsMenu(Menu menu); @Override boolean onOptionsItemSelected(MenuItem item); }
SearchActivity extends BaseListActivity { private void sort(boolean byTime) { if (AlgoliaClient.sSortByTime == byTime) { return; } AlgoliaClient.sSortByTime = byTime; Preferences.setSortByRecent(this, byTime); ListFragment listFragment = (ListFragment) getSupportFragmentManager() .findFragmentByTag(LIST_FRAGMENT_TAG); if (listFragment != null) { listFragment.filter(mQuery); } }  @Override boolean onCreateOptionsMenu(Menu menu); @Override boolean onPrepareOptionsMenu(Menu menu); @Override boolean onOptionsItemSelected(MenuItem item);  }