Example usage for android.database MatrixCursor addRow

List of usage examples for android.database MatrixCursor addRow

Introduction

In this page you can find the example usage for android.database MatrixCursor addRow.

Prototype

public void addRow(Iterable<?> columnValues) 

Source Link

Document

Adds a new row to the end with the given column values.

Usage

From source file:com.grayfox.android.app.widget.CategoryCursorAdapter.java

public void set(Category... categories) {
    MatrixCursor cursor = createCursor();
    for (int i = 0; i < categories.length; i++) {
        cursor.addRow(new String[] { String.valueOf(i + 1), categories[i].getName(), categories[i].getIconUrl(),
                categories[i].getFoursquareId() });
    }// w w  w.  j  a  va2  s  . c o m
    changeCursor(cursor);
}

From source file:com.xbm.android.matisse.internal.loader.AlbumMediaLoader.java

@Override
public Cursor loadInBackground() {
    Cursor result = super.loadInBackground();
    if (!mEnableCapture || !MediaStoreCompat.hasCameraFeature(getContext())) {
        return result;
    }/*from   w  w w  .  ja v  a 2 s. co  m*/
    MatrixCursor dummy = new MatrixCursor(PROJECTION);
    dummy.addRow(new Object[] { Item.ITEM_ID_CAPTURE, Item.ITEM_DISPLAY_NAME_CAPTURE, "", 0, 0 });
    return new MergeCursor(new Cursor[] { dummy, result });
}

From source file:com.actionbarsherlock.sample.demos.SearchViews.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    //Used to put dark icons on light action bar
    boolean isLight = SampleList.THEME == R.style.Theme_Sherlock_Light;

    //Create the search view
    SearchView searchView = new SearchView(getSupportActionBar().getThemedContext());
    searchView.setQueryHint("Search for countries");
    searchView.setOnQueryTextListener(this);
    searchView.setOnSuggestionListener(this);

    if (mSuggestionsAdapter == null) {
        MatrixCursor cursor = new MatrixCursor(COLUMNS);
        cursor.addRow(new String[] { "1", "'Murica" });
        cursor.addRow(new String[] { "2", "Canada" });
        cursor.addRow(new String[] { "3", "Denmark" });
        mSuggestionsAdapter = new SuggestionsAdapter(getSupportActionBar().getThemedContext(), cursor);
    }/*  w  ww  . j  a va  2 s  . c  om*/

    searchView.setSuggestionsAdapter(mSuggestionsAdapter);

    menu.add("Search").setIcon(isLight ? R.drawable.ic_search_inverse : R.drawable.abs__ic_search)
            .setActionView(searchView)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

    return true;
}

From source file:com.sbox.absforpwdassi.demo.SearchViews.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    //Used to put dark icons on light action bar
    boolean isLight = SampleList.THEME == R.style.Theme_Sherlock_Light;

    //Create the search view
    SearchView searchView = new SearchView(getSupportActionBar().getThemedContext());
    searchView.setQueryHint("Search for countries");
    searchView.setOnQueryTextListener(this);
    searchView.setOnSuggestionListener(this);

    if (mSuggestionsAdapter == null) {
        MatrixCursor cursor = new MatrixCursor(COLUMNS);
        cursor.addRow(new String[] { "1", "'Murica" });
        cursor.addRow(new String[] { "2", "Canada" });
        cursor.addRow(new String[] { "3", "Denmark" });
        mSuggestionsAdapter = new SuggestionsAdapter(getSupportActionBar().getThemedContext(), cursor);
    }//from  w w  w.  jav a  2  s.c  om

    searchView.setSuggestionsAdapter(mSuggestionsAdapter);

    menu.add("Search").setIcon(isLight ? R.drawable.ic_search_inverse : R.drawable.abs__ic_search)
            .setActionView(searchView)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

    return true;
}

From source file:com.btmura.android.reddit.content.RelatedSubredditLoader.java

private MatrixCursor buildCursor(TreeSet<String> subreddits) {
    int i = 0;//from  ww  w .j  a v  a  2s.  c  o  m
    MatrixCursor cursor = new MatrixCursor(COLUMN_NAMES, subreddits.size());
    for (String subreddit : subreddits) {
        cursor.addRow(Array.of(i++, subreddit));
    }
    return cursor;
}

