Search in sources :

Example 11 with OnTouchListener

use of android.view.View.OnTouchListener in project MaterialDesignLibrary by navasmdc.

the class Dialog method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.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);
    this.messageTextView = (TextView) findViewById(R.id.message);
    setMessage(message);
    this.buttonAccept = (ButtonFlat) findViewById(R.id.button_accept);
    buttonAccept.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dismiss();
            if (onAcceptButtonClickListener != null)
                onAcceptButtonClickListener.onClick(v);
        }
    });
    if (buttonCancelText != null) {
        this.buttonCancel = (ButtonFlat) findViewById(R.id.button_cancel);
        this.buttonCancel.setVisibility(View.VISIBLE);
        this.buttonCancel.setText(buttonCancelText);
        buttonCancel.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                dismiss();
                if (onCancelButtonClickListener != null)
                    onCancelButtonClickListener.onClick(v);
            }
        });
    }
}
Also used : OnTouchListener(android.view.View.OnTouchListener) TextView(android.widget.TextView) View(android.view.View) MotionEvent(android.view.MotionEvent)

Example 12 with OnTouchListener

use of android.view.View.OnTouchListener in project JamsMusicPlayer by psaravan.

the class WelcomeActivity method showBuildingLibraryProgress.

private void showBuildingLibraryProgress() {
    //Disables swiping events on the pager.
    welcomeViewPager.setCurrentItem(5);
    welcomeViewPager.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View arg0, MotionEvent arg1) {
            return true;
        }
    });
    //Fade out the ViewPager indicator.
    Animation fadeOutAnim = AnimationUtils.loadAnimation(mContext, R.anim.fade_out);
    fadeOutAnim.setDuration(600);
    fadeOutAnim.setAnimationListener(fadeOutListener);
    indicator.startAnimation(fadeOutAnim);
}
Also used : OnTouchListener(android.view.View.OnTouchListener) Animation(android.view.animation.Animation) View(android.view.View) MotionEvent(android.view.MotionEvent)

Example 13 with OnTouchListener

use of android.view.View.OnTouchListener in project android-app by spark.

the class SignUpActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent nextActivityToSkipTo = getNextActivityToSkipTo();
    // NOTE EARLY RETURN HERE
    if (nextActivityToSkipTo != null) {
        if (!isFinishing()) {
            startActivity(nextActivityToSkipTo);
        }
        finish();
        return;
    }
    setContentView(R.layout.activity_sign_up);
    mEmailView = Ui.findView(this, R.id.email);
    mPasswordView = Ui.findView(this, R.id.password);
    Ui.setTextFromHtml(this, R.id.already_have_account, R.string.i_already_have_an_account);
    TextView finePrint = Ui.setTextFromHtml(this, R.id.fine_print, R.string.sign_up_fine_print);
    finePrint.setMovementMethod(LinkMovementMethod.getInstance());
    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(mPasswordView, mEmailView)) {
        view.setOnTouchListener(new OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_UP) {
                    scrollAccountForm();
                }
                return false;
            }
        });
    }
    findViewById(R.id.already_have_account).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            startActivity(new Intent(SignUpActivity.this, LoginActivity.class));
            finish();
        }
    });
}
Also used : KeyEvent(android.view.KeyEvent) OnTouchListener(android.view.View.OnTouchListener) OnClickListener(android.view.View.OnClickListener) Intent(android.content.Intent) 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 14 with OnTouchListener

use of android.view.View.OnTouchListener in project android-app by spark.

the class TinkerFragment method showTinkerSelect.

