Example usage for android.view HapticFeedbackConstants VIRTUAL_KEY

List of usage examples for android.view HapticFeedbackConstants VIRTUAL_KEY

Introduction

In this page you can find the example usage for android.view HapticFeedbackConstants VIRTUAL_KEY.

Prototype

int VIRTUAL_KEY

To view the source code for android.view HapticFeedbackConstants VIRTUAL_KEY.

Click Source Link

Document

The user has pressed on a virtual on-screen key.

Usage

From source file:com.google.android.car.kitchensink.assistant.CarAssistantFragment.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.car_assistant, container, false);
    mMic = (ImageView) v.findViewById(R.id.voice_button);
    Context context = getContext();
    mMic.setOnClickListener(new View.OnClickListener() {
        @Override//from w  w w. j  ava 2 s  .  c  om
        public void onClick(View v) {
            v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
            Intent intent = new Intent();
            intent.setAction(getContext().getString(R.string.assistant_activity_action));
            if (intent.resolveActivity(context.getPackageManager()) != null) {
                startActivity(intent);
            } else {
                Toast.makeText(context, "Assistant app is not available.", Toast.LENGTH_SHORT).show();
            }
        }
    });
    return v;
}

From source file:com.andrewsummers.otashu.DepthPageTransformer.java

/**
 * transformPage used to apply a custom transformation (animation) to page view scrolling.
 * // ww  w  .java 2s  .  c om
 * @param view Incoming view.
 * @param position Current position of page relative to current "front and center" page. As per
 *            the official ViewPager documentation, possible values are: -1 is one page position
 *            to the left 0 is front and center. 1 is one page position to the right
 */
public void transformPage(View view, float position) {
    int pageWidth = view.getWidth();

    // if application touch feedback setting is set, enable touch feedback
    if (pref_touch_feedback_enabled) {
        view.setHapticFeedbackEnabled(true);
        view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY,
                HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
    }

    // current page setting: [-Infinity, -1)
    if (position < -1) {
        // this page is way off-screen to the left
        view.setAlpha(0);
    }
    // current page setting: [-1, 0]
    else if (position <= 0) {
        // use the default slide transition when moving to the left page
        view.setAlpha(1);
        // view.setHapticFeedbackEnabled(hapticFeedbackEnabled);
        view.setTranslationY(pageWidth * position);
        view.setScaleX(1);
        view.setScaleY(1);
    }
    // current page setting: (0, 1)
    else if (position <= 1) {
        // fade page out
        view.setAlpha(1 - position);

        // counteract the default slide transition
        view.setTranslationY(pageWidth * -position);

        // scale the page down (between MIN_SCALE and 1)
        float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position));
        view.setScaleX(scaleFactor);
        view.setScaleY(scaleFactor);
    }
    // current page setting: (1, +Infinity]
    else {
        // this page is way off-screen to the right
        view.setAlpha(0);
    }
}

