Search in sources :

Example 6 with Item

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());
}
Also used : Item(email.schaal.ocreader.database.model.Item) ArrayList(java.util.ArrayList) Intent(android.content.Intent) Test(org.junit.Test) LargeTest(android.support.test.filters.LargeTest)

Example 7 with Item

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
    }
}
Also used : Item(email.schaal.ocreader.database.model.Item) Bundle(android.os.Bundle)

Example 8 with Item

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;
}
Also used : Item(email.schaal.ocreader.database.model.Item) ProfileSettingDrawerItem(com.mikepenz.materialdrawer.model.ProfileSettingDrawerItem) PrimaryDrawerItem(com.mikepenz.materialdrawer.model.PrimaryDrawerItem) IDrawerItem(com.mikepenz.materialdrawer.model.interfaces.IDrawerItem) TreeItem(email.schaal.ocreader.database.model.TreeItem) MenuItem(android.view.MenuItem) ProfileDrawerItem(com.mikepenz.materialdrawer.model.ProfileDrawerItem)

Example 9 with Item

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();
}
Also used : Item(email.schaal.ocreader.database.model.Item) TemporaryFeed(email.schaal.ocreader.database.model.TemporaryFeed)

Aggregations

Item (email.schaal.ocreader.database.model.Item)9 Intent (android.content.Intent)2 Bundle (android.os.Bundle)2 MenuItem (android.view.MenuItem)2 PrimaryDrawerItem (com.mikepenz.materialdrawer.model.PrimaryDrawerItem)2 ProfileDrawerItem (com.mikepenz.materialdrawer.model.ProfileDrawerItem)2 ProfileSettingDrawerItem (com.mikepenz.materialdrawer.model.ProfileSettingDrawerItem)2 IDrawerItem (com.mikepenz.materialdrawer.model.interfaces.IDrawerItem)2 Test (org.junit.Test)2 Activity (android.app.Activity)1 BroadcastReceiver (android.content.BroadcastReceiver)1 Context (android.content.Context)1 SharedPreferences (android.content.SharedPreferences)1 DataBindingUtil (android.databinding.DataBindingUtil)1 Bitmap (android.graphics.Bitmap)1 BitmapFactory (android.graphics.BitmapFactory)1 PreferenceManager (android.preference.PreferenceManager)1 NonNull (android.support.annotation.NonNull)1 Nullable (android.support.annotation.Nullable)1 Snackbar (android.support.design.widget.Snackbar)1