private void showTinkerSelect(Pin pin) {
    // No current action on the pin
    mutePinsExcept(pin);
    toggleViewVisibilityWithFade(R.id.tinker_logo, false);
    final View selectDialogView = getActivity().getLayoutInflater().inflate(R.layout.tinker_select, null);
    selectDialog = new AlertDialog.Builder(getActivity(), R.style.AppTheme_DialogNoDimBackground).setView(selectDialogView).setCancelable(true).setOnCancelListener(new OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            dialog.dismiss();
        }
    }).create();
    selectDialog.setCanceledOnTouchOutside(true);
    selectDialog.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            unmutePins();
            toggleViewVisibilityWithFade(R.id.tinker_logo, true);
            selectDialog = null;
        }
    });
    final View analogRead = Ui.findView(selectDialogView, R.id.tinker_button_analog_read);
    final View analogWrite = Ui.findView(selectDialogView, R.id.tinker_button_analog_write);
    final View digitalRead = Ui.findView(selectDialogView, R.id.tinker_button_digital_read);
    final View digitalWrite = Ui.findView(selectDialogView, R.id.tinker_button_digital_write);
    final List<View> allButtons = list(analogRead, analogWrite, digitalRead, digitalWrite);
    analogRead.setOnTouchListener(new OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                setTinkerSelectButtonSelected(analogRead, allButtons);
            }
            return false;
        }
    });
    analogWrite.setOnTouchListener(new OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                setTinkerSelectButtonSelected(analogWrite, allButtons);
            }
            return false;
        }
    });
    digitalRead.setOnTouchListener(new OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                setTinkerSelectButtonSelected(digitalRead, allButtons);
            }
            return false;
        }
    });
    digitalWrite.setOnTouchListener(new OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                setTinkerSelectButtonSelected(digitalWrite, allButtons);
            }
            return false;
        }
    });
    digitalWrite.setOnClickListener(this);
    digitalRead.setOnClickListener(this);
    analogRead.setOnClickListener(this);
    analogWrite.setOnClickListener(this);
    if (!digitalWritePins.contains(pin)) {
        digitalWrite.setVisibility(View.INVISIBLE);
    } else {
        digitalWrite.setVisibility(View.VISIBLE);
    }
    if (!digitalReadPins.contains(pin)) {
        digitalRead.setVisibility(View.INVISIBLE);
    } else {
        digitalRead.setVisibility(View.VISIBLE);
    }
    if (!analogReadPins.contains(pin)) {
        analogRead.setVisibility(View.INVISIBLE);
    } else {
        analogRead.setVisibility(View.VISIBLE);
    }
    if (!analogWritePins.contains(pin)) {
        analogWrite.setVisibility(View.INVISIBLE);
    } else {
        analogWrite.setVisibility(View.VISIBLE);
    }
    ((TextView) selectDialogView.findViewById(R.id.tinker_select_pin)).setText(pin.name);
    PinAction action = pin.getConfiguredAction();
    switch(action) {
        case ANALOG_READ:
            setTinkerSelectButtonSelected(analogRead, allButtons);
            break;
        case ANALOG_WRITE:
            setTinkerSelectButtonSelected(analogWrite, allButtons);
            break;
        case DIGITAL_READ:
            setTinkerSelectButtonSelected(digitalRead, allButtons);
            break;
        case DIGITAL_WRITE:
            setTinkerSelectButtonSelected(digitalWrite, allButtons);
            break;
        case NONE:
            setTinkerSelectButtonSelected(null, allButtons);
            break;
    }
    selectDialog.show();
    View decorView = selectDialog.getWindow().getDecorView();
    noIReallyMeanItIWantThisToBeTransparent(decorView);
}
Also used : AlertDialog(android.app.AlertDialog) OnTouchListener(android.view.View.OnTouchListener) DialogInterface(android.content.DialogInterface) OnDismissListener(android.content.DialogInterface.OnDismissListener) TextView(android.widget.TextView) View(android.view.View) TextView(android.widget.TextView) OnCancelListener(android.content.DialogInterface.OnCancelListener) MotionEvent(android.view.MotionEvent)

Example 15 with OnTouchListener

use of android.view.View.OnTouchListener in project platform_frameworks_base by android.

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

Aggregations

MotionEvent (android.view.MotionEvent)44 View (android.view.View)44 OnTouchListener (android.view.View.OnTouchListener)44 TextView (android.widget.TextView)28 ImageView (android.widget.ImageView)15 OnClickListener (android.view.View.OnClickListener)14 ListView (android.widget.ListView)8 SuppressLint (android.annotation.SuppressLint)7 AdapterView (android.widget.AdapterView)7 Intent (android.content.Intent)5 Rect (android.graphics.Rect)5 OnGenericMotionListener (android.view.View.OnGenericMotionListener)5 AbsListView (android.widget.AbsListView)5 DialogInterface (android.content.DialogInterface)4 KeyEvent (android.view.KeyEvent)4 RelativeLayout (android.widget.RelativeLayout)4 ScrollView (android.widget.ScrollView)4 Builder (android.app.AlertDialog.Builder)3 WindowManager (android.view.WindowManager)3 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)3