use of android.support.v4.content.CursorLoader in project musicbrainz-android by jdamcd.
the class SuggestionHelper method getMatchingEntries.
private Cursor getMatchingEntries(String constraint) {
if (constraint == null) {
return null;
}
String where = COLUMN + " LIKE ?";
String[] args = { constraint.trim() + "%" };
CursorLoader cursorLoader = new CursorLoader(context, Uri.parse(URI), null, where, args, COLUMN + " ASC");
Cursor cursor = cursorLoader.loadInBackground();
if (cursor != null) {
cursor.moveToFirst();
}
return cursor;
}
use of android.support.v4.content.CursorLoader in project MultiImageChooser by derosa.
the class MultiImageChooserActivity method onCreateLoader.
@Override
public Loader<Cursor> onCreateLoader(int cursorID, Bundle arg1) {
CursorLoader cl = null;
ArrayList<String> img = new ArrayList<String>();
switch(cursorID) {
case CURSORLOADER_THUMBS:
img.add(MediaStore.Images.Media._ID);
break;
case CURSORLOADER_REAL:
img.add(MediaStore.Images.Thumbnails.DATA);
break;
default:
break;
}
cl = new CursorLoader(MultiImageChooserActivity.this, MediaStore.Images.Media.EXTERNAL_CONTENT_URI, img.toArray(new String[img.size()]), null, null, null);
return cl;
}
use of android.support.v4.content.CursorLoader in project iosched by google.
the class StarredSessionDetailModelTest method createCursorLoader_SessionQuery_ReturnsCursorLoader.
@Test
public void createCursorLoader_SessionQuery_ReturnsCursorLoader() {
// Given a mock uri and mock cursor loader
SessionDetailModel spyModel = spy(new SessionDetailModel(mMockUri, mMockContext, mMockSessionsHelper, mMockLoaderManager));
doReturn(FAKE_ID).when(spyModel).extractSessionId(mMockUri);
doReturn(mMockCursorLoader).when(spyModel).getCursorLoaderInstance(any(Context.class), any(Uri.class), any(String[].class), any(String.class), any(String[].class), any(String.class));
// When ran with mock uri and session query loader id
CursorLoader createdCursorLoader = (CursorLoader) spyModel.createCursorLoader(SessionDetailModel.SessionDetailQueryEnum.SESSIONS, null);
// Then the returned cursor loader is the mock cursor loader
assertThat(createdCursorLoader, sameInstance(mMockCursorLoader));
}
use of android.support.v4.content.CursorLoader in project iosched by google.
the class StarredSessionDetailModelTest method createCursorLoader_NullQuery_ReturnsNullCursor.
@Test
public void createCursorLoader_NullQuery_ReturnsNullCursor() {
// When ran with mock uri and null query loader id
CursorLoader createdCursorLoader = (CursorLoader) mSessionDetailModel.createCursorLoader(null, null);
// Then the returned cursor loader is null
assertThat(createdCursorLoader, nullValue());
}
use of android.support.v4.content.CursorLoader in project iosched by google.
the class StarredSessionDetailModelTest method createCursorLoader_SpeakersQuery_ReturnsCursor.
@Test
public void createCursorLoader_SpeakersQuery_ReturnsCursor() {
// Given a mock uri and mock cursor loader
SessionDetailModel spyModel = spy(new SessionDetailModel(mMockUri, mMockContext, mMockSessionsHelper, mMockLoaderManager));
doReturn(mMockUri).when(spyModel).getSpeakersDirUri(any(String.class));
doReturn(mMockCursorLoader).when(spyModel).getCursorLoaderInstance(any(Context.class), any(Uri.class), any(String[].class), any(String.class), any(String[].class), any(String.class));
// When ran with mock uri and speakers query loader id
CursorLoader createdCursorLoader = (CursorLoader) spyModel.createCursorLoader(SessionDetailModel.SessionDetailQueryEnum.SPEAKERS, null);
// Then the returned cursor loader is the mock cursor loader
assertThat(createdCursorLoader, sameInstance(mMockCursorLoader));
}
Aggregations