From source file:za.co.neilson.alarm.preferences.AlarmPreferencesActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // requestWindowFeature(Window.FEATURE_NO_TITLE);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    setContentView(R.layout.alarm_preferences);

    pref = getSharedPreferences("AppPref", MODE_PRIVATE);
    email = getIntent().getStringExtra("email");
    Log.d("? ???!!! ", "" + email);

    Bundle bundle = getIntent().getExtras();
    if (bundle != null && bundle.containsKey("alarm")) {
        setMathAlarm((Alarm) bundle.getSerializable("alarm"));
    } else {/*  w  w w  .ja va 2 s  . c  o  m*/
        setMathAlarm(new Alarm());
    }
    if (bundle != null && bundle.containsKey("adapter")) {
        setListAdapter((AlarmPreferenceListAdapter) bundle.getSerializable("adapter"));
    } else {
        setListAdapter(new AlarmPreferenceListAdapter(this, getMathAlarm()));
    }

    getListView().setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> l, View v, int position, long id) {
            final AlarmPreferenceListAdapter alarmPreferenceListAdapter = (AlarmPreferenceListAdapter) getListAdapter();
            final AlarmPreference alarmPreference = (AlarmPreference) alarmPreferenceListAdapter
                    .getItem(position);

            AlertDialog.Builder alert;
            v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
            switch (alarmPreference.getType()) {
            case BOOLEAN:
                CheckedTextView checkedTextView = (CheckedTextView) v;
                boolean checked = !checkedTextView.isChecked();
                ((CheckedTextView) v).setChecked(checked);
                switch (alarmPreference.getKey()) {
                case ALARM_ACTIVE:
                    alarm.setAlarmActive(checked);
                    break;
                case ALARM_VIBRATE:
                    alarm.setVibrate(checked);
                    if (checked) {
                        Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
                        vibrator.vibrate(1000);
                    }
                    break;
                }
                alarmPreference.setValue(checked);
                break;
            case STRING:

                alert = new AlertDialog.Builder(AlarmPreferencesActivity.this);

                alert.setTitle(alarmPreference.getTitle());
                // alert.setMessage(message);

                // Set an EditText view to get user input
                final EditText input = new EditText(AlarmPreferencesActivity.this);

                input.setText(alarmPreference.getValue().toString());

                alert.setView(input);
                alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {

                        alarmPreference.setValue(input.getText().toString());

                        if (alarmPreference.getKey() == Key.ALARM_NAME) {
                            alarm.setAlarmName(alarmPreference.getValue().toString());
                        }

                        alarmPreferenceListAdapter.setMathAlarm(getMathAlarm());
                        alarmPreferenceListAdapter.notifyDataSetChanged();
                    }
                });
                alert.show();
                break;
            case LIST:
                alert = new AlertDialog.Builder(AlarmPreferencesActivity.this);

                alert.setTitle(alarmPreference.getTitle());
                // alert.setMessage(message);

                CharSequence[] items = new CharSequence[alarmPreference.getOptions().length];
                for (int i = 0; i < items.length; i++)
                    items[i] = alarmPreference.getOptions()[i];

                alert.setItems(items, new OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        switch (alarmPreference.getKey()) {
                        case ALARM_DIFFICULTY:
                            Alarm.Difficulty d = Alarm.Difficulty.values()[which];
                            alarm.setDifficulty(d);
                            break;
                        case ALARM_TONE:
                            alarm.setAlarmTonePath(alarmPreferenceListAdapter.getAlarmTonePaths()[which]);
                            if (alarm.getAlarmTonePath() != null) {
                                if (mediaPlayer == null) {
                                    mediaPlayer = new MediaPlayer();
                                } else {
                                    if (mediaPlayer.isPlaying())
                                        mediaPlayer.stop();
                                    mediaPlayer.reset();
                                }
                                try {
                                    // mediaPlayer.setVolume(1.0f, 1.0f);
                                    mediaPlayer.setVolume(0.2f, 0.2f);
                                    mediaPlayer.setDataSource(AlarmPreferencesActivity.this,
                                            Uri.parse(alarm.getAlarmTonePath()));
                                    mediaPlayer.setAudioStreamType(AudioManager.STREAM_ALARM);
                                    mediaPlayer.setLooping(false);
                                    mediaPlayer.prepare();
                                    mediaPlayer.start();

                                    // Force the mediaPlayer to stop after 3
                                    // seconds...
                                    if (alarmToneTimer != null)
                                        alarmToneTimer.cancel();
                                    alarmToneTimer = new CountDownTimer(3000, 3000) {
                                        @Override
                                        public void onTick(long millisUntilFinished) {

                                        }

                                        @Override
                                        public void onFinish() {
                                            try {
                                                if (mediaPlayer.isPlaying())
                                                    mediaPlayer.stop();
                                            } catch (Exception e) {

                                            }
                                        }
                                    };
                                    alarmToneTimer.start();
                                } catch (Exception e) {
                                    try {
                                        if (mediaPlayer.isPlaying())
                                            mediaPlayer.stop();
                                    } catch (Exception e2) {

                                    }
                                }
                            }
                            break;
                        default:
                            break;
                        }
                        alarmPreferenceListAdapter.setMathAlarm(getMathAlarm());
                        alarmPreferenceListAdapter.notifyDataSetChanged();
                    }

                });

                alert.show();
                break;
            case MULTIPLE_LIST:
                alert = new AlertDialog.Builder(AlarmPreferencesActivity.this);

                alert.setTitle(alarmPreference.getTitle());
                // alert.setMessage(message);

                CharSequence[] multiListItems = new CharSequence[alarmPreference.getOptions().length];
                for (int i = 0; i < multiListItems.length; i++)
                    multiListItems[i] = alarmPreference.getOptions()[i];

                boolean[] checkedItems = new boolean[multiListItems.length];
                for (Alarm.Day day : getMathAlarm().getDays()) {
                    checkedItems[day.ordinal()] = true;
                }
                alert.setMultiChoiceItems(multiListItems, checkedItems, new OnMultiChoiceClickListener() {

                    @Override
                    public void onClick(final DialogInterface dialog, int which, boolean isChecked) {

                        Alarm.Day thisDay = Alarm.Day.values()[which];

                        if (isChecked) {
                            alarm.addDay(thisDay);
                        } else {
                            // Only remove the day if there are more than 1
                            // selected
                            if (alarm.getDays().length > 1) {
                                alarm.removeDay(thisDay);
                            } else {
                                // If the last day was unchecked, re-check
                                // it
                                ((AlertDialog) dialog).getListView().setItemChecked(which, true);
                            }
                        }

                    }
                });
                alert.setOnCancelListener(new OnCancelListener() {
                    @Override
                    public void onCancel(DialogInterface dialog) {
                        alarmPreferenceListAdapter.setMathAlarm(getMathAlarm());
                        alarmPreferenceListAdapter.notifyDataSetChanged();

                    }
                });
                alert.show();
                break;
            case TIME:
                TimePickerDialog timePickerDialog = new TimePickerDialog(AlarmPreferencesActivity.this,
                        new OnTimeSetListener() {

                            @Override
                            public void onTimeSet(TimePicker timePicker, int hours, int minutes) {
                                Calendar newAlarmTime = Calendar.getInstance();
                                newAlarmTime.set(Calendar.HOUR_OF_DAY, hours);
                                newAlarmTime.set(Calendar.MINUTE, minutes);
                                newAlarmTime.set(Calendar.SECOND, 0);
                                alarm.setAlarmTime(newAlarmTime);
                                alarmPreferenceListAdapter.setMathAlarm(getMathAlarm());
                                alarmPreferenceListAdapter.notifyDataSetChanged();
                            }
                        }, alarm.getAlarmTime().get(Calendar.HOUR_OF_DAY),
                        alarm.getAlarmTime().get(Calendar.MINUTE), true);
                timePickerDialog.setTitle(alarmPreference.getTitle());
                timePickerDialog.show();
            default:
                break;
            }
        }
    });
}

