use of android.view.View.OnTouchListener in project GT by Tencent.
the class GTFloatView method createView.
private void createView() {
wm = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
wmParams = new WindowManager.LayoutParams();
wmParams.type = 2002;
wmParams.flags |= 8;
wmParams.flags = WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | 8;
// 调整悬浮窗口至左上角
wmParams.gravity = Gravity.LEFT | Gravity.TOP;
wmParams.x = 0;
wmParams.y = 0;
wmParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
wmParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
wmParams.format = 1;
try {
wm.addView(view_floatview, wmParams);
} catch (Exception e) {
/*
* 有的Android6会报permission denied for this window type问题
* https://github.com/intercom/intercom-android/issues/116
* 在这种系统上直接屏蔽悬浮窗
*/
stopSelf();
return;
}
final int sbar_height = DeviceUtils.getStatusBarHeight(getApplicationContext());
view_floatview.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
x = event.getRawX();
y = event.getRawY() - sbar_height;
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
move_event = false;
up_event = false;
state = MotionEvent.ACTION_DOWN;
StartX = x;
StartY = y;
mTouchStartX = event.getX();
mTouchStartY = event.getY();
touchX = mTouchStartX;
touchY = mTouchStartY;
ProX = event.getRawX();
ProY = event.getRawY();
clickHandler.sendEmptyMessage(0);
break;
case MotionEvent.ACTION_MOVE:
state = MotionEvent.ACTION_MOVE;
moveX = event.getRawX();
moveY = event.getRawY();
final ViewConfiguration configuration = ViewConfiguration.get(getApplicationContext());
int mTouchSlop = configuration.getScaledTouchSlop();
// 第一次move
if (move_oldX == -1000 && move_oldY == -1000) {
move_oldX = moveX;
move_oldY = moveY;
if (Math.abs(moveX - ProX) < mTouchSlop * 2 && Math.abs(moveY - ProY) < mTouchSlop * 2) {
move_event = false;
} else {
move_event = true;
updateViewPosition();
}
} else {
if (move_event == false) {
if (Math.abs(moveX - move_oldX) < mTouchSlop * 2 && Math.abs(moveY - move_oldY) < mTouchSlop * 2) {
move_event = false;
} else {
move_event = true;
updateViewPosition();
}
} else {
updateViewPosition();
}
}
break;
case MotionEvent.ACTION_UP:
state = MotionEvent.ACTION_UP;
updateViewPositionEnd();
move_oldX = -1000;
move_oldY = -1000;
mTouchStartX = mTouchStartY = 0;
up_event = true;
clickHandler.sendEmptyMessage(1);
break;
}
return true;
}
});
}
use of android.view.View.OnTouchListener in project GT by Tencent.
the class GTFloatView method initInParamLayout.
private void initInParamLayout() {
// 初始化出参布局
tv_floatview_ip1 = (TextView) view_floatview.findViewById(R.id.floatview_ip1);
tv_floatview_ip1_value = (TextView) view_floatview.findViewById(R.id.floatview_ip1_value);
tv_floatview_ip2 = (TextView) view_floatview.findViewById(R.id.floatview_ip2);
tv_floatview_ip2_value = (TextView) view_floatview.findViewById(R.id.floatview_ip2_value);
tv_floatview_ip3 = (TextView) view_floatview.findViewById(R.id.floatview_ip3);
tv_floatview_ip3_value = (TextView) view_floatview.findViewById(R.id.floatview_ip3_value);
// 初始化相应点击事件的view
// 设置点击事件
tv_floatview_ip1.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
tv_floatview_ip_clickHandler.sendEmptyMessage(0);
break;
}
return false;
}
});
tv_floatview_ip1_value.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
tv_floatview_ip_clickHandler.sendEmptyMessage(0);
break;
}
return false;
}
});
tv_floatview_ip2.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
tv_floatview_ip_clickHandler.sendEmptyMessage(1);
break;
}
return false;
}
});
tv_floatview_ip2_value.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
tv_floatview_ip_clickHandler.sendEmptyMessage(1);
break;
}
return false;
}
});
tv_floatview_ip3.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
tv_floatview_ip_clickHandler.sendEmptyMessage(2);
break;
}
return false;
}
});
tv_floatview_ip3_value.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
tv_floatview_ip_clickHandler.sendEmptyMessage(2);
break;
}
return false;
}
});
}
use of android.view.View.OnTouchListener in project Fairphone by Kwamecorp.
the class OOBEActivity method setupTheVideo.
private void setupTheVideo() {
RelativeLayout rl = (RelativeLayout) findViewById(R.id.oobeVideoViewGroup);
rl.setVisibility(View.VISIBLE);
mVideo = (VideoView) findViewById(R.id.fp_oobe_video);
Uri uri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.fp_buy_a_phone_start_a_movement);
mVideo.setMediaController(null);
mVideo.requestFocus();
mVideo.setVideoURI(uri);
mVideo.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
mVideo.start();
mVideo.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
stopIntroVideo();
}
});
// button
mSkipVideoButton = (Button) findViewById(R.id.fp_oobe_video_skip_button);
mSkipVideoButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
stopIntroVideo();
}
});
}
use of android.view.View.OnTouchListener in project KJFrameForAndroid by kymjs.
the class Browser method initWidget.
@Override
public void initWidget() {
super.initWidget();
initWebView();
initBarAnim();
mGestureDetector = new GestureDetector(aty, new MyGestureListener());
mWebView.loadUrl(mCurrentUrl);
mWebView.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return mGestureDetector.onTouchEvent(event);
}
});
}
use of android.view.View.OnTouchListener in project MaterialDesignLibrary by navasmdc.
the class ColorSelector method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.color_selector);
view = (LinearLayout) findViewById(R.id.contentSelector);
backView = (RelativeLayout) findViewById(R.id.rootSelector);
backView.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getX() < view.getLeft() || event.getX() > view.getRight() || event.getY() > view.getBottom() || event.getY() < view.getTop()) {
dismiss();
}
return false;
}
});
colorView = findViewById(R.id.viewColor);
colorView.setBackgroundColor(color);
// Resize ColorView
colorView.post(new Runnable() {
@Override
public void run() {
LayoutParams params = (LayoutParams) colorView.getLayoutParams();
params.height = colorView.getWidth();
colorView.setLayoutParams(params);
}
});
// Configure Sliders
red = (Slider) findViewById(R.id.red);
green = (Slider) findViewById(R.id.green);
blue = (Slider) findViewById(R.id.blue);
int r = (this.color >> 16) & 0xFF;
int g = (this.color >> 8) & 0xFF;
int b = (this.color >> 0) & 0xFF;
red.setValue(r);
green.setValue(g);
blue.setValue(b);
red.setOnValueChangedListener(this);
green.setOnValueChangedListener(this);
blue.setOnValueChangedListener(this);
}
Aggregations