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