use of android.view.View.OnTouchListener in project GT by Tencent.
the class GTLogo method createView.
private void createView() {
wm = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
wmParams = new WindowManager.LayoutParams();
wmParams.type = 2002;
wmParams.flags |= 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(entrance_view, wmParams);
} catch (Exception e) {
/*
* 有的Android6会报permission denied for this window type问题
* https://github.com/intercom/intercom-android/issues/116
* 在这种系统上直接屏蔽悬浮窗
*/
stopSelf();
return;
}
entrance_img.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
x = event.getRawX();
y = event.getRawY() - DeviceUtils.getStatusBarHeight(getApplicationContext());
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
move_event = false;
mTouchStartX = event.getX();
mTouchStartY = event.getY();
ProX = event.getRawX();
ProY = event.getRawY();
clickHandler.sendEmptyMessage(0);
break;
case 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:
updateViewPositionEnd();
move_oldX = -1000;
move_oldY = -1000;
mTouchStartX = mTouchStartY = 0;
clickHandler.sendEmptyMessage(1);
break;
}
return true;
}
});
}
use of android.view.View.OnTouchListener in project GT by Tencent.
the class GTFloatView method initOutParamLayout.
private void initOutParamLayout() {
// 初始化出参布局
tv_floatview_op1 = (TextView) view_floatview.findViewById(R.id.floatview_op1);
tv_floatview_op1_value = (TextView) view_floatview.findViewById(R.id.floatview_op1_value);
tv_floatview_op2 = (TextView) view_floatview.findViewById(R.id.floatview_op2);
tv_floatview_op2_value = (TextView) view_floatview.findViewById(R.id.floatview_op2_value);
tv_floatview_op3 = (TextView) view_floatview.findViewById(R.id.floatview_op3);
tv_floatview_op3_value = (TextView) view_floatview.findViewById(R.id.floatview_op3_value);
// 设置点击事件
tv_floatview_op1_value.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
tv_floatview_op_clickHandler.sendEmptyMessage(0);
break;
}
return false;
}
});
tv_floatview_op2_value.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
tv_floatview_op_clickHandler.sendEmptyMessage(1);
break;
}
return false;
}
});
tv_floatview_op3_value.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
tv_floatview_op_clickHandler.sendEmptyMessage(2);
break;
}
return false;
}
});
}
use of android.view.View.OnTouchListener in project MaterialDesignLibrary by navasmdc.
the class ProgressDialog method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.progress_dialog);
view = (RelativeLayout) findViewById(R.id.contentDialog);
backView = (RelativeLayout) findViewById(R.id.dialog_rootView);
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;
}
});
this.titleTextView = (TextView) findViewById(R.id.title);
setTitle(title);
if (progressColor != -1) {
ProgressBarCircularIndeterminate progressBarCircularIndeterminate = (ProgressBarCircularIndeterminate) findViewById(R.id.progressBarCircularIndetermininate);
progressBarCircularIndeterminate.setBackgroundColor(progressColor);
}
}
use of android.view.View.OnTouchListener in project android_frameworks_base by DirtyUnicorns.
the class Interaction method register.
public static void register(View v, final Callback callback) {
v.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
callback.onInteraction();
return false;
}
});
v.setOnGenericMotionListener(new OnGenericMotionListener() {
@Override
public boolean onGenericMotion(View v, MotionEvent event) {
callback.onInteraction();
return false;
}
});
}
use of android.view.View.OnTouchListener in project SeaStar by 13120241790.
the class RecordDialog method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.getContext().setTheme(android.R.style.Theme_InputMethod);
setContentView(R.layout.layout_dialog_record);
Window window = getWindow();
WindowManager.LayoutParams attributesParams = window.getAttributes();
attributesParams.flags = WindowManager.LayoutParams.FLAG_DIM_BEHIND;
attributesParams.dimAmount = 0.4f;
@SuppressWarnings("deprecation") int width = (int) (window.getWindowManager().getDefaultDisplay().getWidth() * 0.85);
window.setLayout(width, LayoutParams.WRAP_CONTENT);
downMinTimer = new DownTimer();
downMinTimer.setListener(new DownTimerListener() {
@Override
public void onTick(long millisUntilFinished) {
recordTimeFlag = false;
}
@Override
public void onFinish() {
recordTimeFlag = true;
}
});
downMaxTimer = new DownTimer();
downMaxTimer.setListener(new DownTimerListener() {
@Override
public void onTick(long millisUntilFinished) {
}
@Override
public void onFinish() {
animation.stop();
recorderUtils.onRecord(false);
view_line.setVisibility(View.VISIBLE);
btn_detail_record.setVisibility(View.GONE);
img_record_animation.setVisibility(View.GONE);
btn_detail_confirm.setVisibility(View.VISIBLE);
btn_detail_confirm.setText(R.string.submit_text);
btn_detail_cancel.setVisibility(View.VISIBLE);
img_record_bg.setVisibility(View.VISIBLE);
tv_record_play.setVisibility(View.VISIBLE);
NToast.shortToast(getContext(), R.string.record_time_max_text);
}
});
recorderUtils = new MediaRecorderUtils();
img_record_animation = (ImageView) findViewById(R.id.img_record_animation);
img_record_bg = (ImageView) findViewById(R.id.img_record_bg);
tv_record_play = (TextView) findViewById(R.id.tv_record_play);
tv_record_play.setOnClickListener(this);
animation = (AnimationDrawable) img_record_animation.getBackground();
btn_detail_cancel = (Button) findViewById(R.id.btn_detail_cancel);
btn_detail_cancel.setOnClickListener(this);
btn_detail_cancel.setVisibility(View.GONE);
view_line = (View) findViewById(R.id.view_line);
view_line.setVisibility(View.GONE);
btn_detail_confirm = (Button) findViewById(R.id.btn_detail_confirm);
btn_detail_confirm.setOnClickListener(this);
btn_detail_confirm.setVisibility(View.GONE);
btn_detail_record = (Button) findViewById(R.id.btn_detail_record);
btn_detail_record.setVisibility(View.VISIBLE);
btn_detail_record.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View arg0, MotionEvent event) {
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
animation.stop();
animation.start();
if (downMinTimer != null) {
downMinTimer.stopDown();
}
downMinTimer.startDown(2000);
if (downMaxTimer != null) {
downMaxTimer.stopDown();
}
downMaxTimer.startDown(5000);
recorderUtils.onRecord(true);
break;
case MotionEvent.ACTION_UP:
animation.stop();
recorderUtils.onRecord(false);
if (downMaxTimer != null) {
downMaxTimer.stopDown();
}
if (recordTimeFlag) {
view_line.setVisibility(View.VISIBLE);
btn_detail_record.setVisibility(View.GONE);
img_record_animation.setVisibility(View.GONE);
btn_detail_confirm.setVisibility(View.VISIBLE);
btn_detail_confirm.setText(R.string.submit_text);
btn_detail_cancel.setVisibility(View.VISIBLE);
img_record_bg.setVisibility(View.VISIBLE);
tv_record_play.setVisibility(View.VISIBLE);
} else {
NToast.shortToast(getContext(), R.string.record_time_text);
}
break;
}
return false;
}
});
}
Aggregations