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


Java SparseArrayCompat.keyAt方法代碼示例

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


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

示例1: getRowItems

import android.support.v4.util.SparseArrayCompat; //導入方法依賴的package包/類
/**
 * Get all row's items
 *
 * @param row row index
 * @return Collection with row's Objects
 */
@NonNull
Collection<TObj> getRowItems(int row) {
    Collection<TObj> result = new LinkedList<>();
    SparseArrayCompat<TObj> array = mData.get(row);
    for (int count = array.size(), i = 0; i < count; i++) {
        int key = array.keyAt(i);
        TObj columnObj = array.get(key);
        if (columnObj != null) {
            result.add(columnObj);
        }

    }
    return result;
}
 
開發者ID:Cleveroad,項目名稱:AdaptiveTableLayout,代碼行數:21,代碼來源:SparseMatrix.java

示例2: getAll

import android.support.v4.util.SparseArrayCompat; //導入方法依賴的package包/類
/**
 * Get all matrix's items
 *
 * @return Collection with column's Objects
 */
@NonNull
Collection<TObj> getAll() {
    Collection<TObj> result = new LinkedList<>();
    for (int countR = mData.size(), i = 0; i < countR; i++) {
        int rowKey = mData.keyAt(i);
        SparseArrayCompat<TObj> columns = mData.get(rowKey);
        for (int countC = columns.size(), j = 0; j < countC; j++) {
            int key = columns.keyAt(j);
            result.add(columns.get(key));
        }
    }
    return result;
}
 
開發者ID:Cleveroad,項目名稱:AdaptiveTableLayout,代碼行數:19,代碼來源:SparseMatrix.java

示例3: findUpMigrationPath

import android.support.v4.util.SparseArrayCompat; //導入方法依賴的package包/類
private List<alpha1.android.arch.persistence.room.migration.Migration> findUpMigrationPath(List<alpha1.android.arch.persistence.room.migration.Migration> result, boolean upgrade,
                                                                                           int start, int end) {
    final int searchDirection = upgrade ? -1 : 1;
    while (upgrade ? start < end : start > end) {
        SparseArrayCompat<alpha1.android.arch.persistence.room.migration.Migration>
            targetNodes = mMigrations.get(start);
        if (targetNodes == null) {
            return null;
        }
        // keys are ordered so we can start searching from one end of them.
        final int size = targetNodes.size();
        final int firstIndex;
        final int lastIndex;

        if (upgrade) {
            firstIndex = size - 1;
            lastIndex = -1;
        } else {
            firstIndex = 0;
            lastIndex = size;
        }
        boolean found = false;
        for (int i = firstIndex; i != lastIndex; i += searchDirection) {
            int targetVersion = targetNodes.keyAt(i);
            if (targetVersion <= end && targetVersion > start) {
                result.add(targetNodes.valueAt(i));
                start = targetVersion;
                found = true;
                break;
            }
        }
        if (!found) {
            return null;
        }
    }
    return result;
}
 
開發者ID:CaMnter,項目名稱:AndroidLife,代碼行數:38,代碼來源:RoomDatabase.java

示例4: convertTypesForFilter

import android.support.v4.util.SparseArrayCompat; //導入方法依賴的package包/類
/**
 * Helper method to convert list of selected types of a {@link com.schautup.data.Filter} to a string with sep {@link
 * #DIV}.
 *
 * @param types
 * 		A list of all {@link com.schautup.data.Filter}s.
 *
 * @return Selected {@link com.schautup.data.Filter}s in string with sep {@link #DIV}.
 */
private static StringBuilder convertTypesForFilter(SparseArrayCompat<ScheduleType> types) {
	StringBuilder stringBuilder = new StringBuilder();
	int key;
	ScheduleType type;
	for (int i = 0; i < types.size(); i++) {
		key = types.keyAt(i);
		type = types.get(key);
		stringBuilder.append(type.getCode());
		if (i != types.size() - 1) {//Last one?
			stringBuilder.append(DIV);
		}
	}
	return stringBuilder;
}
 
開發者ID:XinyueZ,項目名稱:schautup,代碼行數:24,代碼來源:DB.java

示例5: onEvent

import android.support.v4.util.SparseArrayCompat; //導入方法依賴的package包/類
/**
 * Handler for {@link com.schautup.bus.ShowSetFilterEvent}.
 *
 * @param e
 * 		Event {@link  com.schautup.bus.ShowSetFilterEvent}.
 */
