use of email.schaal.ocreader.database.model.Item in project ocreader by schaal.
the class ItemPagerActivityTest method testItemPagerActivity.
@Test
public void testItemPagerActivity() throws Exception {
Intent intent = new Intent(Intent.ACTION_VIEW);
ArrayList<Item> items = new ArrayList<>();
items.add(TestGenerator.getTestItem(1));
items.add(TestGenerator.getTestItem(2));
intent.putExtra("ARG_ITEMS", items);
activityTestRule.launchActivity(intent);
onView(withId(R.id.container)).perform(swipeLeft());
onView(withId(R.id.container)).perform(swipeRight());
}
use of email.schaal.ocreader.database.model.Item in project ocreader by schaal.
the class ItemPageFragment method onStart.
@Override
public void onStart() {
super.onStart();
final Bundle arguments = getArguments();
if (arguments != null) {
final Item item = arguments.getParcelable(ARG_ITEM);
webView.setItem(item);
} else {
// TODO: 3/30/18 show error
}
}
use of email.schaal.ocreader.database.model.Item in project ocreader by schaal.
the class ListActivity method onPrepareActionMode.
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
int selectedItemsCount = adapter.getSelectedItemsCount();
// the menu only changes on the first and second selection
if (selectedItemsCount > 2)
return false;
Item firstSelectedItem = adapter.getFirstSelectedItem();
boolean firstSelectedUnread = firstSelectedItem != null && firstSelectedItem.isUnread();
menu.findItem(R.id.action_mark_read).setVisible(firstSelectedUnread);
menu.findItem(R.id.action_mark_unread).setVisible(!firstSelectedUnread);
boolean firstSelectedStarred = firstSelectedItem != null && firstSelectedItem.isStarred();
menu.findItem(R.id.action_mark_starred).setVisible(!firstSelectedStarred);
menu.findItem(R.id.action_mark_unstarred).setVisible(firstSelectedStarred);
menu.findItem(R.id.action_mark_above_read).setVisible(selectedItemsCount == 1);
return true;
}
use of email.schaal.ocreader.database.model.Item in project ocreader by schaal.
the class ItemsAdapter method updateItems.
public void updateItems(boolean updateTemporaryFeed) {
if (state.getTreeItem() == null)
return;
final TemporaryFeed temporaryFeed = TemporaryFeed.getListTemporaryFeed(realm);
if (updateTemporaryFeed || temporaryFeed.getTreeItemId() != state.getTreeItem().getId()) {
realm.executeTransaction(realm -> {
List<Item> tempItems = state.getTreeItem().getItems(realm, isOnlyUnread());
temporaryFeed.setTreeItemId(state.getTreeItem().getId());
temporaryFeed.setName(state.getTreeItem().getName());
temporaryFeed.getItems().clear();
if (tempItems != null) {
temporaryFeed.getItems().addAll(tempItems);
}
});
}
items = temporaryFeed.getItems().sort(Preferences.SORT_FIELD.getString(preferences), Preferences.ORDER.getOrder(preferences));
notifyDataSetChanged();
}
Aggregations