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:org.mariotaku.twidere.activity.SignInActivity.java

private void doLogin(final boolean is_browser_sign_in, final Bundle extras) {
    final LoaderManager lm = getSupportLoaderManager();
    final Bundle args = new Bundle();
    if (extras != null) {
        args.putAll(extras);//w ww  . java 2s .com
    }
    args.putBoolean(INTENT_KEY_IS_BROWSER_SIGN_IN, is_browser_sign_in);
    lm.destroyLoader(0);
    if (mLoaderInitialized) {
        lm.restartLoader(0, args, this);
    } else {
        lm.initLoader(0, args, this);
        mLoaderInitialized = true;
    }
}

From source file:org.getlantern.firetweet.fragment.support.MessagesConversationFragment.java

private void searchUsers(long accountId, String query, boolean fromCache) {
    final Bundle args = new Bundle();
    args.putLong(EXTRA_ACCOUNT_ID, accountId);
    args.putString(EXTRA_QUERY, query);/*from  www .j  a v a 2s .  co m*/
    args.putBoolean(EXTRA_FROM_CACHE, fromCache);
    final LoaderManager lm = getLoaderManager();
    if (mSearchUsersLoaderInitialized) {
        lm.restartLoader(LOADER_ID_SEARCH_USERS, args, mSearchLoadersCallback);
    } else {
        mSearchUsersLoaderInitialized = true;
        lm.initLoader(LOADER_ID_SEARCH_USERS, args, mSearchLoadersCallback);
    }
}

From source file:com.gdgdevfest.android.apps.devfestbcn.ui.MapFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View mapView = super.onCreateView(inflater, container, savedInstanceState);

    View v = inflater.inflate(R.layout.fragment_map, container, false);
    FrameLayout layout = (FrameLayout) v.findViewById(R.id.map_container);

    layout.addView(mapView, 0);//from  w w  w.  ja va 2  s .  co m

    mFloorControls = layout.findViewById(R.id.map_floorcontrol);

    // setup floor button handlers
    mFloorButtons[0] = (Button) v.findViewById(R.id.map_floor1);
    mFloorButtons[1] = (Button) v.findViewById(R.id.map_floor2);
    mFloorButtons[2] = (Button) v.findViewById(R.id.map_floor3);
    mFloorButtons[0].setVisibility(View.GONE);
    mFloorButtons[1].setVisibility(View.GONE);
    mFloorButtons[2].setVisibility(View.GONE);
    mFloorControls.setVisibility(View.GONE);
    for (int i = 0; i < mFloorButtons.length; i++) {
        final int j = i;
        mFloorButtons[i].setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showFloor(j);
            }
        });

    }

    // get the height and width of the view
    mapView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

        @SuppressWarnings("deprecation")
        @SuppressLint("NewApi")
        @Override
        public void onGlobalLayout() {
            final View v = getView();
            mHeight = v.getHeight();
            mWidth = v.getWidth();

            // also requires width and height
            enableFloors();

            if (v.getViewTreeObserver().isAlive()) {
                // remove this layout listener
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                    v.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                } else {
                    v.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                }
            }
        }
    });

    if (mMap == null) {
        setupMap(true);
    }

    // load all markers
    LoaderManager lm = getActivity().getSupportLoaderManager();
    lm.initLoader(MarkerQuery._TOKEN, null, this);

    // load the tile overlays
    lm.initLoader(OverlayQuery._TOKEN, null, this);

    // load tracks data
    lm.initLoader(TracksQuery._TOKEN, null, this);

    return v;
}

From source file:org.getlantern.firetweet.fragment.support.MessagesConversationFragment.java

public void showConversation(final ParcelableAccount account, final ParcelableUser recipient) {
    mAccount = account;/*w w w .jav a  2s  . c om*/
    mRecipient = recipient;
    if (account == null || recipient == null)
        return;
    final LoaderManager lm = getLoaderManager();
    final Bundle args = new Bundle();
    args.putLong(EXTRA_ACCOUNT_ID, account.account_id);
    args.putLong(EXTRA_RECIPIENT_ID, recipient.id);
    if (mLoaderInitialized) {
        lm.restartLoader(0, args, this);
    } else {
        mLoaderInitialized = true;
        lm.initLoader(0, args, this);
    }
    AsyncTask.execute(new Runnable() {
        @Override
        public void run() {

        }
    });
    new SetReadStateTask(getActivity(), account, recipient).execute();
    updateActionBar();
    updateProfileImage();
}

