项目:androidbeginners-Lesson3
文件:MainActivity.java
@Override
public Loader<Cursor> onCreateLoader(int id,Bundle args) {
String[] projectionFields = new String[]{
ContactsContract.Contacts._ID,ContactsContract.Contacts.disPLAY_NAME,ContactsContract.Contacts.PHOTO_URI
};
CursorLoader cursorLoader = new CursorLoader(MainActivity.this,ContactsContract.Contacts.CONTENT_URI,projectionFields,null,null);
return cursorLoader;
}
项目:mobile-store
文件:UpdatesAdapter.java
@Override
public Loader<Cursor> onCreateLoader(int id,Bundle args) {
Uri uri;
switch (id) {
case LOADER_CAN_UPDATE:
uri = AppProvider.getCanUpdateUri();
break;
case LOADER_KNowN_VULN:
uri = AppProvider.getInstalledWithKNownVulnsUri();
break;
default:
throw new IllegalStateException("UnkNown loader requested: " + id);
}
return new CursorLoader(
activity,uri,Schema.AppMetadataTable.Cols.ALL,Schema.AppMetadataTable.Cols.NAME);
}
项目:mobile-store
文件:SelectAppsView.java
@Override
public CursorLoader onCreateLoader(int id,Bundle args) {
Uri uri;
if (TextUtils.isEmpty(currentFilterString)) {
uri = InstalledAppProvider.getContentUri();
} else {
uri = InstalledAppProvider.getSearchUri(currentFilterString);
}
return new CursorLoader(
getActivity(),InstalledAppTable.Cols.ALL,InstalledAppTable.Cols.APPLICATION_LABEL);
}
项目:News24x7-news-from-every-part-of-the-world
文件:NewsLoader.java
@Override
public Loader<Cursor> onCreateLoader(int i,Bundle bundle) {
//checking on rotate
if (mAttachedFragment != null && mAttachedFragment.getActivity() != null) {
if (favflag == 0) {
return new CursorLoader(mAttachedFragment.getActivity(),NewsProvider.Mynews.CONTENT_URI,null);
} else {
if (favflag == 1) {
return new CursorLoader(mAttachedFragment.getActivity(),NewsProvider.NewsFavourite.CONTENT_URI_FAVOURITE,null);
}
}
}
return null;
}
项目:SOS-The-Healthcare-Companion
文件:ContactPickerActivity.java
@Override
public Loader<Cursor> onCreateLoader(int id,Bundle args) {
String selection = "";
if (mOnlyWithPhoneNumbers) {
selection = ContactsContract.Contacts.HAS_PHONE_NUMBER;
}
switch (id) {
case CONTACTS_LOADER_ID:
return new CursorLoader(this,CONTACTS_URI,CONTACTS_PROJECTION,selection,CONTACTS_SORT);
case CONTACT_DETAILS_LOADER_ID:
return new CursorLoader(this,CONTACT_DETAILS_URI,CONTACT_DETAILS_PROJECTION,null);
case GROUPS_LOADER_ID:
return new CursorLoader(this,GROUPS_URI,GROUPS_PROJECTION,GROUPS_SELECTION,GROUPS_SORT);
}
return null;
}
项目:chuck
文件:TransactionListFragment.java
@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;
}
项目:AgentWeb
文件:AgentWebUtils.java
private static String getRealPathBelowVersion(Context context,Uri uri) {
String filePath = null;
LogUtils.i(TAG,"method -> getRealPathBelowVersion " + uri + " path:" + uri.getPath() + " getAuthority:" + uri.getAuthority());
String[] projection = {MediaStore.Images.Media.DATA};
CursorLoader loader = new CursorLoader(context,projection,null);
Cursor cursor = loader.loadInBackground();
if (cursor != null) {
cursor.movetoFirst();
filePath = cursor.getString(cursor.getColumnIndex(projection[0]));
cursor.close();
}
if (filePath == null) {
filePath = uri.getPath();
}
return filePath;
}
项目:GoUbiquitous
文件:DetailActivity.java
/**
* Creates and returns a CursorLoader that loads the data for our URI and stores it in a Cursor.
*
* @param loaderId The loader ID for which we need to create a loader
* @param loaderArgs Any arguments supplied by the caller
*
* @return A new Loader instance that is ready to start loading.
*/
@Override
public Loader<Cursor> onCreateLoader(int loaderId,Bundle loaderArgs) {
switch (loaderId) {
case ID_DETAIL_LOADER:
return new CursorLoader(this,mUri,WEATHER_DETAIL_PROJECTION,null);
default:
throw new RuntimeException("Loader Not Implemented: " + loaderId);
}
}
项目:MVP-Android
文件:RealPathUtils.java
@SuppressLint("NewApi")
public static String getRealPathFromURI_API11to18(Context context,Uri contentUri) {
String[] proj = { MediaStore.Images.Media.DATA };
String result = null;
try {
CursorLoader cursorLoader = new CursorLoader(context,contentUri,proj,null);
Cursor cursor = cursorLoader.loadInBackground();
if (cursor != null) {
int column_index =
cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.movetoFirst();
result = cursor.getString(column_index);
}
}
catch (Exception e){
e.printstacktrace();
}
return result;
}
项目:Android_Sunshine_Watch
文件:MainActivity.java
@Override
public Loader<Cursor> onCreateLoader(int loaderId,Bundle bundle) {
switch (loaderId) {
case ID_FORECAST_LOADER:
Uri forecastQueryUri = WeatherContract.WeatherEntry.CONTENT_URI;
String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC";
String selection = WeatherContract.WeatherEntry.getsqlSelectForTodayOnwards();
return new CursorLoader(this,forecastQueryUri,MAIN_FORECAST_PROJECTION,sortOrder);
default:
throw new RuntimeException("Loader Not Implemented: " + loaderId);
}
}
项目:Android_Sunshine_Watch
文件:DetailActivity.java
/**
* Creates and returns a CursorLoader that loads the data for our URI and stores it in a Cursor.
*
* @param loaderId The loader ID for which we need to create a loader
* @param loaderArgs Any arguments supplied by the caller
*
* @return A new Loader instance that is ready to start loading.
*/
@Override
public Loader<Cursor> onCreateLoader(int loaderId,null);
default:
throw new RuntimeException("Loader Not Implemented: " + loaderId);
}
}
项目:android-dev-challenge
文件:DetailActivity.java
/**
* Creates and returns a CursorLoader that loads the data for our URI and stores it in a Cursor.
*
* @param loaderId The loader ID for which we need to create a loader
* @param loaderArgs Any arguments supplied by the caller
*
* @return A new Loader instance that is ready to start loading.
*/
@Override
public Loader<Cursor> onCreateLoader(int loaderId,null);
default:
throw new RuntimeException("Loader Not Implemented: " + loaderId);
}
}
项目:VanGogh
文件:AlbumMediaLoader.java
public static CursorLoader newInstance(Context context,Album album,boolean capture) {
if (album.isAll()) {
return new AlbumMediaLoader(
context,QUERY_URI,PROJECTION,SELECTION_ALL,SELECTION_ALL_ARGS,ORDER_BY,capture);
} else {
return new AlbumMediaLoader(
context,SELECTION_ALBUM,getSelectionAlbumArgs(album.getId()),false);
}
}
项目:android_firebase_green_thumb
文件:ShoppingCartActivity.java
@Override
public Loader<Cursor> onCreateLoader(int id,Bundle args) {
String[] projection = {
PlantEntry._ID,PlantEntry.COLUMN_NAME,PlantEntry.COLUMN_PRICE,PlantEntry.COLUMN_CART_QUANTITY
};
String selection = PlantEntry.COLUMN_CART_QUANTITY + " > 0";
return new CursorLoader(this,PlantEntry.CONTENT_URI,null);
}
项目:android_firebase_green_thumb
文件:PlantDetailActivity.java
@Override
public Loader<Cursor> onCreateLoader(int id,PlantEntry.COLUMN_DESCRIPTION,PlantEntry.COLUMN_PRICE
};
String selection = PlantEntry._ID + " = " + mItemId;
return new CursorLoader(this,null);
}
项目:Udacity_Sunshine
文件:ForecastFragment.java
@Override
public Loader<Cursor> onCreateLoader(int i,Bundle bundle) {
// This is called when a new Loader needs to be created. This
// fragment only uses one loader,so we don't care about checking the id.
// To only show current and future dates,filter the query to return weather only for
// dates after or including today.
// Sort order: Ascending,by date.
String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC";
String locationSetting = Utility.getPreferredLocation(getActivity());
Uri weatherForLocationUri = WeatherContract.WeatherEntry.buildWeatherLocationWithStartDate(
locationSetting,System.currentTimeMillis());
return new CursorLoader(getActivity(),weatherForLocationUri,FORECAST_COLUMNS,sortOrder);
}
项目:TVGuide
文件:ChannelFragment.java
@Override
public Loader<Cursor> onCreateLoader(int id,Bundle args) {
if (id == CHANNELS_LOADER) {
return new CursorLoader(
getActivity(),ChannelEntry.CONTENT_URI,CHANNEL_COLUMNS,TextUtils.isEmpty(category) ? null
: ChannelEntry.TABLE_NAME + "."
+ ChannelEntry.COLUMN_CHANNEL_CATEGORY_ID + " = ?",TextUtils.isEmpty(category) ? null :
new String[]{String.valueOf(category)},Utility.getPrefSortChannelOrder(sortBy));
}
return null;
}
项目:NovelReader
文件:LoaderCreator.java
public static CursorLoader create(Context context,int id,Bundle bundle) {
LocalFileLoader loader = null;
switch (id){
case ALL_BOOK_FILE:
loader = new LocalFileLoader(context);
break;
default:
loader = null;
break;
}
if (loader != null) {
return loader;
}
throw new IllegalArgumentException("The id of Loader is invalid!");
}
项目:recyclerview-android
文件:CursorDatasourceExampleActivity.java
@Override
public Loader<Cursor> onCreateLoader(final int id,final Bundle args) {
final Uri contentUri = CallLog.Calls.CONTENT_URI.buildUpon()
.appendQueryParameter("limit","100")
.build();
final String[] projection = {
CallLog.Calls._ID,CallLog.Calls.CACHED_NAME,CallLog.Calls.NUMBER,CallLog.Calls.DATE,CallLog.Calls.DURATION,CallLog.Calls.TYPE
};
final String sortOrder = CallLog.Calls.DEFAULT_SORT_ORDER;
return new CursorLoader(this,sortOrder);
}
项目:ActivityDiary
文件:MainActivity.java
@Override
public Loader<Cursor> onCreateLoader(int id,Bundle args) {
// Now create and return a CursorLoader that will take care of
// creating a Cursor for the data being displayed.
return new CursorLoader(this,ActivityDiaryContract.DiaryImage.CONTENT_URI,PROJECTION_IMG,ActivityDiaryContract.DiaryImage.TABLE_NAME + "." + ActivityDiaryContract.DiaryImage.DIARY_ID + "=? AND "
+ ActivityDiaryContract.DiaryImage._DELETED + "=0",mCurrentDiaryUri == null ? new String[]{"0"}:new String[]{mCurrentDiaryUri.getLastPathSegment()},ActivityDiaryContract.DiaryImage.soRT_ORDER_DEFAULT);
}
项目:Android-DFU-App
文件:UARTLogFragment.java
@Override
public Loader<Cursor> onCreateLoader(final int id,final Bundle args) {
switch (id) {
case LOG_REQUEST_ID: {
return new CursorLoader(getActivity(),mLogSession.getSessionEntriesUri(),LOG_PROJECTION,LogContract.Log.TIME);
}
}
return null;
}
项目:Linphone4Android
文件:ChatFragment.java
public String getRealPathFromURI(Uri contentUri) {
String[] proj = {MediaStore.Images.Media.DATA};
CursorLoader loader = new CursorLoader(getActivity(),null);
Cursor cursor = loader.loadInBackground();
if (cursor != null && cursor.movetoFirst()) {
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
String result = cursor.getString(column_index);
cursor.close();
return result;
}
return null;
}
项目:Canvas-Vision
文件:CollectionActivity.java
@Override
public Loader<Cursor> onCreateLoader(int id,Bundle args) {
CursorLoader cursorLoader = new CursorLoader(CollectionActivity.this,CanvasDownloadTable.CONTENT_URI,// URI
null,// projection fields
null,// the selection criteria
null,// the selection args
null // the sort order
);
return cursorLoader;
}
项目:OpenHomeAnalysis
文件:OhaEnergyUseLogHelper.java
/**
* Carregar o cursor conforme a hora inicial,final e {@link FilterWatts}
*/
@Override
public Loader<Cursor> onCreateLoader(int id,Bundle args) {
iOhaEnergyUseLogHelper.onBeginLoader();
String selections;
String[] selectionsArgs;
switch (this.filterWatts) {
case PHASE1:
case PHASE2:
case PHASE3:
case TOTAL:
selections = String.format("(%s BETWEEN ? AND ?) AND (%s BETWEEN ? AND ?)",EnergyUseLogEntry._ID,this.filterWatts.getFieldName());
selectionsArgs = new String[]{Long.toString(this.beginDateTime),Long.toString(this.endDateTime),Double.toString(this.beginWatts),Double.toString(this.endWatts)};
break;
case NONE:
default:
selections = String.format("%s BETWEEN ? AND ?",EnergyUseLogEntry._ID);
selectionsArgs = new String[]{Long.toString(this.beginDateTime),Long.toString(this.endDateTime)};
break;
}
return new CursorLoader(
this.iOhaEnergyUseLogHelper.getContext(),CONTENT_URI_LOG,LOG_COLUMNS,selections,selectionsArgs,String.format("%s ASC",EnergyUseLogEntry._ID)
);
}
项目:OpenHomeAnalysis
文件:OhaMainActivity.java
@Override
public Loader<Cursor> onCreateLoader(int id,Bundle args) {
this.swipeRefreshLayout.setRefreshing(true);
if (id == R.id.nav_energy_use_day) {
//Carregar o cursor com o a utilização de energia por dia.
return new CursorLoader(
this,OhaEnergyUseContract.getUriDays(new Date()),String.format("%s DESC",EnergyUseLogEntry._ID)
);
} else if (id == R.id.nav_energy_use_bill) {
//Carregar o cursor com o a utilização de energia por conta.
return new CursorLoader(
this,CONTENT_URI_BILL,EnergyUseBillEntry.COLUMN_FROM));
}
return null;
}
项目:ubiquitous
文件:MainActivity.java
/**
* Called by the {@link android.support.v4.app.LoaderManagerImpl} when a new Loader needs to be
* created. This Activity only uses one loader,so we don't necessarily NEED to check the
* loaderId,but this is certainly best practice.
*
* @param loaderId The loader ID for which we need to create a loader
* @param bundle Any arguments supplied by the caller
* @return A new Loader instance that is ready to start loading.
*/
@Override
public Loader<Cursor> onCreateLoader(int loaderId,Bundle bundle) {
switch (loaderId) {
case ID_FORECAST_LOADER:
/* URI for all rows of weather data in our weather table */
Uri forecastQueryUri = WeatherContract.WeatherEntry.CONTENT_URI;
/* Sort order: Ascending by date */
String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC";
/*
* A SELECTION in sql declares which rows you'd like to return. In our case,we
* want all weather data from today onwards that is stored in our weather table.
* We created a handy method to do that in our WeatherEntry class.
*/
String selection = WeatherContract.WeatherEntry.getsqlSelectForTodayOnwards();
return new CursorLoader(this,sortOrder);
default:
throw new RuntimeException("Loader Not Implemented: " + loaderId);
}
}
项目:music-player
文件:LocalMusicPresenter.java
@Override
public Loader<Cursor> onCreateLoader(int id,Bundle args) {
if (id != URL_LOAD_LOCAL_MUSIC) return null;
return new CursorLoader(
mView.getContext(),MEDIA_URI,PROJECTIONS,WHERE,ORDER_BY
);
}
项目:Matisse
文件:AlbumMediaLoader.java
public static CursorLoader newInstance(Context context,boolean capture) {
String selection;
String[] selectionArgs;
boolean enableCapture;
if (album.isAll()) {
if (SelectionSpec.getInstance().onlyShowImages()) {
selection = SELECTION_ALL_FOR_SINGLE_MEDIA_TYPE;
selectionArgs = getSelectionArgsForSingleMediaType(MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE);
} else if (SelectionSpec.getInstance().onlyShowVideos()) {
selection = SELECTION_ALL_FOR_SINGLE_MEDIA_TYPE;
selectionArgs = getSelectionArgsForSingleMediaType(MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO);
} else {
selection = SELECTION_ALL;
selectionArgs = SELECTION_ALL_ARGS;
}
enableCapture = capture;
} else {
if (SelectionSpec.getInstance().onlyShowImages()) {
selection = SELECTION_ALBUM_FOR_SINGLE_MEDIA_TYPE;
selectionArgs = getSelectionAlbumArgsForSingleMediaType(MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE,album.getId());
} else if (SelectionSpec.getInstance().onlyShowVideos()) {
selection = SELECTION_ALBUM_FOR_SINGLE_MEDIA_TYPE;
selectionArgs = getSelectionAlbumArgsForSingleMediaType(MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO,album.getId());
} else {
selection = SELECTION_ALBUM;
selectionArgs = getSelectionAlbumArgs(album.getId());
}
enableCapture = false;
}
return new AlbumMediaLoader(context,selectionArgs,enableCapture);
}
项目:mobile-store
文件:CategoriesViewBinder.java
@Override
public Loader<Cursor> onCreateLoader(int id,Bundle args) {
if (id != LOADER_ID) {
return null;
}
return new CursorLoader(
activity,CategoryProvider.getAllCategories(),Schema.CategoryTable.Cols.ALL,null
);
}