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

This code example shows how to use the following methods:
 
    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 }));
    } 
 
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        if (id == GROUP_ID_ALL_CONTACTS) {
            mController.onAllContactsSelected();
        } else if (id == GROUP_ID_FAVORITES) {
            mController.onFavoritesSelected();
        } else { 
            Cursor cursor = (Cursor) mAdapter.getItem(position);
            mController.onGroupSelected(cursor.getString(GroupsListLoader.COLUMN_TITLE));
        } 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:getColumnIndex, moveToPosition, getString
    } 
 
    @Override 
    protected void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);
        mMergedCursor.moveToPosition(position);
        int titleIndex = mMergedCursor.getColumnIndex(Browser.BookmarkColumns.TITLE);
        int urlIndex = mMergedCursor.getColumnIndex(Browser.BookmarkColumns.URL);
        Intent data = new Intent();
        data.putExtra("TITLE", mMergedCursor.getString(titleIndex));
        data.putExtra("URL", mMergedCursor.getString(urlIndex));
        this.setResult(Activity.RESULT_OK, data);
        finish();
    } 
} 
6
CodeRank
This code example shows how to use the following methods:
	} 
 
	private static Cursor cursorWithHeader(Cursor cursor) {
		MatrixCursor header = new MatrixCursor(new String[]{"_id"}, 1);
		header.addRow(new Object[] { new Long(-1)});
		return new MergeCursor(new Cursor[] {header, cursor});
	} 
} 
5
CodeRank
This code example shows how to use the following methods:
		Log.d(TAG, "limit: " + limit);
		final String[] proj = new String[] { "_id",
				"address as " + SearchManager.SUGGEST_COLUMN_TEXT_1,
				"body as " + SearchManager.SUGGEST_COLUMN_TEXT_2 };
		final String where = "body like '%" + query + "%'";
		return new MergeCursor(new Cursor[] { this.getContext().getContentResolver()
				.query(SMS_URI, proj, where, null, null) });
	} 
 
	/** 
	 * {@inheritDoc} 
	 */ 
	@Override 
	public boolean onCreate() { 
		return true; 
	} 
 
	/** 
	 * {@inheritDoc} 
	 */ 
5
CodeRank
This code example shows how to use the following methods:
                                        "_id", Integer.toString(times*mStep));
            // isFinished = (newCursor.getCount() < times*mStep); 
             
            mCursors.add(newCursor);
         
            mCursor = new MergeCursor(mCursors.toArray(new Cursor[mCursors.size()]));
         
            partialCount = mCursor.getCount();
            mCursor.moveToPosition(oldPos);
            if (Log.isLoggable(TAG, Log.DEBUG)) Log.d(TAG,"Loaded HugeSQLiteCursor up to ["+(partialCount-1)+"].");
        } 
    } 
 
    /* (non-Javadoc) 
     * @see android.database.Cursor#isLast() 
     */ 
    @Override 
    public boolean isLast() { 
        int cnt = getCount();
        return ((getPosition() == (cnt - 1))) && (cnt != 0); //&& isFinished;
3
CodeRank
This code example shows how to use the following methods:
            } 
 
            if (!hasOldCalls) {
                // Return only the new calls. 
                MoreCloseables.closeQuietly(mOldCallsCursor);
                return new MergeCursor(
                        new Cursor[]{ createNewCallsHeaderCursor(), mNewCallsCursor });
            } 
 
            return new MergeCursor(new Cursor[]{
                    createNewCallsHeaderCursor(), mNewCallsCursor,
                    createOldCallsHeaderCursor(), mOldCallsCursor});
        } finally { 
            // Any cursor still open is now owned, directly or indirectly, by the caller. 
            mNewCallsCursor = null;
            mOldCallsCursor = null;
        } 
    } 
 
    /** 
3
CodeRank
This code example shows how to use the following methods:
            } 
 
            if (!hasOldCalls) {
                // Return only the new calls. 
                MoreCloseables.closeQuietly(mOldCallsCursor);
                return new MergeCursor(
                        new Cursor[]{ createNewCallsHeaderCursor(), mNewCallsCursor });
            } 
 
            return new MergeCursor(new Cursor[]{
                    createNewCallsHeaderCursor(), mNewCallsCursor,
                    createOldCallsHeaderCursor(), mOldCallsCursor});
        } finally { 
            // Any cursor still open is now owned, directly or indirectly, by the caller. 
            mNewCallsCursor = null;
            mOldCallsCursor = null;
        } 
    } 
 
    /** 
3
CodeRank
This code example shows how to use the following methods:
	         
	        selection = KEY_STATION_ID + " MATCH ?";
	         
	        Cursor curB = query(selection, selectionArgs, columns);
	         
	        MergeCursor mCur = new MergeCursor(new Cursor[] {curA, curB});
	        return mCur;
//	        CursorJoiner joiner = new CursorJoiner(curA, columns, curB, columns); 
//	       	return joiner; 
 
//	        return query(selection, selectionArgs, columns); 
 
	        /* This builds a query that looks like: 
	         *     SELECT <columns> FROM <table> WHERE <KEY_WORD> MATCH 'query*' 
	         * which is an FTS3 search for the query text (plus a wildcard) inside the word column. 
	         * 
	         * - "rowid" is the unique id for all rows but we need this value for the "_id" column in 
	         *    order for the Adapters to work, so the columns need to make "_id" an alias for "rowid" 
	         * - "rowid" also needs to be used by the SUGGEST_COLUMN_INTENT_DATA alias in order 
	         *   for suggestions to carry the proper intent data. 
3
CodeRank
This code example shows how to use the following methods:
				, projectionPhone //
				, wherePhone //
				, wherePhoneParameters //
				, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME //
				); 
		return new MergeCursor(new Cursor[] { emailCur, phoneCur });
	} 
 
	public static Contact getContactWithAdress(Cursor cur, ContentResolver contentResolver) {
		Contact contact = new Contact();
		String id = cur.getString(cur.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.CONTACT_ID));
		contact.setId(id);
		contact.setDisplayName(cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)));
		Adress adress = new Adress();
		adress.setFormattedAddress(cur.getString(cur.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.FORMATTED_ADDRESS)));
		contact.setAdress(adress);
		contact.setPhotoBitmap(getPhotoStream(id, contentResolver));
 
		return contact;
	} 
4
CodeRank
This code example shows how to use the following methods:
    public Cursor getAllMediaCursor()
    { 
        Cursor cursor1 = getImagesCursor();
        Cursor cursor2 = getVideosCursor();
         
        MergeCursor mergedCursor = new MergeCursor(new Cursor[] {cursor1, cursor2});
        return mergedCursor;
    } 
     
     
    public ArrayList<MediaVO> getMediaImageList()
    { 
        final ArrayList<MediaVO> resultList = new ArrayList<MediaVO>();
        boolean extStorgAvailable = FileUtils.isExtStorgAvailable();
 
        Uri imageURI = extStorgAvailable ? Images.Media.EXTERNAL_CONTENT_URI : Images.Media.INTERNAL_CONTENT_URI;
        addMedia(resultList, imageURI);
 
        return resultList;
 
4
CodeRank

Related Android MergeCursor Questions & Answers:

See Code Examples for Android MergeCursor Methods: