Example usage for android.support.v4.app LoaderManager initLoader

List of usage examples for android.support.v4.app LoaderManager initLoader

Introduction

In this page you can find the example usage for android.support.v4.app LoaderManager initLoader.

Prototype

public abstract <D> Loader<D> initLoader(int id, Bundle args, LoaderManager.LoaderCallbacks<D> callback);

Source Link

Document

Ensures a loader is initialized and active.

Usage

From source file:com.kncwallet.wallet.ui.HomeFragment.java

@Override
public void onResume() {
    super.onResume();
    LoaderManager lm = getLoaderManager();
    lm.initLoader(ID_BALANCE_LOADER, null, balanceLoaderCallbacks);
    lm.initLoader(ID_RATE_LOADER, null, rateLoaderCallbacks);

    if (broadcastReceiverIntent == null) {
        broadcastReceiverIntent = activity.registerReceiver(broadcastReceiver,
                new IntentFilter(BlockchainService.ACTION_BLOCKCHAIN_STATE));
    }/* w w w .j  a  v a  2  s  . co  m*/

    activity.registerReceiver(broadcastReceiver, new IntentFilter(BlockchainService.ACTION_BLOCKCHAIN_STATE));
    prefs.registerOnSharedPreferenceChangeListener(prefsListener);

    updateBalanceView();
    updateAddressView();
    updateBackupView();

}

From source file:com.github.jobs.ui.fragment.JobListFragment.java

private void queryList() {
    try {/*from w ww. ja v  a  2s  . c om*/
        FragmentActivity activity = getActivity();
        if (activity == null || !isAdded()) {
            return;
        }
        LoaderManager loaderManager = activity.getSupportLoaderManager();
        Loader<Object> loader = loaderManager.getLoader(mCurrentSearch.hashCode());
        if (loader == null) {
            loaderManager.initLoader(mCurrentSearch.hashCode(), null, this);
        } else {
            loaderManager.restartLoader(mCurrentSearch.hashCode(), null, this);
        }
    } catch (IllegalStateException e) {
        // happens when activity is closed. We can't use isResumed since it will be false when the activity is
        // not being shown, thus it will cause problems if user loads another screen while this is still loading
    }
}

From source file:com.jefftharris.passwdsafe.FileListFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    //noinspection ConstantConditions
    if (PasswdSafeApp.DEBUG_AUTO_FILE != null) {
        openFile(new File(PasswdSafeApp.DEBUG_AUTO_FILE));
    }//from   w  w w.  j  av  a 2 s  .c o  m

    LoaderManager lm = getLoaderManager();
    lm.initLoader(0, null, this);
}

From source file:info.guardianproject.gpg.KeyListFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setEmptyText(getString(R.string.search_hint));
    setHasOptionsMenu(true);//  w  w  w  .  j  av  a 2 s .  co  m
    mListView = getListView();

    mAction = getArguments().getString("action");
    // TODO should everything be CHOICE_MODE_MULTIPLE?
    if (mAction == null || mAction.equals(Action.SHOW_PUBLIC_KEYS)) {
        mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    } else if (mAction.equals(Action.FIND_KEYS)) {
        mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    } else if (mAction.equals(Action.SELECT_PUBLIC_KEYS)) {
        mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    } else if (mAction.equals(Action.SELECT_SECRET_KEYS)) {
        mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    } else {
        mListView.setChoiceMode(ListView.CHOICE_MODE_NONE);
    }
    registerReceiver();
    handleIntent(mAction, getArguments().getBundle("extras"));
    LoaderManager lm = getLoaderManager();
    if (mAction.equals(Action.FIND_KEYS) && lm.getLoader(Tabs.FIND_KEYS) != null) {
        lm.initLoader(Tabs.FIND_KEYS, null, this);
    }
}

From source file:nu.firetech.android.pactrack.frontend.ParcelDetailsFragment.java

@Override
public void refreshDone() {
    int[] loaders = { PARCEL_LOADER_ID, EVENTS_LOADER_ID };

    LoaderManager lm = getLoaderManager();
    for (int loader_id : loaders) {
        if (lm.getLoader(loader_id) == null) {
            lm.initLoader(loader_id, null, this);
        } else {/*  w ww .  j av  a 2 s  . c o  m*/
            lm.restartLoader(loader_id, null, this);
        }
    }
}

From source file:it.geosolutions.android.map.fragment.FeatureInfoAttributeListFragment.java

