Search in sources :

Example 11 with CursorLoader

use of androidx.loader.content.CursorLoader in project collect by opendatakit.

the class CursorLoaderFactory method createEditableInstancesCursorLoader.

public CursorLoader createEditableInstancesCursorLoader(CharSequence charSequence, String sortOrder) {
    CursorLoader cursorLoader;
    if (charSequence.length() == 0) {
        cursorLoader = createEditableInstancesCursorLoader(sortOrder);
    } else {
        String selection = DatabaseInstanceColumns.STATUS + " !=? " + "and " + DatabaseInstanceColumns.STATUS + " !=? " + "and " + DatabaseInstanceColumns.DISPLAY_NAME + " LIKE ?";
        String[] selectionArgs = { Instance.STATUS_SUBMITTED, Instance.STATUS_SUBMISSION_FAILED, "%" + charSequence + "%" };
        cursorLoader = getInstancesCursorLoader(selection, selectionArgs, sortOrder);
    }
    return cursorLoader;
}
Also used : CursorLoader(androidx.loader.content.CursorLoader)

Example 12 with CursorLoader

use of androidx.loader.content.CursorLoader in project Applozic-Android-SDK by AppLozic.

the class ChannelDatabaseService method getSearchCursorForGroupsLoader.

public Loader<Cursor> getSearchCursorForGroupsLoader(final String searchString) {
    return new CursorLoader(context, null, null, null, null, MobiComDatabaseHelper.CHANNEL_DISPLAY_NAME + " asc") {

        @Override
        public Cursor loadInBackground() {
            SQLiteDatabase db = dbHelper.getReadableDatabase();
            Cursor cursor;
            StringBuffer stringBuffer = new StringBuffer();
            stringBuffer.append("SELECT ").append(" * ").append(" FROM ").append(MobiComDatabaseHelper.CHANNEL).append(" where ").append(MobiComDatabaseHelper.TYPE).append(" NOT IN ('").append(Channel.GroupType.CONTACT_GROUP.getValue()).append("')");
            if (!TextUtils.isEmpty(searchString)) {
                stringBuffer.append(" AND " + MobiComDatabaseHelper.CHANNEL_DISPLAY_NAME + " like '%" + searchString.replaceAll("'", "''") + "%'");
            }
            stringBuffer.append(" order by " + MobiComDatabaseHelper.CHANNEL_DISPLAY_NAME + " COLLATE NOCASE asc ");
            cursor = db.rawQuery(stringBuffer.toString(), null);
            return cursor;
        }
    };
}
Also used : CursorLoader(androidx.loader.content.CursorLoader) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Cursor(android.database.Cursor)

Aggregations

CursorLoader (androidx.loader.content.CursorLoader)12 Uri (android.net.Uri)4 Cursor (android.database.Cursor)2 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)2 NonNull (androidx.annotation.NonNull)2 CloudEntry (com.amaze.filemanager.database.models.explorer.CloudEntry)1 CloudPluginException (com.amaze.filemanager.file_operations.exceptions.CloudPluginException)1 Test (org.junit.Test)1