当前位置: 首页>>代码示例>>Java>>正文


Java MatrixCursor.addRow方法代码示例

本文整理汇总了Java中android.database.MatrixCursor.addRow方法的典型用法代码示例。如果您正苦于以下问题:Java MatrixCursor.addRow方法的具体用法?Java MatrixCursor.addRow怎么用?Java MatrixCursor.addRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.database.MatrixCursor的用法示例。


在下文中一共展示了MatrixCursor.addRow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateCursorForDownloadedFile

import android.database.MatrixCursor; //导入方法依赖的package包/类
private void updateCursorForDownloadedFile(Context context, Uri uri) {
    synchronized (this) {
        closeCursor();
        MatrixCursor cursor = new MatrixCursor(PROJECTION_MATRIX);
        String title = getValueForDownloadedFile(this, uri, "title");
        cursor.addRow(new Object[]{
                null,
                null,
                null,
                title,
                null,
                null,
                null,
                null
        });
        mCursor = cursor;
        mCursor.moveToFirst();
    }
}
 
开发者ID:Vinetos,项目名称:Hello-Music-droid,代码行数:20,代码来源:MusicService.java

示例2: buildAdapterCursor

import android.database.MatrixCursor; //导入方法依赖的package包/类
private MatrixCursor buildAdapterCursor(Cursor cursor) {
    // Create a clone of the provided cursor but keep only the needed columns
    MatrixCursor newCursor = new MatrixCursor(SCRAPER_ADAPTER_COLS);

    if (mFileCount > 0) {
        int columns = newCursor.getColumnCount();
        cursor.moveToFirst();
        do {
            // Build an array with the data corresponding to the current row
            ArrayList<String> rowData = new ArrayList<String>(columns);
            rowData.add(cursor.getString(mIdIndex));
            rowData.add(cursor.getString(mDataIndex));
            rowData.add(cursor.getString(mTitleIndex));

            // Add the row to the cloned cursor
            newCursor.addRow(rowData);
        } while (cursor.moveToNext());
    }

    return newCursor;
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:22,代码来源:AutoScraperActivity.java

示例3: loadInBackground

import android.database.MatrixCursor; //导入方法依赖的package包/类
@Override
public Cursor loadInBackground() {
    Cursor albums = super.loadInBackground();
    MatrixCursor allAlbum = new MatrixCursor(COLUMNS);
    int totalCount = 0;
    String allAlbumCoverPath = "";
    if (albums != null) {
        while (albums.moveToNext()) {
            totalCount += albums.getInt(albums.getColumnIndex(COLUMN_COUNT));
        }
        if (albums.moveToFirst()) {
            allAlbumCoverPath = albums.getString(albums.getColumnIndex(MediaStore.MediaColumns.DATA));
        }
    }
    allAlbum.addRow(new String[]{Album.ALBUM_ID_ALL, Album.ALBUM_ID_ALL, Album.ALBUM_NAME_ALL, allAlbumCoverPath,
            String.valueOf(totalCount)});

    return new MergeCursor(new Cursor[]{allAlbum, albums});
}
 
开发者ID:zhihu,项目名称:Matisse,代码行数:20,代码来源:AlbumLoader.java

示例4: getUnarchivedConversationList

import android.database.MatrixCursor; //导入方法依赖的package包/类
private Cursor getUnarchivedConversationList() {
  List<Cursor> cursorList = new LinkedList<>();
  cursorList.add(DatabaseFactory.getThreadDatabase(context).getConversationList());

  int archivedCount = DatabaseFactory.getThreadDatabase(context)
                                     .getArchivedConversationListCount();

  if (archivedCount > 0) {
    MatrixCursor switchToArchiveCursor = new MatrixCursor(new String[] {
        ThreadDatabase.ID, ThreadDatabase.DATE, ThreadDatabase.MESSAGE_COUNT,
        ThreadDatabase.RECIPIENT_IDS, ThreadDatabase.SNIPPET, ThreadDatabase.READ,
        ThreadDatabase.TYPE, ThreadDatabase.SNIPPET_TYPE, ThreadDatabase.SNIPPET_URI,
        ThreadDatabase.ARCHIVED, ThreadDatabase.STATUS, ThreadDatabase.RECEIPT_COUNT,
        ThreadDatabase.EXPIRES_IN, ThreadDatabase.LAST_SEEN}, 1);

    switchToArchiveCursor.addRow(new Object[] {-1L, System.currentTimeMillis(), archivedCount,
                                               "-1", null, 1, ThreadDatabase.DistributionTypes.ARCHIVE,
                                               0, null, 0, -1, 0, 0, 0});
    
    cursorList.add(switchToArchiveCursor);
  }

  return new MergeCursor(cursorList.toArray(new Cursor[0]));
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:25,代码来源:ConversationListLoader.java

示例5: queryNextItemInPlaylist

import android.database.MatrixCursor; //导入方法依赖的package包/类
private Cursor queryNextItemInPlaylist(String videoId) {
    ProviderPlaylistItem nextItem = getNextItemInPlaylist(videoId);
    MatrixCursor cursor = new MatrixCursor(new String[] {
            COL_VIDEO_ID,
            COL_VIDEO_TITLE,
            COL_VIDEO_URL,
            COL_STREAM_TYPE
    });
    
    if (nextItem != null) {
        cursor.addRow(new String[] {
                nextItem.getVideoId(),
                nextItem.getTitle(),
                nextItem.getUrl(),
                Integer.toString(nextItem.getStreamType())
        });
        return cursor;
    }
    
    return null;
}
 
开发者ID:OvomediaTV,项目名称:TVPlatformContentProvider,代码行数:22,代码来源:AbsPlaylistProvider.java

示例6: test_findGateways

import android.database.MatrixCursor; //导入方法依赖的package包/类
@Test
public void test_findGateways() {
    MatrixCursor cursor = new MatrixCursor(new String[] {
            "_id", "name", "ip_address", "port_number", "system_type_id"
    });

    cursor.addRow(new String[] {"1", "gateway 1", "192.168.1.100", "11000", "1"});
    cursor.addRow(new String[] {"2", "gateway 2", "192.168.1.150", "11000", "1"});
    cursor.addRow(new String[] {"3", "gateway 3", "192.168.1.200", "11000", "1"});

    when(database.rawQuery(anyString(), any(String[].class))).thenReturn(cursor);
    List<Gateway> gateways = source.findGateways();

    assertEquals(3, gateways.size());
    assertEquals("gateway 1", gateways.get(0).getName());
    assertEquals("gateway 2", gateways.get(1).getName());
    assertEquals("gateway 3", gateways.get(2).getName());
}
 
开发者ID:sourceallies,项目名称:zonebeacon,代码行数:19,代码来源:DataSourceTest.java

示例7: test_findCommands

import android.database.MatrixCursor; //导入方法依赖的package包/类
@Test
public void test_findCommands() {
    MatrixCursor cursor = new MatrixCursor(new String[] {
            "_id", "name", "gateway_id", "number", "command_type_id", "controller_number"
    });

    cursor.addRow(new String[] {"1", "command 1", "1", "1", "1", "1"});
    cursor.addRow(new String[] {"2", "command 2", "1", "1", "1", "1"});
    cursor.addRow(new String[] {"3", "command 3", "1", "1", "1", "1"});

    when(database.rawQuery(anyString(), any(String[].class))).thenReturn(cursor);

    Gateway gateway = new Gateway();
    gateway.setId(1);
    List<Command> commands = source.findCommands(gateway);

    assertEquals(3, commands.size());
    assertEquals("command 1", commands.get(0).getName());
    assertEquals("command 2", commands.get(1).getName());
    assertEquals("command 3", commands.get(2).getName());
}
 
开发者ID:sourceallies,项目名称:zonebeacon,代码行数:22,代码来源:DataSourceTest.java

示例8: createMergedSearchCursor

import android.database.MatrixCursor; //导入方法依赖的package包/类
/**
 * Create a {@link MatrixCursor} given the tags and search cursors.
 * @param tags Cursor with the projection {@link SearchTopicsSessions#TOPIC_TAG_PROJECTION}.
 * @param search Cursor with the projection
 *              {@link SearchTopicsSessions#SEARCH_SESSIONS_PROJECTION}.
 * @return Returns a MatrixCursor always with {@link SearchTopicsSessions#DEFAULT_PROJECTION}
 */
private Cursor createMergedSearchCursor(Cursor tags, Cursor search) {
    // How big should our MatrixCursor be?
    int maxCount = (tags == null ? 0 : tags.getCount()) +
            (search == null ? 0 : search.getCount());

    MatrixCursor matrixCursor = new MatrixCursor(
            SearchTopicsSessions.DEFAULT_PROJECTION, maxCount);

    // Iterate over the tags cursor and add rows.
    if (tags != null && tags.moveToFirst()) {
        do {
            matrixCursor.addRow(
                    new Object[]{
                            tags.getLong(0),
                            tags.getString(1), /*tag_id*/
                            "{" + tags.getString(2) + "}", /*search_snippet*/
                            1}); /*is_topic_tag*/
        } while (tags.moveToNext());
    }
    // Iterate over the search cursor and add rows.
    if (search != null && search.moveToFirst()) {
        do {
            matrixCursor.addRow(
                    new Object[]{
                            search.getLong(0),
                            search.getString(1),
                            search.getString(2), /*search_snippet*/
                            0}); /*is_topic_tag*/
        } while (search.moveToNext());
    }
    return matrixCursor;
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:40,代码来源:ScheduleProvider.java

示例9: getAccountUnread

import android.database.MatrixCursor; //导入方法依赖的package包/类
private Cursor getAccountUnread(int accountNumber) {

            MatrixCursor cursor = new MatrixCursor(UNREAD_PROJECTION);

            Account myAccount;
            AccountStats myAccountStats;

            Object[] values = new Object[2];

            for (Account account : Preferences.getPreferences(getContext()).getAvailableAccounts()) {
                if (account.getAccountNumber() == accountNumber) {
                    myAccount = account;
                    try {
                        myAccountStats = account.getStats(getContext());
                        values[0] = myAccount.getDescription();
                        if (myAccountStats == null) {
                            values[1] = 0;
                        } else {
                            values[1] = myAccountStats.unreadMessageCount;
                        }
                    } catch (MessagingException e) {
                        Timber.e(e.getMessage());
                        values[0] = "Unknown";
                        values[1] = 0;
                    }
                    cursor.addRow(values);
                }
            }

            return cursor;
        }
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:32,代码来源:MessageProvider.java

示例10: query

import android.database.MatrixCursor; //导入方法依赖的package包/类
@Override
public synchronized Cursor query(Uri uri, String[] projection, String selection,
        String[] selectionArgs, String sortOrder) {
    assert(uri.getPathSegments().isEmpty());

    // In this sample, we only query without any parameters, so we can just return a cursor to
    // all the weather data.
    final MatrixCursor c = new MatrixCursor(
            new String[]{ Columns.ID, Columns.DAY, Columns.TEMPERATURE });
    for (int i = 0; i < sData.size(); ++i) {
        final WeatherDataPoint data = sData.get(i);
        c.addRow(new Object[]{ new Integer(i), data.day, new Integer(data.degrees) });
    }
    return c;
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:16,代码来源:WeatherDataProvider.java

示例11: setupCryptoProviderStatus

import android.database.MatrixCursor; //导入方法依赖的package包/类
private void setupCryptoProviderStatus(Address address, String uidStatus, String autocryptStatus) {
    MatrixCursor cursorCryptoStatus = new MatrixCursor(PROJECTION_CRYPTO_STATUS);
    cursorCryptoStatus.addRow(new String[] { address.getAddress(), uidStatus, autocryptStatus });

    when(contentResolver
            .query(eq(Uri.parse("content://" + CRYPTO_PROVIDER + ".provider.exported/autocrypt_status")),
                    aryEq(PROJECTION_CRYPTO_STATUS), any(String.class),
                    aryEq(new String[] { address.getAddress() }),
                    any(String.class))).thenReturn(cursorCryptoStatus);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:11,代码来源:RecipientLoaderTest.java

示例12: query

import android.database.MatrixCursor; //导入方法依赖的package包/类
@Override public Cursor query(Uri uri, String[] projection, String selection,
    String[] selectionArgs, String sortOrder) {
  MatrixCursor result = new MatrixCursor(new String[] { KEY, VALUE });
  for (Map.Entry<String, String> entry : storage.entrySet()) {
    result.addRow(new Object[] { entry.getKey(), entry.getValue() });
  }
  return result;
}
 
开发者ID:jiechic,项目名称:sqlbrite-sqlcipher,代码行数:9,代码来源:BriteContentResolverTest.java

示例13: filterNonPushContacts

import android.database.MatrixCursor; //导入方法依赖的package包/类
private @NonNull Cursor filterNonPushContacts(@NonNull Cursor cursor) {
  try {
    final long startMillis = System.currentTimeMillis();
    final MatrixCursor matrix = new MatrixCursor(new String[]{ContactsDatabase.ID_COLUMN,
                                                              ContactsDatabase.NAME_COLUMN,
                                                              ContactsDatabase.NUMBER_COLUMN,
                                                              ContactsDatabase.NUMBER_TYPE_COLUMN,
                                                              ContactsDatabase.LABEL_COLUMN,
                                                              ContactsDatabase.CONTACT_TYPE_COLUMN});
    while (cursor.moveToNext()) {
      final String number = cursor.getString(cursor.getColumnIndexOrThrow(ContactsDatabase.NUMBER_COLUMN));
      final Recipients recipients = RecipientFactory.getRecipientsFromString(getContext(), number, true);

      if (DirectoryHelper.getUserCapabilities(getContext(), recipients)
                         .getTextCapability() != Capability.SUPPORTED)
      {
        matrix.addRow(new Object[]{cursor.getLong(cursor.getColumnIndexOrThrow(ContactsDatabase.ID_COLUMN)),
                                   cursor.getString(cursor.getColumnIndexOrThrow(ContactsDatabase.NAME_COLUMN)),
                                   number,
                                   cursor.getString(cursor.getColumnIndexOrThrow(ContactsDatabase.NUMBER_TYPE_COLUMN)),
                                   cursor.getString(cursor.getColumnIndexOrThrow(ContactsDatabase.LABEL_COLUMN)),
                                   ContactsDatabase.NORMAL_TYPE});
      }
    }
    Log.w(TAG, "filterNonPushContacts() -> " + (System.currentTimeMillis() - startMillis) + "ms");
    return matrix;
  } finally {
    cursor.close();
  }
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:31,代码来源:ContactsCursorLoader.java

示例14: query

import android.database.MatrixCursor; //导入方法依赖的package包/类
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String order) {
	MatrixCursor resCursor = new MatrixCursor(new String[] { SipConfigManager.FIELD_NAME, SipConfigManager.FIELD_VALUE });
	if (URI_MATCHER.match(uri) == PREF_ID) {
		String name = uri.getLastPathSegment();
		Class<?> aClass = null;
		if (TextUtils.isEmpty(selection)) {
			aClass = PreferencesWrapper.gPrefClass(name);
		} else {
			try {
				aClass = Class.forName(selection);
			} catch (ClassNotFoundException e) {
				Log.e(THIS_FILE, "Impossible to retrieve class from selection");
			}
		}
		Object value = null;
		if (aClass == String.class) {
			value = prefs.getPreferenceStringValue(name);
		} else if (aClass == Float.class) {
			value = prefs.getPreferenceFloatValue(name);
		} else if (aClass == Boolean.class) {
		    Boolean v = prefs.getPreferenceBooleanValue(name);
		    if(v != null) {
		        value = v ? 1 : 0;
		    }else {
		        value = -1;
		    }
		} else if(aClass == Integer.class) {
		    value = prefs.getPreferenceIntegerValue(name);
		}
		
		if (value != null) {
			resCursor.addRow(new Object[] { name, value });
		} else {
			resCursor = null;
		}
	}
	return resCursor;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:40,代码来源:PreferenceProvider.java

示例15: query

import android.database.MatrixCursor; //导入方法依赖的package包/类
@Override
public Cursor query(@NonNull Uri url, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
  Log.w(TAG, "query() called: " + url);
  MasterSecret masterSecret = KeyCachingService.getMasterSecret(getContext());

  if (projection == null || projection.length <= 0) return null;

  switch (uriMatcher.match(url)) {
    case SINGLE_ROW:
      PartUriParser      partUri      = new PartUriParser(url);
      DatabaseAttachment attachment   = DatabaseFactory.getAttachmentDatabase(getContext()).getAttachment(masterSecret, partUri.getPartId());

      if (attachment == null) return null;

      MatrixCursor       matrixCursor = new MatrixCursor(projection, 1);
      Object[]           resultRow    = new Object[projection.length];

      for (int i=0;i<projection.length;i++) {
        if (OpenableColumns.DISPLAY_NAME.equals(projection[i])) {
          resultRow[i] = attachment.getFileName();
        }
      }

      matrixCursor.addRow(resultRow);
      return matrixCursor;
  }

  return null;
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:30,代码来源:PartProvider.java


注:本文中的android.database.MatrixCursor.addRow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。