Example usage for android.content.res TypedArray getBoolean

List of usage examples for android.content.res TypedArray getBoolean

Introduction

In this page you can find the example usage for android.content.res TypedArray getBoolean.

Prototype

public boolean getBoolean(@StyleableRes int index, boolean defValue) 

Source Link

Document

Retrieve the boolean value for the attribute at index.

Usage

From source file:com.andremion.floatingnavigationview.FloatingNavigationView.java

public FloatingNavigationView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    setImageResource(R.drawable.ic_menu_vector);

    mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);

    mNavigationView = (NavigationView) LayoutInflater.from(context).inflate(R.layout.navigation_view, null);
    mNavigationView.setOnTouchListener(mNavigationTouchListener);
    mNavigationMenuView = (NavigationMenuView) mNavigationView.findViewById(R.id.design_navigation_view);

    mFabView = (ImageView) mNavigationView.findViewById(R.id.fab_view);
    mFabView.setOnClickListener(mFabClickListener);
    mFabView.setContentDescription(getContentDescription());
    mFabView.bringToFront();//from   w  ww.ja va2  s  .c o  m

    // Custom attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MenuView, defStyleAttr,
            R.style.Widget_Design_NavigationView);
    if (a.hasValue(R.styleable.MenuView_menu)) {
        mNavigationView.inflateMenu(a.getResourceId(R.styleable.MenuView_menu, 0));
    }
    if (a.hasValue(R.styleable.MenuView_headerLayout)) {
        mNavigationView.inflateHeaderView(a.getResourceId(R.styleable.MenuView_headerLayout, 0));
    }
    mDrawMenuBelowFab = a.getBoolean(R.styleable.MenuView_drawMenuBelowFab, false);
    a.recycle();
}

From source file:com.alex.view.loop.IndicatorView.java

public IndicatorView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    // ?//w  ww  . j a v a  2  s.  com
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.IndicatorView);
    normalBp = drawableToBitamp(ta.getDrawable(R.styleable.IndicatorView_normalDrawable));
    selectBp = drawableToBitamp(ta.getDrawable(R.styleable.IndicatorView_selectDrawable));
    mInterval = ta.getDimensionPixelOffset(R.styleable.IndicatorView_indicatorInterval, 6);
    normalColor = ta.getColor(R.styleable.IndicatorView_normalColor, Color.GRAY);
    selectColor = ta.getColor(R.styleable.IndicatorView_selectColor, Color.RED);
    mRadius = ta.getInteger(R.styleable.IndicatorView_indicatorRadius, 6);
    isCirculate = ta.getBoolean(R.styleable.IndicatorView_isCirculate, true);
    ta.recycle();
    // ?
    init();

}

From source file:com.antew.redditinpictures.library.widget.SwipeListView.java

private void initialize(AttributeSet attrs) {

    // If we are in an IDE Preview, don't initialize.
    if (isInEditMode()) {
        return;//from  w  w w.j a  v  a2  s . c om
    }

    if (attrs != null) {
        TypedArray styled = getContext().obtainStyledAttributes(attrs, R.styleable.SwipeListView);
        mFrontViewId = styled.getResourceId(R.styleable.SwipeListView_frontViewId, 0);
        mBackViewId = styled.getResourceId(R.styleable.SwipeListView_backViewId, 0);
        mCloseAllWhenScrolling = styled.getBoolean(R.styleable.SwipeListView_closeAllWhenScrolling, true);
        mOpenOnLongPress = styled.getBoolean(R.styleable.SwipeListView_openOnLongPress, true);
        setSwipeDirection(styled.getInt(R.styleable.SwipeListView_swipeDirection, SWIPE_DIRECTION_BOTH));
    }

    if (mFrontViewId == 0 || mBackViewId == 0) {
        throw new RuntimeException("You must specify a Front View and Back View");
    }

    ViewConfiguration viewConfig = ViewConfiguration.get(getContext());
    mTouchSlop = viewConfig.getScaledTouchSlop();
    mMinFlingVelocity = viewConfig.getScaledMinimumFlingVelocity();
    mMaxFlingVelocity = viewConfig.getScaledMaximumFlingVelocity();
    mAnimationTime = getResources().getInteger(android.R.integer.config_shortAnimTime);

    super.setOnScrollListener(mInternalOnScrollListener);
    super.setOnItemLongClickListener(mInternalOnItemLongClickListener);
}

From source file:com.chao.facebookzc.widget.LoginButton.java

