Android CursorLoader - 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 CursorLoader class.

This code example shows how to use the following methods: getProjection, getSelection, getSelectionArgs, getSortOrder, getUri
    Uri uri = Uri.parse("http://robolectric.org");
    String[] projection = new String[] { "_id", "TestColumn" };
    String selection = "_id = ?";
    String[] selectionArgs = new String[] { "5" };
    String sortOrder = "_id";
    CursorLoader cursorLoader = new CursorLoader(new Activity(),
        uri,
        projection,
        selection,
        selectionArgs,
        sortOrder);
 
    assertThat(cursorLoader.getUri()).isEqualTo(uri);
    assertThat(cursorLoader.getProjection()).isEqualTo(projection);
    assertThat(cursorLoader.getSelection()).isEqualTo(selection);
    assertThat(cursorLoader.getSelectionArgs()).isEqualTo(selectionArgs);
    assertThat(cursorLoader.getSortOrder()).isEqualTo(sortOrder);
  } 
 
  @Test 

9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: getProjection, getSelection, getSelectionArgs, getSortOrder, getUri
        Uri uri = Uri.parse("http://robolectric.org");
        String[] projection = new String[] { "_id", "TestColumn" };
        String selection = "_id = ?";
        String[] selectionArgs = new String[] { "5" };
        String sortOrder = "_id";
        CursorLoader cursorLoader = new CursorLoader(new Activity(),
                uri,
                projection,
                selection,
                selectionArgs,
                sortOrder);
 
        assertThat(cursorLoader.getUri()).isEqualTo(uri);
        assertThat(cursorLoader.getProjection()).isEqualTo(projection);
        assertThat(cursorLoader.getSelection()).isEqualTo(selection);
        assertThat(cursorLoader.getSelectionArgs()).isEqualTo(selectionArgs);
        assertThat(cursorLoader.getSortOrder()).isEqualTo(sortOrder);
    } 
     
    @Test 

9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: setProjection, setSelection, setSelectionArgs, setSortOrder, setUri
    return new WrappedLoaderBuilder<Out>(query.getQueryData(), wrapper);
  } 
 
  public Loader<Cursor> build(Context context) {
    final QueryData queryData = query.getQueryData();
    final CursorLoader loader = new CursorLoader(context);
    loader.setUri(queryData.getUri());
    loader.setProjection(queryData.getProjection());
    loader.setSelection(queryData.getSelection());
    loader.setSelectionArgs(queryData.getSelectionArgs());
    loader.setSortOrder(queryData.getOrderBy());
    return loader;
  } 
} 
Full Snippet Info
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
public class IdentityLoader extends CursorLoader {
 
  private final Context context;
 
  public IdentityLoader(Context context) {
    super(context);
    this.context      = context.getApplicationContext();
  } 
 
  @Override 
  public Cursor loadInBackground() {
    return DatabaseFactory.getIdentityDatabase(context).getIdentities();
  } 
 
} 
Full Snippet Info
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
 
  private final String filter;
  private final Context context;
 
  public ConversationListLoader(Context context, String filter) {
    super(context);
    this.filter  = filter;
    this.context = context.getApplicationContext();
  } 
 
  @Override 
  public Cursor loadInBackground() {
    if (filter != null && filter.trim().length() != 0) {
      List<String> numbers = ContactAccessor.getInstance()
          .getNumbersForThreadSearchFilter(filter, context.getContentResolver());
 
      return DatabaseFactory.getThreadDatabase(context).getFilteredConversationList(numbers);
    } else { 
      return DatabaseFactory.getThreadDatabase(context).getConversationList();
    } 
Full Snippet Info
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: setUpdateThrottle
            MainTable._ID,
            MainTable.COLUMN_NAME_DATA,
        }; 
 
        public Loader<Cursor> onCreateLoader(int id, Bundle args) {
            CursorLoader cl = new CursorLoader(getActivity(), MainTable.CONTENT_URI,
                    PROJECTION, null, null, null);
            cl.setUpdateThrottle(2000); // update at most every 2 seconds.
            return cl;
        } 
 
        public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
            mAdapter.swapCursor(data);
 
            // The list should now be shown. 
            if (isResumed()) {
                setListShown(true);
            } else { 
                setListShownNoAnimation(true);
            } 
Full Snippet Info
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
 
import static android.support.v4.app.Watson.OnCreateOptionsMenuListener; 
import static android.support.v4.app.Watson.OnOptionsItemSelectedListener; 
import static android.support.v4.app.Watson.OnPrepareOptionsMenuListener; 
 
public class SherlockFragment extends Fragment implements OnCreateOptionsMenuListener, OnPrepareOptionsMenuListener, OnOptionsItemSelectedListener {
    private SherlockFragmentActivity mActivity;
 
    public SherlockFragmentActivity getSherlockActivity() { 
        return mActivity;
    } 
 
    @Override 
    public void onAttach(Activity activity) {
        if (!(activity instanceof SherlockFragmentActivity)) {
            throw new IllegalStateException(getClass().getSimpleName() + " must be attached to a SherlockFragmentActivity.");
        } 
        mActivity = (SherlockFragmentActivity)activity;
 
        super.onAttach(activity);
Full Snippet Info
10
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
 
    @Override 
    public Loader<Cursor> onCreateLoader(int loaderID, Bundle bundle) { 
        switch (loaderID) { 
        case GALLERY_LOADER: 
            return new CursorLoader( 
                        this, 
                        MediaStore.Images.Media.EXTERNAL_CONTENT_URI, 
                        new String[] { ImageColumns._ID, 
                                       ImageColumns.DATE_TAKEN }, 
                        null, 
                        null, 
                        ImageColumns.DATE_TAKEN + " DESC" 
        ); 
        default: 
            return null; 
        } 
    } 
 
    @Override 
Full Snippet Info
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: setRetainInstance
	 
	public ColorFragment() {  
		this(R.color.white);
	} 
	 
	public ColorFragment(int colorRes) {
		mColorRes = colorRes;
		setRetainInstance(true);
	} 
 
	@Override 
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		if (savedInstanceState != null)
			mColorRes = savedInstanceState.getInt("mColorRes");
		int color = getResources().getColor(mColorRes);
		// construct the RelativeLayout 
		RelativeLayout v = new RelativeLayout(getActivity());
		v.setBackgroundColor(color);		
		return v;
	} 
Full Snippet Info
10
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
package com.newsblur.fragment; 
 
import android.os.Bundle; 
import android.support.v4.app.Fragment; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.view.ViewGroup; 
 
import com.newsblur.R; 
 
public class LoadingFragment extends Fragment {
	 
	@Override 
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		return inflater.inflate(R.layout.fragment_loadingitems, null);
	} 
 
} 

10
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Android CursorLoader Methods: