當前位置: 首頁>>代碼示例>>Java>>正文


Java MatrixCursor.RowBuilder方法代碼示例

本文整理匯總了Java中android.database.MatrixCursor.RowBuilder方法的典型用法代碼示例。如果您正苦於以下問題:Java MatrixCursor.RowBuilder方法的具體用法?Java MatrixCursor.RowBuilder怎麽用?Java MatrixCursor.RowBuilder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.database.MatrixCursor的用法示例。


在下文中一共展示了MatrixCursor.RowBuilder方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createMatrixCursor

import android.database.MatrixCursor; //導入方法依賴的package包/類
private MatrixCursor createMatrixCursor(Cursor cursor, int cursorOrigin) {
    MatrixCursor matrixCursor = new MatrixCursor(suggestionsColumnNames, cursor.getCount());
    MatrixCursor.RowBuilder builder;
    if (cursor.moveToFirst()) {
        do {
            builder = matrixCursor.newRow();
            if (cursorOrigin == RECENT_SEARCH_ORIGIN) {

                builder.add(FindQuickSearchAdapter.HISTORY_ROW);
                builder.add(cursor.getString(cursor.getColumnIndex(SearchManager.SUGGEST_COLUMN_QUERY)));

            } else {

                builder.add(FindQuickSearchAdapter.DATABASE_ROW);
                builder.add(cursor.getString(cursor.getColumnIndex(DbContract.FarmaciasEntity.NAME)));
            }
        } while (cursor.moveToNext());
    }
    cursor.close();
    return matrixCursor;
}
 
開發者ID:cahergil,項目名稱:Farmacias,代碼行數:22,代碼來源:DbProvider.java

示例2: transformListInToCursor

import android.database.MatrixCursor; //導入方法依賴的package包/類
public MatrixCursor transformListInToCursor(List<Pharmacy> pharmacyList) {
    if (pharmacyList == null) return null;
    String[] columnNames = {DbContract.FarmaciasEntity._ID,
            DbContract.FarmaciasEntity.NAME,
            DbContract.FarmaciasEntity.ADDRESS,
            DbContract.FarmaciasEntity.LOCALITY,
            DbContract.FarmaciasEntity.PROVINCE
    };
    MatrixCursor cursor = new MatrixCursor(columnNames, pharmacyList.size());
    MatrixCursor.RowBuilder builder;
    for (Pharmacy ph : pharmacyList) {
        builder = cursor.newRow();
        builder.add(ph.get_id());
        builder.add(ph.getName());
        builder.add(ph.getAddress());
        builder.add(ph.getLocality());
        builder.add(ph.getProvince());
    }
    return cursor;
}
 
開發者ID:cahergil,項目名稱:Farmacias,代碼行數:21,代碼來源:FindFragment.java

示例3: mergeDates

import android.database.MatrixCursor; //導入方法依賴的package包/類
private MergeCursor mergeDates(long nextId, Map<Long, MatrixCursor> agenda) {
    List<Cursor> allCursors = new ArrayList<>();

    for (long dateMilli: agenda.keySet()) {
        DateTime date = new DateTime(dateMilli);
        MatrixCursor dateCursor = new MatrixCursor(Columns.AGENDA_SEPARATOR_COLS);
        MatrixCursor.RowBuilder dateRow = dateCursor.newRow();
        dateRow.add(nextId++);
        dateRow.add(userTimeFormatter.formatDate(AgendaUtils.buildOrgDateTimeFromDate(date, null)));
        dateRow.add(1); // Separator
        allCursors.add(dateCursor);
        allCursors.add(agenda.get(dateMilli));
    }

    return new MergeCursor(allCursors.toArray(new Cursor[allCursors.size()]));
}
 
開發者ID:orgzly,項目名稱:orgzly-android,代碼行數:17,代碼來源:AgendaFragment.java

示例4: queryRoots

import android.database.MatrixCursor; //導入方法依賴的package包/類
@Override
public Cursor queryRoots(final String[] projection) throws FileNotFoundException {
    // Create a cursor with either the requested fields, or the default
    // projection if "projection" is null.
    final MatrixCursor result = new MatrixCursor(projection != null ? projection
            : DEFAULT_ROOT_PROJECTION);
    // Add Home directory
    File homeDir = Environment.getExternalStorageDirectory();
    final MatrixCursor.RowBuilder row = result.newRow();
    // These columns are required
    row.add(Root.COLUMN_ROOT_ID, homeDir.getAbsolutePath());
    row.add(Root.COLUMN_DOCUMENT_ID, homeDir.getAbsolutePath());
    row.add(Root.COLUMN_TITLE, getContext().getString(R.string.internal_storage));
    row.add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY | Root.FLAG_SUPPORTS_CREATE);
    row.add(Root.COLUMN_ICON, R.drawable.ic_provider);
    // These columns are optional
    row.add(Root.COLUMN_AVAILABLE_BYTES, homeDir.getFreeSpace());
    // Root.COLUMN_MIME_TYPE is another optional column and useful if you
    // have multiple roots with different
    // types of mime types (roots that don't match the requested mime type
    // are automatically hidden)
    return result;
}
 
開發者ID:Datatellit,項目名稱:xlight_android_native,代碼行數:24,代碼來源:LocalStorageProvider.java

示例5: includeFile

import android.database.MatrixCursor; //導入方法依賴的package包/類
private void includeFile(final MatrixCursor result, final File file)
        throws FileNotFoundException {
    final MatrixCursor.RowBuilder row = result.newRow();
    // These columns are required
    row.add(Document.COLUMN_DOCUMENT_ID, file.getAbsolutePath());
    row.add(Document.COLUMN_DISPLAY_NAME, file.getName());
    String mimeType = getDocumentType(file.getAbsolutePath());
    row.add(Document.COLUMN_MIME_TYPE, mimeType);
    int flags = file.canWrite() ? Document.FLAG_SUPPORTS_DELETE | Document.FLAG_SUPPORTS_WRITE
            : 0;
    // We only show thumbnails for image files - expect a call to
    // openDocumentThumbnail for each file that has
    // this flag set
    if (mimeType.startsWith("image/"))
        flags |= Document.FLAG_SUPPORTS_THUMBNAIL;
    row.add(Document.COLUMN_FLAGS, flags);
    // COLUMN_SIZE is required, but can be null
    row.add(Document.COLUMN_SIZE, file.length());
    // These columns are optional
    row.add(Document.COLUMN_LAST_MODIFIED, file.lastModified());
    // Document.COLUMN_ICON can be a resource id identifying a custom icon.
    // The system provides default icons
    // based on mime type
    // Document.COLUMN_SUMMARY is optional additional information about the
    // file
}
 
開發者ID:Datatellit,項目名稱:xlight_android_native,代碼行數:27,代碼來源:LocalStorageProvider.java

示例6: queryRoots

import android.database.MatrixCursor; //導入方法依賴的package包/類
@Override
public Cursor queryRoots(final String[] projection) throws FileNotFoundException {
    // Create a cursor with either the requested fields, or the default
    // projection if "projection" is null.
    final MatrixCursor result = new MatrixCursor(projection != null ? projection
            : DEFAULT_ROOT_PROJECTION);
    // Add Home directory
    File homeDir = Environment.getExternalStorageDirectory();
    final MatrixCursor.RowBuilder row = result.newRow();
    // These columns are required
    row.add(Root.COLUMN_ROOT_ID, homeDir.getAbsolutePath());
    row.add(Root.COLUMN_DOCUMENT_ID, homeDir.getAbsolutePath());
    row.add(Root.COLUMN_TITLE, "internal storage");
    row.add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY | Root.FLAG_SUPPORTS_CREATE);
    //row.add(Root.COLUMN_ICON, R.drawable.ic_provider);
    // These columns are optional
    row.add(Root.COLUMN_AVAILABLE_BYTES, homeDir.getFreeSpace());
    // Root.COLUMN_MIME_TYPE is another optional column and useful if you
    // have multiple roots with different
    // types of mime types (roots that don't match the requested mime type
    // are automatically hidden)
    return result;
}
 
開發者ID:AppLozic,項目名稱:Applozic-Android-Chat-Sample,代碼行數:24,代碼來源:LocalStorageProvider.java

