Example usage for android.support.v4.content CursorLoader CursorLoader

List of usage examples for android.support.v4.content CursorLoader CursorLoader

Introduction

In this page you can find the example usage for android.support.v4.content CursorLoader CursorLoader.

Prototype

public CursorLoader(Context context) 

Source Link

Document

Creates an empty unspecified CursorLoader.

Usage

From source file:com.amsterdam.marktbureau.makkelijkemarkt.MarktenFragment.java

/**
 * Create the loader to get the markten from the database
 * @param id the unique id for this loader
 * @param args the arguments given in the initloader call in oncreateview
 * @return a cursor containing the markten
 *//*ww w  .j  av a  2 s .c o  m*/
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {

    // create the loader
    CursorLoader loader = new CursorLoader(getActivity());
    loader.setUri(MakkelijkeMarktProvider.mUriMarkt);
    loader.setProjection(new String[] { MakkelijkeMarktProvider.Markt.COL_ID,
            MakkelijkeMarktProvider.Markt.COL_NAAM, MakkelijkeMarktProvider.Markt.COL_AANWEZIGE_OPTIES });
    loader.setSortOrder(MakkelijkeMarktProvider.Markt.COL_NAAM + " ASC");

    return loader;
}

From source file:com.activiti.android.ui.fragments.form.picker.ActivitiUserPickerFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    switch (requestCode) {
    case RequestCode.PICK_CONTACT: {
        if (resultCode == Activity.RESULT_OK && data != null) {
            try {
                Uri contactUri = data.getData();

                // Cursor loader to query optional contact email
                CursorLoader clEmail = new CursorLoader(getActivity());
                clEmail.setProjection(new String[] { ContactsContract.CommonDataKinds.Email.ADDRESS });
                clEmail.setUri(contactUri);
                Cursor cursor = clEmail.loadInBackground();
                cursor.moveToFirst();//from   w  ww .  j a  va  2  s.  c  o  m

                // Retrieve the phone number from the NUMBER column
                int column = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Email.ADDRESS);
                String email = cursor.getString(column);
                searchForm.setText(email);
                ((MaterialDialog) getDialog()).getActionButton(DialogAction.POSITIVE).setEnabled(true);
            } catch (Exception error) {
                Snackbar.make(getActivity().findViewById(R.id.left_panel), error.getMessage(),
                        Snackbar.LENGTH_LONG).show();
            }
        }
        break;
    }
    default:
        super.onActivityResult(requestCode, resultCode, data);
        break;
    }
}

From source file:com.amsterdam.marktbureau.makkelijkemarkt.LoginFragment.java

/**
 * Create the cursorloader that will load the accounts from the db
 * @param id the unique id given in the initloader call
 * @param args the arguments given in the initloader call
 * @return the cursor containing the accounts when loaded from the db
 *//*from w ww  . j a v  a2s  .  co m*/
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {

    // create the loader
    CursorLoader loader = new CursorLoader(getActivity());
    loader.setUri(MakkelijkeMarktProvider.mUriAccount);
    loader.setProjection(
            new String[] { MakkelijkeMarktProvider.Account.COL_ID, MakkelijkeMarktProvider.Account.COL_NAAM });
    loader.setSortOrder(MakkelijkeMarktProvider.Account.COL_NAAM + " ASC");

    return loader;
}

From source file:com.customprogrammingsolutions.MediaStreamer.MainActivity.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle arg1) {
    CursorLoader loader = null;/*from  w  ww  . j  ava  2 s  .c  o m*/
    ;
    if (id == 0) {
        loader = new CursorLoader(MainActivity.this) {
            final RecentsDBHelper rdb = new RecentsDBHelper(MainActivity.this).open();

            @Override
            public Cursor loadInBackground() {
                Cursor c = null;
                c = rdb.getAllRecents();
                return c;
            }

        };
    } else if (id == 1) {
        loader = new CursorLoader(MainActivity.this) {
            final FavoritesDBHelper fdb = new FavoritesDBHelper(MainActivity.this).open();

            @Override
            public Cursor loadInBackground() {
                Cursor c = null;
                c = fdb.getAllFavorites();
                return c;
            }

        };
    }

    return loader;
}

From source file:com.amsterdam.marktbureau.makkelijkemarkt.DagvergunningFragmentKoopman.java

/**
 * Create the cursor loader that will load the koopman from the database
 *///  w  w w.  jav a  2s.  c o m
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {

    // load the koopman with given id in the arguments bundle and where doorgehaald is false
    if (mKoopmanId != -1) {
        CursorLoader loader = new CursorLoader(getActivity());
        loader.setUri(MakkelijkeMarktProvider.mUriKoopmanJoined);
        loader.setSelection(
                MakkelijkeMarktProvider.mTableKoopman + "." + MakkelijkeMarktProvider.Koopman.COL_ID + " = ? ");
        loader.setSelectionArgs(new String[] { String.valueOf(mKoopmanId) });

        return loader;
    }

    return null;
}

From source file:com.amsterdam.marktbureau.makkelijkemarkt.DagvergunningFragment.java

/**
 * Create the loader that will load the dagvergunning from the db when we are editing an existing one
 * @param id the unique loader id//from w  w  w.  j  a v  a2s .co m
 * @param args an arguments bundle that contains the dagvergunning id
 * @return a cursor with one record containing the joined dagvergunning details
 */
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {

    // load the dagvergunning with given id in the arguments bundle
    if (args != null && args.getInt(MakkelijkeMarktProvider.Dagvergunning.COL_ID, 0) != 0) {
        CursorLoader loader = new CursorLoader(getActivity());
        loader.setUri(MakkelijkeMarktProvider.mUriDagvergunningJoined);
        loader.setSelection(MakkelijkeMarktProvider.mTableDagvergunning + "."
                + MakkelijkeMarktProvider.Dagvergunning.COL_ID + " = ? ");
        loader.setSelectionArgs(
                new String[] { String.valueOf(args.getInt(MakkelijkeMarktProvider.Dagvergunning.COL_ID, 0)) });

        return loader;
    }

    return null;
}