Search in sources :

Example 21 with CursorLoader

use of android.support.v4.content.CursorLoader in project apps-android-commons by commons-app.

the class ContributionsActivity method onCreateLoader.

@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    int uploads = sharedPref.getInt(Prefs.UPLOADS_SHOWING, 100);
    return new CursorLoader(this, ContributionsContentProvider.BASE_URI, Contribution.Table.ALL_FIELDS, CONTRIBUTION_SELECTION, null, CONTRIBUTION_SORT + "LIMIT " + uploads);
}
Also used : CursorLoader(android.support.v4.content.CursorLoader) SharedPreferences(android.content.SharedPreferences)

Example 22 with CursorLoader

use of android.support.v4.content.CursorLoader in project quran_android by quran.

the class SearchActivity method onCreateLoader.

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    String query = args.getString(EXTRA_QUERY);
    this.query = query;
    return new CursorLoader(this, QuranDataProvider.SEARCH_URI, null, null, new String[] { query }, null);
}
Also used : CursorLoader(android.support.v4.content.CursorLoader) SpannableString(android.text.SpannableString)

Example 23 with CursorLoader

use of android.support.v4.content.CursorLoader in project Android-Group-39 by Area51TrainingCenter.

the class MovieDetailActivity method onCreateLoader.

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    final String selection;
    final String[] selectionArguments;
    final Uri uri;
    switch(id) {
        case LOADER_ID_MOVIE_DETAIL:
            uri = MovieContract.MovieEntry.CONTENT_URI;
            selection = MovieContract.MovieEntry.REMOTE_ID + "=?";
            selectionArguments = new String[] { movieRemoteId };
            break;
        case LOADER_ID_MOVIE_REVIEWS:
            uri = MovieContract.ReviewEntry.CONTENT_URI;
            selection = MovieContract.ReviewEntry.MOVIE_ID + "=?";
            selectionArguments = new String[] { movieId };
            break;
        case LOADER_ID_MOVIE_VIDEOS:
            uri = MovieContract.VideoEntry.CONTENT_URI;
            selection = MovieContract.VideoEntry.MOVIE_ID + "=?";
            selectionArguments = new String[] { movieId };
            break;
        default:
            throw new RuntimeException(String.format("Loader with ID %s not Implemented", id));
    }
    return new CursorLoader(this, uri, null, selection, selectionArguments, null);
}
Also used : CursorLoader(android.support.v4.content.CursorLoader) Uri(android.net.Uri)

Example 24 with CursorLoader

use of android.support.v4.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(MobiComDatabaseHelper._ID).append(",").append(MobiComDatabaseHelper.CHANNEL_KEY).append(",").append(MobiComDatabaseHelper.CLIENT_GROUP_ID).append(",").append(MobiComDatabaseHelper.CHANNEL_DISPLAY_NAME).append(",").append(MobiComDatabaseHelper.ADMIN_ID).append(",").append(MobiComDatabaseHelper.TYPE).append(",").append(MobiComDatabaseHelper.UNREAD_COUNT).append(",").append(MobiComDatabaseHelper.CHANNEL_IMAGE_URL).append(",").append(MobiComDatabaseHelper.CHANNEL_IMAGE_LOCAL_URI).append(",").append(MobiComDatabaseHelper.NOTIFICATION_AFTER_TIME).append(" , ").append(MobiComDatabaseHelper.DELETED_AT).append(",").append(MobiComDatabaseHelper.CHANNEL_META_DATA).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(android.support.v4.content.CursorLoader) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Cursor(android.database.Cursor)

Example 25 with CursorLoader

use of android.support.v4.content.CursorLoader in project Applozic-Android-SDK by AppLozic.

the class ContactDatabase method getSearchCursorLoader.

public Loader<Cursor> getSearchCursorLoader(final String searchString, final String[] userIdArray) {
    return new CursorLoader(context, null, null, null, null, MobiComDatabaseHelper.DISPLAY_NAME + " asc") {

        @Override
        public Cursor loadInBackground() {
            if (TextUtils.isEmpty(userPreferences.getUserId())) {
                return null;
            }
            SQLiteDatabase db = dbHelper.getReadableDatabase();
            Cursor cursor;
            String query = "select userId as _id, fullName, contactNO, " + "displayName,contactImageURL,contactImageLocalURI,email," + "applicationId,connected,lastSeenAt,unreadCount,blocked," + "blockedBy,status,contactType,userTypeId,deletedAtTime,notificationAfterTime,userRoleType,userMetadata,lastMessagedAt from " + CONTACT + " where deletedAtTime=0 ";
            if (userIdArray != null && userIdArray.length > 0) {
                String placeHolderString = Utils.makePlaceHolders(userIdArray.length);
                if (!TextUtils.isEmpty(searchString)) {
                    query = query + " and fullName like '%" + searchString.replaceAll("'", "''") + "%' and  userId  IN (" + placeHolderString + ")";
                } else {
                    query = query + " and userId IN (" + placeHolderString + ")";
                }
                query = query + " order by connected desc,lastSeenAt desc ";
                cursor = db.rawQuery(query, userIdArray);
            } else {
                if (ApplozicClient.getInstance(context).isShowMyContacts()) {
                    if (!TextUtils.isEmpty(searchString)) {
                        query = query + " and fullName like '%" + searchString.replaceAll("'", "''") + "%' AND contactType != 0 AND userId NOT IN ('" + userPreferences.getUserId().replaceAll("'", "''") + "')";
                    } else {
                        query = query + " and contactType != 0 AND userId != '" + userPreferences.getUserId() + "'";
                    }
                } else {
                    if (!TextUtils.isEmpty(searchString)) {
                        query = query + " and fullName like '%" + searchString.replaceAll("'", "''") + "%' AND userId NOT IN ('" + userPreferences.getUserId().replaceAll("'", "''") + "')";
                    } else {
                        query = query + " and userId != '" + userPreferences.getUserId() + "'";
                    }
                }
                query = query + " order by fullName COLLATE NOCASE,userId COLLATE NOCASE asc ";
                cursor = db.rawQuery(query, null);
            }
            return cursor;
        }
    };
}
Also used : CursorLoader(android.support.v4.content.CursorLoader) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Cursor(android.database.Cursor)

Aggregations

CursorLoader (android.support.v4.content.CursorLoader)36 Uri (android.net.Uri)18 Cursor (android.database.Cursor)13 Test (org.junit.Test)8 SmallTest (android.test.suitebuilder.annotation.SmallTest)6 SpannableString (android.text.SpannableString)5 TagMetadataTest (com.google.samples.apps.iosched.model.TagMetadataTest)5 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 Context (android.content.Context)4 Matchers.anyString (org.mockito.Matchers.anyString)4 SettingsMockContext (com.google.samples.apps.iosched.testutils.SettingsMockContext)3 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)2 ArrayList (java.util.ArrayList)2 SuppressLint (android.annotation.SuppressLint)1 SharedPreferences (android.content.SharedPreferences)1 Bundle (android.os.Bundle)1 Loader (android.support.v4.content.Loader)1 SimpleCursorAdapter (android.support.v4.widget.SimpleCursorAdapter)1 CloudEntry (com.amaze.filemanager.database.models.CloudEntry)1 CloudPluginException (com.amaze.filemanager.exceptions.CloudPluginException)1