From source file:com.dz.ritesh.SignupPhoneField.VerifyPhoneFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.activity_signup, container, false);
    ButterKnife.bind(this, rootView);

    /*spinner click method and not clicked methos (Start)*/
    spinner.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener<String>() {

        @Override//from w w  w  .j ava  2  s .c o  m
        public void onItemSelected(MaterialSpinner view, int position, long id, String item) {
            spinner.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
            Toast.makeText(getActivity(), "Position :" + "  " + position + "  Clicked " + "" + item,
                    Toast.LENGTH_SHORT).show();

            android.support.design.widget.Snackbar
                    .make(view, "Clicked " + item, android.support.design.widget.Snackbar.LENGTH_SHORT).show();
            Str_User_TypeSelectedValue = item;

        }
    });
    spinner.setOnNothingSelectedListener(new MaterialSpinner.OnNothingSelectedListener() {

        @Override
        public void onNothingSelected(MaterialSpinner spinner) {
            Toast.makeText(getActivity(), "Please select User Type", Toast.LENGTH_SHORT).show();

            android.support.design.widget.Snackbar
                    .make(spinner, "Nothing selected", android.support.design.widget.Snackbar.LENGTH_SHORT)
                    .show();

        }
    });
    /*spinner click method and not clicked methos (End)*/

    if (Utils.isConnected(getActivity())) {
        UserTypeListJsontask task = new UserTypeListJsontask();
        task.execute();
    } else {

        SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP).margin(15, 15)
                .backgroundDrawable(R.drawable.snackbar_custom_layout)
                .text("Please Your Internet Connectivity..!!"));

    }

    /*circular progress bar (Start)*/
    mCircularProgressBar = (CircularProgressBar) rootView.findViewById(R.id.signup_progressbar_circular);
    //        signupProgress.setVisibility(View.GONE);
    ((CircularProgressDrawable) mCircularProgressBar.getIndeterminateDrawable()).start();
    updateValues();
    /*circular progress bar (End)*/

    /*spinner.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener<String>() {
            
    @Override public void onItemSelected(MaterialSpinner view, int position, long id, String item) {
        android.support.design.widget.Snackbar.make(view, "Clicked " + item, android.support.design.widget.Snackbar.LENGTH_LONG).show();
    }
    });
    spinner.setOnNothingSelectedListener(new MaterialSpinner.OnNothingSelectedListener() {
            
    @Override public void onNothingSelected(MaterialSpinner spinner) {
        android.support.design.widget.Snackbar.make(spinner, "Nothing selected", android.support.design.widget.Snackbar.LENGTH_LONG).show();
    }
    });*/

    CV_btn_signup.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            str_user_first_name = ET_UserFirstName.getText().toString().trim();
            str_user_last_name = ET_UserLastName.getText().toString().trim();
            str_emailid = ET_UserEmail.getText().toString().trim();
            str_password = ET_Password.getText().toString().trim();
            str_confirm_password = ET_Confirm_Password.getText().toString().trim();
            str_phone_number = ET_phone.getText().toString();
            str_phone_number = str_phone_number.replace(" ", "");

            Log.e(" Sign Up Fields data :",
                    "\n" + "Str_User_TypeSelectedValue :" + "" + Str_User_TypeSelectedValue + "\n"
                            + "str_user_first_name :" + "" + str_user_first_name + "\n" + "str_user_last_name :"
                            + "" + str_user_last_name + "\n" + "str_emailid :" + "" + str_emailid + "\n"
                            + "str_phone_number :" + "" + str_phone_number + "\n" + "str_password :" + ""
                            + str_password + "\n" + "str_confirm_password :" + "" + str_confirm_password);

            if (spinner.getSelectedIndex() == 0) {
                Log.e("error", "ok");
                iserror = true;
                v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
                /**************** Start Animation ****************/
                YoYo.with(Techniques.Shake).duration(700).playOn(CV_signup_user_type);
                /**************** End Animation ****************/

                /*Toast.makeText(getApplicationContext(), "Please enter more than 5 character in password.",
                    Toast.LENGTH_SHORT).show();*/

                SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP)
                        .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout)
                        .text("Please Select User Type"));

            } else if (str_user_first_name.equals("")) {
                iserror = true;
                v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
                /**************** Start Animation ****************/
                /*https://github.com/daimajia/AndroidViewAnimations/blob/master/README.md*/

                YoYo.with(Techniques.Tada).duration(700).playOn(ET_UserFirstName);
                /**************** End Animation ****************/

                /*Toast.makeText(getApplicationContext(), "Please enter your Name",
                    Toast.LENGTH_SHORT).show();*/

                SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP)
                        .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout)
                        .textColor(R.color.black_clr).text("Please enter your First Name"));

            } else if (str_emailid.equals("")) {
                iserror = true;
                v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
                /**************** Start Animation ****************/
                YoYo.with(Techniques.Tada).duration(700).playOn(ET_UserEmail);
                /**************** End Animation ****************/

                /*Toast.makeText(getApplicationContext(),
                    "Please enter your Email Id", Toast.LENGTH_SHORT).show();*/

                SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP)
                        .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout)
                        .textColor(R.color.black_clr).text("Please enter your Email Id"));

            } else if (!isValidEmail(str_emailid)) {
                iserror = true;
                v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
                //   emailedit.requestFocus();
                /**************** Start Animation ****************/
                YoYo.with(Techniques.Shake).duration(700).playOn(ET_UserEmail);
                /**************** End Animation ****************/
                /*Toast.makeText(getApplicationContext(),
                    "Please enter valid email address.", Toast.LENGTH_SHORT).show();*/

                SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP)
                        .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout)
                        .textColor(R.color.black_clr).text("Please enter valid email address."));

            } else if (str_phone_number.equals("")) {
                iserror = true;
                v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
                /**************** Start Animation ****************/
                YoYo.with(Techniques.Tada).duration(700).playOn(ET_phone);
                /**************** End Animation ****************/

                /*Toast.makeText(getApplicationContext(),
                    "Please enter your Email Id", Toast.LENGTH_SHORT).show();*/

                SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP)
                        .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout)
                        .textColor(R.color.black_clr).text("Please enter your Phone Number"));

            } else if (str_password.equals("")) {
                iserror = true;
                v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
                /**************** Start Animation ****************/
                YoYo.with(Techniques.Tada).duration(700).playOn(ET_Password);
                /**************** End Animation ****************/

                /*Toast.makeText(getApplicationContext(),
                    "Please enter your Password", Toast.LENGTH_SHORT).show();*/

                SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP)
                        .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout)
                        .textColor(R.color.black_clr).text("Please enter your Password"));

            } else if (str_password.length() < 5) {
                iserror = true;
                v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
                /**************** Start Animation ****************/
                YoYo.with(Techniques.Shake).duration(700).playOn(ET_Password);
                /**************** End Animation ****************/

                /*Toast.makeText(getApplicationContext(), "Please enter more than 5 character in password.",
                    Toast.LENGTH_SHORT).show();*/

                SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP)
                        .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout)
                        .textColor(R.color.black_clr)
                        .text("Please enter more than 5 character \n in password."));

            } else if (!str_confirm_password.equals(str_password)) {
                iserror = true;
                v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
                /**************** Start Animation ****************/
                YoYo.with(Techniques.Swing).duration(700).playOn(ET_Password);

                YoYo.with(Techniques.Swing).duration(700).playOn(ET_Confirm_Password);
                /**************** End Animation ****************/

                /*Toast.makeText(getApplicationContext(),
                    "oopsss....\n Password not Match Please try again", Toast.LENGTH_SHORT).show();*/

                SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP)
                        .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout)
                        .textColor(R.color.black_clr)
                        .text("oopsss....\\n Password not Match Please try again"));

            } else if (!iserror) {
                v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
                /*Toast.makeText(getApplicationContext(),
                    "Good", Toast.LENGTH_SHORT).show();*/

                SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP)
                        .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout)
                        .textColor(R.color.black_clr).text("Good All Value Correct"));

                if (Utils.isConnected(getActivity())) {
                    SignUpJsontask task = new SignUpJsontask();
                    task.execute();
                } else {

                    SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP)
                            .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout)
                            .textColor(R.color.black_clr).text("Please Your Internet Connectivity..!!"));

                }

            }

        }
    });

    FaceBook_signup.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toast.makeText(getActivity(), "FaceBook Signup ", Toast.LENGTH_SHORT).show();
        }
    });

    Twitter_signup.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toast.makeText(getActivity(), "Twitter Signup ", Toast.LENGTH_SHORT).show();
        }
    });

    Instagram_signup.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toast.makeText(getActivity(), "Instagram Signup ", Toast.LENGTH_SHORT).show();
        }
    });

    TV_terms_condition.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toast.makeText(getActivity(), "Terms & condition ", Toast.LENGTH_SHORT).show();
        }
    });

    initUI(rootView);
    return rootView;
}

