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();
}
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();
}
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();
}
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) {
}
}
}
}
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;
}
Aggregations