Example usage for android.view HapticFeedbackConstants LONG_PRESS

List of usage examples for android.view HapticFeedbackConstants LONG_PRESS

Introduction

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

Prototype

int LONG_PRESS

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

Click Source Link

Document

The user has performed a long press on an object that is resulting in an action being performed.

Usage

From source file:com.waz.zclient.ui.views.TouchFilterableFrameLayout.java

public TouchFilterableFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    gestureDetectorCompat = new GestureDetectorCompat(context, new GestureDetector.SimpleOnGestureListener() {
        @Override/*from  ww  w  .j av a  2 s.  c o m*/
        public boolean onSingleTapUp(MotionEvent e) {
            if (!filterAllClickEvents) {
                return false;
            }
            if (onClickListener != null) {
                onClickListener.onClick();
            }
            return true;
        }

        @Override
        public void onLongPress(MotionEvent e) {
            if (!filterAllClickEvents) {
                return;
            }
            performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            if (onLongClickListener != null) {
                onLongClickListener.onLongClick();
            }
        }
    });
}

From source file:com.waz.zclient.ui.views.TouchFilterableLinearLayout.java

public TouchFilterableLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    gestureDetectorCompat = new GestureDetectorCompat(context, new GestureDetector.SimpleOnGestureListener() {
        @Override/*ww w  . ja va 2 s .  c  o m*/
        public boolean onSingleTapUp(MotionEvent e) {
            if (!filterAllClickEvents) {
                return false;
            }
            if (onClickListener != null) {
                onClickListener.onClick();
            }
            return true;
        }

        @Override
        public void onLongPress(MotionEvent e) {
            if (!filterAllClickEvents) {
                return;
            }
            performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            if (onLongClickListener != null) {
                onLongClickListener.onLongClick();
            }
        }
    });
}

From source file:com.waz.zclient.pages.main.conversation.views.row.message.views.RecyclingLinearLayout.java

public RecyclingLinearLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    gestureDetectorCompat = new GestureDetectorCompat(context, new GestureDetector.SimpleOnGestureListener() {
        @Override/*from w  w w  . j a  v a2 s  .  c o m*/
        public boolean onSingleTapUp(MotionEvent e) {
            if (!filterAllClickEvents) {
                return false;
            }
            if (onClickListener != null) {
                onClickListener.onClick();
            }
            return true;
        }

        @Override
        public void onLongPress(MotionEvent e) {
            if (!filterAllClickEvents) {
                return;
            }
            performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            if (onLongClickListener != null) {
                onLongClickListener.onLongClick();
            }
        }
    });
}

From source file:com.hijacker.InstallToolsDialog.java

@Override
public void onStart() {
    super.onStart();
    //Override positiveButton action to dismiss the fragment only when the directories exist, not on error
    AlertDialog d = (AlertDialog) getDialog();
    if (d != null) {
        final Button positiveButton = d.getButton(Dialog.BUTTON_POSITIVE);
        positiveButton.setOnLongClickListener(new View.OnLongClickListener() {
            @Override//from  w w w  .j  a v a  2 s .  c  o  m
            public boolean onLongClick(View v) {
                v.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
                String tools_location = ((EditText) view.findViewById(R.id.tools_location)).getText()
                        .toString();
                String lib_location = ((EditText) view.findViewById(R.id.lib_location)).getText().toString();
                if (check(tools_location, lib_location, true, v)) {
                    install(tools_location, lib_location);
                    dismissAllowingStateLoss();
                }
                return false;
            }
        });
        positiveButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String tools_location = ((EditText) view.findViewById(R.id.tools_location)).getText()
                        .toString();
                String lib_location = ((EditText) view.findViewById(R.id.lib_location)).getText().toString();

                if (check(tools_location, lib_location, false, v)) {
                    install(tools_location, lib_location);
                    dismissAllowingStateLoss();
                }
            }
        });
    }
}

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.  ja 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:com.hijacker.InstallFirmwareDialog.java

@Override
public void onStart() {
    super.onStart();
    //Override positiveButton action to dismiss the fragment only when the directories exist, not on error
    AlertDialog d = (AlertDialog) getDialog();
    if (d != null) {
        final Button positiveButton = d.getButton(Dialog.BUTTON_POSITIVE);
        Button neutralButton = d.getButton(Dialog.BUTTON_NEUTRAL);
        positiveButton.setOnLongClickListener(new View.OnLongClickListener() {
            @Override/* w  ww  .j a v  a 2 s  .  c om*/
            public boolean onLongClick(View v) {
                v.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
                attemptInstall(true);
                return false;
            }
        });
        positiveButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                attemptInstall(false);
            }
        });
        neutralButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                positiveButton.setActivated(false);
                ProgressBar progress = (ProgressBar) dialogView.findViewById(R.id.install_firm_progress);
                progress.setIndeterminate(true);
                shell.run(busybox + " find /system/ -type f -name \"fw_bcmdhd.bin\"; echo ENDOFFIND");

                String lastline = getLastLine(shell.getShell_out(), "ENDOFFIND");
                if (lastline.equals("ENDOFFIND")) {
                    Snackbar.make(v, R.string.firm_notfound_bcm, Snackbar.LENGTH_LONG).show();
                } else {
                    lastline = lastline.substring(0, lastline.length() - 14);
                    firmView.setText(lastline);
                }

                progress.setIndeterminate(false);
                positiveButton.setActivated(true);
            }
        });
    }
}

