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

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

Introduction

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

Prototype

public void setUri(Uri uri) 

Source Link

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
 *///from  w  w  w  .  j a  v a  2  s.c om
@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.amsterdam.marktbureau.makkelijkemarkt.NotitiesFragment.java

/**
 * Get the non-removed notities for selected markt and dag
 * @param id//from   www.  ja va2 s. com
 * @param args
 * @return
 */
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {

    // create the loader that will load the notities with joined table data for selected
    // markt for today sorted descending on aanmaak tijd
    CursorLoader loader = new CursorLoader(getActivity());
    loader.setUri(MakkelijkeMarktProvider.mUriNotitie);
    loader.setSelection(MakkelijkeMarktProvider.Notitie.COL_VERWIJDERD + " = ? AND "
            + MakkelijkeMarktProvider.Notitie.COL_MARKT_ID + " = ? AND "
            + MakkelijkeMarktProvider.Notitie.COL_DAG + " = ?");
    loader.setSelectionArgs(
            new String[] { "0", args.getString(getString(R.string.sharedpreferences_key_markt_id), null),
                    args.getString(getString(R.string.sharedpreferences_key_date_today), "") });
    loader.setSortOrder(MakkelijkeMarktProvider.Notitie.COL_AANGEMAAKT_DATUMTIJD + " DESC");

    return loader;
}

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

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

    // load the koopman with given id
    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:pl.itiner.grave.ResultList.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle bundle) {
    CursorLoader loader = new CursorLoader(getActivity());
    if (bundle != null)
        loader.setUri(Uri.parse(bundle.getString(CONTENT_PROVIDER_URI)));
    return loader;
}

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
 *///  w w  w.j  a  v a 2s. 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.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 w w  .  ja va  2s .c om

                // 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.google.android.demos.jamendo.widget.Loadable.java

/**
 * Appends query parameters to a {@link CursorLoader} {@link Uri}.
 * /*from   ww  w  . j  av a  2s  .co  m*/
 * @param loader the {@link CursorLoader} to modify.
 * @param args the arguments.
 * @return the modified {@link CursorLoader}.
 */
private CursorLoader appendQueryParameters(CursorLoader loader, Bundle args) {
    Uri.Builder builder = loader.getUri().buildUpon();
    if (args.containsKey(ARG_NUMBER)) {
        int n = args.getInt(ARG_NUMBER);
        builder.appendQueryParameter(JamendoContract.PARAM_NUMBER, Integer.toString(n));
    }
    if (args.containsKey(ARG_MAX_AGE)) {
        long maxAge = args.getLong(ARG_MAX_AGE);
        builder.appendQueryParameter(JamendoContract.PARAM_MAX_AGE, Long.toString(maxAge));
    }
    loader.setUri(builder.build());
    return loader;
}

From source file:com.wuman.androidimageloader.samples.ui.Loadable.java

/**
 * Appends query parameters to a {@link CursorLoader} {@link Uri}.
 * //from   w ww.j av a  2s.c om
 * @param loader
 *            the {@link CursorLoader} to modify.
 * @param args
 *            the arguments.
 * @return the modified {@link CursorLoader}.
 */
private CursorLoader appendQueryParameters(CursorLoader loader, Bundle args) {
    Uri.Builder builder = loader.getUri().buildUpon();
    if (args.containsKey(ARG_NUMBER)) {
        int n = args.getInt(ARG_NUMBER);
        builder.appendQueryParameter(SamplesContract.PARAM_NUMBER, Integer.toString(n));
    }
    if (args.containsKey(ARG_MAX_AGE)) {
        long maxAge = args.getLong(ARG_MAX_AGE);
        builder.appendQueryParameter(SamplesContract.PARAM_MAX_AGE, Long.toString(maxAge));
    }
    loader.setUri(builder.build());
    return loader;
}

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

/**
 * Create the cursor loader that will load the koopman from the database
 *///from   w  w w. j av a2  s  .  c om
@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.silentcircle.contacts.list.ScDefaultContactListAdapter.java

@Override
public void configureLoader(CursorLoader loader, long directoryId) {
    if (loader instanceof ProfileAndContactsLoader) {
        ((ProfileAndContactsLoader) loader).setLoadProfile(shouldIncludeProfile());
    }/* ww  w  . j av a  2 s . com*/

    ContactListFilter filter = getFilter();
    if (isSearchMode()) {
        String query = getQueryString();
        if (query == null) {
            query = "";
        }
        query = query.trim();
        if (TextUtils.isEmpty(query)) {
            // Regardless of the directory, we don't want anything returned,
            // so let's just send a "nothing" query to the local directory.
            loader.setUri(RawContacts.CONTENT_URI);
            loader.setProjection(getProjection(false));
            loader.setSelection("0");
        } else {
            Builder builder = RawContacts.CONTENT_FILTER_URI.buildUpon();
            builder.appendPath(query); // Builder will encode the query
            builder.appendQueryParameter(ScContactsContract.DIRECTORY_PARAM_KEY, String.valueOf(directoryId));
            if (directoryId != Directory.DEFAULT && directoryId != Directory.LOCAL_INVISIBLE) {
                builder.appendQueryParameter(ScContactsContract.LIMIT_PARAM_KEY,
                        String.valueOf(getDirectoryResultLimit()));
            }
            builder.appendQueryParameter(SearchSnippetColumns.SNIPPET_ARGS_PARAM_KEY, SNIPPET_ARGS);
            builder.appendQueryParameter(SearchSnippetColumns.DEFERRED_SNIPPETING_KEY, "1");
            loader.setUri(builder.build());
            loader.setProjection(getProjection(true));
        }
    } else {
        configureUri(loader, directoryId, filter);
        loader.setProjection(getProjection(false));
        configureSelection(loader, directoryId, filter);
    }

    String sortOrder;
    if (getSortOrder() == ScContactsContract.Preferences.SORT_ORDER_PRIMARY) {
        sortOrder = RawContacts.SORT_KEY_PRIMARY;
    } else {
        sortOrder = RawContacts.SORT_KEY_ALTERNATIVE;
    }
    loader.setSortOrder(sortOrder);
}