private void parseAttributes(AttributeSet attrs) {
    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.com_facebook_login_view);
    confirmLogout = a.getBoolean(R.styleable.com_facebook_login_view_confirm_logout, true);
    fetchUserInfo = a.getBoolean(R.styleable.com_facebook_login_view_fetch_user_info, true);
    loginText = a.getString(R.styleable.com_facebook_login_view_login_text);
    logoutText = a.getString(R.styleable.com_facebook_login_view_logout_text);
    a.recycle();//  w w w . j a  va2  s . c o  m
}

From source file:com.bitfyr.picassoswiperefreshlayout.PicassoSwipeRefreshLayout.java

/**
 * Constructor that is called when inflating SwipeRefreshLayout from XML.
 *
 * @param context/*w w  w  .  j a v a2  s  . c o  m*/
 * @param attrs
 */
public PicassoSwipeRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    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();

    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    mCircleWidth = (int) (CIRCLE_DIAMETER * metrics.density);
    mCircleHeight = (int) (CIRCLE_DIAMETER * metrics.density);

    createProgressView();
    ViewCompat.setChildrenDrawingOrderEnabled(this, true);
    // the absolute offset has to take into account that the circle starts at an offset
    mSpinnerFinalOffset = DEFAULT_CIRCLE_TARGET * metrics.density;
    mTotalDragDistance = mSpinnerFinalOffset;
}

From source file:com.dystu.toolbar.widget.MySwipeRefreshLayout.java

/**
 * Constructor that is called when inflating SwipeRefreshLayout from XML.
 *
 * @param context/*  w ww .java 2 s. c  o  m*/
 * @param attrs
 */
public MySwipeRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    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();

    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    mCircleWidth = (int) (CIRCLE_DIAMETER * metrics.density);
    mCircleHeight = (int) (CIRCLE_DIAMETER * metrics.density);

    createProgressView();
    ViewCompat.setChildrenDrawingOrderEnabled(this, true);
    // the absolute offset has to take into account that the circle starts at an offset
    mSpinnerFinalOffset = DEFAULT_CIRCLE_TARGET * metrics.density;
    mTotalDragDistance = mSpinnerFinalOffset;
}

From source file:com.eutectoid.dosomething.picker.PlacePickerFragment.java

@Override
public void onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState) {
    super.onInflate(activity, attrs, savedInstanceState);
    TypedArray a = activity.obtainStyledAttributes(attrs, R.styleable.picker_place_picker_fragment);

    setRadiusInMeters(a.getInt(R.styleable.picker_place_picker_fragment_radius_in_meters, radiusInMeters));
    setResultsLimit(a.getInt(R.styleable.picker_place_picker_fragment_results_limit, resultsLimit));
    if (a.hasValue(R.styleable.picker_place_picker_fragment_results_limit)) {
        setSearchText(a.getString(R.styleable.picker_place_picker_fragment_search_text));
    }//from  w  w w  . ja  va 2 s .c  om
    showSearchBox = a.getBoolean(R.styleable.picker_place_picker_fragment_show_search_box, showSearchBox);

    a.recycle();
}

From source file:com.adhere.view.swipe.SwipeRefreshLayout.java

/**
 * Constructor that is called when inflating SwipeRefreshLayout from XML.
 *
 * @param context/*ww w.  j av  a  2s  . c o  m*/
 * @param attrs
 */
public SwipeRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    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();

    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    mCircleWidth = (int) (CIRCLE_DIAMETER * metrics.density);
    mCircleHeight = (int) (CIRCLE_DIAMETER * metrics.density);

    createProgressView();
    ViewCompat.setChildrenDrawingOrderEnabled(this, true);
    // the absolute offset has to take into account that the circle starts at an offset
    mSpinnerFinalOffset = DEFAULT_CIRCLE_TARGET * metrics.density;
    mTotalDragDistance = mSpinnerFinalOffset;
}

From source file:com.example.administrator.mytest.easyRecycleView.swipe.SwipeRefreshLayout.java

/**
 * Constructor that is called when inflating SwipeRefreshLayout from XML.
 *
 * @param context/*from  ww w  . j a  v a 2  s  .c o  m*/
 * @param attrs
 */
public SwipeRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    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();

    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    mCircleWidth = (int) (CIRCLE_DIAMETER * metrics.density);
    mCircleHeight = (int) (CIRCLE_DIAMETER * metrics.density);

    createProgressView();
    ViewCompat.setChildrenDrawingOrderEnabled(this, true);
    // the absolute offset has to take into account that the circle starts at an offset
    mSpinnerFinalOffset = DEFAULT_CIRCLE_TARGET * metrics.density;
    mTotalDragDistance = mSpinnerFinalOffset;

    requestDisallowInterceptTouchEvent(true);
}