Search in sources :

Example 11 with Entry

use of com.newsrob.Entry in project newsrob by marianokamp.

the class ShowArticleActivity method onPause.

@Override
protected void onPause() {
    final String tmpTitle = selectedEntry != null ? selectedEntry.getTitle() : "Selected Entry is null";
    PL.log("ADV: onPause() Article " + tmpTitle + " was already read=" + articleWasAlreadyRead + " leaving this activity=" + leavingThisActivity, this);
    if (!leavingThisActivity && !articleWasAlreadyRead) {
        Entry selectedEntry = getSelectedEntry();
        if (selectedEntry != null && selectedEntry.getReadState() == ReadState.READ) {
            PL.log("ADV: onPause() Article " + selectedEntry.getTitle() + " submitting mark unread", this);
            setArticleReadStateAsynchronously(selectedEntry, ReadState.UNREAD);
        }
    }
    getEntryManager().removeListener(this);
    webView.stopLoading();
    webView.clearCache(true);
    if (false)
        googleAdsUtil.hideAds(this);
    if (getSelectedEntry() != null) {
        try {
            savedContentCursorPosition = contentCursor.getPosition();
            savedContentCursoCurrentId = contentCursor.getLong(0);
        } catch (CursorIndexOutOfBoundsException cioobe) {
            savedContentCursorPosition = -1;
            savedContentCursoCurrentId = null;
        }
    }
    if (false)
        UIHelper.pauseWebViews(this);
    webView.pauseTimers();
    try {
        Method m = webView.getClass().getMethod("onPause", null);
        m.invoke(webView, new Object[] {});
    } catch (Exception e) {
        e.printStackTrace();
    }
    super.onPause();
}
Also used : CursorIndexOutOfBoundsException(android.database.CursorIndexOutOfBoundsException) Entry(com.newsrob.Entry) Method(java.lang.reflect.Method) FileNotFoundException(java.io.FileNotFoundException) ActivityNotFoundException(android.content.ActivityNotFoundException) IOException(java.io.IOException) CursorIndexOutOfBoundsException(android.database.CursorIndexOutOfBoundsException)

Example 12 with Entry

use of com.newsrob.Entry in project newsrob by marianokamp.

the class MarkReadUntilHereUITests method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    setActivityInitialTouchMode(false);
    entryManager = EntryManager.getInstance(getActivity());
    entryManager.doClearCache();
    setMarkAllReadConfirmationThreshold(50);
    for (String atomId : new String[] { "a1", "a2", "a3", "a4", "a5" }) {
        Entry e = new Entry();
        e.setAtomId(atomId);
        e.setFeedTitle("feed_title " + atomId);
        e.setFeedAtomId("feed_atom_id " + atomId);
        e.setTitle("title " + atomId);
        e.setUpdated(new Date().getTime() * 1000);
        entryManager.insert(e);
    }
    entryManager.fireModelUpdated();
    assertEquals(5, entryManager.getUnreadArticleCount());
    assertEquals(5, entryManager.getArticleCount());
}
Also used : Entry(com.newsrob.Entry) Date(java.util.Date)

Example 13 with Entry

use of com.newsrob.Entry in project newsrob by marianokamp.

the class DashboardListActivityTests method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    setActivityInitialTouchMode(false);
    activity = getActivity();
    listView = (ListView) activity.findViewById(android.R.id.list);
    entryManager = EntryManager.getInstance(activity);
    Label l1 = new Label();
    l1.setName("l1");
    Label l2 = new Label();
    l2.setName("l2");
    // 1st article
    Entry e = new Entry();
    e.setAtomId("atomid");
    e.setFeedTitle("feed_title");
    e.setFeedAtomId("feed_atom_id");
    e.setTitle("title");
    e.setUpdated(new Date().getTime() * 1000);
    entryManager.insert(e);
    // 2nd article
    e.setAtomId("atomid_2");
    e.setTitle("title2");
    e.addLabel(l1);
    entryManager.insert(e);
    // 3rd article
    e.setAtomId("atomid_3");
    e.setTitle("title3");
    e.setFeedTitle("feed_title2");
    e.setFeedAtomId("feed_atom_id2");
    e.addLabel(l2);
    entryManager.insert(e);
    entryManager.fireModelUpdated();
    System.out.println("Loaded db.");
}
Also used : Entry(com.newsrob.Entry) Label(com.newsrob.Label) Date(java.util.Date)

Example 14 with Entry

