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


Java SparseArray.clear方法代码示例

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


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

示例1: clear

import android.util.SparseArray; //导入方法依赖的package包/类
void clear() {
    final SparseArray<View> scrapHeap = mScrapHeap;
    final int count = scrapHeap.size();
    for (int i = 0; i < count; i++) {
        final View view = scrapHeap.valueAt(i);
        if (view != null) {
            removeDetachedView(view, true);
        }
    }
    scrapHeap.clear();
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:12,代码来源:IcsAbsSpinner.java

示例2: query

import android.util.SparseArray; //导入方法依赖的package包/类
/**
 * Query the table of the given model, returning a model list over the
 * result set.
 * 
 * @param modelClass
 *            The model to compile the query against.
 * @param columns
 *            A list of which columns to return. Passing null will return
 *            all columns, which is discouraged to prevent reading data from
 *            storage that isn't going to be used.
 * @param selection
 *            A filter declaring which rows to return, formatted as an SQL
 *            WHERE clause (excluding the WHERE itself). Passing null will
 *            return all rows for the given table.
 * @param selectionArgs
 *            You may include ?s in selection, which will be replaced by the
 *            values from selectionArgs, in order that they appear in the
 *            selection. The values will be bound as Strings.
 * @param groupBy
 *            A filter declaring how to group rows, formatted as an SQL
 *            GROUP BY clause (excluding the GROUP BY itself). Passing null
 *            will cause the rows to not be grouped.
 * @param having
 *            A filter declare which row groups to include in the cursor, if
 *            row grouping is being used, formatted as an SQL HAVING clause
 *            (excluding the HAVING itself). Passing null will cause all row
 *            groups to be included, and is required when row grouping is
 *            not being used.
 * @param orderBy
 *            How to order the rows, formatted as an SQL ORDER BY clause
 *            (excluding the ORDER BY itself). Passing null will use the
 *            default sort order, which may be unordered.
 * @param limit
 *            Limits the number of rows returned by the query, formatted as
 *            LIMIT clause. Passing null denotes no LIMIT clause.
 * @param foreignKeyAssociations
 *            Associated classes which have foreign keys in the current
 *            model's table.
 * @return A model list. The list may be empty.
 */
@SuppressWarnings("unchecked")
protected <T> List<T> query(Class<T> modelClass, String[] columns, String selection,
		String[] selectionArgs, String groupBy, String having, String orderBy, String limit,
		List<AssociationsInfo> foreignKeyAssociations) {
	List<T> dataList = new ArrayList<T>();
	Cursor cursor = null;
	try {
           List<Field> supportedFields = getSupportedFields(modelClass.getName());
           List<Field> supportedGenericFields = getSupportedGenericFields(modelClass.getName());
           String[] customizedColumns = DBUtility.convertSelectClauseToValidNames(getCustomizedColumns(columns, supportedGenericFields, foreignKeyAssociations));
           String tableName = getTableName(modelClass);
		cursor = mDatabase.query(tableName, customizedColumns, selection, selectionArgs,
				groupBy, having, orderBy, limit);
		if (cursor.moveToFirst()) {
               SparseArray<QueryInfoCache> queryInfoCacheSparseArray = new SparseArray<QueryInfoCache>();
               Map<Field, GenericModel> genericModelMap = new HashMap<Field, GenericModel>();
			do {
				T modelInstance = (T) createInstanceFromClass(modelClass);
				giveBaseObjIdValue((DataSupport) modelInstance,
						cursor.getLong(cursor.getColumnIndexOrThrow("id")));
				setValueToModel(modelInstance, supportedFields, foreignKeyAssociations, cursor, queryInfoCacheSparseArray);
                   setGenericValueToModel((DataSupport) modelInstance, supportedGenericFields, genericModelMap);
				if (foreignKeyAssociations != null) {
					setAssociatedModel((DataSupport) modelInstance);
				}
				dataList.add(modelInstance);
			} while (cursor.moveToNext());
               queryInfoCacheSparseArray.clear();
               genericModelMap.clear();
		}
		return dataList;
	} catch (Exception e) {
		throw new DataSupportException(e.getMessage(), e);
	} finally {
		if (cursor != null) {
			cursor.close();
		}
	}
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:80,代码来源:DataHandler.java


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