本文整理汇总了Java中android.support.v4.util.SparseArrayCompat类的典型用法代码示例。如果您正苦于以下问题:Java SparseArrayCompat类的具体用法?Java SparseArrayCompat怎么用?Java SparseArrayCompat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SparseArrayCompat类属于android.support.v4.util包,在下文中一共展示了SparseArrayCompat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import android.support.v4.util.SparseArrayCompat; //导入依赖的package包/类
private void init(Context context) {
mViewHolders = new SparseMatrix<>();
mLayoutDirectionHelper = new LayoutDirectionHelper(mLayoutDirection);
mHeaderColumnViewHolders = new SparseArrayCompat<>();
mHeaderRowViewHolders = new SparseArrayCompat<>();
mDragAndDropPoints = new DragAndDropPoints();
mState = new AdaptiveTableState();
mManager = new AdaptiveTableManagerRTL(mLayoutDirectionHelper);
mLastSwitchHeaderPoint = new Point();
mVisibleArea = new Rect();
// init scroll and fling helpers
mScrollerRunnable = new SmoothScrollRunnable(this);
mScrollerDragAndDropRunnable = new DragAndDropScrollRunnable(this);
mRecycler = new Recycler();
mSettings = new AdaptiveTableLayoutSettings();
mScrollHelper = new ScrollHelper(context);
mScrollHelper.setListener(this);
mShadowHelper = new ShadowHelper(mLayoutDirectionHelper);
}
示例2: setChoiceMode
import android.support.v4.util.SparseArrayCompat; //导入依赖的package包/类
@TargetApi(11)
public void setChoiceMode(int choiceMode) {
this.mChoiceMode = choiceMode;
if (VERSION.SDK_INT >= 11 && this.mChoiceActionMode != null) {
if (VERSION.SDK_INT >= 11) {
((ActionMode) this.mChoiceActionMode).finish();
}
this.mChoiceActionMode = null;
}
if (this.mChoiceMode != 0) {
if (this.mCheckStates == null) {
this.mCheckStates = new SparseArrayCompat();
}
if (this.mCheckedIdStates == null && this.mAdapter != null && this.mAdapter.hasStableIds()) {
this.mCheckedIdStates = new LongSparseArray();
}
if (VERSION.SDK_INT >= 11 && this.mChoiceMode == 3) {
clearChoices();
setLongClickable(true);
}
}
}
示例3: notifyDataSetChanged
import android.support.v4.util.SparseArrayCompat; //导入依赖的package包/类
@Override
public void notifyDataSetChanged() {
SparseArrayCompat<Fragment> newFragments =
new SparseArrayCompat<>(fragments.size());
for (int i = 0; i < fragments.size(); i++) {
final int oldPos = fragments.keyAt(i);
final Fragment f = fragments.valueAt(i);
final int newPos = getItemPosition(f);
if (newPos != POSITION_NONE) {
final int pos = (newPos >= 0) ? newPos : oldPos;
newFragments.put(pos, f);
}
}
fragments = newFragments;
super.notifyDataSetChanged();
}
示例4: attachChildViewBlock
import android.support.v4.util.SparseArrayCompat; //导入依赖的package包/类
private void attachChildViewBlock(@NonNull UIKitComponent component, SparseArrayCompat<String>
childViewBlockClassNamesArray, int index, View childView) {
int childViewChildAtId = childView.getId();
int indexOfKey = childViewBlockClassNamesArray.indexOfKey(childViewChildAtId);
if (indexOfKey < 0) {
indexOfKey = childViewBlockClassNamesArray.indexOfKey(index);
}
if (indexOfKey < 0) {
return;
}
String name = childViewBlockClassNamesArray.valueAt(indexOfKey);
if (name == null) {
return;
}
ViewBlock parentBlock = component.getViewBlock();
ViewBlock viewBlock = createViewBlock(childView, childViewChildAtId, name);
if (viewBlock != null) {
addViewBlockToViewBlockManager(viewBlock, parentBlock, component.getViewBlockManager());
}
childViewBlockClassNamesArray.removeAt(indexOfKey);
}
示例5: onCreate
import android.support.v4.util.SparseArrayCompat; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.offset_activity_test);
ItemsAdapter adapter = new ItemsAdapter(this);
adapter.setList(new ItemPagedList(this));
manage(adapter);
SparseArrayCompat<Integer> offsetItems = new SparseArrayCompat<>();
offsetItems.put(1, Integer.MAX_VALUE - 1);
offsetItems.put(10, Integer.MAX_VALUE - 2);
OffsetTestAdapter offsetAdapter = new OffsetTestAdapter(this, adapter, offsetItems);
manage(offsetAdapter);
RecyclerView items = (RecyclerView) findViewById(R.id.items);
items.setLayoutManager(new LinearLayoutManager(this));
items.setAdapter(offsetAdapter);
}
示例6: onCreate
import android.support.v4.util.SparseArrayCompat; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.offset_activity_test);
ItemsAdapter adapter = new ItemsAdapter(this);
adapter.setList(new ItemPagedList(this));
manage(adapter);
SparseArrayCompat<Integer> offsetItems = new SparseArrayCompat<>();
offsetItems.put(0, Integer.MAX_VALUE - 1);
offsetItems.put(1, Integer.MAX_VALUE - 2);
offsetItems.put(2, Integer.MAX_VALUE - 3);
OffsetTestAdapter offsetAdapter = new OffsetTestAdapter(this, adapter, offsetItems);
manage(offsetAdapter);
RecyclerView items = (RecyclerView) findViewById(R.id.items);
items.setLayoutManager(new LinearLayoutManager(this));
items.setAdapter(offsetAdapter);
}
示例7: init
import android.support.v4.util.SparseArrayCompat; //导入依赖的package包/类
public void init(Rect bounds, float startFrame, float endFrame, float frameRate, int majorVersion,
int minorVersion, int patchVersion, List<Layer> layers, LongSparseArray<Layer> layerMap,
Map<String, List<Layer>> precomps, Map<String, LottieImageAsset> images,
SparseArrayCompat<FontCharacter> characters, Map<String, Font> fonts) {
this.bounds = bounds;
this.startFrame = startFrame;
this.endFrame = endFrame;
this.frameRate = frameRate;
this.majorVersion = majorVersion;
this.minorVersion = minorVersion;
this.patchVersion = patchVersion;
this.layers = layers;
this.layerMap = layerMap;
this.precomps = precomps;
this.images = images;
this.characters = characters;
this.fonts = fonts;
}
示例8: setCity
import android.support.v4.util.SparseArrayCompat; //导入依赖的package包/类
/**
* 设置第二个列表数据
*
* @param city
*/
public void setCity(SparseArrayCompat<List<DataModel>> city) {
mCitisDatasMap = city;
List<DataModel> temp_city = city.get(mProvinceId);
if (temp_city != null) {
for (int i = 0; i < temp_city.size(); i++) {
DataModel data = temp_city.get(i);
if (data.Id == mCityId) {
mCityPosition = i;
break;
}
}
}
updateCities(mCityPosition);
// mCity.setCurrentItem(mCityPosition);
}
示例9: setArea
import android.support.v4.util.SparseArrayCompat; //导入依赖的package包/类
/**
* 设置第三个列表数据
*
* @param area
*/
public void setArea(SparseArrayCompat<List<DataModel>> area) {
mAreaDatasMap = area;
List<DataModel> temp_area = area.get(mCityId);
if (temp_area != null) {
for (int i = 0; i < temp_area.size(); i++) {
DataModel data = temp_area.get(i);
if (data.Id == mAreaId) {
mAreaPosition = i;
break;
}
}
}
updateAreas(mAreaPosition);
// mArea.setCurrentItem(mAreaPosition);
}
示例10: onPageScrolled
import android.support.v4.util.SparseArrayCompat; //导入依赖的package包/类
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
int currentItem = mViewPager.getCurrentItem();
if (positionOffsetPixels > 0) {
SparseArrayCompat<ScrollTabHolder> scrollTabHolders = mAdapter.getScrollTabHolders();
ScrollTabHolder fragmentContent;
if (position < currentItem) {
// Revealed the previous page
fragmentContent = scrollTabHolders.valueAt(position);
} else {
// Revealed the next page
fragmentContent = scrollTabHolders.valueAt(position + 1);
}
fragmentContent.adjustScroll((int) (mHeader.getHeight() + mHeader.getTranslationY()),
mHeader.getHeight());
}
}
示例11: onPageScrolled
import android.support.v4.util.SparseArrayCompat; //导入依赖的package包/类
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
int currentItem = mViewPager.getCurrentItem();
if (positionOffsetPixels > 0) {
SparseArrayCompat<ScrollHolder> scrollTabHolders = mAdapter.getScrollTabHolders();
ScrollHolder fragmentContent;
if (position < currentItem) {
fragmentContent = scrollTabHolders.valueAt(position);
} else {
fragmentContent = scrollTabHolders.valueAt(position + 1);
}
fragmentContent.adjustScroll((int) (mStickheader.getHeight() + mStickheader.getTranslationY()), mStickheader.getHeight());
}
}
示例12: onPageScrolled
import android.support.v4.util.SparseArrayCompat; //导入依赖的package包/类
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
if (positionOffsetPixels > 0) {
int currentItem = mViewPager.getCurrentItem();
SparseArrayCompat<ScrollTabHolder> scrollTabHolders = mPagerAdapter.getScrollTabHolders();
ScrollTabHolder currentHolder;
if (position < currentItem) {
currentHolder = scrollTabHolders.valueAt(position);
} else {
currentHolder = scrollTabHolders.valueAt(position + 1);
}
if (NEEDS_PROXY) {
// TODO is not good
currentHolder.adjustScroll(mHeader.getHeight() - mLastY);
mHeader.postInvalidate();
} else {
currentHolder.adjustScroll((int) (mHeader.getHeight() + mHeader.getTranslationY()));
}
}
}
示例13: 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();
}
示例14: getView
import android.support.v4.util.SparseArrayCompat; //导入依赖的package包/类
protected <T extends View> T getView(View view, int viewId)
{
SparseArrayCompat<View> viewHolder = (SparseArrayCompat<View>) view.getTag();
if (viewHolder == null)
{
viewHolder = new SparseArrayCompat<View>();
view.setTag(viewHolder);
}
View res = viewHolder.get(viewId);
if (res == null)
{
res = view.findViewById(viewId);
viewHolder.put(viewId, res);
}
return (T) res;
}
示例15: switchHeaders
import android.support.v4.util.SparseArrayCompat; //导入依赖的package包/类
/**
* Method switch view holders in map (map with headers view holders).
*
* @param map header view holder's map
* @param fromIndex index from view holder
* @param toIndex index to view holder
* @param type type of items (column header or row header)
*/
@SuppressWarnings("unused")
private void switchHeaders(SparseArrayCompat<ViewHolder> map, int fromIndex, int toIndex, int type) {
ViewHolder fromVh = map.get(fromIndex);
if (fromVh != null) {
map.remove(fromIndex);
if (type == ViewHolderType.COLUMN_HEADER) {
fromVh.setColumnIndex(toIndex);
} else if (type == ViewHolderType.ROW_HEADER) {
fromVh.setRowIndex(toIndex);
}
}
ViewHolder toVh = map.get(toIndex);
if (toVh != null) {
map.remove(toIndex);
if (type == ViewHolderType.COLUMN_HEADER) {
toVh.setColumnIndex(fromIndex);
} else if (type == ViewHolderType.ROW_HEADER) {
toVh.setRowIndex(fromIndex);
}
}
if (fromVh != null) {
map.put(toIndex, fromVh);
}
if (toVh != null) {
map.put(fromIndex, toVh);
}
}