From source file:in.com.ralarm.AlarmActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.alarm_activity);

    //insert testing ******************************************

    try {/*from w  ww.j  a v  a  2 s .c  om*/
        loadJSONFromAsset();
        Database.init(getApplicationContext());
        //Database.deleteAll();

        JSONArray m_jArry = new JSONArray(loadJSONFromAsset());
        for (int i = 0; i < m_jArry.length(); i++) {
            JSONObject jo_inside = m_jArry.getJSONObject(i);
            Log.d("Details-->", jo_inside.getString("Active"));
            String time = jo_inside.getString("Time");
            String dayss = jo_inside.getString("Days");
            String active = jo_inside.getString("Medication");
            String name = jo_inside.getString("Medication");

            //Alarm.Day[] days = {Alarm.Day.MONDAY, Alarm.Day.TUESDAY, Alarm.Day.WEDNESDAY, Alarm.Day.THURSDAY, Alarm.Day.FRIDAY, Alarm.Day.SATURDAY, Alarm.Day.SUNDAY};
            Alarm.Day[] days = { Alarm.Day.MONDAY, Alarm.Day.TUESDAY, Alarm.Day.WEDNESDAY, Alarm.Day.THURSDAY,
                    Alarm.Day.FRIDAY };
            //Alarm.Day[] daysA ={Alarm.Day.valueOf(dayss)};//one day basis
            Alarm a = new Alarm();
            Alarm.Day[] daysA;
            String[] items = dayss.split(",");

            List<Alarm.Day> result = new LinkedList<Alarm.Day>();
            for (String item : items) {
                result.add(Alarm.Day.valueOf(item));
            }

            a.setDays(result.toArray(new Alarm.Day[result.size()]));

            //a.setDays(daysA);
            a.setAlarmActive(true);
            a.setAlarmTime(time);
            a.setDifficulty(Alarm.Difficulty.EASY);
            a.setAlarmName(name);
            a.setVibrate(true);
            Database.create(a);

        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    /*
    //insert test
     Database.init(getApplicationContext());
    //Alarm.Day[] days = {Alarm.Day.MONDAY, Alarm.Day.TUESDAY, Alarm.Day.WEDNESDAY, Alarm.Day.THURSDAY, Alarm.Day.FRIDAY, Alarm.Day.SATURDAY, Alarm.Day.SUNDAY};
    Alarm.Day[] days = {Alarm.Day.MONDAY, Alarm.Day.TUESDAY, Alarm.Day.WEDNESDAY, Alarm.Day.THURSDAY, Alarm.Day.FRIDAY};
      Alarm a = new Alarm();
    a.setAlarmActive(true);
    a.setAlarmTime("17:08");
    a.setDays(days);
    a.setAlarmName("rahul");
    a.setVibrate(true);
     Database.create(a);
     // insert ends ******************************************
       */
    // insert ends ******************************************

    mathAlarmListView = (ListView) findViewById(android.R.id.list);
    mathAlarmListView.setLongClickable(true);
    mathAlarmListView.setOnItemLongClickListener(new OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> adapterView, View view, int position, long id) {
            view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            final Alarm alarm = (Alarm) alarmListAdapter.getItem(position);
            Builder dialog = new AlertDialog.Builder(AlarmActivity.this);
            dialog.setTitle("Delete");
            dialog.setMessage("Delete this alarm?");
            dialog.setPositiveButton("Ok", new OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {

                    Database.init(AlarmActivity.this);
                    Database.deleteEntry(alarm);
                    AlarmActivity.this.callMathAlarmScheduleService();

                    updateAlarmList();
                }
            });
            dialog.setNegativeButton("Cancel", new OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });

            dialog.show();

            return true;
        }
    });

    callMathAlarmScheduleService();

    alarmListAdapter = new AlarmListAdapter(this);
    this.mathAlarmListView.setAdapter(alarmListAdapter);
    mathAlarmListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View v, int position, long id) {
            v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
            Alarm alarm = (Alarm) alarmListAdapter.getItem(position);
            Intent intent = new Intent(AlarmActivity.this, AlarmPreferencesActivity.class);
            intent.putExtra("alarm", alarm);
            startActivity(intent);
        }

    });
}

