/** * Maps an int to a specific mode. This is needed when saving state, or inflating the view from * XML where the mode is given through a attr int. * * @param modeInt - int to map a Mode to * @return Mode that modeInt maps to, or PULL_FROM_START by default. */ static SlideMode mapIntToValue(final int modeInt) { for (SlideMode value : SlideMode.values()) { if (modeInt == value.getIntValue()) { return value; } } // If not, return default return getDefault(); }
/** * Init ListView * * @param attrs AttributeSet */ private void init(AttributeSet attrs) { if (attrs != null) { TypedArray styled = getContext().obtainStyledAttributes(attrs, R.styleable.SlideListView); mAnimationTime = styled.getInteger(R.styleable.SlideListView_slideAnimationTime, 0); mSlideMode = SlideMode.mapIntToValue(styled.getInteger(R.styleable.SlideListView_slideMode, 0)); mSlideLeftAction = SlideAction.mapIntToValue( styled.getInteger(R.styleable.SlideListView_slideLeftAction, 0)); mSlideRightAction = SlideAction.mapIntToValue( styled.getInteger(R.styleable.SlideListView_slideRightAction, 0)); styled.recycle(); } mTouchListener = new SlideTouchListener(this); // You can't use setOnTouchListener() in your own code setOnTouchListener(mTouchListener); // You can use setOnScrollListener() in your own code setOnScrollListener(mInnerOnScrollListener); // You can use setOnItemClickListener() in your own code setOnItemClickListener(mInnerOnItemClickListener); }