Search in sources :

Example 11 with CursorIndexOutOfBoundsException

use of android.database.CursorIndexOutOfBoundsException in project android_frameworks_base by ParanoidAndroid.

the class DatabaseCursorTest method testCursor2.

@MediumTest
public void testCursor2() throws Exception {
    populateDefaultTable();
    Cursor c = mDatabase.query("test", null, "_id > 1000", null, null, null, null);
    assertEquals(0, c.getCount());
    assertTrue(c.isBeforeFirst());
    try {
        c.getInt(0);
        fail("CursorIndexOutOfBoundsException expected");
    } catch (CursorIndexOutOfBoundsException ex) {
    // expected
    }
    int i;
    for (c.moveToFirst(), i = 0; !c.isAfterLast(); c.moveToNext(), i++) {
        c.getInt(0);
    }
    assertEquals(0, i);
    try {
        c.getInt(0);
        fail("CursorIndexOutOfBoundsException expected");
    } catch (CursorIndexOutOfBoundsException ex) {
    // expected
    }
    c.close();
}
Also used : CursorIndexOutOfBoundsException(android.database.CursorIndexOutOfBoundsException) SQLiteCursor(android.database.sqlite.SQLiteCursor) Cursor(android.database.Cursor) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 12 with CursorIndexOutOfBoundsException

use of android.database.CursorIndexOutOfBoundsException in project android_frameworks_base by DirtyUnicorns.

the class DatabaseCursorTest method testCursor2.

@MediumTest
public void testCursor2() throws Exception {
    populateDefaultTable();
    Cursor c = mDatabase.query("test", null, "_id > 1000", null, null, null, null);
    assertEquals(0, c.getCount());
    assertTrue(c.isBeforeFirst());
    try {
        c.getInt(0);
        fail("CursorIndexOutOfBoundsException expected");
    } catch (CursorIndexOutOfBoundsException ex) {
    // expected
    }
    int i;
    for (c.moveToFirst(), i = 0; !c.isAfterLast(); c.moveToNext(), i++) {
        c.getInt(0);
    }
    assertEquals(0, i);
    try {
        c.getInt(0);
        fail("CursorIndexOutOfBoundsException expected");
    } catch (CursorIndexOutOfBoundsException ex) {
    // expected
    }
    c.close();
}
Also used : CursorIndexOutOfBoundsException(android.database.CursorIndexOutOfBoundsException) SQLiteCursor(android.database.sqlite.SQLiteCursor) Cursor(android.database.Cursor) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 13 with CursorIndexOutOfBoundsException

use of android.database.CursorIndexOutOfBoundsException 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 14 with CursorIndexOutOfBoundsException

use of android.database.CursorIndexOutOfBoundsException in project newsrob by marianokamp.

the class ShowArticleActivity method onClick.

public void onClick(View v) {
    try {
        if (NewsRob.isDebuggingEnabled(this)) {
            switchTiming = new Timing("Click to load", this);
            if ("1".equals(NewsRob.getDebugProperties(this).getProperty("dumpClickToLoad", "0"))) {
                new File(Environment.getExternalStorageDirectory(), "t").mkdirs();
                Debug.startMethodTracing("t/click-to-load_" + new SimpleDateFormat("yyMMdd-hh:mm:ss").format(new Date()).replace(':', '-'));
            }
        }
        try {
            if (v == nextButton) {
                if (!contentCursor.moveToNext()) {
                    PL.log(TAG + ": MoveToNext failed.", this);
                    finish();
                    return;
                }
                newPosition();
            } else if (v == prevButton) {
                if (!contentCursor.moveToPrevious()) {
                    PL.log(TAG + ": MoveToPrevious failed.", this);
                    finish();
                    return;
                }
                newPosition();
            } else {
                toggleViewMode(false);
                view();
            }
        } catch (IllegalStateException ise) {
        // ignore
        } catch (CursorIndexOutOfBoundsException cioobe) {
        // ignore -- moveToNext
        }
    } finally {
        if (switchTiming != null) {
            switchTiming.stop();
            try {
                if ("1".equals(NewsRob.getDebugProperties(this).getProperty("dumpClickToLoad", "0")))
                    Debug.stopMethodTracing();
            } catch (Throwable t) {
            }
        }
    }
}
Also used : CursorIndexOutOfBoundsException(android.database.CursorIndexOutOfBoundsException) Timing(com.newsrob.util.Timing) File(java.io.File) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 15 with CursorIndexOutOfBoundsException

use of android.database.CursorIndexOutOfBoundsException 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)

Aggregations

CursorIndexOutOfBoundsException (android.database.CursorIndexOutOfBoundsException)17 Cursor (android.database.Cursor)14 SQLiteCursor (android.database.sqlite.SQLiteCursor)12 MediumTest (android.test.suitebuilder.annotation.MediumTest)12 Entry (com.newsrob.Entry)3 ActivityNotFoundException (android.content.ActivityNotFoundException)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 Method (java.lang.reflect.Method)2 Timing (com.newsrob.util.Timing)1 File (java.io.File)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1