From source file:eu.dirtyharry.androidopsiadmin.Main.java

public void buttonListener(final View view) {
    if (vibrate) {
        view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
    }//from ww  w.ja  v a 2  s . com
    // new Functions().noPreferences(Main.this,
    // getString(R.string.gen_title_error),
    // getString(R.string.gen_setpreferences));
    if (!new Functions().checkPreferences(Main.this)) {
        new Functions().noPreferences(Main.this, getString(R.string.gen_title_error),
                getString(R.string.gen_setserverpreferences));
        return;
    }
    // noPreferences(Main.this,
    // getString(R.string.gen_title_error),
    // getString(R.string.gen_setpreferences));
    switch (view.getId()) {
    case R.id.bt_scanqr:
        // Intent intent = new
        // Intent("com.google.zxing.client.android.SCAN");
        // intent.setPackage("com.google.zxing.client.android");
        // intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
        // setResult(RESULT_OK, intent);
        // startActivityForResult(intent, 0);
        Intent qrDroid = new Intent("la.droid.qr.scan");
        qrDroid.putExtra("la.droid.qr.complete", true);
        try {
            startActivityForResult(qrDroid, GET_QR);
        } catch (ActivityNotFoundException activity) {
            Functions.qrDroidRequired(Main.this);
        }

        break;

    case R.id.bt_getopsiclients:
        Log.d("Barcode", "getopsiclient");
        // if (Networking.isConnected(Main.this)) {
        getOpsiClientsTask();
        // } else {
        // Toast.makeText(Main.this, R.string.to_wifinotconnected,
        // Toast.LENGTH_LONG).show();
        // }
        break;
    case R.id.bt_defineclientselection:
        if (Networking.isConnected(Main.this)) {
            final ProgressDialog dialog = ProgressDialog.show(Main.this,
                    getString(R.string.gen_title_pleasewait), getString(R.string.pd_getclients), true);
            final Handler handler = new Handler() {
                public void handleMessage(Message msg) {
                    dialog.dismiss();
                    if (GlobalVar.getInstance().getError().equals("null")) {
                        if (doit.equals("serverdown")) {
                            Toast.makeText(Main.this,
                                    String.format(getString(R.string.to_servernotrechable), serverip),
                                    Toast.LENGTH_LONG).show();
                        }
                    } else {
                        new Functions().msgBox(Main.this, getString(R.string.gen_title_error),
                                GlobalVar.getInstance().getError(), false);
                    }
                }
            };

            Thread checkUpdate = new Thread() {
                public void run() {
                    Looper.prepare();

                    if (Networking.isServerUp(serverip, serverport, serverusername, serverpasswd)) {
                        doit = "true";
                        Intent i = new Intent(Main.this, ShowOpsiClientFilter.class);
                        startActivity(i);
                    } else {
                        doit = "serverdown";
                    }
                    handler.sendEmptyMessage(0);

                }
            };
            checkUpdate.start();
        } else {
            Toast.makeText(Main.this, R.string.to_wifinotconnected, Toast.LENGTH_LONG).show();
        }
        break;
    case R.id.bt_createopsiclient:
        // new Functions().notImplementet(Main.this);
        Intent i = new Intent(Main.this, ShowOpsiCreateClient.class);
        startActivity(i);
        break;
    case R.id.bt_showdepotconfig:
        // new Functions().notImplementet(Main.this);
        Log.d("Barcode", "depotconfig");
        if (Networking.isConnected(Main.this)) {
            getOPSIDepots();
        } else {
            Toast.makeText(Main.this, R.string.to_wifinotconnected, Toast.LENGTH_LONG).show();
        }
        break;
    // case R.id.bt_test:
    // ArrayList<String> test = new ArrayList<String>();
    // test.add("test1");
    // test.add("test2");
    // test.add("test3");
    // test.add("test4");
    // ShowOpsiClientOptionsButtonDialog buttondialog = new
    // ShowOpsiClientOptionsButtonDialog(Main.this,test);
    // buttondialog.setTitle("testtitle");
    // buttondialog.show();
    // break;
    }

}

