Search in sources :

Example 56 with OnTouchListener

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;
        }
    });
}
Also used : OnTouchListener(android.view.View.OnTouchListener) OnClickListener(android.view.View.OnClickListener) SuppressLint(android.annotation.SuppressLint) View(android.view.View) MotionEvent(android.view.MotionEvent) SuppressLint(android.annotation.SuppressLint)

Example 57 with OnTouchListener

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);
        }
    });
}
Also used : OnTouchListener(android.view.View.OnTouchListener) View(android.view.View) MotionEvent(android.view.MotionEvent)

Example 58 with OnTouchListener

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;
        }
    });
}
Also used : OnTouchListener(android.view.View.OnTouchListener) Resources(android.content.res.Resources) CategoryView(com.android.gallery3d.filtershow.category.CategoryView) SwipableView(com.android.gallery3d.filtershow.category.SwipableView) WaterMarkView(com.android.gallery3d.filtershow.category.WaterMarkView) View(android.view.View) AdapterView(android.widget.AdapterView) Point(android.graphics.Point) MotionEvent(android.view.MotionEvent)

Example 59 with OnTouchListener

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);
        }
    });
}
Also used : NetConnectionHelper(io.spark.core.android.util.NetConnectionHelper) KeyEvent(android.view.KeyEvent) OnTouchListener(android.view.View.OnTouchListener) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) OnClickListener(android.view.View.OnClickListener) View(android.view.View) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) MotionEvent(android.view.MotionEvent)

Example 60 with OnTouchListener

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) {
        }
    });
}
Also used : LayoutParams(android.view.WindowManager.LayoutParams) OnTouchListener(android.view.View.OnTouchListener) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) View(android.view.View) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout) MotionEvent(android.view.MotionEvent)

Aggregations

OnTouchListener (android.view.View.OnTouchListener)70 MotionEvent (android.view.MotionEvent)68 View (android.view.View)68 TextView (android.widget.TextView)40 OnClickListener (android.view.View.OnClickListener)21 ImageView (android.widget.ImageView)19 ListView (android.widget.ListView)16 AdapterView (android.widget.AdapterView)15 SuppressLint (android.annotation.SuppressLint)12 KeyEvent (android.view.KeyEvent)8 Intent (android.content.Intent)7 AbsListView (android.widget.AbsListView)7 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)6 Rect (android.graphics.Rect)5 Handler (android.os.Handler)5 GestureDetector (android.view.GestureDetector)5 OnGenericMotionListener (android.view.View.OnGenericMotionListener)5 WindowManager (android.view.WindowManager)5 DialogInterface (android.content.DialogInterface)4 Editable (android.text.Editable)4