Android Loader - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Loader class.

This code example shows how to use the following methods:onContentChanged
    this.loader=loader;
  } 
 
  @Override 
  protected void onPostExecute(T3 param) {
    loader.onContentChanged();
  } 
} 
6
CodeRank
This code example shows how to use the following methods:getId
        return null; 
    } 
 
    @Override 
    public void onLoadFinished(Loader loader, Cursor data) {
        switch (loader.getId()) {
            case LOADER_GROUPS: {
                setData(data);
                break; 
            } 
        } 
    } 
 
    private void setData(Cursor groups) {
        MatrixCursor psuedoGroups = new MatrixCursor(new String[] { "_id", "name" });
        psuedoGroups.newRow().add(-1).add("All Contacts");
        psuedoGroups.newRow().add(-2).add("Favorites");
        mAdapter.changeCursor(new MergeCursor(new Cursor[] { psuedoGroups, groups }));
    } 
 
6
CodeRank
This code example shows how to use the following methods:getId
        return null; 
    } 
 
    @Override 
    public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
        if (loader.getId() == LOADER_SNAPSHOTS) {
            if (mAdapter == null) {
                mAdapter = new SnapshotAdapter(getActivity(), data);
                mGrid.setAdapter(mAdapter);
            } else { 
                mAdapter.changeCursor(data);
            } 
            if (mAnimateId > 0) {
                mAdapter.animateIn(mAnimateId);
                mAnimateId = 0;
                getArguments().remove(EXTRA_ANIMATE_ID);
            } 
            boolean empty = mAdapter.isEmpty();
            mGrid.setVisibility(empty ? View.GONE : View.VISIBLE);
            mEmpty.setVisibility(empty ? View.VISIBLE : View.GONE);
5
CodeRank
This code example shows how to use the following methods:getId
    } 
 
    @Override 
    public void onLoaderReset(Loader<Cursor> cursorLoader) {
        mDisplayView.setText("");
        switch (cursorLoader.getId()) {
            case ID_CHANGE_LOADER:
                mChangeAdapter.swapCursor(null);
                break; 
            case ID_DELETE_LOADER:
                mDeleteAdapter.swapCursor(null);
                break; 
        } 
    } 
 
    private class DeleteCursorWrapper extends CursorWrapper {
 
        /** 
         * Creates a cursor wrapper. 
         * 
5
CodeRank
This code example shows how to use the following methods:getId
 
	@Override 
	public void onLoaderReset(Loader<Cursor> loader) {
		if (loader == null)
			return; 
		int id = loader.getId();
		if (DEBUG) Log.d(TAG, "enter onLoaderReset: " + id);
		switch (id) {
			case PRIMARY_LOADER:
			break; 
			case SPECIES_LOADER:
				speciesAdapter.swapCursor(null);
			break; 
			case BREED_LOADER:
				breedAdapter.swapCursor(null);
			break; 
		} 
		if (DEBUG) Log.d(TAG, "leave onLoaderReset: " + id);
	} 
 
3
CodeRank
This code example shows how to use the following methods:getId
        return null; 
    } 
 
    @Override 
    public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
        if (loader.getId() == LOADER_SNAPSHOTS) {
            if (mAdapter == null) {
                mAdapter = new SnapshotAdapter(getActivity(), data);
                mGrid.setAdapter(mAdapter);
            } else { 
                mAdapter.changeCursor(data);
            } 
            if (mAnimateId > 0) {
                mAdapter.animateIn(mAnimateId);
                mAnimateId = 0;
                getArguments().remove(EXTRA_ANIMATE_ID);
            } 
            boolean empty = mAdapter.isEmpty();
            mGrid.setVisibility(empty ? View.GONE : View.VISIBLE);
            mEmpty.setVisibility(empty ? View.VISIBLE : View.GONE);
3
CodeRank
This code example shows how to use the following methods:getId
        return null; 
    } 
 
    @Override 
    public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
        if (loader.getId() == LOADER_SNAPSHOTS) {
            if (mAdapter == null) {
                mAdapter = new SnapshotAdapter(getActivity(), data);
                mGrid.setAdapter(mAdapter);
            } else { 
                mAdapter.changeCursor(data);
            } 
            if (mAnimateId > 0) {
                mAdapter.animateIn(mAnimateId);
                mAnimateId = 0;
                getArguments().remove(EXTRA_ANIMATE_ID);
            } 
            boolean empty = mAdapter.isEmpty();
            mGrid.setVisibility(empty ? View.GONE : View.VISIBLE);
            mEmpty.setVisibility(empty ? View.VISIBLE : View.GONE);
3
CodeRank
This code example shows how to use the following methods:getId
	public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
		if (getActivity() == null) {
			return; 
		} 
 
		int token = loader.getId();
		if (token == DogsQuery._TOKEN) {
			mAdapter.changeCursor(cursor);
			Bundle arguments = getArguments();
 
			if (arguments != null && arguments.containsKey("_uri")) {
				String uri = arguments.get("_uri").toString();
			} 
		} else { 
			Log.d(TAG, "Query complete, Not Actionable: " + token);
			cursor.close();
		} 
	} 
 
	@Override 
3
CodeRank
This code example shows how to use the following methods:getId
		return null; 
	} 
 
	@Override 
	public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
		if (loader.getId() == LOADER_MESSAGE) {
			if (cursor != null) {
				mListAdapter.swapCursor(cursor);
			} 
		} 
	} 
 
	@Override 
	public void onLoaderReset(Loader<Cursor> loader) {
		if (loader.getId() == LOADER_MESSAGE) {
			mListAdapter.swapCursor(null);
		} 
	} 
 
} 
4
CodeRank
This code example shows how to use the following methods:getId
        } 
    } 
 
    @Override 
    public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
        switch (loader.getId()) {
        case LOADER_PHONENBR_ID:
            setPhone(data);
            break; 
        case LOADER_ADDRESS_ID:
            setAddress(data);
            break; 
        default: 
            throw new IllegalArgumentException();
        }         
    } 
 
    private void setPhone(Cursor data) {
        data.moveToFirst();
        if (!data.isAfterLast()) {
4
CodeRank

Related Android Loader Questions & Answers:

See Code Examples for Android Loader Methods: