Example usage for android.view ViewConfiguration get

List of usage examples for android.view ViewConfiguration get

Introduction

In this page you can find the example usage for android.view ViewConfiguration get.

Prototype

public static ViewConfiguration get(Context context) 

Source Link

Document

Returns a configuration for the specified context.

Usage

From source file:com.example.marvin.familylink._UI.pager.CirclePageIndicator.java

public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;//w  w  w .j  a  va2  s.  c  om

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultFooterColor = res.getColor(R.color.default_title_indicator_footer_color);
    final float defaultFooterLineHeight = res.getDimension(R.dimen.default_title_indicator_footer_line_height);
    final int defaultFooterIndicatorStyle = res
            .getInteger(R.integer.default_title_indicator_footer_indicator_style);
    final float defaultFooterIndicatorHeight = res
            .getDimension(R.dimen.default_title_indicator_footer_indicator_height);
    final float defaultFooterIndicatorUnderlinePadding = res
            .getDimension(R.dimen.default_title_indicator_footer_indicator_underline_padding);
    final float defaultFooterPadding = res.getDimension(R.dimen.default_title_indicator_footer_padding);
    final int defaultSelectedColor = res.getColor(R.color.default_title_indicator_selected_color);
    final boolean defaultSelectedBold = res.getBoolean(R.bool.default_title_indicator_selected_bold);
    final int defaultTextColor = res.getColor(R.color.default_title_indicator_text_color);
    final float defaultTextSize = res.getDimension(R.dimen.default_title_indicator_text_size);
    final float defaultTitlePadding = res.getDimension(R.dimen.default_title_indicator_title_padding);
    final float defaultClipPadding = res.getDimension(R.dimen.default_title_indicator_clip_padding);
    final float defaultTopPadding = res.getDimension(R.dimen.default_title_indicator_top_padding);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TitlePageIndicator, defStyle, 0);

    //Retrieve the colors to be used for this view and apply them.
    mFooterLineHeight = a.getDimension(R.styleable.TitlePageIndicator_footerLineHeight,
            defaultFooterLineHeight);
    mFooterIndicatorStyle = IndicatorStyle.fromValue(
            a.getInteger(R.styleable.TitlePageIndicator_footerIndicatorStyle, defaultFooterIndicatorStyle));
    mFooterIndicatorHeight = a.getDimension(R.styleable.TitlePageIndicator_footerIndicatorHeight,
            defaultFooterIndicatorHeight);
    mFooterIndicatorUnderlinePadding = a.getDimension(
            R.styleable.TitlePageIndicator_footerIndicatorUnderlinePadding,
            defaultFooterIndicatorUnderlinePadding);
    mFooterPadding = a.getDimension(R.styleable.TitlePageIndicator_footerPadding, defaultFooterPadding);
    mTopPadding = a.getDimension(R.styleable.TitlePageIndicator_topPadding, defaultTopPadding);
    mTitlePadding = a.getDimension(R.styleable.TitlePageIndicator_titlePadding, defaultTitlePadding);
    mClipPadding = a.getDimension(R.styleable.TitlePageIndicator_clipPadding, defaultClipPadding);
    mColorSelected = a.getColor(R.styleable.TitlePageIndicator_selectedColor, defaultSelectedColor);
    mColorText = a.getColor(R.styleable.TitlePageIndicator_android_textColor, defaultTextColor);
    mBoldText = a.getBoolean(R.styleable.TitlePageIndicator_selectedBold, defaultSelectedBold);

    final float textSize = a.getDimension(R.styleable.TitlePageIndicator_android_textSize, defaultTextSize);
    final int footerColor = a.getColor(R.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:com.baitouwei.swiperefresh.ASwipeRefreshLayout.java

private void init() {
    if (headerInterpolator == null) {
        headerInterpolator = new DecelerateInterpolator();
    }//from  w  w  w  . j a va2 s .  co  m
    if (footerInterpolator == null) {
        footerInterpolator = new DecelerateInterpolator();
    }
    touchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
    if (headerView == null || footerView == null) {
        headerView = new DefaultSwipeView(getContext());
        footerView = new DefaultSwipeView(getContext());
        SwipeRefreshHelp.buildDrawerSwipeRefreshLayout(this);
    }

    addView(headerView);
    addView(footerView);
    headerView.setVisibility(INVISIBLE);
    footerView.setVisibility(INVISIBLE);

    setWillNotDraw(true);
    ViewCompat.setChildrenDrawingOrderEnabled(this, true);
}

From source file:com.bullmobi.message.ui.fragments.EasyNotificationFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Resources res = getResources();
    mConfigWidgetPinDuration = res.getInteger(R.integer.config_maxPinTime);
    mConfigWidgetSelectDelay = res.getInteger(R.integer.config_iconSelectDelayMillis);
    ViewConfiguration vc = ViewConfiguration.get(getActivity());
    mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity();
    mMinFlingVelocity = vc.getScaledMinimumFlingVelocity();

    // Clock widget
    mClockWidget = new ClockWidget(this, this);

    // Media widget
    mMediaController = MediaController2.newInstance(getActivity());
    mMediaWidget = new MediaWidget(this, this);

    // Transitions
    if (Device.hasKitKatApi()) {
        mTransitionJit = new TransitionSet().setOrdering(TransitionSet.ORDERING_TOGETHER)
                .addTransition(new Fade()).addTransition(new ChangeBounds());
        mTransitionSwitchScene = new TransitionSet().setOrdering(TransitionSet.ORDERING_TOGETHER)
                .addTransition(new Fade(Fade.OUT).setDuration(200))
                .addTransition(new Fade(Fade.IN).setStartDelay(80))
                .addTransition(new ChangeBounds().setStartDelay(80));
    }/*from  w ww.j av a2s  . c om*/

    // Timeout
    mTimeout = isNotDemo() ? mActivityAcd.getTimeout() : new Timeout();
}

