use of android.view.View.OnTouchListener in project AndroidStudy by tinggengyan.
the class TouchMainActivity method onCreate.
@SuppressLint("ClickableViewAccessibility")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setContentView(R.layout.acitivity_touch);
mButton = (TouchButton) findViewById(R.id.button_touch);
mButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
}
});
mButton.setOnTouchListener(new OnTouchListener() {
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouch(View v, MotionEvent event) {
return false;
}
});
}
use of android.view.View.OnTouchListener in project LanSoEditor_common by LanSoSdk.
the class SegmentRecorderActivity method initView.
// ----------------follow is ui code----------一下是UI界面代码--------------------------------------------------------------------------------------------------------
private void initView() {
quitBtn = (Button) findViewById(R.id.quitBtn);
flashBtn = (Button) findViewById(R.id.recorder_flashlight);
cancelBtn = (Button) findViewById(R.id.recorder_cancel);
nextBtn = (Button) findViewById(R.id.recorder_next);
recorderVideoBtn = (Button) findViewById(R.id.recorder_video);
switchCameraIcon = (Button) findViewById(R.id.recorder_frontcamera);
progressView = (VideoProgressView) findViewById(R.id.recorder_progress);
cameraTextureView = (VideoPreviewView) findViewById(R.id.recorder_surface);
focusView = (VideoFocusView) findViewById(R.id.video_focus_view);
quitBtn.setOnClickListener(this);
flashBtn.setOnClickListener(this);
cancelBtn.setOnClickListener(this);
nextBtn.setOnClickListener(this);
switchCameraIcon.setOnClickListener(this);
recorderVideoBtn.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
handler.sendEmptyMessage(MSG_STARTRECORD);
break;
case MotionEvent.ACTION_UP:
handler.sendEmptyMessage(MSG_PAUSERECORD);
break;
}
return true;
}
});
focusView.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
return onSquareFocusViewTouch(v, event);
}
});
}
use of android.view.View.OnTouchListener in project android_packages_apps_Gallery2 by LineageOS.
the class FilterShowActivity method loadXML.
private void loadXML() {
setContentView(R.layout.filtershow_activity);
Resources r = getResources();
setActionBar();
mPopUpText = r.getString(R.string.discard).toUpperCase(Locale.getDefault());
mCancel = r.getString(R.string.cancel).toUpperCase(Locale.getDefault());
int marginTop = r.getDimensionPixelSize(R.dimen.compare_margin_top);
int marginRight = r.getDimensionPixelSize(R.dimen.compare_margin_right);
imgComparison = (ImageButton) findViewById(R.id.imgComparison);
rlImageContainer = (RelativeLayout) findViewById(R.id.imageContainer);
mImageShow = (ImageShow) findViewById(R.id.imageShow);
mImageViews.add(mImageShow);
setupEditors();
mEditorPlaceHolder.hide();
mImageShow.attach();
setupStatePanel();
imgComparison.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
action = action & MotionEvent.ACTION_MASK;
if (action == MotionEvent.ACTION_DOWN) {
MasterImage.getImage().setShowsOriginal(true);
v.setPressed(true);
if (mWaterMarkView != null) {
mWaterMarkView.setVisibility(View.GONE);
}
}
if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_OUTSIDE) {
v.setPressed(false);
MasterImage.getImage().setShowsOriginal(false);
if (mWaterMarkView != null) {
mWaterMarkView.setVisibility(View.VISIBLE);
}
}
return false;
}
});
}
use of android.view.View.OnTouchListener in project android-app by spark.
the class LoginActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_log_in);
mEmailView = Ui.findView(this, R.id.email);
mPasswordView = Ui.findView(this, R.id.password);
mEmailView.setText(prefs.getUsername());
netConnectionHelper = new NetConnectionHelper(this);
mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
if (id == R.id.login || id == EditorInfo.IME_NULL) {
attemptLogin();
return true;
}
return false;
}
});
accountAction = Ui.findView(this, R.id.sign_up_button);
accountAction.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
attemptLogin();
}
});
// keyboard pops up
for (View view : list(mEmailView, mPasswordView)) {
view.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
scrollAccountForm();
}
return false;
}
});
}
TextView noAccountYet = Ui.setTextFromHtml(this, R.id.no_account_yet, R.string.i_dont_have_an_account);
noAccountYet.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
launchSignUpActivity();
}
});
TextView forgotPassword = Ui.setTextFromHtml(this, R.id.forgot_password, R.string.action_forgot_password);
forgotPassword.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
openUri(R.string.uri_forgot_password);
}
});
}
use of android.view.View.OnTouchListener in project OkHttp3 by MrZhousf.
the class NetSpeedService method initView.
private void initView() {
final LayoutParams layoutParams = new LayoutParams();
windowManager = (WindowManager) getApplication().getSystemService(WINDOW_SERVICE);
// layoutParams.type = LayoutParams.TYPE_SYSTEM_ALERT;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
layoutParams.type = WindowManager.LayoutParams.TYPE_ACCESSIBILITY_OVERLAY;
} else {
layoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
}
layoutParams.format = PixelFormat.RGBA_8888;
layoutParams.flags = LayoutParams.FLAG_NOT_FOCUSABLE;
layoutParams.gravity = Gravity.START | Gravity.TOP;
layoutParams.width = dpToPx(getApplicationContext(), 75);
layoutParams.height = LayoutParams.WRAP_CONTENT;
layoutParams.x = (getScreenWidth(getApplicationContext()) - layoutParams.width) / 10;
layoutParams.y = 10;
// 初始化浮动窗口布局
linearLayout = new LinearLayout(getApplicationContext());
linearLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
linearLayout.setOrientation(LinearLayout.VERTICAL);
linearLayout.setGravity(Gravity.CENTER);
linearLayout.setPadding(0, 5, 0, 5);
SelectorFactory.newShapeSelector().setStrokeWidth(1).setCornerRadius(10).setDefaultStrokeColor(Color.GRAY).setDefaultBgColor(Color.WHITE).bind(linearLayout);
linearLayout.getBackground().setAlpha(150);
textView = new TextView(getApplicationContext());
textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
final String text = "0K/s";
textView.setText(text);
textView.setTextSize(12);
textView.setTextColor(Color.BLACK);
linearLayout.addView(textView);
windowManager.addView(linearLayout, layoutParams);
linearLayout.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
textView.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
layoutParams.x = (int) event.getRawX() - textView.getMeasuredWidth() / 2;
layoutParams.y = (int) event.getRawY() - textView.getMeasuredHeight() / 2 - 25;
windowManager.updateViewLayout(linearLayout, layoutParams);
return false;
}
});
textView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
}
});
}
Aggregations