示例7: includeFile

import android.database.MatrixCursor; //導入方法依賴的package包/類
private void includeFile(final MatrixCursor result, final File file) throws FileNotFoundException {
    final MatrixCursor.RowBuilder row = result.newRow();
    // These columns are required
    row.add(Document.COLUMN_DOCUMENT_ID, file.getAbsolutePath());
    row.add(Document.COLUMN_DISPLAY_NAME, file.getName());
    String mimeType = getDocumentType(file.getAbsolutePath());
    row.add(Document.COLUMN_MIME_TYPE, mimeType);
    int flags = file.canWrite() ? Document.FLAG_SUPPORTS_DELETE | Document.FLAG_SUPPORTS_WRITE : 0;
    // We only show thumbnails for image files - expect a call to
    // openDocumentThumbnail for each file that has
    // this flag set
    if (mimeType.startsWith("image/"))
        flags |= Document.FLAG_SUPPORTS_THUMBNAIL;
    row.add(Document.COLUMN_FLAGS, flags);
    // COLUMN_SIZE is required, but can be null
    row.add(Document.COLUMN_SIZE, file.length());
    // These columns are optional
    row.add(Document.COLUMN_LAST_MODIFIED, file.lastModified());
    // Document.COLUMN_ICON can be a resource id identifying a custom icon.
    // The system provides default icons
    // based on mime type
    // Document.COLUMN_SUMMARY is optional additional information about the
    // file
}
 
開發者ID:goodev,項目名稱:droidddle,代碼行數:25,代碼來源:LocalStorageProvider.java

示例8: queryFile

import android.database.MatrixCursor; //導入方法依賴的package包/類
public MatrixCursor.RowBuilder queryFile(AbstractTransport transport,
                                         MatrixCursor result, String id) {

    FEchoFile file_entry = transport.getFileMeta(id);
    String filename = file_entry.filename;

    if (!filename.contains(".") || !file_entry.existsLocally()) return null;
    else {
        MatrixCursor.RowBuilder row = result.newRow();

        int dotindex = filename.lastIndexOf(".") + 1;
        String extension = filename.substring(dotindex).toLowerCase();
        String mimetype = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);

        row.add(DocumentsContract.Document.COLUMN_DOCUMENT_ID, "idecfile://" + id);
        row.add(DocumentsContract.Document.COLUMN_DISPLAY_NAME, filename);
        row.add(DocumentsContract.Document.COLUMN_FLAGS, null);
        row.add(DocumentsContract.Document.COLUMN_MIME_TYPE, mimetype);
        row.add(DocumentsContract.Document.COLUMN_SIZE, file_entry.serverSize);
        row.add(DocumentsContract.Document.COLUMN_LAST_MODIFIED, null);

    }
    return null;
}
 
開發者ID:vit1-irk,項目名稱:idec-mobile,代碼行數:25,代碼來源:FechoFilesProvider.java

示例9: includeFile

import android.database.MatrixCursor; //導入方法依賴的package包/類
private void includeFile(final MatrixCursor result, final File file) throws FileNotFoundException {
  final MatrixCursor.RowBuilder row = result.newRow();
  // These columns are required
  row.add(Document.COLUMN_DOCUMENT_ID, file.getAbsolutePath());
  row.add(Document.COLUMN_DISPLAY_NAME, file.getName());
  String mimeType = getDocumentType(file.getAbsolutePath());
  row.add(Document.COLUMN_MIME_TYPE, mimeType);
  int flags = file.canWrite()
          ? Document.FLAG_SUPPORTS_DELETE | Document.FLAG_SUPPORTS_WRITE | Document.FLAG_SUPPORTS_RENAME
          | (mimeType.equals(Document.MIME_TYPE_DIR) ? Document.FLAG_DIR_SUPPORTS_CREATE : 0) : 0;
  // We only show thumbnails for image files - expect a call to openDocumentThumbnail for each file that has
  // this flag set
  if (mimeType.startsWith("image/"))
    flags |= Document.FLAG_SUPPORTS_THUMBNAIL;
  row.add(Document.COLUMN_FLAGS, flags);
  // COLUMN_SIZE is required, but can be null
  row.add(Document.COLUMN_SIZE, file.length());
  // These columns are optional
  row.add(Document.COLUMN_LAST_MODIFIED, file.lastModified());
  // Document.COLUMN_ICON can be a resource id identifying a custom icon. The system provides default icons
  // based on mime type
  // Document.COLUMN_SUMMARY is optional additional information about the file
}
 