From source file:android.support.v7ox.widget.SwitchCompat.java

/**
 * Construct a new Switch with a default style determined by the given theme attribute,
 * overriding specific style attributes as requested.
 *
 * @param context The Context that will determine this widget's theming.
 * @param attrs Specification of attributes that should deviate from the default styling.
 * @param defStyleAttr An attribute in the current theme that contains a
 *        reference to a style resource that supplies default values for
 *        the view. Can be 0 to not look for defaults.
 *//*  ww  w .j a v a  2 s  .c  om*/
public SwitchCompat(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);

    final Resources res = getResources();
    mTextPaint.density = res.getDisplayMetrics().density;

    final TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs, R.styleable.SwitchCompat,
            defStyleAttr, 0);
    mThumbDrawable = a.getDrawable(R.styleable.SwitchCompat_android_thumb);
    if (mThumbDrawable != null) {
        mThumbDrawable.setCallback(this);
    }
    mTrackDrawable = a.getDrawable(R.styleable.SwitchCompat_track);
    if (mTrackDrawable != null) {
        mTrackDrawable.setCallback(this);
    }
    mTextOn = a.getText(R.styleable.SwitchCompat_android_textOn);
    mTextOff = a.getText(R.styleable.SwitchCompat_android_textOff);
    mShowText = a.getBoolean(R.styleable.SwitchCompat_showText, true);
    mThumbTextPadding = a.getDimensionPixelSize(R.styleable.SwitchCompat_thumbTextPadding, 0);
    mSwitchMinWidth = a.getDimensionPixelSize(R.styleable.SwitchCompat_switchMinWidth, 0);
    mSwitchPadding = a.getDimensionPixelSize(R.styleable.SwitchCompat_switchPadding, 0);
    mSplitTrack = a.getBoolean(R.styleable.SwitchCompat_splitTrack, false);

    final int appearance = a.getResourceId(R.styleable.SwitchCompat_switchTextAppearance, 0);
    if (appearance != 0) {
        setSwitchTextAppearance(context, appearance);
    }

    mDrawableManager = AppCompatDrawableManager.get();

    a.recycle();

    final ViewConfiguration config = ViewConfiguration.get(context);
    mTouchSlop = config.getScaledTouchSlop();
    mMinFlingVelocity = config.getScaledMinimumFlingVelocity();

    // Refresh display with current params
    refreshDrawableState();
    setChecked(isChecked());
}

