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.asc_ii.bangnote.bigbang.BigBangLayout.java

private void readAttribute(AttributeSet attrs) {
    if (attrs != null) {
        TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.BigBangLayout);
        mItemSpace = typedArray.getDimensionPixelSize(R.styleable.BigBangLayout_itemSpace,
                getResources().getDimensionPixelSize(R.dimen.big_bang_default_item_space));
        mLineSpace = typedArray.getDimensionPixelSize(R.styleable.BigBangLayout_lineSpace,
                getResources().getDimensionPixelSize(R.dimen.big_bang_default_line_space));
        mItemTextSize = typedArray.getDimensionPixelSize(R.styleable.BigBangLayout_textSize,
                getResources().getDimensionPixelSize(R.dimen.big_bang_default_text_size));
        typedArray.recycle();//from w  w  w  .j  a  v  a2s.  c o  m
        mActionBarBottomHeight = mLineSpace;
        mActionBarTopHeight = getResources().getDimensionPixelSize(R.dimen.big_bang_action_bar_height);
    }

    mActionBar = new BigBangActionBar(getContext());
    mActionBar.setVisibility(View.GONE);
    mActionBar.setActionListener(this);

    addView(mActionBar, 0);

    setClipChildren(false);

    mScaledTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();

    if (isInEditMode()) {
        // ?
        addTextItem("BigBang");
        addTextItem("");
        addTextItem("");
        addTextItem("?");
        addTextItem("");
        addTextItem("");
        addTextItem("");
        addTextItem("?");
    }
}

From source file:com.halloon.android.util.UnderLinePageIndicator.java

public UnderLinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;//w  w  w.j av  a 2 s .  co  m

    final Resources res = getResources();

    // Load defaults from resources
    final boolean defaultFades = res.getBoolean(R.bool.default_underline_indicator_fades);
    final int defaultFadeDelay = res.getInteger(R.integer.default_underline_indicator_fade_delay);
    final int defaultFadeLength = res.getInteger(R.integer.default_underline_indicator_fade_length);
    final int defaultSelectedColor = res.getColor(R.color.default_underline_indicator_selected_color);

    setFades(defaultFades);
    setSelectedColor(defaultSelectedColor);
    setFadeDelay(defaultFadeDelay);
    setFadeLength(defaultFadeLength);

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:com.app.gongza.libs.view.scrollablelayout.ScrollableLayout.java

private void init(Context context) {
    mHelper = new ScrollableHelper();
    mScroller = new Scroller(context);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = configuration.getScaledTouchSlop();
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
}

From source file:com.cttapp.bby.mytlc.layer8apps.MyTlc.java

/************
 *  PURPOSE: Primary thread that starts everything
 *  ARGUMENTS: <Bundle> savedInstanceState
 *  RETURNS: void/*ww  w .j a  va 2  s.  co  m*/
 *  AUTHOR: Casey Stark <starkca90@gmail.com>, Devin Collins <agent14709@gmail.com>, Bobby Ore <bob1987@gmail.com>
 ************/
