android.support.v4.view.InputDeviceCompat Java Examples

The following examples show how to use android.support.v4.view.InputDeviceCompat. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: X8ValueSeakBarWithTip.java    From FimiX8-RE with MIT License 6 votes vote down vote up
private void readAttr(Context context, AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.X8ValueSeakBarView);
    this.accuracy = a.getInteger(R.styleable.X8ValueSeakBarView_x8_value_accuracy, 1);
    this.title = a.getString(R.styleable.X8ValueSeakBarView_x8_value_title);
    this.suffix = a.getString(R.styleable.X8ValueSeakBarView_x8_value_suffix);
    this.closeColor = a.getColor(R.styleable.X8ValueSeakBarView_x8_value_close_color, -1);
    this.openColor = a.getColor(R.styleable.X8ValueSeakBarView_x8_value_open_color, InputDeviceCompat.SOURCE_ANY);
    this.seekBarMax = a.getFloat(R.styleable.X8ValueSeakBarView_x8_value_seekbar_max, 0.0f) * ((float) this.accuracy);
    this.seekBarMin = a.getFloat(R.styleable.X8ValueSeakBarView_x8_value_seekbar_min, 0.0f) * ((float) this.accuracy);
    this.seekBarDefault = a.getFloat(R.styleable.X8ValueSeakBarView_x8_value_seekbar_default, 0.0f);
    this.isFloat = a.getBoolean(R.styleable.X8ValueSeakBarView_x8_value_seekbar_float, false);
    a.recycle();
    if (this.isFloat) {
        this.MAX = (int) (this.seekBarMax - this.seekBarMin);
    } else {
        this.MAX = (int) (this.seekBarMax - this.seekBarMin);
    }
}
 
Example #2
Source File: X8ValueSeakBarView.java    From FimiX8-RE with MIT License 6 votes vote down vote up
private void readAttr(Context context, AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.X8ValueSeakBarView);
    this.accuracy = a.getInteger(R.styleable.X8ValueSeakBarView_x8_value_accuracy, 1);
    this.title = a.getString(R.styleable.X8ValueSeakBarView_x8_value_title);
    this.suffix = a.getString(R.styleable.X8ValueSeakBarView_x8_value_suffix);
    this.closeColor = a.getColor(R.styleable.X8ValueSeakBarView_x8_value_close_color, -1);
    this.openColor = a.getColor(R.styleable.X8ValueSeakBarView_x8_value_open_color, InputDeviceCompat.SOURCE_ANY);
    this.seekBarMax = a.getFloat(R.styleable.X8ValueSeakBarView_x8_value_seekbar_max, 0.0f) * ((float) this.accuracy);
    this.seekBarMin = a.getFloat(R.styleable.X8ValueSeakBarView_x8_value_seekbar_min, 0.0f) * ((float) this.accuracy);
    this.seekBarDefault = a.getFloat(R.styleable.X8ValueSeakBarView_x8_value_seekbar_default, 0.0f);
    this.isFloat = a.getBoolean(R.styleable.X8ValueSeakBarView_x8_value_seekbar_float, false);
    a.recycle();
    if (this.isFloat) {
        this.MAX = (int) (this.seekBarMax - this.seekBarMin);
    } else {
        this.MAX = (int) (this.seekBarMax - this.seekBarMin);
    }
}
 
Example #3
Source File: ByteHexHelper.java    From FimiX8-RE with MIT License 6 votes vote down vote up
public static byte decodeBinaryString(String byteStr) {
    if (byteStr == null) {
        return (byte) 0;
    }
    int len = byteStr.length();
    if (len != 4 && len != 8) {
        return (byte) 0;
    }
    int re;
    if (len != 8) {
        re = Integer.parseInt(byteStr, 2);
    } else if (byteStr.charAt(0) == '0') {
        re = Integer.parseInt(byteStr, 2);
    } else {
        re = Integer.parseInt(byteStr, 2) + InputDeviceCompat.SOURCE_ANY;
    }
    return (byte) re;
}
 
Example #4
Source File: MotionEventFactory.java    From FunnyDraw with Apache License 2.0 5 votes vote down vote up
static MotionEvent create(int action, long downTime, int x, int y) {
    MotionEvent event = MotionEvent.obtain(downTime, SystemClock.uptimeMillis(), action, x, y,
            1.0f,1.0f, 0, 1.0f, 1.0f, 0,
            0);
    event.setSource(InputDeviceCompat.SOURCE_TOUCHSCREEN);
    return event;
}
 
Example #5
Source File: FragmentActivity.java    From letv with Apache License 2.0 5 votes vote down vote up
public final void validateRequestPermissionsRequestCode(int requestCode) {
    if (this.mRequestedPermissionsFromFragment) {
        this.mRequestedPermissionsFromFragment = false;
    } else if ((requestCode & InputDeviceCompat.SOURCE_ANY) != 0) {
        throw new IllegalArgumentException("Can only use lower 8 bits for requestCode");
    }
}
 
Example #6
Source File: FragmentActivity.java    From letv with Apache License 2.0 5 votes vote down vote up
private void requestPermissionsFromFragment(Fragment fragment, String[] permissions, int requestCode) {
    if (requestCode == -1) {
        ActivityCompat.requestPermissions(this, permissions, requestCode);
    } else if ((requestCode & InputDeviceCompat.SOURCE_ANY) != 0) {
        throw new IllegalArgumentException("Can only use lower 8 bits for requestCode");
    } else {
        this.mRequestedPermissionsFromFragment = true;
        ActivityCompat.requestPermissions(this, permissions, ((fragment.mIndex + 1) << 8) + (requestCode & 255));
    }
}
 
Example #7
Source File: NestedScrollView.java    From MyBlogDemo with Apache License 2.0 5 votes vote down vote up
public boolean onGenericMotionEvent(MotionEvent event) {
    if ((MotionEventCompat.getSource(event) & InputDeviceCompat.SOURCE_CLASS_POINTER) != 0) {
        switch (event.getAction()) {
            case MotionEventCompat.ACTION_SCROLL: {
                if (!mIsBeingDragged) {
                    final float vscroll = MotionEventCompat.getAxisValue(event,
                            MotionEventCompat.AXIS_VSCROLL);
                    if (vscroll != 0) {
                        final int delta = (int) (vscroll * getVerticalScrollFactorCompat());
                        final int range = getScrollRange();
                        int oldScrollY = getScrollY();
                        int newScrollY = oldScrollY - delta;
                        if (newScrollY < 0) {
                            newScrollY = 0;
                        } else if (newScrollY > range) {
                            newScrollY = range;
                        }
                        if (newScrollY != oldScrollY) {
                            super.scrollTo(getScrollX(), newScrollY);
                            return true;
                        }
                    }
                }
            }
        }
    }
    return false;
}