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:org.rm3l.ddwrt.fragments.DDWRTBaseFragment.java
private void initLoaders() { // initiate the loaders to do the background work final LoaderManager loaderManager = getLoaderManager(); loaderManager.initLoader(0, null, this); this.setLoaderStopped(false); loaderIdsInUse.put(0, this); Log.d(LOG_TAG, "fragmentTiles: " + this.fragmentTiles); if (this.fragmentTiles != null) { for (final DDWRTTile ddwrtTile : fragmentTiles) { if (ddwrtTile == null) { continue; }/* w w w . ja v a2 s .c om*/ final int nextLoaderId = Long.valueOf(Utils.getNextLoaderId()).intValue(); loaderManager.initLoader(nextLoaderId, null, ddwrtTile); ddwrtTile.setLoaderStopped(false); loaderIdsInUse.put(nextLoaderId, ddwrtTile); } } }
From source file:org.dmfs.webcal.fragments.CalendarItemFragment.java
@Override public View onCreateItemView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View returnView = inflater.inflate(R.layout.fragment_calendar_item, container, false); // TODO: don't put the progress indicator into the header view View progressView = inflater.inflate(R.layout.progress_indicator, null, false); mProgressBar = (ProgressBar) progressView.findViewById(android.R.id.progress); mListView = (ListView) returnView.findViewById(android.R.id.list); mListView.addHeaderView(progressView); mListView.setOnItemClickListener(this); mListView.setHeaderDividersEnabled(false); mListAdapter = new EventListAdapter(inflater.getContext(), null); mListView.setAdapter(mSectionAdapter = new SectionTitlesAdapter(inflater.getContext(), mListAdapter, new SectionIndexer() { @Override// ww w . j a v a2s.com public String getSectionTitle(int index) { Time start = new Time(TimeZone.getDefault().getID()); start.set(index & 0x00ff, (index >> 8) & 0x00ff, (index >> 16) & 0x0ffff); return DateUtils.formatDateTime(getActivity(), start.toMillis(true), DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_WEEKDAY | DateUtils.FORMAT_ABBREV_WEEKDAY); } @Override public int getSectionIndex(Object object) { Cursor cursor = (Cursor) object; Time start = new Time( cursor.getString(cursor.getColumnIndex(WebCalReaderContract.Events.TIMZONE))); start.set(cursor.getLong(cursor.getColumnIndex(WebCalReaderContract.Events.DTSTART))); boolean allday = cursor .getInt(cursor.getColumnIndex(WebCalReaderContract.Events.IS_ALLDAY)) == 1; start.allDay = allday; // we return an encoded date as index return (start.year << 16) + (start.month << 8) + start.monthDay; } }, R.layout.events_preview_list_section_header)); FragmentManager fm = getChildFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); mTitleFragment = (CalendarTitleFragment) fm.findFragmentById(R.id.calendar_title_fragment_container); if (mTitleFragment == null) { mTitleFragment = CalendarTitleFragment.newInstance(); ft.replace(R.id.calendar_title_fragment_container, mTitleFragment); } if (!ft.isEmpty()) { ft.commit(); } LoaderManager lm = getLoaderManager(); lm.initLoader(LOADER_CALENDAR_ITEM, null, this); lm.initLoader(LOADER_SUBSCRIBED_CALENDAR, null, this); lm.initLoader(LOADER_SUBSCRIPTION, null, this); // set this to true, so the menu is cleared automatically when leaving the fragment, otherwise the star icon will stay visible setHasOptionsMenu(true); return returnView; }
From source file:org.mariotaku.twidere.activity.TwitterLoginActivity.java
private void doLogin() { final LoaderManager lm = getSupportLoaderManager(); lm.destroyLoader(0);/*from www . j av a 2 s. com*/ if (mLoaderInitialized) { lm.restartLoader(0, null, this); } else { lm.initLoader(0, null, this); mLoaderInitialized = true; } }
From source file:me.futuretechnology.blops.ui.FeedFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mAdapter = new AltCursorAdapter(getActivity(), new int[] { R.layout.news_item }, null, new String[] { DB.News.TITLE, DB.News.PUBLISHED_DATE }, new int[] { R.id.news_title, R.id.news_date }); mAdapter.setViewBinder(new BinderNews(getActivity())); setListAdapter(mAdapter);//w w w .j a va2 s . co m initUI(); // on screen orientation changes, the loaders will return the last result, // without doing the background work again LoaderManager lm = getLoaderManager(); lm.initLoader(LoaderIds.CURSOR_GET_FEED + getArguments().getInt("position"), null, cursorCallbacks); }
From source file:org.mariotaku.twidere.fragment.support.UserProfileEditorFragment.java
private void getUserInfo() { if (getActivity() == null || isDetached()) return;/* w w w. j a va 2 s . c o m*/ final LoaderManager lm = getLoaderManager(); lm.destroyLoader(LOADER_ID_USER); mGetUserInfoCalled = true; if (mUserInfoLoaderInitialized) { lm.restartLoader(LOADER_ID_USER, null, this); } else { lm.initLoader(LOADER_ID_USER, null, this); mUserInfoLoaderInitialized = true; } }
From source file:com.bangz.smartmute.LocationsMapFragment.java
private void setupMap() { mMap.getUiSettings().setMapToolbarEnabled(false); //mMap.setMyLocationEnabled(true); //mMap.getUiSettings().setMyLocationButtonEnabled(true); markerManager = new MarkerManager(mMap); MarkerManager.Collection colData = markerManager.newCollection(MC_ID_CURRPLACE); colData.setOnMarkerClickListener(this); colData = markerManager.newCollection(MC_ID_DATABASE); colData.setOnMarkerClickListener(this); colData.setOnInfoWindowAdapter(new MyInfoWindowAddapter()); colData = markerManager.newCollection(MC_ID_NEWPLACE); colData.setOnMarkerClickListener(this); mMap.setInfoWindowAdapter(markerManager); mMap.setOnMarkerClickListener(markerManager); mMap.setOnMapLongClickListener(this); mMap.setOnMapClickListener(this); mMap.setOnInfoWindowClickListener(this); restoreSavedMarkers();//from w w w. j ava2 s . co m LoaderManager lm = getLoaderManager(); lm.initLoader(1, null, this); }
From source file:org.mozilla.gecko.FilePickerResultHandler.java
@Override public void onActivityResult(int resultCode, Intent intent) { if (resultCode != Activity.RESULT_OK) { sendResult(""); return;//w ww. j av a 2 s . co m } // Camera results won't return an Intent. Use the file name we passed to the original intent. // In Android M, camera results return an empty Intent rather than null. if (intent == null || (intent.getAction() == null && intent.getData() == null)) { if (mImageName != null) { File file = new File(Environment.getExternalStorageDirectory(), mImageName); sendResult(file.getAbsolutePath()); } else { sendResult(""); } return; } Uri uri = intent.getData(); if (uri == null) { sendResult(""); return; } // Some file pickers may return a file uri if ("file".equals(uri.getScheme())) { String path = uri.getPath(); sendResult(path == null ? "" : path); return; } final FragmentActivity fa = (FragmentActivity) GeckoAppShell.getGeckoInterface().getActivity(); final LoaderManager lm = fa.getSupportLoaderManager(); // Finally, Video pickers and some file pickers may return a content provider. Cursor cursor = null; try { // Try a query to make sure the expected columns exist final ContentResolver cr = fa.getContentResolver(); cursor = cr.query(uri, new String[] { MediaStore.Video.Media.DATA }, null, null, null); int index = cursor.getColumnIndex(MediaStore.Video.Media.DATA); if (index >= 0) { lm.initLoader(intent.hashCode(), null, new VideoLoaderCallbacks(uri)); return; } } catch (Exception ex) { // We'll try a different loader below } finally { if (cursor != null) { cursor.close(); } } lm.initLoader(uri.hashCode(), null, new FileLoaderCallbacks(uri, cacheDir, tabId)); }
From source file:de.vanita5.twittnuker.activity.support.UserProfileEditorActivity.java
private void getUserInfo() { final LoaderManager lm = getSupportLoaderManager(); lm.destroyLoader(LOADER_ID_USER);// w w w. jav a 2 s.c o m mGetUserInfoCalled = true; if (mUserInfoLoaderInitialized) { lm.restartLoader(LOADER_ID_USER, null, this); } else { lm.initLoader(LOADER_ID_USER, null, this); mUserInfoLoaderInitialized = true; } }
From source file:com.packpublishing.asynchronousandroid.chapter4.WhoIsOnlineActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.chapter4_room_list); final LoaderManager lm = getSupportLoaderManager(); final Bundle bundle = new Bundle(); bundle.putString("chatRoom", "Developers"); // lm.initLoader(WHO_IS_ONLINE_LOADER_ID, bundle, this); Button initButton = (Button) findViewById(R.id.init); Button restartButton = (Button) findViewById(R.id.restart); Button destroyButton = (Button) findViewById(R.id.destroy); Button closeButton = (Button) findViewById(R.id.closeActivty); initButton.setOnClickListener(new View.OnClickListener() { @Override// w w w. ja v a2 s .c om public void onClick(View v) { Log.i("WhoIsOnlineLoader", "LoaderManager.init [" + WHO_IS_ONLINE_LOADER_ID + "]"); lm.initLoader(WHO_IS_ONLINE_LOADER_ID, bundle, WhoIsOnlineActivity.this); } }); restartButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.i("WhoIsOnlineLoader", "LoaderManager.restart [" + WHO_IS_ONLINE_LOADER_ID + "]"); lm.restartLoader(WHO_IS_ONLINE_LOADER_ID, bundle, WhoIsOnlineActivity.this); } }); destroyButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.i("WhoIsOnlineLoader", "LoaderManager.destroy [" + WHO_IS_ONLINE_LOADER_ID + "]"); lm.destroyLoader(WHO_IS_ONLINE_LOADER_ID); } }); closeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { WhoIsOnlineActivity.this.finish(); } }); }
From source file:de.vanita5.twittnuker.fragment.support.UserListDetailsFragment.java
public void getUserListInfo(final boolean omit_intent_extra) { final LoaderManager lm = getLoaderManager(); lm.destroyLoader(0);/*from w w w .j a v a2s . c om*/ final Bundle args = new Bundle(getArguments()); args.putBoolean(EXTRA_OMIT_INTENT_EXTRA, omit_intent_extra); if (!mUserListLoaderInitialized) { lm.initLoader(0, args, this); mUserListLoaderInitialized = true; } else { lm.restartLoader(0, args, this); } }