use of com.newsrob.Entry in project newsrob by marianokamp.

the class DifferentialUpdateTests method createTestDataSet1.

private void createTestDataSet1() {
    Label l1 = new Label();
    l1.setName("l1");
    Label l2 = new Label();
    l2.setName("l2");
    // 1st article
    Entry e = new Entry();
    e.setAtomId(getAtomIdForArticle(1));
    e.setReadState(ReadState.READ);
    e.setReadStatePending(false);
    e.setFeedTitle("feed_title");
    e.setFeedAtomId("feed_atom_id");
    e.setTitle("title");
    e.setUpdated(new Date().getTime() * 1000);
    entryManager.insert(e);
    // 2nd article
    e = new Entry();
    e.setAtomId(getAtomIdForArticle(2));
    e.setFeedTitle("feed_title");
    e.setFeedAtomId("feed_atom_id");
    e.setReadState(ReadState.UNREAD);
    e.setReadStatePending(false);
    e.setTitle("title");
    e.setUpdated(new Date().getTime() * 1000);
    entryManager.insert(e);
    // 3rd article
    e = new Entry();
    e.setAtomId(getAtomIdForArticle(3));
    e.setFeedTitle("feed_title");
    e.setFeedAtomId("feed_atom_id");
    e.setReadState(ReadState.PINNED);
    e.setReadStatePending(false);
    e.setTitle("title");
    e.setUpdated(new Date().getTime() * 1000);
    entryManager.insert(e);
}
Also used : Entry(com.newsrob.Entry) Label(com.newsrob.Label) Date(java.util.Date)

Example 15 with Entry

use of com.newsrob.Entry in project newsrob by marianokamp.

the class DifferentialUpdateTests method testDifferentialUpdateRead1.

public void testDifferentialUpdateRead1() throws Exception {
    createTestDataSet1();
    // One pinned, one unread, one read
    assertEquals(3, entryManager.getArticleCount());
    assertEquals(2, entryManager.getUnreadArticleCount());
    assertEquals(1, entryManager.getUnreadArticleCountExcludingPinned());
    // do
    final EntriesRetriever entriesRetriever = getEntriesRetriever(new String[] { getAtomIdForArticle(1) });
    // First article should now be unread,
    // 2nd article should now be read,
    // 3rd article should now be read.
    entriesRetriever.differentialUpdateOfArticlesStates(entryManager, TestUtil.getDummyJob(entryManager), EntriesRetriever.GOOGLE_STATE_READING_LIST, EntriesRetriever.GOOGLE_STATE_READ, ArticleDbState.READ);
    // Unchanged
    assertEquals(3, entryManager.getArticleCount());
    assertEquals(1, entryManager.getUnreadArticleCount());
    assertEquals(1, entryManager.getUnreadArticleCountExcludingPinned());
    Entry firstArticle = entryManager.findEntryByAtomId(getAtomIdForArticle(1));
    assertEquals(ReadState.UNREAD, firstArticle.getReadState());
    assertFalse(firstArticle.isReadStatePending());
    Entry secondArticle = entryManager.findEntryByAtomId(getAtomIdForArticle(2));
    assertEquals(ReadState.READ, secondArticle.getReadState());
    assertFalse(secondArticle.isReadStatePending());
    Entry thirdArticle = entryManager.findEntryByAtomId(getAtomIdForArticle(3));
    assertEquals(ReadState.READ, thirdArticle.getReadState());
    assertFalse(thirdArticle.isReadStatePending());
}
Also used : Entry(com.newsrob.Entry) EntriesRetriever(com.newsrob.EntriesRetriever)

Aggregations

Entry (com.newsrob.Entry)24 Date (java.util.Date)6 Label (com.newsrob.Label)4 CursorIndexOutOfBoundsException (android.database.CursorIndexOutOfBoundsException)3 FileNotFoundException (java.io.FileNotFoundException)3 ActivityNotFoundException (android.content.ActivityNotFoundException)2 DBQuery (com.newsrob.DBQuery)2 EntriesRetriever (com.newsrob.EntriesRetriever)2 Feed (com.newsrob.Feed)2 IOException (java.io.IOException)2 Method (java.lang.reflect.Method)2 Cursor (android.database.Cursor)1 TextView (android.widget.TextView)1 IEntryModelUpdateListener (com.newsrob.IEntryModelUpdateListener)1 ModelUpdateResult (com.newsrob.jobs.ModelUpdateResult)1