From source file:za.co.neilson.alarm.AlarmActivity.java

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

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle("E-care");
    setSupportActionBar(toolbar);/*from  w  ww .j a va  2 s  .c om*/

    db = new SQLiteHandler(getApplicationContext());
    session = new SessionManager(getApplicationContext());

    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    NavigationView view = (NavigationView) findViewById(R.id.navigation_view);
    view.getMenu().getItem(3).setChecked(true);
    view.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override
        public boolean onNavigationItemSelected(MenuItem menuItem) {
            Toast.makeText(AlarmActivity.this, menuItem.getItemId() + " pressed", Toast.LENGTH_LONG).show();
            Log.d(R.id.nav_1 + "", menuItem.getItemId() + " ");
            Intent intent = new Intent();
            switch (menuItem.getItemId()) {
            case R.id.nav_1:
                intent.setClass(AlarmActivity.this, Case_history_review.class);
                startActivity(intent);
                break;
            case R.id.nav_2:
                intent.setClass(AlarmActivity.this, ShowAppointmentList.class);
                //intent .putExtra("name", "Hello B Activity");
                startActivity(intent);
                break;
            case R.id.nav_3:
                intent.setClass(AlarmActivity.this, Appointmentcreate.class);
                //intent .putExtra("name", "Hello B Activity");
                startActivity(intent);
                break;
            case R.id.nav_4:
                intent.setClass(AlarmActivity.this, AlarmActivity.class);
                //intent .putExtra("name", "Hello B Activity");
                startActivity(intent);
                break;
            case R.id.nav_5:
                intent.setClass(AlarmActivity.this, PatientReport.class);
                //intent .putExtra("name", "Hello B Activity");
                startActivity(intent);
                break;
            case R.id.nav_6:
                //logout
                AlertDialog.Builder builder = new AlertDialog.Builder(AlarmActivity.this);
                //Uncomment the below code to Set the message and title from the strings.xml file
                //builder.setMessage(R.string.dialog_message) .setTitle(R.string.dialog_title);

                //Setting message manually and performing action on button click
                builder.setMessage("Do you want to close this application ?").setCancelable(false)
                        .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                session.setLogin(false);
                                db.deleteUsers();
                                final Intent intent_logout = new Intent(AlarmActivity.this,
                                        LoginActivity.class);
                                startActivity(intent_logout);
                                finish();
                            }
                        }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                //  Action for 'NO' Button
                                dialog.cancel();
                            }
                        });

                //Creating dialog box
                AlertDialog alert = builder.create();
                //Setting the title manually
                alert.setTitle("AlertDialogExample");
                alert.show();

                break;
            }
            menuItem.setChecked(true);
            drawerLayout.closeDrawers();
            return true;
        }
    });

    ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar,
            R.string.drawer_open, R.string.drawer_close) {
        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
        }
    };

    HashMap<String, String> dbuser = db.getUserDetails();
    View header = view.getHeaderView(0);
    TextView headerName = (TextView) header.findViewById(R.id.drawer_name);
    String username = dbuser.get("name");
    headerName.setText(username);
    ImageLoader imageLoader = AppController.getInstance().getImageLoader();
    CirculaireNetworkImageView headerphoto = (CirculaireNetworkImageView) header
            .findViewById(R.id.drawer_thumbnail);
    headerphoto.setImageUrl("http://192.168.43.216/test/" + dbuser.get("image"), imageLoader);
    drawerLayout.setDrawerListener(actionBarDrawerToggle);
    actionBarDrawerToggle.syncState();

    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:org.isoron.uhabits.fragments.ListHabitsFragment.java

private void toggleCheck(View v) {
    Long id = helper.getHabitIdFromCheckmarkView(v);
    Habit habit = loader.habits.get(id);
    if (habit == null)
        return;//  ww w  .j  av a2 s .  c o  m

    float x = v.getX() + v.getWidth() / 2.0f + ((View) v.getParent()).getX();
    float y = v.getY() + v.getHeight() / 2.0f + ((View) v.getParent()).getY();
    helper.triggerRipple((View) v.getParent().getParent(), x, y);

    listView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    helper.toggleCheckmarkView(v, habit);

    long timestamp = helper.getTimestampFromCheckmarkView(v);
    executeCommand(new ToggleRepetitionCommand(habit, timestamp), habit.getId());
}

From source file:com.waz.zclient.pages.main.conversation.views.row.message.views.TextMessageWithTimestamp.java

@Override
public void onLongPress(MotionEvent e) {
    performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    longClickListener.onLongClick(this);
}