開發者ID:Nik-Sch,項目名稱:ChatApp-Android,代碼行數:24,代碼來源:LocalStorageProvider.java

示例10: queryRoots

import android.database.MatrixCursor; //導入方法依賴的package包/類
@Override
public Cursor queryRoots(final String[] projection) throws FileNotFoundException {
    // Create a cursor with either the requested fields, or the default
    // projection if "projection" is null.
    final MatrixCursor result = new MatrixCursor(projection != null ? projection
            : DEFAULT_ROOT_PROJECTION);
    // Add Home directory
    File homeDir = Environment.getExternalStorageDirectory();
    final MatrixCursor.RowBuilder row = result.newRow();
    // These columns are required
    row.add(Root.COLUMN_ROOT_ID, homeDir.getAbsolutePath());
    row.add(Root.COLUMN_DOCUMENT_ID, homeDir.getAbsolutePath());
    row.add(Root.COLUMN_TITLE, "Internal storage");
    row.add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY | Root.FLAG_SUPPORTS_CREATE);
    row.add(Root.COLUMN_ICON, R.drawable.ic_provider);
    // These columns are optional
    row.add(Root.COLUMN_AVAILABLE_BYTES, homeDir.getFreeSpace());
    // Root.COLUMN_MIME_TYPE is another optional column and useful if you
    // have multiple roots with different
    // types of mime types (roots that don't match the requested mime type
    // are automatically hidden)
    return result;
}
 
開發者ID:IamAlchemist,項目名稱:AlchemistAndroidUtil,代碼行數:24,代碼來源:LocalStorageProvider.java

示例11: queryRoots

import android.database.MatrixCursor; //導入方法依賴的package包/類
@Override
public Cursor queryRoots(final String[] projection) throws FileNotFoundException {
    // Create a cursor with either the requested fields, or the default
    // projection if "projection" is null.
    final MatrixCursor result = new MatrixCursor(projection != null ? projection : DEFAULT_ROOT_PROJECTION);
    // Add Home directory
    File homeDir = Environment.getExternalStorageDirectory();
    final MatrixCursor.RowBuilder row = result.newRow();
    // These columns are required
    row.add(Root.COLUMN_ROOT_ID, homeDir.getAbsolutePath());
    row.add(Root.COLUMN_DOCUMENT_ID, homeDir.getAbsolutePath());
    row.add(Root.COLUMN_TITLE, getContext().getString(R.string.internal_storage));
    row.add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY | Root.FLAG_SUPPORTS_CREATE);
    row.add(Root.COLUMN_ICON, R.drawable.ic_shot_project);
    // These columns are optional
    row.add(Root.COLUMN_AVAILABLE_BYTES, homeDir.getFreeSpace());
    // Root.COLUMN_MIME_TYPE is another optional column and useful if you
    // have multiple roots with different
    // types of mime types (roots that don't match the requested mime type
    // are automatically hidden)
    return result;
}
 
開發者ID:goodev,項目名稱:droidddle,代碼行數:23,代碼來源:LocalStorageProvider.java

示例12: includeFile

import android.database.MatrixCursor; //導入方法依賴的package包/類
/**
 * Add a representation of a file to a cursor.
 *
 * @param result the cursor to modify
 * @param file   the File object representing the desired file (may be null if given docID)
 */
private void includeFile(MatrixCursor result, File file) {
    MatrixCursor.RowBuilder row = result.newRow();
    row.add(ImageContract.Columns.DISPLAY_NAME, file.getName());
    row.add(ImageContract.Columns.SIZE, file.length());
    row.add(ImageContract.Columns.ABSOLUTE_PATH, file.getAbsolutePath());
}
 
