use of android.view.GestureDetector in project material by rey5137.
the class BottomSheetDialog method init.
private void init(Context context, int style) {
mContainer = new ContainerFrameLayout(context);
cancelable(true);
canceledOnTouchOutside(true);
onCreate();
applyStyle(style);
mMinFlingVelocity = ViewConfiguration.get(context).getScaledMinimumFlingVelocity() * 2;
mGestureDetector = new GestureDetector(context, new GestureDetector.OnGestureListener() {
@Override
public boolean onDown(MotionEvent e) {
return false;
}
@Override
public void onShowPress(MotionEvent e) {
}
@Override
public boolean onSingleTapUp(MotionEvent e) {
return false;
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
return false;
}
@Override
public void onLongPress(MotionEvent e) {
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if (velocityY > mMinFlingVelocity) {
dismiss();
return true;
}
return false;
}
});
super.setContentView(mContainer);
}
use of android.view.GestureDetector in project weiciyuan by qii.
the class SwipeFrameLayout method init.
private void init() {
scroller = new OverScroller(getContext(), new DecelerateInterpolator());
setBackground(ThemeUtility.getDrawable(android.R.attr.windowBackground));
this.activity = (Activity) getContext();
this.topView = ((View) (activity.findViewById(android.R.id.content).getParent()));
this.max_motion_event_down_x_position = Utility.dip2px(25);
this.gestureDetector = new GestureDetector(getContext(), new SwipeRightToCloseOnGestureListener());
this.setId(R.id.swipe_framelayout);
}
use of android.view.GestureDetector in project Float-Bar by tianzhijiexian.
the class FloatService method createFloatView.
////////////////////////////////////////////////////////////////////////////
private void createFloatView() {
wmParams = Util.getParams(wmParams);
// 悬浮窗默认显示以左上角为起始坐标
wmParams.gravity = Gravity.RIGHT | Gravity.TOP;
if (!prefs.isRightMode()) {
wmParams.gravity = Gravity.LEFT | Gravity.TOP;
}
// 以屏幕右上角为原点,设置x、y初始值,确定显示窗口的起始位置
wmParams.x = 0;
wmParams.y = 0;
mWindowManager = (WindowManager) service.getSystemService(Context.WINDOW_SERVICE);
LayoutInflater inflater = LayoutInflater.from(service);
// 获取浮动窗口视图所在布局
mFloatLayout = (LinearLayout) inflater.inflate(R.layout.floating, null);
// 添加悬浮窗的视图
mWindowManager.addView(mFloatLayout, wmParams);
/**
* 设置悬浮窗的点击、滑动事件
*/
sampleFloat = (ImageButton) mFloatLayout.findViewById(R.id.float_button_id);
sampleFloat.getBackground().setAlpha(150);
sampleFloat.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
prefs.doTouch(service);
}
});
/**
* 设置有无反馈
*/
MyOnGestureListener listener = new MyOnGestureListener();
@SuppressWarnings("deprecation") final GestureDetector mGestureDetector = new GestureDetector(listener);
sampleFloat.setOnTouchListener(new MyOnTouchListener(mGestureDetector));
}
use of android.view.GestureDetector in project Shuttle by timusus.
the class ArtworkFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_artwork, container, false);
GestureDetector gestureDetector = new GestureDetector(this.getActivity(), new GestureListener(this));
imageView = (ImageView) rootView.findViewById(R.id.image);
imageView.setOnTouchListener((view, motionEvent) -> gestureDetector.onTouchEvent(motionEvent));
updateArtwork();
return rootView;
}
use of android.view.GestureDetector in project DropListView by ufo22940268.
the class DropView method init.
private void init(AttributeSet attrs, int defStyle) {
mColor = getResources().getColor(R.color.drop_view_color);
mGestureDetector = new GestureDetector(getContext(), mGestureListener);
mMaxRadius1 = dpToPx(25);
mRadius1 = mMaxRadius1;
mMinRadius1 = mRadius1 * MIN_RADIUS1_FACTOR;
mRadius2 = mRadius1;
mMinRadius2 = (float) (mRadius2 * MIN_RADIUS2_FACTOR);
mTopPadding = dpToPx(15);
mPullThreshold = dpToPx(100);
mBzrOffset = dpToPx(10);
mLoadingView = new ProgressBar(getContext());
mLoadingView.setIndeterminate(true);
int size = mRadius1 * 2 + dpToPx(5);
LayoutParams params = new LayoutParams(size, size);
params.topMargin = mTopPadding - dpToPx(5);
params.gravity = Gravity.CENTER_HORIZONTAL;
mLoadingView.setLayoutParams(params);
mIconBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_refresh_white_48dp);
/**
* Adjust loading view position to fit drop view.
*/
mLoadingView.setPadding(0, 0, dpToPx(15), 0);
addView(mLoadingView);
enableLoading(false);
}
Aggregations