From source file:caesar.feng.framework.widget.StaggeredGrid.ExtendableListView.java

public ExtendableListView(final Context context, final AttributeSet attrs, final int defStyle) {
    super(context, attrs, defStyle);

    // setting up to be a scrollable view group
    setWillNotDraw(false);/* w  ww  . j a v a 2 s . com*/
    setClipToPadding(false);
    setFocusableInTouchMode(false);

    final ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
    mTouchSlop = viewConfiguration.getScaledTouchSlop();
    mMaximumVelocity = viewConfiguration.getScaledMaximumFlingVelocity();
    mFlingVelocity = viewConfiguration.getScaledMinimumFlingVelocity();

    mRecycleBin = new RecycleBin();
    mObserver = new AdapterDataSetObserver();

    mHeaderViewInfos = new ArrayList<FixedViewInfo>();
    mFooterViewInfos = new ArrayList<FixedViewInfo>();

    // start our layout mode drawing from the top
    mLayoutMode = LAYOUT_NORMAL;
}

From source file:com.android.dialer.widget.OverlappingPaneLayout.java

public OverlappingPaneLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final float density = context.getResources().getDisplayMetrics().density;
    mOverhangSize = (int) (DEFAULT_OVERHANG_SIZE * density + 0.5f);

    setWillNotDraw(false);//from   w w w.  j  a  v  a  2 s  .c  o m

    ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate());

    mDragHelper = ViewDragHelper.create(this, 0.5f, new DragHelperCallback());
    mDragHelper.setMinVelocity(MIN_FLING_VELOCITY * density);

    mReleaseScrollSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
}

From source file:android.support.v7.widget.SwitchCompat.java

/**
 * Construct a new Switch with a default style determined by the given theme attribute,
 * overriding specific style attributes as requested.
 *
 * @param context The Context that will determine this widget's theming.
 * @param attrs Specification of attributes that should deviate from the default styling.
 * @param defStyleAttr An attribute in the current theme that contains a
 *        reference to a style resource that supplies default values for
 *        the view. Can be 0 to not look for defaults.
 *///  w  ww. j  ava 2  s . co  m
public SwitchCompat(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);

    final Resources res = getResources();
    mTextPaint.density = res.getDisplayMetrics().density;

    final TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs, R.styleable.SwitchCompat,
            defStyleAttr, 0);
    mThumbDrawable = a.getDrawable(R.styleable.SwitchCompat_android_thumb);
    if (mThumbDrawable != null) {
        mThumbDrawable.setCallback(this);
    }
    mTrackDrawable = a.getDrawable(R.styleable.SwitchCompat_track);
    if (mTrackDrawable != null) {
        mTrackDrawable.setCallback(this);
    }
    mTextOn = a.getText(R.styleable.SwitchCompat_android_textOn);
    mTextOff = a.getText(R.styleable.SwitchCompat_android_textOff);
    mShowText = a.getBoolean(R.styleable.SwitchCompat_showText, true);
    mThumbTextPadding = a.getDimensionPixelSize(R.styleable.SwitchCompat_thumbTextPadding, 0);
    mSwitchMinWidth = a.getDimensionPixelSize(R.styleable.SwitchCompat_switchMinWidth, 0);
    mSwitchPadding = a.getDimensionPixelSize(R.styleable.SwitchCompat_switchPadding, 0);
    mSplitTrack = a.getBoolean(R.styleable.SwitchCompat_splitTrack, false);

    final int appearance = a.getResourceId(R.styleable.SwitchCompat_switchTextAppearance, 0);
    if (appearance != 0) {
        setSwitchTextAppearance(context, appearance);
    }

    mTintManager = a.getTintManager();

    a.recycle();

    final ViewConfiguration config = ViewConfiguration.get(context);
    mTouchSlop = config.getScaledTouchSlop();
    mMinFlingVelocity = config.getScaledMinimumFlingVelocity();

    // Refresh display with current params
    refreshDrawableState();
    setChecked(isChecked());
}

From source file:com.ichi2.anki.Reviewer.java