@Override
public void onCreate(Bundle savedInstanceState) {

    /*************
     * The following try statement makes the app think that the user doesn't
     * have a hard settings button.  This allows the options menu to always be
     * visible
     ************/

    currentMyTLCActivity = this;

    try {
        // Get the configuration of the device
        ViewConfiguration config = ViewConfiguration.get(this);
        // Check if the phone has a hard settings key
        Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
        // If it does...
        if (menuKeyField != null) {
            // Make our app think it doesn't!
            menuKeyField.setAccessible(true);
            menuKeyField.setBoolean(config, false);
        }
    } catch (Exception ex) {
        // Do nothing
    }

    // Create a new preferences manager
    pf = new Preferences(this);
    // Set the theme of the app
    int logo = applyTheme();
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    ImageView imgLogo = (ImageView) findViewById(R.id.logo);

    imgLogo.setImageDrawable(getResources().getDrawable(logo));

    txtUsername = (EditText) findViewById(R.id.txtUsername);
    txtUsername.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    txtPassword = (EditText) findViewById(R.id.txtPassword);
    //        remember = (CheckBox) findViewById(R.id.remember);
    results = (TextView) findViewById(R.id.results);

    // Get a reference to our last handler
    final Object handler = getLastCustomNonConfigurationInstance();
    // If the last handler existed
    if (handler != null) {
        // Cast the handler to MyHandler so we can use it
        mHandler = (MyHandler) handler;
    } else {
        // Otherwise create a new handler
        mHandler = new MyHandler();
    }
    // Assign the activity for our handler so it knows the proper reference
    mHandler.setActivity(this);

    // Load all of the users saved options
    checkSavedSettings();

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());

    System.out.println("Saved Shifts:\n" + pf.getJSONString());

    loginButton = (Button) findViewById(R.id.loginButton);
    loginButton.setOnClickListener(this);

    // Show the ads
    //showAds();
}

From source file:com.example.client.activity.imported.ViewPagerTab2Activity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_viewpagertab2);

    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));

    ViewCompat.setElevation(findViewById(R.id.header), getResources().getDimension(R.dimen.toolbar_elevation));
    mToolbarView = findViewById(R.id.toolbar);
    mPagerAdapter = new NavigationAdapter(getSupportFragmentManager());
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mPagerAdapter);/*from www.  ja  v a  2 s  .  co m*/
    // Padding for ViewPager must be set outside the ViewPager itself
    // because with padding, EdgeEffect of ViewPager become strange.
    final int tabHeight = getResources().getDimensionPixelSize(R.dimen.tab_height);
    findViewById(R.id.pager_wrapper).setPadding(0, getActionBarSize() + tabHeight, 0, 0);

    SlidingTabLayout slidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tabs);
    slidingTabLayout.setCustomTabView(R.layout.tab_indicator, android.R.id.text1);
    slidingTabLayout.setSelectedIndicatorColors(getResources().getColor(R.color.accent));
    slidingTabLayout.setDistributeEvenly(true);
    slidingTabLayout.setViewPager(mPager);

    ViewConfiguration vc = ViewConfiguration.get(this);
    mSlop = vc.getScaledTouchSlop();
    mInterceptionLayout = (TouchInterceptionFrameLayout) findViewById(R.id.container);
    mInterceptionLayout.setScrollInterceptionListener(mInterceptionListener);
}

From source file:com.brandon.mailbox.RecyclerSwipeListener.java

/**
 * Constructs a new swipe touch listener for the given {@link android.support.v7.widget.RecyclerView}
 *
 * @param recyclerView The recycler view whose items should be dismissable by swiping.
 * @param listener     The listener for the swipe events.
 *//*  w  ww  .j av  a2 s . c o m*/
public RecyclerSwipeListener(RecyclerView recyclerView, SwipeListener listener) {
    ViewConfiguration vc = ViewConfiguration.get(recyclerView.getContext());
    mSlop = vc.getScaledTouchSlop();
    mMinFlingVelocity = vc.getScaledMinimumFlingVelocity() * 16;
    mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity();
    mAnimationTime = recyclerView.getContext().getResources()
            .getInteger(android.R.integer.config_shortAnimTime);
    mRecyclerView = recyclerView;
    mSwipeListener = listener;
    /**
     * This will ensure that this SwipeableRecyclerViewTouchListener is paused during list view scrolling.
     * If a scroll listener is already assigned, the caller should still pass scroll changes through
     * to this listener.
     */
    mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            setEnabled(newState != RecyclerView.SCROLL_STATE_DRAGGING);
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
        }
    });
}

From source file:com.easemob.easeui.widget.viewpagerindicator.CirclePageIndicator.java