/**
 * Create an array of <FeatureInfoTaskQuery> to pass to the loader and
 * initialize the loader// w  ww . j  ava2 s .co  m
 * 
 * @param query the <FeatureInfoQuery> with bbox
 * @param layers array of <String> to generate the queryQueue
 * @param start
 * @param limit
 */
private void startDataLoading(FeatureInfoQuery query, ArrayList<String> layers, Integer start, Integer limit) {
    // create task query
    queryQueue = FeatureInfoUtils.createTaskQueryQueue(layers, query, start, limit);

    // 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(start, null, this); // uses start to get the
}

From source file:com.gbozza.android.popularmovies.fragments.MovieGridFragment.java

/**
 * A method that invokes the AsyncTask to populate the RecyclerView,
 * it's based on the sorting option selected by the user. Default is "most popular"
 *//* www. j a  va  2s.  com*/
public void loadCards() {
    if (null != mSwipeContainer && mSwipeContainer.isRefreshing()) {
        mSwipeContainer.setRefreshing(false);
    }
    if (NetworkUtilities.isOnline(mContext)) {
        switch (mSorting) {
        case SORTING_POPULAR:
            new FetchMoviesTask().execute(
                    new String[] { NetworkUtilities.getMoviedbMethodPopular(), String.valueOf(mPage) });
            break;
        case SORTING_RATED:
            new FetchMoviesTask()
                    .execute(new String[] { NetworkUtilities.getMoviedbMethodRated(), String.valueOf(mPage) });
            break;
        case SORTING_FAVOURITES:
            LoaderManager loaderManager = getActivity().getSupportLoaderManager();
            if (null == loaderManager.getLoader(ID_FAVOURITES_LOADER)) {
                loaderManager.initLoader(ID_FAVOURITES_LOADER, null, this);
            } else {
                loaderManager.restartLoader(ID_FAVOURITES_LOADER, null, this);
            }
            break;
        }
    } else {
        showErrorMessage(R.string.error_no_connectivity, mContext);
    }
}

From source file:it.geosolutions.android.map.fragment.featureinfo.FeatureInfoAttributeListFragment.java

/**
 * Create an array of <BaseFeatureInfoQuery> to pass to the loader and
 * initialize the loader// www  .j  av  a  2s. c om
 * 
 * @param query the <BaseFeatureInfoQuery>
 * @param layers array of <String> to generate the queryQueue
 * @param start
 * @param limit
 */
private void startDataLoading(BaseFeatureInfoQuery query, ArrayList<Layer> layers, Integer start,
        Integer limit) {

    // create task query
    if (query instanceof BBoxQuery)
        queryQueue = FeatureInfoUtils.createTaskQueryQueue(layers, (BBoxQuery) query, start, limit);
    else if (query instanceof CircleQuery)
        queryQueue = FeatureInfoUtils.createTaskQueryQueue(layers, (CircleQuery) query, start, limit);
    else
        queryQueue = FeatureInfoUtils.createTaskQueryQueue(layers, (PolygonQuery) query, start, limit);

    // 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(start, null, this); // uses start to get the
}

From source file:com.kaliturin.blacklist.fragments.SMSConversationsListFragment.java

private void loadListViewItems(int listPosition, boolean markSeen, boolean showProgress) {
    if (!isAdded()) {
        return;/*  ww  w.  ja  v a  2 s.c o  m*/
    }
    int loaderId = 0;
    ConversationsLoaderCallbacks callbacks = new ConversationsLoaderCallbacks(getContext(), listView,
            listPosition, cursorAdapter, markSeen, showProgress);

    LoaderManager manager = getLoaderManager();
    Loader<?> loader = manager.getLoader(loaderId);
    if (loader == null) {
        // init and run the items loader
        manager.initLoader(loaderId, null, callbacks);
    } else {
        // restart loader
        manager.restartLoader(loaderId, null, callbacks);
    }
}

From source file:com.kaliturin.blacklist.fragments.SMSConversationFragment.java

private void loadListViewItems(int threadId, int unreadCount, int listPosition) {
    if (!isAdded()) {
        return;/*  w w w .ja  v  a 2  s .  c o  m*/
    }
    int loaderId = 0;
    ConversationLoaderCallbacks callbacks = new ConversationLoaderCallbacks(getContext(), threadId, unreadCount,
            listView, listPosition, cursorAdapter);

    LoaderManager manager = getLoaderManager();
    if (manager.getLoader(loaderId) == null) {
        // init and run the items loader
        manager.initLoader(loaderId, null, callbacks);
    } else {
        // restart loader
        manager.restartLoader(loaderId, null, callbacks);
    }
}