use of android.database.Cursor in project Talon-for-Twitter by klinker24.
the class MentionsDataSource method getLastIds.
public synchronized long[] getLastIds(int account) {
long[] ids = new long[] { 0, 0 };
Cursor cursor;
try {
cursor = getCursor(account);
} catch (Exception e) {
return ids;
}
try {
if (cursor.moveToLast()) {
ids[0] = cursor.getLong(cursor.getColumnIndex(MentionsSQLiteHelper.COLUMN_TWEET_ID));
}
if (cursor.moveToPrevious()) {
ids[1] = cursor.getLong(cursor.getColumnIndex(MentionsSQLiteHelper.COLUMN_TWEET_ID));
}
} catch (Exception e) {
}
cursor.close();
return ids;
}
use of android.database.Cursor in project Talon-for-Twitter by klinker24.
the class MentionsDataSource method getUnreadCount.
public synchronized int getUnreadCount(int account) {
Cursor cursor = getUnreadCursor(account);
int count = cursor.getCount();
cursor.close();
return count;
}
use of android.database.Cursor in project cordova-android-chromeview by thedracle.
the class CameraLauncher method checkForDuplicateImage.
/**
* Used to find out if we are in a situation where the Camera Intent adds to images
* to the content store. If we are using a FILE_URI and the number of images in the DB
* increases by 2 we have a duplicate, when using a DATA_URL the number is 1.
*
* @param type FILE_URI or DATA_URL
*/
private void checkForDuplicateImage(int type) {
int diff = 1;
Uri contentStore = whichContentStore();
Cursor cursor = queryImgDB(contentStore);
int currentNumOfImages = cursor.getCount();
if (type == FILE_URI && this.saveToPhotoAlbum) {
diff = 2;
}
// delete the duplicate file if the difference is 2 for file URI or 1 for Data URL
if ((currentNumOfImages - numPics) == diff) {
cursor.moveToLast();
int id = Integer.valueOf(cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media._ID)));
if (diff == 2) {
id--;
}
Uri uri = Uri.parse(contentStore + "/" + id);
this.cordova.getActivity().getContentResolver().delete(uri, null, null);
}
}
use of android.database.Cursor in project cordova-android-chromeview by thedracle.
the class Capture method checkForDuplicateImage.
/**
* Used to find out if we are in a situation where the Camera Intent adds to images
* to the content store.
*/
private void checkForDuplicateImage() {
Uri contentStore = whichContentStore();
Cursor cursor = queryImgDB(contentStore);
int currentNumOfImages = cursor.getCount();
// delete the duplicate file if the difference is 2
if ((currentNumOfImages - numPics) == 2) {
cursor.moveToLast();
int id = Integer.valueOf(cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media._ID))) - 1;
Uri uri = Uri.parse(contentStore + "/" + id);
this.cordova.getActivity().getContentResolver().delete(uri, null, null);
}
}
use of android.database.Cursor in project Shuttle by timusus.
the class QueryToListOperator method call.
@Override
public Subscriber<? super SqlBrite.Query> call(final Subscriber<? super List<T>> subscriber) {
return new Subscriber<SqlBrite.Query>(subscriber) {
@Override
public void onNext(SqlBrite.Query query) {
try {
Cursor cursor = query.run();
if (cursor == null) {
return;
}
List<T> items = new ArrayList<>(cursor.getCount());
try {
for (int i = 1; cursor.moveToNext() && !subscriber.isUnsubscribed(); i++) {
T item = mapper.call(cursor);
if (item == null) {
throw new NullPointerException("Mapper returned null for row " + i);
}
items.add(item);
}
} finally {
cursor.close();
}
if (!subscriber.isUnsubscribed()) {
subscriber.onNext(items);
}
} catch (Throwable e) {
Exceptions.throwIfFatal(e);
onError(OnErrorThrowable.addValueAsLastCause(e, query.toString()));
}
}
@Override
public void onCompleted() {
subscriber.onCompleted();
}
@Override
public void onError(Throwable e) {
subscriber.onError(e);
}
};
}
Aggregations