use of android.support.v4.content.CursorLoader in project iosched by google.
the class StarredSessionDetailModelTest method createCursorLoader_FeedbackQuery_ReturnsCursor.
@Test
public void createCursorLoader_FeedbackQuery_ReturnsCursor() {
// Given a mock uri and mock cursor loader
SessionDetailModel spyModel = spy(new SessionDetailModel(mMockUri, mMockContext, mMockSessionsHelper, mMockLoaderManager));
doReturn(mMockUri).when(spyModel).getFeedbackUri(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 feedback query loader id
CursorLoader createdCursorLoader = (CursorLoader) spyModel.createCursorLoader(SessionDetailModel.SessionDetailQueryEnum.FEEDBACK, 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_TagMetadaQuery_ReturnsCursorLoader.
@Test
public void createCursorLoader_TagMetadaQuery_ReturnsCursorLoader() {
// Given a mock uri and mock cursor loader
SessionDetailModel spyModel = spy(new SessionDetailModel(mMockUri, mMockContext, mMockSessionsHelper, mMockLoaderManager));
doReturn(mMockCursorLoader).when(spyModel).getTagMetadataLoader();
// When ran with mock uri and tag metadata query loader id
CursorLoader createdCursorLoader = (CursorLoader) spyModel.createCursorLoader(SessionDetailModel.SessionDetailQueryEnum.TAG_METADATA, null);
// Then the returned cursor loader is the mock cursor loader
assertThat(createdCursorLoader, sameInstance(mMockCursorLoader));
}
use of android.support.v4.content.CursorLoader in project android-ui-design-pattern by MathieuCalba.
the class FeedListFragment method onCreateLoader.
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle b) {
final int realId = id - mFeedId * 100 - mCategoryId;
if (realId == LOADER_ID_BASE_FEED_LIST) {
if (b != null) {
final int feedId = b.getInt(EXTRA_FEED_ID, -1);
if (feedId != -1) {
final int categoryId = b.getInt(EXTRA_CATEGORY_ID, -1);
Uri uri = null;
if (categoryId == -1) {
uri = YANAContract.ArticleTable.buildUriWithFeedId(feedId);
} else {
uri = YANAContract.ArticleTable.buildUriWithFeedIdAndCategoryId(feedId, categoryId);
}
return new CursorLoader(getActivity(), uri, YANAContract.ArticleTable.PROJ_LIST.COLS, null, null, YANAContract.ArticleTable.DEFAULT_SORT);
}
}
}
return null;
}
use of android.support.v4.content.CursorLoader in project chuck by jgilfelt.
the class TransactionListFragment method onCreateLoader.
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
CursorLoader loader = new CursorLoader(getContext());
loader.setUri(ChuckContentProvider.TRANSACTION_URI);
if (!TextUtils.isEmpty(currentFilter)) {
if (TextUtils.isDigitsOnly(currentFilter)) {
loader.setSelection("responseCode LIKE ?");
loader.setSelectionArgs(new String[] { currentFilter + "%" });
} else {
loader.setSelection("path LIKE ?");
loader.setSelectionArgs(new String[] { "%" + currentFilter + "%" });
}
}
loader.setProjection(HttpTransaction.PARTIAL_PROJECTION);
loader.setSortOrder("requestDate DESC");
return loader;
}
use of android.support.v4.content.CursorLoader in project AgentWebX5 by Justson.
the class AgentWebX5Utils method getRealPathBelowVersion.
private static String getRealPathBelowVersion(Context context, Uri uri) {
String filePath = null;
String[] projection = { MediaStore.Images.Media.DATA };
CursorLoader loader = new CursorLoader(context, uri, projection, null, null, null);
Cursor cursor = loader.loadInBackground();
if (cursor != null) {
cursor.moveToFirst();
filePath = cursor.getString(cursor.getColumnIndex(projection[0]));
cursor.close();
}
return filePath;
}
Aggregations