List of usage examples for android.content.res TypedArray getInteger
public int getInteger(@StyleableRes int index, int defValue)
From source file:com.young.icontacts.view.SwipeListView.java
/** * Init ListView// w w w.j a v a 2 s . c o m * * @param attrs AttributeSet */ @SuppressLint("ClickableViewAccessibility") private void init(AttributeSet attrs) { int swipeMode = SWIPE_MODE_BOTH; boolean swipeOpenOnLongPress = true; boolean swipeCloseAllItemsWhenMoveList = true; long swipeAnimationTime = 0; float swipeOffsetLeft = 0; float swipeOffsetRight = 0; int swipeDrawableChecked = 0; int swipeDrawableUnchecked = 0; int swipeActionLeft = SWIPE_ACTION_REVEAL; int swipeActionRight = SWIPE_ACTION_REVEAL; if (attrs != null) { TypedArray styled = getContext().obtainStyledAttributes(attrs, R.styleable.SwipeListView); swipeMode = styled.getInt(R.styleable.SwipeListView_swipeMode, SWIPE_MODE_BOTH); swipeActionLeft = styled.getInt(R.styleable.SwipeListView_swipeActionLeft, SWIPE_ACTION_REVEAL); swipeActionRight = styled.getInt(R.styleable.SwipeListView_swipeActionRight, SWIPE_ACTION_REVEAL); swipeOffsetLeft = styled.getDimension(R.styleable.SwipeListView_swipeOffsetLeft, 0); swipeOffsetRight = styled.getDimension(R.styleable.SwipeListView_swipeOffsetRight, 0); swipeOpenOnLongPress = styled.getBoolean(R.styleable.SwipeListView_swipeOpenOnLongPress, true); swipeAnimationTime = styled.getInteger(R.styleable.SwipeListView_swipeAnimationTime, 0); swipeCloseAllItemsWhenMoveList = styled .getBoolean(R.styleable.SwipeListView_swipeCloseAllItemsWhenMoveList, true); swipeDrawableChecked = styled.getResourceId(R.styleable.SwipeListView_swipeDrawableChecked, 0); swipeDrawableUnchecked = styled.getResourceId(R.styleable.SwipeListView_swipeDrawableUnchecked, 0); swipeFrontView = styled.getResourceId(R.styleable.SwipeListView_swipeFrontView, 0); swipeBackView = styled.getResourceId(R.styleable.SwipeListView_swipeBackView, 0); styled.recycle(); } if (swipeFrontView == 0 || swipeBackView == 0) { swipeFrontView = getContext().getResources().getIdentifier(SWIPE_DEFAULT_FRONT_VIEW, "id", getContext().getPackageName()); swipeBackView = getContext().getResources().getIdentifier(SWIPE_DEFAULT_BACK_VIEW, "id", getContext().getPackageName()); if (swipeFrontView == 0 || swipeBackView == 0) { throw new RuntimeException(String.format( "You forgot the attributes swipeFrontView or swipeBackView. You can add this attributes or use '%s' and '%s' identifiers", SWIPE_DEFAULT_FRONT_VIEW, SWIPE_DEFAULT_BACK_VIEW)); } } final ViewConfiguration configuration = ViewConfiguration.get(getContext()); touchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); touchListener = new SwipeListViewTouchListenerTwo(this, swipeFrontView, swipeBackView); if (swipeAnimationTime > 0) { touchListener.setAnimationTime(swipeAnimationTime); } touchListener.setRightOffset(swipeOffsetRight); touchListener.setLeftOffset(swipeOffsetLeft); touchListener.setSwipeActionLeft(swipeActionLeft); touchListener.setSwipeActionRight(swipeActionRight); touchListener.setSwipeMode(swipeMode); touchListener.setSwipeClosesAllItemsWhenListMoves(swipeCloseAllItemsWhenMoveList); touchListener.setSwipeOpenOnLongPress(swipeOpenOnLongPress); touchListener.setSwipeDrawableChecked(swipeDrawableChecked); touchListener.setSwipeDrawableUnchecked(swipeDrawableUnchecked); setOnTouchListener(touchListener); setOnScrollListener(touchListener.makeScrollListener()); }
From source file:com.mianamiana.library.LiquidBallProgressBar.java
private void initAttrs(Context context, AttributeSet attrs) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LiquidBallProgressBar); try {//from www . j ava 2 s .c o m mBorderColor = a.getColor(R.styleable.LiquidBallProgressBar_lbpb_borderColor, mBorderColor); mTextColor = a.getColor(R.styleable.LiquidBallProgressBar_lbpb_textColor, mTextColor); mWaveColor = a.getColor(R.styleable.LiquidBallProgressBar_lbpb_waveColor, mWaveColor); mUnfilledWaveColor = a.getColor(R.styleable.LiquidBallProgressBar_lbpb_unfilledColor, mUnfilledWaveColor); mTextOverlapColor = a.getColor(R.styleable.LiquidBallProgressBar_lbpb_textOverlapColor, mTextOverlapColor); int textsize = a.getDimensionPixelSize(R.styleable.LiquidBallProgressBar_lbpb_textSize, 0); if (textsize != 0) { mTextSize = textsize / context.getResources().getDisplayMetrics().scaledDensity; } mBorderWidth = (int) (a.getDimension(R.styleable.LiquidBallProgressBar_lbpb_borderWidth, mBorderWidth) + 0.5f); mProgress = a.getInteger(R.styleable.LiquidBallProgressBar_lbpb_progress, mProgress); mMaxProgress = a.getInteger(R.styleable.LiquidBallProgressBar_lbpb_maxProgress, mMaxProgress); } finally { a.recycle(); } }
From source file:com.yishang.E.view.swipelistview.SwipeListView.java
/** * Init ListView/*from w ww .j av a 2s .c o m*/ * * @param attrs AttributeSet */ private void init(AttributeSet attrs) { int swipeMode = SWIPE_MODE_BOTH; boolean swipeOpenOnLongPress = true; boolean swipeCloseAllItemsWhenMoveList = true; long swipeAnimationTime = 0; float swipeOffsetLeft = 0; float swipeOffsetRight = 0; int swipeDrawableChecked = 0; int swipeDrawableUnchecked = 0; int swipeActionLeft = SWIPE_ACTION_REVEAL; int swipeActionRight = SWIPE_ACTION_REVEAL; if (attrs != null) { TypedArray styled = getContext().obtainStyledAttributes(attrs, R.styleable.SwipeListView); swipeMode = styled.getInt(R.styleable.SwipeListView_swipeMode, SWIPE_MODE_BOTH); swipeActionLeft = styled.getInt(R.styleable.SwipeListView_swipeActionLeft, SWIPE_ACTION_REVEAL); swipeActionRight = styled.getInt(R.styleable.SwipeListView_swipeActionRight, SWIPE_ACTION_REVEAL); swipeOffsetLeft = styled.getDimension(R.styleable.SwipeListView_swipeOffsetLeft, 0); swipeOffsetRight = styled.getDimension(R.styleable.SwipeListView_swipeOffsetRight, 0); swipeOpenOnLongPress = styled.getBoolean(R.styleable.SwipeListView_swipeOpenOnLongPress, true); swipeAnimationTime = styled.getInteger(R.styleable.SwipeListView_swipeAnimationTime, 0); swipeCloseAllItemsWhenMoveList = styled .getBoolean(R.styleable.SwipeListView_swipeCloseAllItemsWhenMoveList, true); swipeDrawableChecked = styled.getResourceId(R.styleable.SwipeListView_swipeDrawableChecked, 0); swipeDrawableUnchecked = styled.getResourceId(R.styleable.SwipeListView_swipeDrawableUnchecked, 0); swipeFrontView = styled.getResourceId(R.styleable.SwipeListView_swipeFrontView, 0); swipeBackView = styled.getResourceId(R.styleable.SwipeListView_swipeBackView, 0); } if (swipeFrontView == 0 || swipeBackView == 0) { swipeFrontView = getContext().getResources().getIdentifier(SWIPE_DEFAULT_FRONT_VIEW, "id", getContext().getPackageName()); swipeBackView = getContext().getResources().getIdentifier(SWIPE_DEFAULT_BACK_VIEW, "id", getContext().getPackageName()); if (swipeFrontView == 0 || swipeBackView == 0) { throw new RuntimeException(String.format( "You forgot the attributes swipeFrontView or swipeBackView. You can add this attributes or use '%s' and '%s' identifiers", SWIPE_DEFAULT_FRONT_VIEW, SWIPE_DEFAULT_BACK_VIEW)); } } final ViewConfiguration configuration = ViewConfiguration.get(getContext()); touchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); touchListener = new SwipeListViewTouchListener(this, swipeFrontView, swipeBackView); if (swipeAnimationTime > 0) { touchListener.setAnimationTime(swipeAnimationTime); } touchListener.setRightOffset(swipeOffsetRight); touchListener.setLeftOffset(swipeOffsetLeft); touchListener.setSwipeActionLeft(swipeActionLeft); touchListener.setSwipeActionRight(swipeActionRight); touchListener.setSwipeMode(swipeMode); touchListener.setSwipeClosesAllItemsWhenListMoves(swipeCloseAllItemsWhenMoveList); touchListener.setSwipeOpenOnLongPress(swipeOpenOnLongPress); touchListener.setSwipeDrawableChecked(swipeDrawableChecked); touchListener.setSwipeDrawableUnchecked(swipeDrawableUnchecked); setOnTouchListener(touchListener); setOnScrollListener(touchListener.makeScrollListener()); // setXListViewListener(this); // httpCallBack.initListView(); }
From source file:com.aoeng.degu.views.swipe.SwipeListSingleView.java
/** * Init ListView//www . java2 s .c om * * @param attrs * AttributeSet */ private void init(AttributeSet attrs) { int swipeMode = SWIPE_MODE_BOTH; boolean swipeOpenOnLongPress = true; boolean swipeCloseAllItemsWhenMoveList = true; long swipeAnimationTime = 0; float swipeOffsetLeft = 0; float swipeOffsetRight = 0; int swipeDrawableChecked = 0; int swipeDrawableUnchecked = 0; int swipeActionLeft = SWIPE_ACTION_REVEAL; int swipeActionRight = SWIPE_ACTION_REVEAL; if (attrs != null) { TypedArray styled = getContext().obtainStyledAttributes(attrs, R.styleable.SwipeListView); swipeMode = styled.getInt(R.styleable.SwipeListView_swipeMode, SWIPE_MODE_BOTH); swipeActionLeft = styled.getInt(R.styleable.SwipeListView_swipeActionLeft, SWIPE_ACTION_REVEAL); swipeActionRight = styled.getInt(R.styleable.SwipeListView_swipeActionRight, SWIPE_ACTION_REVEAL); swipeOffsetLeft = styled.getDimension(R.styleable.SwipeListView_swipeOffsetLeft, 0); swipeOffsetRight = styled.getDimension(R.styleable.SwipeListView_swipeOffsetRight, 0); swipeOpenOnLongPress = styled.getBoolean(R.styleable.SwipeListView_swipeOpenOnLongPress, true); swipeAnimationTime = styled.getInteger(R.styleable.SwipeListView_swipeAnimationTime, 0); swipeCloseAllItemsWhenMoveList = styled .getBoolean(R.styleable.SwipeListView_swipeCloseAllItemsWhenMoveList, true); swipeDrawableChecked = styled.getResourceId(R.styleable.SwipeListView_swipeDrawableChecked, 0); swipeDrawableUnchecked = styled.getResourceId(R.styleable.SwipeListView_swipeDrawableUnchecked, 0); swipeFrontView = styled.getResourceId(R.styleable.SwipeListView_swipeFrontView, 0); swipeBackView = styled.getResourceId(R.styleable.SwipeListView_swipeBackView, 0); } if (swipeFrontView == 0 || swipeBackView == 0) { swipeFrontView = getContext().getResources().getIdentifier(SWIPE_DEFAULT_FRONT_VIEW, "id", getContext().getPackageName()); swipeBackView = getContext().getResources().getIdentifier(SWIPE_DEFAULT_BACK_VIEW, "id", getContext().getPackageName()); if (swipeFrontView == 0 || swipeBackView == 0) { throw new RuntimeException(String.format( "You forgot the attributes swipeFrontView or swipeBackView. You can add this attributes or use '%s' and '%s' identifiers", SWIPE_DEFAULT_FRONT_VIEW, SWIPE_DEFAULT_BACK_VIEW)); } } final ViewConfiguration configuration = ViewConfiguration.get(getContext()); touchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); touchListener = new SwipeListSingleViewTouchListener(this, swipeFrontView, swipeBackView); if (swipeAnimationTime > 0) { touchListener.setAnimationTime(swipeAnimationTime); } touchListener.setRightOffset(swipeOffsetRight); touchListener.setLeftOffset(swipeOffsetLeft); touchListener.setSwipeActionLeft(swipeActionLeft); touchListener.setSwipeActionRight(swipeActionRight); touchListener.setSwipeMode(swipeMode); touchListener.setSwipeClosesAllItemsWhenListMoves(swipeCloseAllItemsWhenMoveList); touchListener.setSwipeOpenOnLongPress(swipeOpenOnLongPress); touchListener.setSwipeDrawableChecked(swipeDrawableChecked); touchListener.setSwipeDrawableUnchecked(swipeDrawableUnchecked); setOnTouchListener(touchListener); setOnScrollListener(touchListener.makeScrollListener()); }
From source file:net.qiujuer.genius.ui.widget.GeniusAbsSeekBar.java
private void init(AttributeSet attrs, int defStyle) { final Context context = getContext(); final Resources resources = getResources(); final boolean notEdit = !isInEditMode(); ColorStateList trackColor = mAttributes.getTrackColor(); ColorStateList thumbColor = mAttributes.getThumbColor(); ColorStateList scrubberColor = mAttributes.getScrubberColor(); ColorStateList rippleColor = mAttributes.getRippleColor(); ColorStateList indicatorColor = mAttributes.getIndicatorColor(); int textAppearanceId = R.style.DefaultBalloonMarkerTextAppearanceStyle; if (attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.GeniusSeekBar, R.attr.GeniusSeekBarStyle, defStyle); // Getting common attributes int customTheme = a.getResourceId(R.styleable.GeniusSeekBar_g_theme, Attributes.DEFAULT_THEME); mAttributes.setTheme(customTheme, resources); // Values int max = a.getInteger(R.styleable.GeniusSeekBar_g_max, mMax); int min = a.getInteger(R.styleable.GeniusSeekBar_g_min, mMin); int value = a.getInteger(R.styleable.GeniusSeekBar_g_value, mValue); mMin = min;//from www. j a v a2s. c o m mMax = Math.max(min + 1, max); mValue = Math.max(min, Math.min(max, value)); // Colors trackColor = a.getColorStateList(R.styleable.GeniusSeekBar_g_trackColor); thumbColor = a.getColorStateList(R.styleable.GeniusSeekBar_g_thumbColor); scrubberColor = a.getColorStateList(R.styleable.GeniusSeekBar_g_scrubberColor); rippleColor = a.getColorStateList(R.styleable.GeniusSeekBar_g_rippleColor); indicatorColor = a.getColorStateList(R.styleable.GeniusSeekBar_g_indicatorBackgroundColor); // Size int tickSize = a.getDimensionPixelSize(R.styleable.GeniusSeekBar_g_tickSize, mSeekBarDrawable.getTickRadius()); int thumbSize = a.getDimensionPixelSize(R.styleable.GeniusSeekBar_g_thumbSize, mSeekBarDrawable.getThumbRadius()); int touchSize = a.getDimensionPixelSize(R.styleable.GeniusSeekBar_g_touchSize, mSeekBarDrawable.getTouchRadius()); int trackStroke = a.getDimensionPixelSize(R.styleable.GeniusSeekBar_g_trackStroke, mSeekBarDrawable.getTrackStroke()); int scrubberStroke = a.getDimensionPixelSize(R.styleable.GeniusSeekBar_g_scrubberStroke, mSeekBarDrawable.getScrubberStroke()); // Set Size setTrackStroke(trackStroke); setScrubberStroke(scrubberStroke); setThumbRadius(thumbSize); setTouchRadius(touchSize); setTickRadius(tickSize); // Other mMirrorForRtl = a.getBoolean(R.styleable.GeniusSeekBar_g_mirrorForRtl, mMirrorForRtl); mAllowTrackClick = a.getBoolean(R.styleable.GeniusSeekBar_g_allowTrackClickToDrag, mAllowTrackClick); mIndicatorFormatter = a.getString(R.styleable.GeniusSeekBar_g_indicatorFormatter); textAppearanceId = a.getResourceId(R.styleable.GeniusSeekBar_g_indicatorTextAppearance, textAppearanceId); a.recycle(); } // Init Colors if (rippleColor == null) { rippleColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { mAttributes.getColor(1) }); } else { mAttributes.setRippleColor(rippleColor); } if (trackColor == null) { int[] colors = new int[] { mAttributes.getColor(4), mAttributes.getColor(5) }; int[][] states = new int[][] { new int[] { android.R.attr.state_enabled }, new int[] { -android.R.attr.state_enabled } }; trackColor = new ColorStateList(states, colors); } else { mAttributes.setTrackColor(trackColor); } if (thumbColor == null) { int[] colors = new int[] { mAttributes.getColor(2), mAttributes.getColor(3) }; int[][] states = new int[][] { new int[] { android.R.attr.state_enabled }, new int[] { -android.R.attr.state_enabled } }; thumbColor = new ColorStateList(states, colors); } else { mAttributes.setThumbColor(thumbColor); } if (scrubberColor == null) { int[] colors = new int[] { mAttributes.getColor(2), mAttributes.getColor(3) }; int[][] states = new int[][] { new int[] { android.R.attr.state_enabled }, new int[] { -android.R.attr.state_enabled } }; scrubberColor = new ColorStateList(states, colors); } else { mAttributes.setScrubberColor(scrubberColor); } if (indicatorColor == null) { int[] colors = new int[] { mAttributes.getColor(2), mAttributes.getColor(1) }; int[][] states = new int[][] { new int[] { android.R.attr.state_enabled }, new int[] { android.R.attr.state_pressed } }; indicatorColor = new ColorStateList(states, colors); } else { mAttributes.setIndicatorColor(indicatorColor); } // Set Colors mRipple.setColorStateList(rippleColor); mSeekBarDrawable.setTrackColor(trackColor); mSeekBarDrawable.setScrubberColor(scrubberColor); mSeekBarDrawable.setThumbColor(thumbColor); if (notEdit) { mIndicator.setIndicatorColor(indicatorColor); mIndicator.setIndicatorTextAppearance(textAppearanceId); } // Set Values mSeekBarDrawable.setNumSegments(mMax - mMin); updateKeyboardRange(); }
From source file:ru.phplego.core.etc.viewpagerindicator.TitlePageIndicator.java
public TitlePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); //Load defaults from resources final Resources res = getResources(); final int defaultFooterColor = res.getColor(Res.getId(Application.getContext().getPackageName(), "color", "default_title_indicator_footer_color")); final float defaultFooterLineHeight = res.getDimension(Res.getId(Application.getContext().getPackageName(), "dimen", "default_title_indicator_footer_line_height")); final int defaultFooterIndicatorStyle = res.getInteger(Res.getId(Application.getContext().getPackageName(), "integer", "default_title_indicator_footer_indicator_style")); final float defaultFooterIndicatorHeight = res .getDimension(Res.getId(Application.getContext().getPackageName(), "dimen", "default_title_indicator_footer_indicator_height")); final float defaultFooterIndicatorUnderlinePadding = res .getDimension(Res.getId(Application.getContext().getPackageName(), "dimen", "default_title_indicator_footer_indicator_underline_padding")); final float defaultFooterPadding = res.getDimension(Res.getId(Application.getContext().getPackageName(), "dimen", "default_title_indicator_footer_padding")); final int defaultSelectedColor = res.getColor(Res.getId(Application.getContext().getPackageName(), "color", "default_title_indicator_selected_color")); final boolean defaultSelectedBold = res.getBoolean(Res.getId(Application.getContext().getPackageName(), "bool", "default_title_indicator_selected_bold")); final int defaultTextColor = res.getColor(Res.getId(Application.getContext().getPackageName(), "color", "default_title_indicator_text_color")); final float defaultTextSize = res.getDimension( Res.getId(Application.getContext().getPackageName(), "dimen", "default_title_indicator_text_size")); final float defaultTitlePadding = res.getDimension(Res.getId(Application.getContext().getPackageName(), "dimen", "default_title_indicator_title_padding")); final float defaultClipPadding = res.getDimension(Res.getId(Application.getContext().getPackageName(), "dimen", "default_title_indicator_clip_padding")); final float defaultTopPadding = res.getDimension(Res.getId(Application.getContext().getPackageName(), "dimen", "default_title_indicator_top_padding")); //Retrieve styles attributes //TypedArray a = context.obtainStyledAttributes(attrs, Res.getId(Application.getContext().getPackageName(), "styleable", "TitlePageIndicator"), defStyle, Res.getId(Application.getContext().getPackageName(), "style", "Widget_TitlePageIndicator")); TypedArray a = context.obtainStyledAttributes(attrs, Res.getIds(Application.getContext().getPackageName(), "styleable", "TitlePageIndicator"), defStyle, Res.getId(Application.getContext().getPackageName(), "style", "Widget_TitlePageIndicator")); //Retrieve the colors to be used for this view and apply them. mFooterLineHeight = a.getDimension(Res.getId(Application.getContext().getPackageName(), "styleable", "TitlePageIndicator_footerLineHeight"), defaultFooterLineHeight); mFooterIndicatorStyle = IndicatorStyle .fromValue(a.getInteger(Res.getId(Application.getContext().getPackageName(), "styleable", "TitlePageIndicator_footerIndicatorStyle"), defaultFooterIndicatorStyle)); mFooterIndicatorHeight = a.getDimension(Res.getId(Application.getContext().getPackageName(), "styleable", "TitlePageIndicator_footerIndicatorHeight"), defaultFooterIndicatorHeight); mFooterIndicatorUnderlinePadding = a.getDimension( Res.getId(Application.getContext().getPackageName(), "styleable", "TitlePageIndicator_footerIndicatorUnderlinePadding"), defaultFooterIndicatorUnderlinePadding); mFooterPadding = a.getDimension(Res.getId(Application.getContext().getPackageName(), "styleable", "TitlePageIndicator_footerPadding"), defaultFooterPadding); mTopPadding = a.getDimension(/* w w w. j av a 2 s.c o m*/ Res.getId(Application.getContext().getPackageName(), "styleable", "TitlePageIndicator_topPadding"), defaultTopPadding); mTitlePadding = a.getDimension(Res.getId(Application.getContext().getPackageName(), "styleable", "TitlePageIndicator_titlePadding"), defaultTitlePadding); mClipPadding = a.getDimension( Res.getId(Application.getContext().getPackageName(), "styleable", "TitlePageIndicator_clipPadding"), defaultClipPadding); mColorSelected = a.getColor(Res.getId(Application.getContext().getPackageName(), "styleable", "TitlePageIndicator_selectedColor"), defaultSelectedColor); mColorText = a.getColor( Res.getId(Application.getContext().getPackageName(), "styleable", "TitlePageIndicator_textColor"), defaultTextColor); mBoldText = a.getBoolean(Res.getId(Application.getContext().getPackageName(), "styleable", "TitlePageIndicator_selectedBold"), defaultSelectedBold); final float textSize = a.getDimension( Res.getId(Application.getContext().getPackageName(), "styleable", "TitlePageIndicator_textSize"), defaultTextSize); final int footerColor = a.getColor( Res.getId(Application.getContext().getPackageName(), "styleable", "TitlePageIndicator_footerColor"), defaultFooterColor); mPaintText.setTextSize(textSize); mPaintText.setAntiAlias(true); mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE); mPaintFooterLine.setStrokeWidth(mFooterLineHeight); mPaintFooterLine.setColor(footerColor); mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE); mPaintFooterIndicator.setColor(footerColor); a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:il.co.globes.android.swipeListView.SwipeListView.java
/** * Init ListView/*w ww . ja v a 2 s. com*/ * * @param attrs * AttributeSet */ private void init(AttributeSet attrs) { int swipeMode = SWIPE_MODE_BOTH; boolean swipeOpenOnLongPress = false; boolean swipeCloseAllItemsWhenMoveList = true; long swipeAnimationTime = 0; float swipeOffsetLeft = 0; float swipeOffsetRight = 0; int swipeDrawableChecked = 0; int swipeDrawableUnchecked = 0; int swipeActionLeft = SWIPE_ACTION_REVEAL; int swipeActionRight = SWIPE_ACTION_REVEAL; if (attrs != null) { TypedArray styled = getContext().obtainStyledAttributes(attrs, R.styleable.SwipeListView); swipeMode = styled.getInt(R.styleable.SwipeListView_swipeMode, SWIPE_MODE_BOTH); swipeActionLeft = styled.getInt(R.styleable.SwipeListView_swipeActionLeft, SWIPE_ACTION_REVEAL); swipeActionRight = styled.getInt(R.styleable.SwipeListView_swipeActionRight, SWIPE_ACTION_REVEAL); swipeOffsetLeft = styled.getDimension(R.styleable.SwipeListView_swipeOffsetLeft, 0); swipeOffsetRight = styled.getDimension(R.styleable.SwipeListView_swipeOffsetRight, 0); // swipeOpenOnLongPress = styled.getBoolean(R.styleable.SwipeListView_swipeOpenOnLongPress, true); swipeAnimationTime = styled.getInteger(R.styleable.SwipeListView_swipeAnimationTime, 0); swipeCloseAllItemsWhenMoveList = styled .getBoolean(R.styleable.SwipeListView_swipeCloseAllItemsWhenMoveList, true); swipeDrawableChecked = styled.getResourceId(R.styleable.SwipeListView_swipeDrawableChecked, 0); swipeDrawableUnchecked = styled.getResourceId(R.styleable.SwipeListView_swipeDrawableUnchecked, 0); swipeFrontView = styled.getResourceId(R.styleable.SwipeListView_swipeFrontView, 0); swipeBackView = styled.getResourceId(R.styleable.SwipeListView_swipeBackView, 0); } if (swipeFrontView == 0 || swipeBackView == 0) { swipeFrontView = getContext().getResources().getIdentifier(SWIPE_DEFAULT_FRONT_VIEW, "id", getContext().getPackageName()); swipeBackView = getContext().getResources().getIdentifier(SWIPE_DEFAULT_BACK_VIEW, "id", getContext().getPackageName()); if (swipeFrontView == 0 || swipeBackView == 0) { throw new RuntimeException(String.format( "You forgot the attributes swipeFrontView or swipeBackView. You can add this attributes or use '%s' and '%s' identifiers", SWIPE_DEFAULT_FRONT_VIEW, SWIPE_DEFAULT_BACK_VIEW)); } } final ViewConfiguration configuration = ViewConfiguration.get(getContext()); touchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); touchListener = new SwipeListViewTouchListener(this, swipeFrontView, swipeBackView); if (swipeAnimationTime > 0) { touchListener.setAnimationTime(swipeAnimationTime); } touchListener.setRightOffset(swipeOffsetRight); touchListener.setLeftOffset(swipeOffsetLeft); touchListener.setSwipeActionLeft(swipeActionLeft); touchListener.setSwipeActionRight(swipeActionRight); touchListener.setSwipeMode(swipeMode); touchListener.setSwipeClosesAllItemsWhenListMoves(swipeCloseAllItemsWhenMoveList); touchListener.setSwipeOpenOnLongPress(swipeOpenOnLongPress); touchListener.setSwipeDrawableChecked(swipeDrawableChecked); touchListener.setSwipeDrawableUnchecked(swipeDrawableUnchecked); setOnTouchListener(touchListener); setOnScrollListener(touchListener.makeScrollListener()); }
From source file:tk.sweetvvck.swipeview.SwipeListView.java
/** * Init ListView//from ww w . ja v a 2 s .c o m * * @param attrs * AttributeSet */ private void init(AttributeSet attrs) { setSelection(1); int swipeMode = SWIPE_MODE_BOTH; boolean swipeOpenOnLongPress = true; boolean swipeCloseAllItemsWhenMoveList = true; long swipeAnimationTime = 0; float swipeOffsetLeft = 0; float swipeOffsetRight = 0; int swipeDrawableChecked = 0; int swipeDrawableUnchecked = 0; int swipeActionLeft = SWIPE_ACTION_REVEAL; int swipeActionRight = SWIPE_ACTION_REVEAL; if (attrs != null) { TypedArray styled = getContext().obtainStyledAttributes(attrs, R.styleable.SwipeListView); swipeMode = styled.getInt(R.styleable.SwipeListView_swipeMode, SWIPE_MODE_BOTH); swipeActionLeft = styled.getInt(R.styleable.SwipeListView_swipeActionLeft, SWIPE_ACTION_REVEAL); swipeActionRight = styled.getInt(R.styleable.SwipeListView_swipeActionRight, SWIPE_ACTION_REVEAL); swipeOffsetLeft = styled.getDimension(R.styleable.SwipeListView_swipeOffsetLeft, 0); swipeOffsetRight = styled.getDimension(R.styleable.SwipeListView_swipeOffsetRight, 0); swipeOpenOnLongPress = styled.getBoolean(R.styleable.SwipeListView_swipeOpenOnLongPress, true); swipeAnimationTime = styled.getInteger(R.styleable.SwipeListView_swipeAnimationTime, 0); swipeCloseAllItemsWhenMoveList = styled .getBoolean(R.styleable.SwipeListView_swipeCloseAllItemsWhenMoveList, true); swipeDrawableChecked = styled.getResourceId(R.styleable.SwipeListView_swipeDrawableChecked, 0); swipeDrawableUnchecked = styled.getResourceId(R.styleable.SwipeListView_swipeDrawableUnchecked, 0); swipeFrontView = styled.getResourceId(R.styleable.SwipeListView_swipeFrontView, 0); swipeBackView = styled.getResourceId(R.styleable.SwipeListView_swipeBackView, 0); } if (swipeFrontView == 0 || swipeBackView == 0) { swipeFrontView = getContext().getResources().getIdentifier(SWIPE_DEFAULT_FRONT_VIEW, "id", getContext().getPackageName()); swipeBackView = getContext().getResources().getIdentifier(SWIPE_DEFAULT_BACK_VIEW, "id", getContext().getPackageName()); if (swipeFrontView == 0 || swipeBackView == 0) { throw new RuntimeException(String.format( "You forgot the attributes swipeFrontView or swipeBackView. You can add this attributes or use '%s' and '%s' identifiers", SWIPE_DEFAULT_FRONT_VIEW, SWIPE_DEFAULT_BACK_VIEW)); } } final ViewConfiguration configuration = ViewConfiguration.get(getContext()); touchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); touchListener = new SwipeListViewTouchListener(this, swipeFrontView, swipeBackView); if (swipeAnimationTime > 0) { touchListener.setAnimationTime(swipeAnimationTime); } touchListener.setRightOffset(swipeOffsetRight); touchListener.setLeftOffset(swipeOffsetLeft); touchListener.setSwipeActionLeft(swipeActionLeft); touchListener.setSwipeActionRight(swipeActionRight); touchListener.setSwipeMode(swipeMode); touchListener.setSwipeClosesAllItemsWhenListMoves(swipeCloseAllItemsWhenMoveList); touchListener.setSwipeOpenOnLongPress(swipeOpenOnLongPress); touchListener.setSwipeDrawableChecked(swipeDrawableChecked); touchListener.setSwipeDrawableUnchecked(swipeDrawableUnchecked); setOnTouchListener(touchListener); setOnScrollListener(touchListener.makeScrollListener()); }
From source file:net.opacapp.multilinecollapsingtoolbar.CollapsingToolbarLayout.java
public CollapsingToolbarLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); ThemeUtils.checkAppCompatTheme(context); mCollapsingTextHelper = new CollapsingTextHelper(this); mCollapsingTextHelper.setTextSizeInterpolator(AnimationUtils.DECELERATE_INTERPOLATOR); // BEGIN MODIFICATION: use own default style TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CollapsingToolbarLayout, defStyleAttr, net.opacapp.multilinecollapsingtoolbar.R.style.Widget_Design_MultilineCollapsingToolbar); // END MODIFICATION mCollapsingTextHelper.setExpandedTextGravity(a.getInt( R.styleable.CollapsingToolbarLayout_expandedTitleGravity, GravityCompat.START | Gravity.BOTTOM)); mCollapsingTextHelper//from ww w .j a v a2 s . com .setCollapsedTextGravity(a.getInt(R.styleable.CollapsingToolbarLayout_collapsedTitleGravity, GravityCompat.START | Gravity.CENTER_VERTICAL)); mExpandedMarginStart = mExpandedMarginTop = mExpandedMarginEnd = mExpandedMarginBottom = a .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMargin, 0); if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginStart)) { mExpandedMarginStart = a .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginStart, 0); } if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginEnd)) { mExpandedMarginEnd = a.getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginEnd, 0); } if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginTop)) { mExpandedMarginTop = a.getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginTop, 0); } if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginBottom)) { mExpandedMarginBottom = a .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginBottom, 0); } mCollapsingTitleEnabled = a.getBoolean(R.styleable.CollapsingToolbarLayout_titleEnabled, true); setTitle(a.getText(R.styleable.CollapsingToolbarLayout_title)); // First load the default text appearances mCollapsingTextHelper.setExpandedTextAppearance(R.style.TextAppearance_Design_CollapsingToolbar_Expanded); // BEGIN MODIFICATION: use own default style mCollapsingTextHelper .setCollapsedTextAppearance(net.opacapp.multilinecollapsingtoolbar.R.style.ActionBar_Title); // END MODIFICATION // Now overlay any custom text appearances if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleTextAppearance)) { mCollapsingTextHelper.setExpandedTextAppearance( a.getResourceId(R.styleable.CollapsingToolbarLayout_expandedTitleTextAppearance, 0)); } if (a.hasValue(R.styleable.CollapsingToolbarLayout_collapsedTitleTextAppearance)) { mCollapsingTextHelper.setCollapsedTextAppearance( a.getResourceId(R.styleable.CollapsingToolbarLayout_collapsedTitleTextAppearance, 0)); } mScrimVisibleHeightTrigger = a.getInt(R.styleable.CollapsingToolbarLayout_scrimVisibleHeightTrigger, -1); mScrimAnimationDuration = a.getInt(R.styleable.CollapsingToolbarLayout_scrimAnimationDuration, DEFAULT_SCRIM_ANIMATION_DURATION); setContentScrim(a.getDrawable(R.styleable.CollapsingToolbarLayout_contentScrim)); setStatusBarScrim(a.getDrawable(R.styleable.CollapsingToolbarLayout_statusBarScrim)); mToolbarId = a.getResourceId(R.styleable.CollapsingToolbarLayout_toolbarId, -1); a.recycle(); setWillNotDraw(false); ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() { @Override public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) { return setWindowInsets(insets); } }); // BEGIN MODIFICATION: set the value of maxNumberOfLines attribute to the mCollapsingTextHelper TypedArray typedArray = context.obtainStyledAttributes(attrs, net.opacapp.multilinecollapsingtoolbar.R.styleable.CollapsingToolbarLayoutExtension, defStyleAttr, 0); mCollapsingTextHelper.setMaxLines(typedArray.getInteger( net.opacapp.multilinecollapsingtoolbar.R.styleable.CollapsingToolbarLayoutExtension_maxLines, 3)); // END MODIFICATION }
From source file:com.brandroidtools.filemanager.fragments.NavigationFragment.java
/** * Method that initializes the view. This method loads all the necessary * information and create an appropriate layout for the view. * * @param tarray The type array//from w w w.ja v a 2 s . co m */ private void init(TypedArray tarray) { // Retrieve the mode this.mNavigationMode = NAVIGATION_MODE.BROWSABLE; int mode = tarray.getInteger(R.styleable.Navigable_navigation, NAVIGATION_MODE.BROWSABLE.ordinal()); if (mode >= 0 && mode < NAVIGATION_MODE.values().length) { this.mNavigationMode = NAVIGATION_MODE.values()[mode]; } // Initialize default restrictions (no restrictions) this.mRestrictions = new HashMap<DisplayRestrictions, Object>(); //Initialize variables this.mFiles = new ArrayList<FileSystemObject>(); // Is ChRooted environment? if (this.mNavigationMode.compareTo(NAVIGATION_MODE.PICKABLE) == 0) { // Pick mode is always ChRooted this.mChRooted = true; } else { this.mChRooted = FileManagerApplication.getAccessMode().compareTo(AccessMode.SAFE) == 0; } //Retrieve the default configuration if (this.mNavigationMode.compareTo(NAVIGATION_MODE.BROWSABLE) == 0) { SharedPreferences preferences = Preferences.getSharedPreferences(); int viewMode = preferences.getInt(FileManagerSettings.SETTINGS_LAYOUT_MODE.getId(), ((ObjectIdentifier) FileManagerSettings.SETTINGS_LAYOUT_MODE.getDefaultValue()).getId()); changeViewMode(NavigationLayoutMode.fromId(viewMode)); } else { // Pick mode has always a details layout changeViewMode(NavigationLayoutMode.DETAILS); } }