@SuppressLint("NewApi")
@Override/*from ww w .jav a  2 s.  c  om*/
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.reviewer, menu);
    Resources res = getResources();
    if (mCurrentCard != null && mCurrentCard.note().hasTag("marked")) {
        menu.findItem(R.id.action_mark_card).setTitle(R.string.menu_unmark_note)
                .setIcon(R.drawable.ic_star_white_24dp);
    } else {
        menu.findItem(R.id.action_mark_card).setTitle(R.string.menu_mark_note)
                .setIcon(R.drawable.ic_star_outline_white_24dp);
    }
    if (colIsOpen() && getCol().undoAvailable()) {
        menu.findItem(R.id.action_undo).setEnabled(true).getIcon().setAlpha(Themes.ALPHA_ICON_ENABLED_LIGHT);
    } else {
        menu.findItem(R.id.action_undo).setEnabled(false).getIcon().setAlpha(Themes.ALPHA_ICON_DISABLED_LIGHT);
    }
    if (mPrefWhiteboard) {
        // Don't force showing mark icon when whiteboard enabled
        // TODO: allow user to customize which icons are force-shown
        MenuItemCompat.setShowAsAction(menu.findItem(R.id.action_mark_card),
                MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
        // Check if we can forceably squeeze in 3 items into the action bar, if not hide "show whiteboard"
        if (CompatHelper.getSdkVersion() >= 14 && !ViewConfiguration.get(this).hasPermanentMenuKey()) {
            // Android 4.x device with overflow menu in the action bar and small screen can't
            // support forcing 2 extra items into the action bar
            Display display = getWindowManager().getDefaultDisplay();
            DisplayMetrics outMetrics = new DisplayMetrics();
            display.getMetrics(outMetrics);
            float density = getResources().getDisplayMetrics().density;
            float dpWidth = outMetrics.widthPixels / density;
            if (dpWidth < 360) {
                menu.findItem(R.id.action_hide_whiteboard).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
            }
        }
        // Configure the whiteboard related items in the action bar
        menu.findItem(R.id.action_enable_whiteboard).setTitle(R.string.disable_whiteboard);
        menu.findItem(R.id.action_hide_whiteboard).setVisible(true);
        menu.findItem(R.id.action_clear_whiteboard).setVisible(true);

        Drawable whiteboardIcon = getResources().getDrawable(R.drawable.ic_gesture_white_24dp);
        if (mShowWhiteboard) {
            whiteboardIcon.setAlpha(255);
            menu.findItem(R.id.action_hide_whiteboard).setIcon(whiteboardIcon);
            menu.findItem(R.id.action_hide_whiteboard).setTitle(R.string.hide_whiteboard);
        } else {
            whiteboardIcon.setAlpha(77);
            menu.findItem(R.id.action_hide_whiteboard).setIcon(whiteboardIcon);
            menu.findItem(R.id.action_hide_whiteboard).setTitle(R.string.show_whiteboard);
        }
    } else {
        menu.findItem(R.id.action_enable_whiteboard).setTitle(R.string.enable_whiteboard);
    }
    if (!CompatHelper.isHoneycomb() && !mDisableClipboard) {
        menu.findItem(R.id.action_search_dictionary).setVisible(true)
                .setEnabled(!(mPrefWhiteboard && mShowWhiteboard))
                .setTitle(clipboardHasText() ? Lookup.getSearchStringTitle()
                        : res.getString(R.string.menu_select));
    }
    if (getCol().getDecks().isDyn(getParentDid())) {
        menu.findItem(R.id.action_open_deck_options).setVisible(false);
    }
    return super.onCreateOptionsMenu(menu);
}

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

/**
 * Constructor that is called when inflating SwipeRefreshLayout from XML.
 *
 * @param context//from  w ww . ja v  a 2s  .  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.android.mail.browse.ConversationContainer.java

public ConversationContainer(Context c, AttributeSet attrs) {
    super(c, attrs);

    mOverlayViews = new SparseArray<OverlayView>();

    mVelocityTracker = new InputSmoother(c);

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

    // Disabling event splitting fixes pinch-zoom when the first pointer goes down on the
    // WebView and the second pointer goes down on an overlay view.
    // Intercepting ACTION_POINTER_DOWN events allows pinch-zoom to work when the first pointer
    // goes down on an overlay view.
    setMotionEventSplittingEnabled(false);
}