From source file:org.mariotaku.twidere.fragment.UserProfileFragment.java

private void getFriendship() {
    final LoaderManager lm = getLoaderManager();
    lm.destroyLoader(LOADER_ID_FRIENDSHIP);
    if (!mGetFriendShipLoaderInitialized) {
        lm.initLoader(LOADER_ID_FRIENDSHIP, null, mFriendshipLoaderCallbacks);
        mGetFriendShipLoaderInitialized = true;
    } else {/*from  w  ww  .  j  a va  2  s.c o m*/
        lm.restartLoader(LOADER_ID_FRIENDSHIP, null, mFriendshipLoaderCallbacks);
    }
}

From source file:org.mariotaku.twidere.activity.ComposeActivity.java

private void reloadAttachedImageThumbnail(final File file) {
    final LoaderManager lm = getSupportLoaderManager();
    lm.destroyLoader(0);/*from   w  w  w  .ja v  a 2s .c o  m*/
    final Bundle args = new Bundle();
    args.putString(INTENT_KEY_FILENAME, file != null ? file.getPath() : null);
    if (mLoaderInitialized) {
        lm.restartLoader(0, args, this);
    } else {
        lm.initLoader(0, args, this);
        mLoaderInitialized = true;
    }
}

From source file:org.mariotaku.twidere.fragment.StatusFragment.java

private void getStatus(final boolean omit_intent_extra) {
    final LoaderManager lm = getLoaderManager();
    lm.destroyLoader(LOADER_ID_STATUS);//ww  w.jav  a2 s. co m
    final Bundle args = new Bundle();
    args.putBoolean(INTENT_KEY_OMIT_INTENT_EXTRA, omit_intent_extra);
    if (!mStatusLoaderInitialized) {
        lm.initLoader(LOADER_ID_STATUS, args, mStatusLoaderCallbacks);
        mStatusLoaderInitialized = true;
    } else {
        lm.restartLoader(LOADER_ID_STATUS, args, mStatusLoaderCallbacks);
    }
}

From source file:org.mariotaku.twidere.fragment.UserProfileFragment.java

private void getBannerImage() {
    final LoaderManager lm = getLoaderManager();
    lm.destroyLoader(LOADER_ID_BANNER);/*from www . j  av  a  2 s.co m*/
    if (mBannerImageLoaderInitialized) {
        lm.restartLoader(LOADER_ID_BANNER, null, mBannerImageCallback);
    } else {
        lm.initLoader(LOADER_ID_BANNER, null, mBannerImageCallback);
        mBannerImageLoaderInitialized = true;
    }
}

From source file:org.mariotaku.twidere.fragment.support.MessagesConversationFragment.java

public void showConversation(final ParcelableCredentials account, final ParcelableUser recipient) {
    mAccount = account;/*from   w  w w.  ja  va 2s.c  o  m*/
    mRecipient = recipient;
    if (account == null || recipient == null)
        return;
    final LoaderManager lm = getLoaderManager();
    final Bundle args = new Bundle();
    args.putLong(EXTRA_ACCOUNT_ID, account.account_id);
    args.putLong(EXTRA_RECIPIENT_ID, recipient.id);
    if (mLoaderInitialized) {
        lm.restartLoader(0, args, this);
    } else {
        mLoaderInitialized = true;
        lm.initLoader(0, args, this);
    }
    AsyncTaskUtils.executeTask(new SetReadStateTask(getActivity(), account, recipient));
    updateActionBar();
    updateRecipientInfo();
    mEditText.requestFocus();
}

From source file:org.mariotaku.twidere.fragment.MessagesConversationFragment.java

private void searchUsers(UserKey accountKey, String query, boolean fromCache) {
    final Bundle args = new Bundle();
    args.putParcelable(EXTRA_ACCOUNT_KEY, accountKey);
    args.putString(EXTRA_QUERY, query);/*from w w  w .  j  a  va 2  s.c  om*/
    args.putBoolean(EXTRA_FROM_CACHE, fromCache);
    final LoaderManager lm = getLoaderManager();
    if (mSearchUsersLoaderInitialized) {
        lm.restartLoader(LOADER_ID_SEARCH_USERS, args, mSearchLoadersCallback);
    } else {
        mSearchUsersLoaderInitialized = true;
        lm.initLoader(LOADER_ID_SEARCH_USERS, args, mSearchLoadersCallback);
    }
}