From source file:org.catrobat.catroid.cast.CastManager.java

private void initGamepadListeners() {

    View.OnClickListener pauseButtonListener = new View.OnClickListener() {
        @Override//from   ww  w.j a  v  a 2 s .  c o  m
        public void onClick(View v) {
            v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
            gamepadActivity.onBackPressed();
        }
    };

    gamepadActivity.findViewById(R.id.gamepadPauseButton).setOnClickListener(pauseButtonListener);

    View.OnTouchListener otl = new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            handleGamepadTouch((ImageButton) v, event);
            return true;
        }
    };

    ImageButton[] gamepadButtons = {

            (ImageButton) gamepadActivity.findViewById(R.id.gamepadButtonA),
            (ImageButton) gamepadActivity.findViewById(R.id.gamepadButtonB),
            (ImageButton) gamepadActivity.findViewById(R.id.gamepadButtonUp),
            (ImageButton) gamepadActivity.findViewById(R.id.gamepadButtonDown),
            (ImageButton) gamepadActivity.findViewById(R.id.gamepadButtonLeft),
            (ImageButton) gamepadActivity.findViewById(R.id.gamepadButtonRight) };

    for (ImageButton btn : gamepadButtons) {
        btn.setOnTouchListener(otl);
    }
}

From source file:org.docrj.smartcard.reader.AppSelectActivity.java