From source file:com.aniruddhc.acemusic.player.Dialogs.AddToPlaylistDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    mContext = getActivity().getApplicationContext();

    //Retrieve the arguments.
    ADD_TYPE = getArguments().getString("ADD_TYPE");

    if (ADD_TYPE.equals("ARTIST")) {
        ARTIST = getArguments().getString("ARTIST");
    } else if (ADD_TYPE.equals("ALBUM_ARTIST")) {
        ALBUM_ARTIST = getArguments().getString("ALBUM_ARTIST");
    } else if (ADD_TYPE.equals("ALBUM")) {
        ARTIST = getArguments().getString("ARTIST");
        ALBUM = getArguments().getString("ALBUM");
    } else if (ADD_TYPE.equals("SONG")) {
        ARTIST = getArguments().getString("ARTIST");
        ALBUM = getArguments().getString("ALBUM");
        SONG = getArguments().getString("SONG");
    } else if (ADD_TYPE.equals("GENRE")) {
        GENRE = getArguments().getString("GENRE");
    } else if (ADD_TYPE.equals("ALBUM_BY_ALBUM_ARTIST")) {
        ALBUM = getArguments().getString("ALBUM");
        ALBUM_ARTIST = getArguments().getString("ALBUM_ARTIST");
    }/*from   ww  w.  ja v a2 s.co  m*/

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    String columns[] = { DBAccessHelper.PLAYLIST_NAME, DBAccessHelper._ID, DBAccessHelper.PLAYLIST_FILE_PATH,
            DBAccessHelper.PLAYLIST_SOURCE, DBAccessHelper.PLAYLIST_ID };
    MatrixCursor matrixCursor = new MatrixCursor(columns);
    matrixCursor.addRow(
            new String[] { getActivity().getResources().getString(R.string.new_playlist), "0", "0", "0", "0" });

    DBAccessHelper playlistsDBHelper = new DBAccessHelper(getActivity().getApplicationContext());
    Cursor userPlaylistsCursor = playlistsDBHelper.getAllSongsInAlbum(null, null);
    final MergeCursor mergeCursor = new MergeCursor(new Cursor[] { matrixCursor, userPlaylistsCursor });

    //Set the dialog title.
    builder.setTitle(R.string.add_to_playlist);
    builder.setCursor(mergeCursor, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            //Index 0 is the dummy playlist that will open the "New Playlist" dialog.
            if (which == 0) {
                showNewPlaylistDialog();
            } else {
                mergeCursor.moveToPosition(which);
                String playlistName = mergeCursor
                        .getString(mergeCursor.getColumnIndex(DBAccessHelper.PLAYLIST_NAME));
                String playlistId = mergeCursor
                        .getString(mergeCursor.getColumnIndex(DBAccessHelper.PLAYLIST_ID));

                AsyncAddSongsToPlaylistTask task = new AsyncAddSongsToPlaylistTask(mContext, playlistName,
                        playlistId, ARTIST, ALBUM, SONG, GENRE, ALBUM_ARTIST, ADD_TYPE);
                task.execute();

            }

        }

    }, DBAccessHelper.PLAYLIST_NAME);

    return builder.create();
}

From source file:ro.expectations.expenses.widget.dialog.CategoryPickerDialogFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    MatrixCursor matrixCursor = new MatrixCursor(
            new String[] { ExpensesContract.Accounts._ID, ExpensesContract.Accounts.TITLE });
    matrixCursor.addRow(new Object[] { "0", getString(R.string.no_category) });
    MergeCursor mergeCursor = new MergeCursor(new Cursor[] { matrixCursor, data });

    mAdapter.swapCursor(mergeCursor);/*  w  w  w  .java2  s. c om*/
}

From source file:com.csipsimple.ui.favorites.FavLoader.java

/**
 * Creates a cursor that contains contacts group corresponding to an sip
 * account.//from   w ww  . j  a v  a2  s  .  co  m
 */
private Cursor createContentCursorFor(SipProfile account) {
    Cursor c = null;
    if (!TextUtils.isEmpty(account.android_group)) {
        c = ContactsWrapper.getInstance().getContactsByGroup(getContext(), account.android_group);
    }
    if (c != null) {
        return c;
    }
    MatrixCursor mc = new MatrixCursor(new String[] { BaseColumns._ID, ContactsWrapper.FIELD_TYPE });
    mc.addRow(new Object[] { account.id, ContactsWrapper.TYPE_CONFIGURE });
    return mc;
}

From source file:io.valuesfeng.picker.loader.AlbumLoader.java

@Override
public Cursor loadInBackground() {
    Cursor albums = super.loadInBackground();
    MatrixCursor allAlbum = new MatrixCursor(PROJECTION);

    long count = 0;
    if (albums.getCount() > 0) {
        while (albums.moveToNext()) {
            count += albums.getLong(3);/*from  w  w  w .  jav  a 2  s.  c o  m*/
        }
    }
    allAlbum.addRow(new String[] { Album.ALBUM_ID_ALL, Album.ALBUM_NAME_ALL, MEDIA_ID_DUMMY, count + "" });

    return new MergeCursor(new Cursor[] { allAlbum, albums });
}

From source file:ro.expectations.expenses.ui.overview.OverviewActivity.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    MatrixCursor matrixCursor = new MatrixCursor(
            new String[] { ExpensesContract.Accounts._ID, ExpensesContract.Accounts.TITLE });
    matrixCursor.addRow(new Object[] { "0", getString(R.string.all_accounts) });
    MergeCursor mergeCursor = new MergeCursor(new Cursor[] { matrixCursor, data });

    mSectionsPagerAdapter.swapCursor(mergeCursor);
    mTabLayout.setupWithViewPager(mViewPager);
}