public void onEvent(ShowSetFilterEvent e) {
	mIsEdit = true;
	Filter item = e.getFilter();
	mId = item.getId();
	mName = item.getName();
	mHour = item.getHour();
	mMinute = item.getMinute();
	mNameEt.setText(mName);
	mHourTv.setText(Utils.convertValue(mHour));
	mMinuteTv.setText(Utils.convertValue(mMinute));
	SparseArrayCompat<ScheduleType> types= item.getSelectedTypes();
	int key;
	ScheduleType type;
	for(int i = 0; i < types.size(); i++) {
		key = types.keyAt(i);
		type = types.get(key);
		switch (type) {
		case MUTE:
			mSetMuteV.performClick();
			break;
		case VIBRATE:
			mSetVibrateV.performClick();
			break;
		case SOUND:
			mSetSoundV.performClick();
			break;
		case WIFI:
			mSetWifiV.performClick();
			break;
		case MOBILE:
			mSetMobileDataV.performClick();
			break;
		case BRIGHTNESS:
			mSetBrightnessV.performClick();
			break;
		case BLUETOOTH:
			mSetBluetoothV.performClick();
			break;
		case STARTAPP:
			mSetStartAppV.performClick();
			break;
		case CALLABORT:
			mSetCallAbortV.performClick();
			break;
		}
	}
	mEventRecurrence = item.getEventRecurrence();
	mEventRecurrence = Utils.showRecurrenceBadge(getActivity(), mEventRecurrence, mRecurrenceBgv);
	EventBus.getDefault().removeStickyEvent(ShowSetFilterEvent.class);
}
 
開發者ID:XinyueZ,項目名稱:schautup,代碼行數:57,代碼來源:FilterDefineDialogFragment.java

示例6: getFilteredSchedules

import android.support.v4.util.SparseArrayCompat; //導入方法依賴的package包/類
/**
 * Returns {@link com.schautup.data.ScheduleItem}s from DB by  hour , minute , type and recurrence which have been filtered.
 *
 * @param hour
 * 		Hour.
 * @param minute
 * 		Minute.
 * @param types
 * 		A list of selected {@link com.schautup.data.ScheduleType}.
 * @param eventRecurrence
 * 		{@link EventRecurrence}.
 *
 * @return {@link com.schautup.data.ScheduleItem}s from DB by hour , minute , type and recurrence.
 */
public synchronized List<ScheduleItem> getFilteredSchedules(int hour, int minute,
		SparseArrayCompat<ScheduleType> types, EventRecurrence eventRecurrence) {
	if (mDB == null || !mDB.isOpen()) {
		open();
	}
	List<ScheduleItem> items = new ArrayList<ScheduleItem>();
	Cursor c = null;
	ScheduleType type;
	ScheduleItem item;
	List<ScheduleItem> list;
	try {
		int key;
		for (int i = 0; i < types.size(); i++) {
			key = types.keyAt(i);
			type = types.get(key);
			c = mDB.query(ScheduleTbl.TABLE_NAME, null, "("+ ScheduleTbl.HOUR + " = ? AND " + ScheduleTbl.MINUTE + " = " +
							"? AND " + ScheduleTbl.RECURRENCE + " = ?) AND " + ScheduleTbl.TYPE + " = ?", new String[] { hour + "", minute + "", eventRecurrence.toString(), type.getCode() + "" }, null,
					null, null, null);
			list = new LinkedList<ScheduleItem>();
			EventRecurrence er;
			while (c.moveToNext()) {
				item = new ScheduleItem(c.getLong(c.getColumnIndex(ScheduleTbl.ID)), ScheduleType.fromCode(c.getInt(
						c.getColumnIndex(ScheduleTbl.TYPE))), c.getInt(c.getColumnIndex(ScheduleTbl.HOUR)), c.getInt(c.getColumnIndex(ScheduleTbl.MINUTE)), c.getLong(c.getColumnIndex(
						ScheduleTbl.EDIT_TIME)));
				er = new EventRecurrence();
				er.parse(c.getString(c.getColumnIndex(ScheduleTbl.RECURRENCE)));
				item.setEventRecurrence(er);
				item.setReserveLeft(c.getString(c.getColumnIndex(ScheduleTbl.RESERVE_LEFT)));
				item.setReserveRight(c.getString(c.getColumnIndex(ScheduleTbl.RESERVE_RIGHT)));
				list.add(item);
			}
			items.addAll(list);
		}
	} finally {
		if (c != null) {
			c.close();
		}
		close();
		return items;
	}
}
 
開發者ID:XinyueZ,項目名稱:schautup,代碼行數:56,代碼來源:DB.java


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