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


Java SparseArrayCompat类代码示例

本文整理汇总了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);
}
 
开发者ID:Cleveroad,项目名称:AdaptiveTableLayout,代码行数:20,代码来源:AdaptiveTableLayout.java

示例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);
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:23,代码来源:AbsHListView.java

示例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();
}
 
开发者ID:Laaidback,项目名称:A.scribe,代码行数:17,代码来源:FragmentStatePagerAdapter2.java

示例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);
}
 
开发者ID:iflove,项目名称:UIKit-ViewBlock,代码行数:26,代码来源:UIKitHelper.java

示例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);
}
 
开发者ID:lifechurch,项目名称:nuclei-android,代码行数:21,代码来源:OffsetTestActivity.java

示例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);
}
 
开发者ID:lifechurch,项目名称:nuclei-android,代码行数:22,代码来源:OffsetTestActivity2.java

示例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;
}
 
开发者ID:airbnb,项目名称:lottie-android,代码行数:19,代码来源:LottieComposition.java

示例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);
    }
 
开发者ID:kingwang666,项目名称:WheelDemo,代码行数:21,代码来源:CharacterPickerView.java

示例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);
    }
 
开发者ID:kingwang666,项目名称:WheelDemo,代码行数:21,代码来源:CharacterPickerView.java

示例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());
    }
}
 
开发者ID:boxme,项目名称:ParallaxHeaderViewPager,代码行数:20,代码来源:ParallaxViewPagerChangeListener.java

示例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());
    }
}
 
开发者ID:w446108264,项目名称:StickyHeaderViewPager,代码行数:17,代码来源:StickHeaderViewPager.java

示例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()));
		}
	}
}
 
开发者ID:kmshack,项目名称:Android-ParallaxHeaderViewPager,代码行数:25,代码来源:MainActivity.java

示例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();
}
 
开发者ID:sephiroth74,项目名称:HListViewAnimations,代码行数:22,代码来源:SimpleHListActivity.java

示例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;
}
 
开发者ID:dmfs,项目名称:opentasks,代码行数:17,代码来源:BaseTaskViewDescriptor.java

示例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);
    }
}
 
开发者ID:Cleveroad,项目名称:AdaptiveTableLayout,代码行数:40,代码来源:AdaptiveTableLayout.java


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