private void prepareViewForMode() {
    mIntro.setText(mManual ? R.string.intro_app_select_manual : R.string.intro_app_select);
    if (mManual) {
        mSelectButton.setOnClickListener(new View.OnClickListener() {
            @Override//from   w  ww .j  a  v a2 s  .co m
            public void onClick(View v) {
                if (mSelectHaptic) {
                    v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY,
                            HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
                }
                clearMessages(false);
                // short delay to show cleared messages
                mHandler.postDelayed(new Runnable() {
                    public void run() {
                        onError(getString(R.string.manual_disconnected));
                    }
                }, 50L);
            }
        });
        if (mSelectBar.getVisibility() == View.INVISIBLE) {
            // slide select bar up and shake the button!
            mSelectBar.setVisibility(View.VISIBLE);
            Animation slideUp = AnimationUtils.loadAnimation(this, R.anim.slide_up);
            mSelectBar.startAnimation(slideUp);
            Animation shake = AnimationUtils.loadAnimation(this, R.anim.shake);
            mSelectButton.startAnimation(shake);
        }
    } else {
        if (mSelectBar.getVisibility() == View.VISIBLE) {
            Animation slideDown = AnimationUtils.loadAnimation(this, R.anim.slide_down);
            mSelectBar.startAnimation(slideDown);
            mSelectBar.setVisibility(View.INVISIBLE);
        }
    }
}