List of usage examples for android.support.v4.app LoaderManager initLoader
public abstract <D> Loader<D> initLoader(int id, Bundle args, LoaderManager.LoaderCallbacks<D> callback);
From source file:com.wit.android.support.database.LoadableAssistant.java
/** * Wrapped {@link android.support.v4.app.LoaderManager#initLoader(int, android.os.Bundle, android.support.v4.app.LoaderManager.LoaderCallbacks)} * called with the current loader id and this assistant as {@code LoaderManager.LoaderCallbacks}. *//* ww w .j ava2 s . c o m*/ public boolean initLoader(@NonNull FragmentActivity activity, @Nullable Bundle params) { if (mLoaderId >= 0) { final LoaderManager loaderManager = activity.getSupportLoaderManager(); if (loaderManager != null) { loaderManager.initLoader(mLoaderId, params, this); return true; } } return false; }
From source file:it.geosolutions.android.map.fragment.FeatureCircleLayerListFragment.java
/** * Create the data loader and bind the loader to the * parent callbacks//from www . ja va2 s . co m * @param query array of <FeatureCircleTaskQuery> to pass to the loader * @param loaderIndex a unique id for query loader */ private void startDataLoading(FeatureCircleTaskQuery[] query, int loaderIndex) { // create task query // initialize Load Manager mCallbacks = this; LoaderManager lm = getSherlockActivity().getSupportLoaderManager(); // NOTE: use the start variable as index in the loadermanager // if you use more than one adapter.clear(); lm.initLoader(loaderIndex, null, this); // uses start to get the }
From source file:edu.mit.mobile.android.locast.itineraries.ItineraryList.java
private void loadData(Uri data) { final String type = getContentResolver().getType(data); if (!MediaProvider.TYPE_ITINERARY_DIR.equals(type)) { throw new IllegalArgumentException("cannot load type: " + type); }// ww w. j av a 2 s .c o m mAdapter = new SimpleThumbnailCursorAdapter(this, getItineraryItemLayout(), null, getItineraryDisplay(), getItineraryLayoutIds(), new int[] { R.id.media_thumbnail }, 0); mListView.setAdapter(new ImageLoaderAdapter(this, mAdapter, mImageCache, new int[] { R.id.media_thumbnail }, 48, 48, ImageLoaderAdapter.UNIT_DIP)); final LoaderManager lm = getSupportLoaderManager(); final Bundle loaderArgs = new Bundle(); loaderArgs.putParcelable(LOADER_DATA, data); lm.initLoader(0, loaderArgs, this); setTitle(R.string.itineraries); mUri = data; }
From source file:edu.mit.mobile.android.locast.ver2.casts.VideoPlayer.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.videoplayer); mVideoView = (VideoView) findViewById(R.id.video); mMediaController = new MediaController(this); mMediaController.setMediaPlayer(mVideoView); mMediaController.setAnchorView(mVideoView); mVideoView.setOnPreparedListener(this); mVideoView.setOnErrorListener(this); mVideoView.setOnCompletionListener(this); mVideoView.setMediaController(mMediaController); mDescriptionView = (TextView) findViewById(R.id.description); mTitleView = (TextView) findViewById(R.id.title); final Intent intent = getIntent(); final String action = intent.getAction(); final String type = intent.resolveType(this); final LoaderManager lm = getSupportLoaderManager(); setProgressBar(true);/*from w w w .j a v a 2 s.c om*/ if (MediaProvider.TYPE_CASTMEDIA_DIR.equals(type)) { lm.initLoader(LOADER_CASTMEDIA_DIR, null, this); } else if (MediaProvider.TYPE_CASTMEDIA_ITEM.equals(type)) { lm.initLoader(LOADER_CASTMEDIA_ITEM, null, this); } adjustForOrientation(getResources().getConfiguration()); }
From source file:org.mariotaku.twidere.activity.AuthorizeActivity.java
private void getRequestToken() { final Bundle extras = getIntent().getExtras(); if (extras == null) { Toast.makeText(this, R.string.error_occurred, Toast.LENGTH_SHORT).show(); finish();/*from w w w. ja va 2s .co m*/ return; } final LoaderManager lm = getSupportLoaderManager(); lm.destroyLoader(0); if (mLoaderInitialized) { lm.restartLoader(0, extras, this); } else { lm.initLoader(0, extras, this); mLoaderInitialized = true; } }
From source file:com.google.android.apps.gutenberg.TimelineFragment.java
@Override public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { if (key.equals(GutenbergApplication.PREF_EVENT_ID)) { LoaderManager manager = getLoaderManager(); Bundle args = new Bundle(); args.putString(ARG_EVENT_ID, prefs.getString(key, null)); manager.destroyLoader(LOADER_ATTENDEES); manager.initLoader(LOADER_ATTENDEES, args, this); manager.destroyLoader(LOADER_EVENT); manager.initLoader(LOADER_EVENT, args, this); }/*from w ww . java 2s . co m*/ }
From source file:edu.mit.mobile.android.locast.ver2.itineraries.ItineraryList.java
private void loadData(Uri data) { final String type = getContentResolver().getType(data); if (!MediaProvider.TYPE_ITINERARY_DIR.equals(type)) { throw new IllegalArgumentException("cannot load type: " + type); }//from w ww .ja v a 2 s. c om mAdapter = new SimpleThumbnailCursorAdapter(this, R.layout.itinerary_item, null, ITINERARY_DISPLAY, new int[] { android.R.id.text1, R.id.media_thumbnail, android.R.id.text2 }, new int[] { R.id.media_thumbnail }, 0); mListView.setAdapter(new ImageLoaderAdapter(this, mAdapter, mImageCache, new int[] { R.id.media_thumbnail }, 48, 48, ImageLoaderAdapter.UNIT_DIP)); final LoaderManager lm = getSupportLoaderManager(); final Bundle loaderArgs = new Bundle(); loaderArgs.putParcelable(LOADER_DATA, data); lm.initLoader(0, loaderArgs, this); setTitle(R.string.itineraries); mUri = data; }
From source file:com.jefftharris.passwdsafe.sync.lib.AbstractSyncedFilesActivity.java
@Override protected void onCreate(Bundle args) { super.onCreate(args); setContentView(R.layout.activity_synced_files); itsProviderUri = getIntent().getParcelableExtra(INTENT_PROVIDER_URI); if (itsProviderUri == null) { PasswdSafeUtil.showFatalMsg("Required args missing", this); return;//from w w w.jav a 2 s . co m } itsFilesUri = itsProviderUri.buildUpon().appendPath(PasswdSafeContract.RemoteFiles.TABLE).build(); if (args == null) { changeDir(ProviderRemoteFile.PATH_SEPARATOR, itsRootId); } itsProviderLoaderCb = new ProviderLoaderCb(); itsFilesLoaderCb = new FilesLoaderCb(); LoaderManager lm = getSupportLoaderManager(); lm.initLoader(LOADER_TITLE, null, itsProviderLoaderCb); lm.initLoader(LOADER_FILES, null, itsFilesLoaderCb); }
From source file:com.example.android.asynctaskloader.MainActivity.java
/** * This method retrieves the search text from the EditText, constructs the * URL (using {@link NetworkUtils}) for the github repository you'd like to find, displays * that URL in a TextView, and finally request that an AsyncTaskLoader performs the GET request. *///from w w w.j av a 2 s. c om private void makeGithubSearchQuery() { String githubQuery = mSearchBoxEditText.getText().toString(); /* * If the user didn't enter anything, there's nothing to search for. In the case where no * search text was entered but the search button was clicked, we will display a message * stating that there is nothing to search for and we will not attempt to load anything. * * If there is text entered in the search box when the search button was clicked, we will * create the URL that will return our Github search results, display that URL, and then * pass that URL to the Loader. The reason we pass the URL as a String is simply a matter * of convenience. There are other ways of achieving this same result, but we felt this * was the simplest. */ if (TextUtils.isEmpty(githubQuery)) { mUrlDisplayTextView.setText("No query entered, nothing to search for."); return; } URL githubSearchUrl = NetworkUtils.buildUrl(githubQuery); mUrlDisplayTextView.setText(githubSearchUrl.toString()); Bundle queryBundle = new Bundle(); queryBundle.putString(SEARCH_QUERY_URL_EXTRA, githubSearchUrl.toString()); /* * Now that we've created our bundle that we will pass to our Loader, we need to decide * if we should restart the loader (if the loader already existed) or if we need to * initialize the loader (if the loader did NOT already exist). * * We do this by first store the support loader manager in the variable loaderManager. * All things related to the Loader go through through the LoaderManager. Once we have a * hold on the support loader manager, (loaderManager) we can attempt to access our * githubSearchLoader. To do this, we use LoaderManager's method, "getLoader", and pass in * the ID we assigned in its creation. You can think of this process similar to finding a * View by ID. We give the LoaderManager an ID and it returns a loader (if one exists). If * one doesn't exist, we tell the LoaderManager to create one. If one does exist, we tell * the LoaderManager to restart it. */ LoaderManager loaderManager = getSupportLoaderManager(); Loader<String> githubSearchLoader = loaderManager.getLoader(GITHUB_SEARCH_LOADER); if (githubSearchLoader == null) { loaderManager.initLoader(GITHUB_SEARCH_LOADER, queryBundle, this); } else { loaderManager.restartLoader(GITHUB_SEARCH_LOADER, queryBundle, this); } }
From source file:it.geosolutions.android.map.geostore.fragment.GeoStoreResourceListFragment.java
/** * Create the data loader and bind the loader to the * parent callbacks// ww w.j av a2 s. c o m * @param URL (not used for now) * @param loaderIndex a unique id for query loader */ private void startDataLoading(String url, int loaderIndex) { // initialize Load Manager mCallbacks = this; //reset page LoaderManager lm = getSherlockActivity().getSupportLoaderManager(); adapter.clear(); page = 0; lm.initLoader(loaderIndex, null, this); }