開發者ID:googlesamples,項目名稱:android-ContentProviderPaging,代碼行數:13,代碼來源:ImageProvider.java

示例13: query

import android.database.MatrixCursor; //導入方法依賴的package包/類
@Override
public Cursor query(final Uri uri, final String[] projection, final String selection,
                    final String[] selectionArgs, final String sortOrder) {
    final Cursor source = super.query(uri, projection, selection, selectionArgs, sortOrder);

    /*
        It's not necessary to overwrite
            public Cursor query(final Uri uri, final String[] projection, final String selection, final String[]
                selectionArgs, final String sortOrder, final CancellationSignal cancellationSignal);
        cause it calls this method.

        == What's happening here? ==
        Some apps rely on the MediaStore.MediaColumns.DATA column in the cursor. To prevent them
        from crashing, we have to copy the initial cursor and add the MediaStore.MediaColumns.DATA
        column. The values of this column will always be null, but we assume that they are able
        to handle that case.
    */

    if(source == null) {
        Log.w(Belvedere.LOG_TAG, "Not able to apply workaround, super.query(...) returned null");
        return null;
    }

    String[] columnNames = source.getColumnNames();
    String[] newColumnNames = columnNamesWithData(columnNames);

    final MatrixCursor cursor = new MatrixCursor(newColumnNames, source.getCount());

    source.moveToPosition(-1);
    while (source.moveToNext()) {
        MatrixCursor.RowBuilder row = cursor.newRow();
        for (int i = 0; i < columnNames.length; i++) {
            row.add(source.getString(i));
        }
    }
    source.close();

    return cursor;
}
 
開發者ID:zendesk,項目名稱:belvedere,代碼行數:40,代碼來源:BelvedereFileProvider.java

示例14: queryDocument

import android.database.MatrixCursor; //導入方法依賴的package包/類
@Override
public Cursor queryDocument(String documentId, String[] projection) throws
        FileNotFoundException {
    // Create a cursor with the requested projection, or the default projection.
    final MatrixCursor result = new
            MatrixCursor(resolveDocumentProjection(projection));
    MatrixCursor.RowBuilder row = result.newRow();
    row.add(Document.COLUMN_DOCUMENT_ID, documentId);

    if (TextUtils.equals(documentId, ROOT_DIRECTORY_ID)) {
        row.add(Document.COLUMN_DISPLAY_NAME,
                getContext().getResources().getString(R.string.app_name));
        row.add(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR);
        row.add(Document.COLUMN_LAST_MODIFIED, null); // Not sure
        row.add(Document.COLUMN_SIZE, null);
    } else if (!documentId.contains("/")) {
        // It is an experiment directory
        // TODO: Use notifyChange to load data off-thread and update only when it is available.
        List<GoosciUserMetadata.ExperimentOverview> overviews =
                AppSingleton.getInstance(getContext()).getDataController()
                        .blockingGetExperimentOverviews(true);
        for (GoosciUserMetadata.ExperimentOverview overview : overviews) {
            if (TextUtils.equals(overview.experimentId, documentId)) {
                addExperimentToRow(row, overview);
                break;
            }
        }

    } else {
        // It is a file
        File file = new File(FileMetadataManager.getExperimentsRootDirectory(getContext()) +
                "/" + documentId);
        addAssetToRow(row, file);
    }
    return result;
}
 
開發者ID:google,項目名稱:science-journal,代碼行數:37,代碼來源:ScienceJournalDocsProvider.java

示例15: addExperimentToRow

import android.database.MatrixCursor; //導入方法依賴的package包/類
private void addExperimentToRow(MatrixCursor.RowBuilder row,
        GoosciUserMetadata.ExperimentOverview overview) {
    row.add(Document.COLUMN_DISPLAY_NAME, Experiment.getDisplayTitle(getContext(),
            overview.title));
    row.add(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR);
    row.add(Document.COLUMN_LAST_MODIFIED, overview.lastUsedTimeMs);
    row.add(Document.COLUMN_SIZE, null);
}
 
開發者ID:google,項目名稱:science-journal,代碼行數:9,代碼來源:ScienceJournalDocsProvider.java


注:本文中的android.database.MatrixCursor.RowBuilder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。