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


Java SparseArrayCompat.size方法代码示例

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


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

示例1: deleteSelectedItems

import android.support.v4.util.SparseArrayCompat; //导入方法依赖的package包/类
private void deleteSelectedItems() {
	SparseArrayCompat<Boolean> checkedItems = listView.getCheckedItemPositions();
	ArrayList<Integer> sorted = new ArrayList<Integer>(checkedItems.size());

	Log.i(LOG_TAG, "deleting: " + checkedItems.size());

	for (int i = 0; i < checkedItems.size(); i++) {
		if (checkedItems.valueAt(i)) {
			sorted.add(checkedItems.keyAt(i));
		}
	}

	Collections.sort(sorted);

	for (int i = sorted.size() - 1; i >= 0; i--) {
		int position = sorted.get(i);
		Log.d(LOG_TAG, "Deleting item at: " + position);
		mAdapter.mItems.remove(position);
	}
	mAdapter.notifyDataSetChanged();
}
 
开发者ID:sephiroth74,项目名称:HListViewAnimations,代码行数:22,代码来源:SimpleHListActivity.java

示例2: 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

示例3: 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

示例4: getCheckItemIds

import android.support.v4.util.SparseArrayCompat; //导入方法依赖的package包/类
@Deprecated
public long[] getCheckItemIds() {
    if (this.mAdapter != null && this.mAdapter.hasStableIds()) {
        return getCheckedItemIds();
    }
    if (this.mChoiceMode == 0 || this.mCheckStates == null || this.mAdapter == null) {
        return new long[0];
    }
    SparseArrayCompat<Boolean> states = this.mCheckStates;
    int count = states.size();
    long[] ids = new long[count];
    ListAdapter adapter = this.mAdapter;
    int i = 0;
    int checkedCount = 0;
    while (i < count) {
        int checkedCount2;
        if (((Boolean) states.valueAt(i)).booleanValue()) {
            checkedCount2 = checkedCount + 1;
            ids[checkedCount] = adapter.getItemId(states.keyAt(i));
        } else {
            checkedCount2 = checkedCount;
        }
        i++;
        checkedCount = checkedCount2;
    }
    if (checkedCount == count) {
        return ids;
    }
    long[] result = new long[checkedCount];
    System.arraycopy(ids, 0, result, 0, checkedCount);
    return result;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:33,代码来源:HListView.java

示例5: getCheckItemIds

import android.support.v4.util.SparseArrayCompat; //导入方法依赖的package包/类
/**
 * Returns the set of checked items ids. The result is only valid if the
 * choice mode has not been set to {@link #CHOICE_MODE_NONE}.
 * 
 * @return A new array which contains the id of each checked item in the
 *         list.
 * 
 * @deprecated Use {@link #getCheckedItemIds()} instead.
 */
@Deprecated
public long[] getCheckItemIds() {
	// Use new behavior that correctly handles stable ID mapping.
	if (mAdapter != null && mAdapter.hasStableIds()) {
		return getCheckedItemIds();
	}

	// Old behavior was buggy, but would sort of work for adapters without
	// stable IDs.
	// Fall back to it to support legacy apps.
	if (mChoiceMode != AbsListView.CHOICE_MODE_NONE && mCheckStates != null && mAdapter != null) {
		final SparseArrayCompat<Boolean> states = mCheckStates;
		final int count = states.size();
		final long[] ids = new long[count];
		final ListAdapter adapter = mAdapter;

		int checkedCount = 0;
		for (int i = 0; i < count; i++) {
			if (states.valueAt(i)) {
				ids[checkedCount++] = adapter.getItemId(states.keyAt(i));
			}
		}

		// Trim array if needed. mCheckStates may contain false values
		// resulting in checkedCount being smaller than count.
		if (checkedCount == count) {
			return ids;
		} else {
			final long[] result = new long[checkedCount];
			System.arraycopy(ids, 0, result, 0, checkedCount);

			return result;
		}
	}
	return new long[0];
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:46,代码来源:HListView.java

示例6: onFinishInflateViewBlock

import android.support.v4.util.SparseArrayCompat; //导入方法依赖的package包/类
void onFinishInflateViewBlock(@NonNull UIKitComponent component) {
    SparseArrayCompat<String> viewBlockClassNamesArray = component.getViewBlockClassNamesArray();
    int size = viewBlockClassNamesArray.size();

    boolean isEmpty = (size == 0);

    if (!isEmpty) {
        int mHostChildCount = mHost.getChildCount();
        for (int i = 0; i < mHostChildCount; i++) {
            View childAt = mHost.getChildAt(i);
            if (!(childAt instanceof ViewGroup)) {
                attachChildViewBlock(component, viewBlockClassNamesArray, i, childAt);
            }
        }
    }

    if (!(component.getActivity() instanceof UIKitActivity)) {
        ViewGroup parent = component.getParentContainer();
        if (parent == null) return;
        if ((parent).getId() == android.R.id.content) {
            ViewBlockManager blockManager = UIKit.getViewBlockManager(component.getActivity());
            SparseArray<ViewBlock> viewBlocks = blockManager.getViewBlocks();
            UIKitActivity.dispatch(viewBlocks, UIKitActivity.ON_CREATE_VIEW);
        }
    }

}
 
开发者ID:iflove,项目名称:UIKit-ViewBlock,代码行数:28,代码来源:UIKitHelper.java

示例7: export

import android.support.v4.util.SparseArrayCompat; //导入方法依赖的package包/类
private void export() {
  SparseArrayCompat<AppInfo> checkedApps = adapter.getCheckedApps();
  final int size = checkedApps.size();
  AppInfo[] appInfos = new AppInfo[size];
  for (int i = 0; i < size; i++) {
    appInfos[i] = checkedApps.valueAt(i);
  }

  mPresenter.export(appInfos);
}
 
开发者ID:8enet,项目名称:AppOpsX,代码行数:11,代码来源:ExportFragment.java

示例8: 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

示例9: asList

import android.support.v4.util.SparseArrayCompat; //导入方法依赖的package包/类
public static <T> List<T> asList(SparseArrayCompat<T> sparseArray) {
    if (sparseArray == null) {
        return null;
    }

    ArrayList<T> list = new ArrayList<>(sparseArray.size());
    for (int i = 0; i < sparseArray.size(); i++) {
        list.add(sparseArray.valueAt(i));
    }
    return list;
}
 
开发者ID:stablekernel,项目名称:standardlib,代码行数:12,代码来源:SparseArrayUtils.java

示例10: onPageSelected

import android.support.v4.util.SparseArrayCompat; //导入方法依赖的package包/类
@Override
public void onPageSelected(int position) {
    SparseArrayCompat<ScrollTabHolder> scrollTabHolders = mAdapter.getScrollTabHolders();

    if (scrollTabHolders == null || scrollTabHolders.size() != mNumFragments) {
        return;
    }

    ScrollTabHolder currentHolder = scrollTabHolders.valueAt(position);
    currentHolder.adjustScroll(
            (int) (mHeader.getHeight() + mHeader.getTranslationY()),
            mHeader.getHeight());
}
 
开发者ID:boxme,项目名称:ParallaxHeaderViewPager,代码行数:14,代码来源:ParallaxViewPagerChangeListener.java

示例11: onPageSelected

import android.support.v4.util.SparseArrayCompat; //导入方法依赖的package包/类
@Override
public void onPageSelected(int position) {
    SparseArrayCompat<ScrollHolder> scrollTabHolders = mAdapter.getScrollTabHolders();

    if (scrollTabHolders == null || scrollTabHolders.size() != mAdapter.getCount()) {
        return;
    }

    ScrollHolder currentHolder = scrollTabHolders.valueAt(position);
    currentHolder.adjustScroll((int) (mStickheader.getHeight() + mStickheader.getTranslationY()), mStickheader.getHeight());
}
 
开发者ID:w446108264,项目名称:StickyHeaderViewPager,代码行数:12,代码来源:StickHeaderViewPager.java

示例12: 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

示例13: isEqualTo

import android.support.v4.util.SparseArrayCompat; //导入方法依赖的package包/类
@Override
public boolean isEqualTo(final SparseArrayCompat<?> array) {

    int count = 0;

    for (final SparseArrayEntry<V> entry : this) {

        final Object value = array.get(entry.getKey());

        if (value == null) {

            if (entry.getValue() != null) {

                return false;
            }

        } else if (!value.equals(entry.getValue())) {

            return false;
        }

        ++count;
    }

    return (count == array.size());
}
 
开发者ID:davide-maestroni,项目名称:robo-fashion,代码行数:27,代码来源:SparseArrayCompatIterableImpl.java

示例14: 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

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