List of usage examples for android.content.res TypedArray getBoolean
public boolean getBoolean(@StyleableRes int index, boolean defValue)
From source file:android.support.v7ox.widget.ButtonBarLayout.java
public ButtonBarLayout(Context context, AttributeSet attrs) { super(context, attrs); final TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.ButtonBarLayout); mAllowStacking = ta.getBoolean(R.styleable.ButtonBarLayout_allowStacking, false); ta.recycle();// w ww . ja v a 2s . com }
From source file:com.example.zhangyangjing.roundcornerimageview.BezelImageView.java
public BezelImageView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // Attribute initialization final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BezelImageView, defStyle, 0); mDesaturateOnPress = a.getBoolean(R.styleable.BezelImageView_desaturateOnPress, mDesaturateOnPress); mCornerRadius = a.getDimension(R.styleable.BezelImageView_cornerRadius, mCornerRadius); a.recycle();//w w w . jav a 2s .c om mDesaturatePaint = new Paint(); mMaskedPaint = new Paint(); mMaskedPaint.setAntiAlias(true); mMaskedPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); // Always want a cache allocated. mCacheBitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); if (mDesaturateOnPress) { // Create a desaturate color filter for pressed state. ColorMatrix cm = new ColorMatrix(); cm.setSaturation(0); mDesaturateColorFilter = new ColorMatrixColorFilter(cm); } }
From source file:com.example.igorklimov.popularmoviesdemo.fragments.MoviesGridFragment.java
@Override public void onInflate(Context context, AttributeSet attrs, Bundle savedInstanceState) { super.onInflate(context, attrs, savedInstanceState); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MoviesGridFragment, 0, 0); mHoldForTransition = a.getBoolean(R.styleable.MoviesGridFragment_sharedElementTransitions, false); mIsTablet = !mHoldForTransition;// w w w .j a v a2 s.co m a.recycle(); }
From source file:android.support.design.widget.BottomSheetDialog.java
boolean shouldWindowCloseOnTouchOutside() { if (!mCanceledOnTouchOutsideSet) { if (Build.VERSION.SDK_INT < 11) { mCanceledOnTouchOutside = true; } else {//from www . j a v a 2 s .co m TypedArray a = getContext() .obtainStyledAttributes(new int[] { android.R.attr.windowCloseOnTouchOutside }); mCanceledOnTouchOutside = a.getBoolean(0, true); a.recycle(); } mCanceledOnTouchOutsideSet = true; } return mCanceledOnTouchOutside; }
From source file:com.chronosystems.nearbyapp.components.loader.ProgressView.java
/** * Constructor that is called when inflating SwipeRefreshLayout from XML. * * @param context//ww w. j a v a2s .c om * @param attrs */ public ProgressView(Context context, AttributeSet attrs) { super(context, attrs); init(CIRCLE_BG_LIGHT, CIRCLE_DIAMETER / 2); mProgress = new MaterialProgressDrawable(getContext(), this); mProgress.setBackgroundColor(CIRCLE_BG_LIGHT); setImageDrawable(mProgress); setColorSchemeResources(AppConstants.LOADER.DEFAULT_COLORS); setVisibility(View.GONE); mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime); setWillNotDraw(false); mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR); final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS); setEnabled(a.getBoolean(0, true)); a.recycle(); }
From source file:cn.ieclipse.af.view.ScrollLayout.java
private void init(Context context, AttributeSet attrs) { if (attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrollLayout); debug = a.getBoolean(R.styleable.ScrollLayout_debug, false); mSnapVelocity = a.getInt(R.styleable.ScrollLayout_snapVelocity, SNAP_VELOCITY); a.recycle();/*from w ww. j a va 2 s. c om*/ } }
From source file:com.dictionary.codebhak.LangTextView.java
/** * Constructs a new {@code LangTextView}. * * @param context the {@link Context} to use * @param attrs the {@link AttributeSet} to use *//*from w ww. j a v a2 s. co m*/ public LangTextView(Context context, AttributeSet attrs) { super(context, attrs); TypedArray attrArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.lang_text_view, 0, 0); try { int attribute = R.styleable.lang_text_view_allowTextSizeChanges; mAllowTextSizeChanges = attrArray.getBoolean(attribute, true); } finally { attrArray.recycle(); } setFont(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); prefs.registerOnSharedPreferenceChangeListener(this); }
From source file:com.artemchep.horario.ui.fragments.details.TeacherDetailsFragment.java
@Override public void onCreate(@Nullable Bundle savedState) { super.onCreate(savedState); // Load theme color TypedArray a = getActivity().getTheme().obtainStyledAttributes(new int[] { R.attr.is_dark_theme }); mIsDarkTheme = a.getBoolean(0, false); a.recycle();//from ww w. j av a 2s . com }
From source file:com.fimagena.filepicker.FilePickerFragment.java
@Override public void onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState) { super.onInflate(activity, attrs, savedInstanceState); if ((savedInstanceState != null) && savedInstanceState.containsKey(KEY_PARAMS)) { mParams = (BitSet) savedInstanceState.getSerializable(KEY_PARAMS); mStartPath = new File(savedInstanceState.getString(KEY_CURRENT_PATH)); } else {//w w w.ja va 2 s. co m // read xml custom-attributes TypedArray attrArray = activity.obtainStyledAttributes(attrs, R.styleable.FilePickerFragment); mParams = new BitSet(4); mParams.set(SELECT_FILE, attrArray.getBoolean(R.styleable.FilePickerFragment_select_file, false)); mParams.set(SELECT_DIR, attrArray.getBoolean(R.styleable.FilePickerFragment_select_dir, false)); mParams.set(ALLOW_CREATE_DIR, attrArray.getBoolean(R.styleable.FilePickerFragment_allow_dir_create, false)); mParams.set(ALLOW_MULTIPLE_SELECT, attrArray.getBoolean(R.styleable.FilePickerFragment_allow_multiple, false)); if (!mParams.get(SELECT_FILE) && !mParams.get(SELECT_DIR)) mParams.set(SELECT_FILE, true); if (attrArray.hasValue(R.styleable.FilePickerFragment_start_path)) mStartPath = new File(attrArray.getText(R.styleable.FilePickerFragment_start_path).toString()); else mStartPath = Environment.getExternalStorageDirectory(); attrArray.recycle(); } }
From source file:com.cyanogenmod.eleven.widgets.ViewPagerTabs.java
public ViewPagerTabs(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setFillViewport(true);/* w ww . j a v a2 s. c o m*/ mSidePadding = (int) (getResources().getDisplayMetrics().density * TAB_SIDE_PADDING_IN_DPS); final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); mTextSize = a.getDimensionPixelSize(0, 0); mTextStyle = a.getInt(1, 0); mTextColor = a.getColorStateList(2); mTextAllCaps = a.getBoolean(3, false); mTabStrip = new ViewPagerTabStrip(context); addView(mTabStrip, new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT)); a.recycle(); // enable shadow casting from view bounds setOutlineProvider(VIEW_BOUNDS_OUTLINE_PROVIDER); }