Search in sources :

Example 16 with Entry

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

the class LikeStateTests method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    entryManager = EntryManager.getInstance(getInstrumentation().getTargetContext());
    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 = new Entry();
    e.setAtomId("atomid2");
    e.setFeedTitle("feed_title");
    e.setFeedAtomId("feed_atom_id");
    e.setTitle("title");
    e.setUpdated(new Date().getTime() * 1000);
    entryManager.insert(e);
    System.out.println("Loaded db.");
}
Also used : Entry(com.newsrob.Entry) Label(com.newsrob.Label) Date(java.util.Date)

Example 17 with Entry

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

the class LikeStateTests method testUpdateNotification.

public void testUpdateNotification() {
    entryManager.addListener(new IEntryModelUpdateListener() {

        @Override
        public void statusUpdated() {
        }

        @Override
        public void modelUpdated(String atomId) {
            modelUpdatedStringCalled = true;
        }

        @Override
        public void modelUpdated() {
            modelUpdatedCalled = true;
        }

        @Override
        public void modelUpdateStarted(boolean fastSyncOnly) {
        }

        @Override
        public void modelUpdateFinished(ModelUpdateResult result) {
        }
    });
    Entry e = findEntryNotLikedNotLikePending();
    assertTrue(modelUpdatedCalled);
}
Also used : IEntryModelUpdateListener(com.newsrob.IEntryModelUpdateListener) Entry(com.newsrob.Entry) ModelUpdateResult(com.newsrob.jobs.ModelUpdateResult)

Example 18 with Entry

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

the class PinTests method testIncreaseReadLevelFromPinned.

/**
	 * In this test only it is also validated that the in-memory and on-disk
	 * version of the article are updated. In the other tests only the in-memory
	 * version is validated as this test's subject are the state transitions.
	 * 
	 * Also this test contains increasing the read level and then increasing the
	 * unread level again.
	 */
public void testIncreaseReadLevelFromPinned() {
    Entry article = createArticleWithReadState(ReadState.PINNED);
    assertFalse(article.isReadStatePending());
    entryManager.increaseReadLevel(article);
    assertEquals(ReadState.READ, article.getReadState());
    assertTrue(article.isReadStatePending());
    article = entryManager.findEntryByAtomId("atomid1");
    assertEquals(ReadState.READ, article.getReadState());
    assertTrue(article.isReadStatePending());
    // no change when increasing the Read Level again
    entryManager.increaseReadLevel(article);
    assertEquals(ReadState.READ, article.getReadState());
    assertTrue(article.isReadStatePending());
    entryManager.increaseUnreadLevel(article);
    assertEquals(ReadState.UNREAD, article.getReadState());
    assertFalse(article.isReadStatePending());
    entryManager.increaseUnreadLevel(article);
    assertEquals(ReadState.PINNED, article.getReadState());
    assertFalse(article.isReadStatePending());
}
Also used : Entry(com.newsrob.Entry)

Example 19 with Entry

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

the class PinTests method testIncreaseReadLevelFromRead.

public void testIncreaseReadLevelFromRead() {
    Entry article = createArticleWithReadState(ReadState.READ);
    entryManager.increaseReadLevel(article);
    assertEquals(ReadState.READ, article.getReadState());
    assertFalse(article.isReadStatePending());
}
Also used : Entry(com.newsrob.Entry)

Example 20 with Entry

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

the class ShowArticleActivity method viewFeedContent.

private void viewFeedContent() {
    setFeedViewsBackgroundColor();
    Entry selectedEntry = getSelectedEntry();
    if (debug)
        PL.log("ADV: viewFeedContent " + selectedEntry.getTitle(), this);
    if (shouldSkipReloading(selectedEntry))
        return;
    webView.getSettings().setUseWideViewPort(false);
    this.atomIdOfCurrentlyShowingArticle = selectedEntry.getAtomId();
    boolean feedContentAvailableLocal = false;
    String localUrl = AssetContentProvider.CONTENT_URI + "/a" + getSelectedEntry().getShortAtomId() + "/a" + getSelectedEntry().getShortAtomId() + "_s.html";
    try {
        feedContentAvailableLocal = (selectedEntry.getDownloaded() == Entry.STATE_DOWNLOADED_FEED_CONTENT || selectedEntry.getDownloaded() == Entry.STATE_DOWNLOADED_FULL_PAGE) && getContentResolver().openFileDescriptor(Uri.parse(localUrl), null) != null;
    } catch (FileNotFoundException e) {
    }
    if (debug)
        PL.log("ADV: viewFeedContent localContentAvailable " + selectedEntry.getTitle() + " " + feedContentAvailableLocal, this);
    if (feedContentAvailableLocal) {
        // webView.loadUrl(localUrl);
        final String baseUrl = selectedEntry.getBaseUrl(getEntryManager());
        final String content = getTopDecoration(selectedEntry) + loadContent(localUrl) + ShowArticleActivity.getBodyBottomDecoration();
        final String contentType = "text/" + selectedEntry.getContentType();
        if (debug)
            PL.log("ADV: viewFeedContent (locally) " + selectedEntry.getTitle() + " \n  baseUrl=" + baseUrl + "\n  contentType=" + contentType + "\n  content=" + content, this);
        webView.loadDataWithBaseURL(baseUrl, content, contentType, "utf-8", null);
    } else if (selectedEntry.getContent() != null) {
        final String content = (selectedEntry.getContent() != null ? selectedEntry.getContent() : "");
        final String html = getTopDecoration(selectedEntry) + content + ShowArticleActivity.getBodyBottomDecoration();
        final String contentType = "text/" + selectedEntry.getContentType();
        if (debug)
            PL.log("ADV: viewFeedContent (inline) " + selectedEntry.getTitle() + "\n  contentType=" + contentType + "\n  content=" + content + "\n  html=" + html, this);
        webView.loadDataWithBaseURL(selectedEntry.getBaseUrl(getEntryManager()), html, contentType, "utf-8", null);
    } else if (selectedEntry.getContentURL() != null) {
        webView.loadUrl(selectedEntry.getContentURL());
    } else {
        if (debug)
            PL.log("ADV: viewFeedContent (title) " + selectedEntry.getTitle(), this);
        final String html = getTopDecoration(selectedEntry) + "<p>" + (UIHelper.linkize(selectedEntry.getAlternateHRef(), selectedEntry.getTitle())) + "</p>" + ShowArticleActivity.getBodyBottomDecoration();
        webView.loadDataWithBaseURL(selectedEntry.getBaseUrl(getEntryManager()), html, "text/html", "UTF-8", null);
    }
}
Also used : Entry(com.newsrob.Entry) FileNotFoundException(java.io.FileNotFoundException)

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