Search in sources :

Example 21 with Entry

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

the class ShowArticleActivity method onResume.

@Override
protected void onResume() {
    NewsRob.lastActivity = this;
    super.onResume();
    webView.resumeTimers();
    try {
        Method m = webView.getClass().getMethod("onResume", null);
        m.invoke(webView, new Object[] {});
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (false)
        UIHelper.resumeWebViews(this);
    if (currentTheme != getEntryManager().getCurrentThemeResourceId()) {
        finish();
        startActivity(getIntent());
    } else {
        if (getWebView() != null) {
            PL.log("WebView timer resumed.", this);
            webView.resumeTimers();
        } else
            PL.log("WebView timer not resumed.", this);
        // that was stored, otherwise rewind.
        try {
            if (savedContentCursorPosition != -1 && savedContentCursoCurrentId != null) {
                contentCursor.moveToPosition(savedContentCursorPosition);
                if (!savedContentCursoCurrentId.equals(contentCursor.getLong(0)))
                    contentCursor.moveToPosition(-1);
            }
        } catch (CursorIndexOutOfBoundsException e) {
            contentCursor.moveToPosition(-1);
        }
        if (false)
            googleAdsUtil.showAds(this);
        leavingThisActivity = false;
        getEntryManager().addListener(this);
        Entry selectedEntry = getSelectedEntry();
        if (selectedEntry != null) {
            PL.log("ADV: onResume()1 Article " + selectedEntry.getTitle() + " was already read=" + articleWasAlreadyRead, this);
            // articleWasAlreadyRead = selectedEntry.getReadState() ==
            // ReadState.READ;
            PL.log("ADV: onResume()2 Article " + selectedEntry.getTitle() + " was already read=" + articleWasAlreadyRead, this);
            if (selectedEntry.getReadState() == ReadState.UNREAD)
                setArticleReadStateAsynchronously(selectedEntry, ReadState.READ);
        }
        view();
        refreshUI();
        savedContentCursorPosition = -1;
        savedContentCursoCurrentId = null;
    }
    if (entryManager.isProVersion() && entryManager.getDaysInstalled() > 0)
        MessageHelper.showMessage(this, R.string.explain_fullscreen_toggle_title, R.string.explain_fullscreen_toggle_message, "explain_fullscreen_toggle");
    if ("1".equals(NewsRob.getDebugProperties(this).getProperty("traceArticleDetailViewLaunch", "0")))
        Debug.stopMethodTracing();
}
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 22 with Entry

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

the class UnsubscribeFeedTask method findEntryByPosition.

private Entry findEntryByPosition(final int position) {
    final Cursor cursor = (Cursor) getListView().getItemAtPosition(position);
    String atomId = null;
    try {
        atomId = cursor.getString(1);
    } catch (final CursorIndexOutOfBoundsException cioobe) {
    // atomId stays null
    }
    if (atomId == null)
        return null;
    final Entry selectedEntry = getEntryManager().findEntryByAtomId(atomId);
    return selectedEntry;
}
Also used : CursorIndexOutOfBoundsException(android.database.CursorIndexOutOfBoundsException) Entry(com.newsrob.Entry) Cursor(android.database.Cursor)

Example 23 with Entry

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

the class UnsubscribeFeedTask method onCreateContextMenu.

@Override
public void onCreateContextMenu(final ContextMenu menu, final View v, final ContextMenuInfo menuInfo, final int position) {
    final Entry entry = findEntryByPosition(position);
    if (entry != null) {
        ArticleViewHelper.createArticleMenu(menu, this, entry);
        if (getEntryManager().isProVersion())
            menu.add(0, MENU_ITEM_MARK_READ_UNTIL_HERE_ID, 3, "Mark Read Until Here");
        else {
            menu.add(0, MENU_ITEM_MARK_READ_UNTIL_HERE_ID, 99, "Mark Read Until Here").setEnabled(false);
        }
        boolean feedCanBeUnsubscribed = false;
        Feed f = getEntryManager().findFeedById(entry.getFeedId());
        if (f != null)
            feedCanBeUnsubscribed = !getEntryManager().isModelCurrentlyUpdated() && getEntryManager().canFeedBeUnsubscribed(f.getAtomId());
        menu.add(0, MENU_ITEM_UNSUBSCRIBE_FEED_ID, 10, "Unsubscribe Feed").setEnabled(feedCanBeUnsubscribed);
    }
}
Also used : Entry(com.newsrob.Entry) Feed(com.newsrob.Feed)

Example 24 with Entry

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

the class ShowArticleInfoActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.show_article_info);
    String atomId = getIntent().getExtras().getString(EXTRA_ATOM_ID);
    if (atomId == null)
        finish();
    Entry entry = EntryManager.getInstance(this).findEntryByAtomId(atomId);
    if (entry == null)
        finish();
    TextView textView = (TextView) findViewById(R.id.error);
    textView.setText("" + entry.getError() + " (" + atomId + ")");
}
Also used : Entry(com.newsrob.Entry) TextView(android.widget.TextView)

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