public CirclePageIndicator(Context context, AttributeSet attrs) {
    super(context, attrs);
    if (isInEditMode())
        return;//w  w  w  .  j a  v  a2  s .  c  o  m
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleIndicator);
    mCentered = a.getBoolean(R.styleable.CircleIndicator_mCentered, true);
    mOrientation = a.getInt(R.styleable.CircleIndicator_android_orientation, 0);
    mPaintPageFill.setStyle(Style.FILL);
    mPaintPageFill.setColor(a.getColor(R.styleable.CircleIndicator_mPageColor, 0xa0000000));
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(a.getColor(R.styleable.CircleIndicator_mStrokeColor, 0xFFDDDDDD));
    mPaintStroke.setStrokeWidth(0); // 1dip
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(R.styleable.CircleIndicator_mFillColor, 0xFFff5f19)); // 0xFFFFFFFF
    mRadius = a.getDimension(R.styleable.CircleIndicator_mRadius, 20); //3dip
    mSnap = a.getBoolean(R.styleable.CircleIndicator_mSnap, true);

    Drawable background = a.getDrawable(R.styleable.CircleIndicator_android_background);
    if (background != null) {
        setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);

}

From source file:com.fortysevendeg.android.swipelistview.SwipeListViewTouchListener.java

/**
 * Constructor//from   w w  w  .j a  v a 2s . com
 * @param swipeListView SwipeListView
 * @param swipeFrontView front view Identifier
 * @param swipeBackView back view Identifier
 */
public SwipeListViewTouchListener(SwipeListView swipeListView, int swipeFrontView, int swipeBackView) {
    mSwipeFrontView = swipeFrontView;
    mSwipeBackView = swipeBackView;
    ViewConfiguration vc = ViewConfiguration.get(swipeListView.getContext());
    mSlop = vc.getScaledTouchSlop();
    mMinFlingVelocity = vc.getScaledMinimumFlingVelocity();
    mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity();
    mAnimationTime = swipeListView.getContext().getResources()
            .getInteger(android.R.integer.config_shortAnimTime);
    this.mSwipeListView = swipeListView;
}

From source file:com.android.photos.views.GalleryThumbnailView.java

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

    final ViewConfiguration vc = ViewConfiguration.get(context);
    mTouchSlop = vc.getScaledTouchSlop();
    mMaximumVelocity = vc.getScaledMaximumFlingVelocity();
    mFlingVelocity = vc.getScaledMinimumFlingVelocity();
    mScroller = new OverScroller(context);

    mLeftEdge = new EdgeEffectCompat(context);
    mRightEdge = new EdgeEffectCompat(context);
    setWillNotDraw(false);/* ww w.  j  a  v a 2 s  . co m*/
    setClipToPadding(false);
}

From source file:com.cyou.cma.clockscreen.widget.LinePageIndicator.java

public LinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/* w w  w. j  a  v  a  2 s  . com*/

    final Resources res = getResources();
    mDrawableUnselected = res.getDrawable(R.drawable.indicator_normal);
    mDrawableSelected = res.getDrawable(R.drawable.indicator_selected);
    // Load defaults from resources
    final int defaultSelectedColor = res.getColor(R.color.default_line_indicator_selected_color);
    final int defaultUnselectedColor = res.getColor(R.color.default_line_indicator_unselected_color);
    final float defaultLineWidth = res.getDimension(R.dimen.default_line_indicator_line_width);
    final float defaultGapWidth = res.getDimension(R.dimen.default_line_indicator_gap_width);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_line_indicator_stroke_width);
    final boolean defaultCentered = res.getBoolean(R.bool.default_line_indicator_centered);

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

    mCentered = defaultCentered;
    mLineWidth = defaultLineWidth;
    mGapWidth = defaultGapWidth;
    setStrokeWidth(defaultStrokeWidth);
    mPaintUnselected.setColor(defaultUnselectedColor);
    mPaintSelected.setColor(defaultSelectedColor);

    // Drawable background = a
    // .getDrawable(R.styleable.LinePageIndicator_android_background);
    // if (background != null) {
    // setBackgroundDrawable(background);
    // }

    // a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}