Example usage for android.content Context VIBRATOR_SERVICE

List of usage examples for android.content Context VIBRATOR_SERVICE

Introduction

In this page you can find the example usage for android.content Context VIBRATOR_SERVICE.

Prototype

String VIBRATOR_SERVICE

To view the source code for android.content Context VIBRATOR_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.os.Vibrator for interacting with the vibration hardware.

Usage

From source file:com.ieeton.agency.activity.ChatActivity.java

private void setUpView() {
    activityInstance = this;
    Intent intent = getIntent();//w  w w .  j  a v a2s.  co  m
    if (intent == null) {
        return;
    }
    mChatUser = (ChatUser) intent.getExtras().getSerializable(EXTRA_USERINFO);
    clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
    manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE))
            .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo");
    // ???
    chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE);

    if (chatType == CHATTYPE_SINGLE) { // ??
        toChatUsername = intent.getStringExtra(EXTRA_USERID);
        String nick = "";
        if (mChatUser != null) {
            nick = mChatUser.getName();
        } else if (!TextUtils.isEmpty(Utils.getNickCache(this, toChatUsername))) {
            nick = Utils.getNickCache(this, toChatUsername);
        } else {
            nick = getString(R.string.default_nick);
        }
        if (toChatUsername.equals(NetEngine.getFeedbackId())) {
            mTitleName.setText(getString(R.string.xiaomishu));
        } else {
            mTitleName.setText(nick);
        }
    } else {
        // ?
        findViewById(R.id.container_to_group).setVisibility(View.VISIBLE);
        findViewById(R.id.container_remove).setVisibility(View.GONE);
        findViewById(R.id.container_voice_call).setVisibility(View.GONE);
        toChatUsername = getIntent().getStringExtra("groupId");
        group = EMGroupManager.getInstance().getGroup(toChatUsername);
        mTitleName.setText(group.getGroupName());
    }
    if (mChatUser == null) {
        new FetchInfoTask().execute(MODE_HUANXIN);
    } else {
        if (ChatUser.USER_DOCTOR.equals(mChatUser.getType())) {
            new FetchInfoTask().execute(MODE_DOCTOR);
        } else if (ChatUser.USER_PATIENT.equals(mChatUser.getType())) {
            new FetchInfoTask().execute(MODE_PATIENT);
        }
    }
    if (toChatUsername.equals(NetEngine.getFeedbackId())) {
        mBtnCall.setVisibility(View.VISIBLE);
    }
    conversation = EMChatManager.getInstance().getConversation(toChatUsername);
    // ?0
    conversation.resetUnsetMsgCount();
    adapter = new MessageAdapter(this, toChatUsername, chatType, new MessageAdapter.HeaderClickListener() {
        @Override
        public void click(int id) {
            if (id == CLICK_LEFT) {
                if (mUser == null) {
                    return;
                }
                //?
                if (mUser.getUserType() == UserInfo.ACCOUNT_DOCTOR) {
                    return;
                }
                Intent intent = new Intent(ChatActivity.this, PatientProfileActivity.class);
                intent.putExtra(PatientProfileActivity.EXTRA_USERID, toChatUsername);
                startActivity(intent);

            } else {
                Intent intent = new Intent(ChatActivity.this, MainActivity.class);
                intent.putExtra(MainActivity.INPUT_INDEX, MainActivity.INPUT_SETTING);
                startActivity(intent);
            }
        }
    });
    // ?
    listView.setAdapter(adapter);
    listView.setOnScrollListener(new ListScrollListener());
    int count = listView.getCount();
    if (count > 0) {
        listView.setSelection(count - 1);
    }

    listView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            hideKeyboard();
            more.setVisibility(View.GONE);
            //iv_emoticons_normal.setVisibility(View.VISIBLE);
            //iv_emoticons_checked.setVisibility(View.INVISIBLE);
            expressionContainer.setVisibility(View.GONE);
            btnContainer.setVisibility(View.GONE);
            return false;
        }
    });

    if (toChatUsername.equals(NetEngine.getFeedbackId()) && conversation.getMsgCount() <= 0) {
        //???
        boolean notificationOn = EMChatManager.getInstance().getChatOptions().getNotificationEnable();
        boolean soundOn = EMChatManager.getInstance().getChatOptions().getNoticedBySound();
        boolean vibrateOn = EMChatManager.getInstance().getChatOptions().getNoticedByVibrate();
        if (notificationOn && soundOn) {
            mSoundID = initSoundPool();
            mSoundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() {
                @Override
                public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
                    playSound();
                }
            });
        }
        if (notificationOn && vibrateOn) {
            mVibrator = (Vibrator) getApplicationContext().getSystemService(Context.VIBRATOR_SERVICE);
            playVibrator();
        }

        EMMessage message = EMMessage.createSendMessage(EMMessage.Type.TXT);
        String msgID = message.getMsgId();
        message.setMsgId("ieeton" + msgID);

        String content = getString(R.string.mishu_begin_conversation);
        TextMessageBody txtBody = new TextMessageBody(content);
        message.addBody(txtBody);

        message.setFrom(toChatUsername);
        message.setTo(DemoApplication.getInstance().getUserName());
        message.direct = EMMessage.Direct.RECEIVE;

        conversation.addMessage(message);
        EMChatManager.getInstance().saveMessage(message);
        adapter.refresh();

    }

    // ?
    receiver = new NewMessageBroadcastReceiver();
    IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction());
    // Mainacitivity,??chat??????
    intentFilter.setPriority(5);
    registerReceiver(receiver, intentFilter);

    // ack?BroadcastReceiver
    IntentFilter ackMessageIntentFilter = new IntentFilter(
            EMChatManager.getInstance().getAckMessageBroadcastAction());
    ackMessageIntentFilter.setPriority(5);
    registerReceiver(ackMessageReceiver, ackMessageIntentFilter);

    // ??BroadcastReceiver
    IntentFilter deliveryAckMessageIntentFilter = new IntentFilter(
            EMChatManager.getInstance().getDeliveryAckMessageBroadcastAction());
    deliveryAckMessageIntentFilter.setPriority(5);
    registerReceiver(deliveryAckMessageReceiver, deliveryAckMessageIntentFilter);

    // ????T
    groupListener = new GroupListener();
    EMGroupManager.getInstance().addGroupChangeListener(groupListener);

    // show forward message if the message is not null
    String forward_msg_id = getIntent().getStringExtra("forward_msg_id");
    if (forward_msg_id != null) {
        // ?????
        forwardMessage(forward_msg_id);
    }

}

From source file:hr.abunicic.angular.CameraActivity.java

/**
 * Method that initializes the camera.// ww w.j  av a 2s. c  om
 */
void initCamera() {
    try {
        mCamera = Camera.open();
    } catch (Exception e) {
        Log.d("ERROR", "Failed to get camera: " + e.getMessage());
    }

    if (mCamera != null) {
        //Creating a CameraView instance to show camera data
        mCameraView = new CameraView(this, mCamera);
        preview = (FrameLayout) findViewById(R.id.camera_view);
        //Adding the CameraView to the layout
        preview.addView(mCameraView);
        params = mCamera.getParameters();

        List<Camera.Size> ls = params.getSupportedPreviewSizes();
        Camera.Size size = ls.get(1);
        params.setPreviewSize(size.width, size.height);

        //Setting focus mode
        params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
        mCamera.setParameters(params);
        mCamera.setDisplayOrientation(90);
    }

    mCameraView.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            Vibrator vib = (Vibrator) getApplicationContext().getSystemService(Context.VIBRATOR_SERVICE);
            vib.vibrate(60);

            //Determining which line is selected
            if (rp != null) {
                try {
                    selectedLine = getTouchedLine(touchX, touchY);
                    selectedLine.color = Color.BLUE;
                } catch (Exception e) {
                }
            } else {
            }

            //AlertDialog for changing the length of the line
            AlertDialog.Builder alert = new AlertDialog.Builder(CameraActivity.this);
            final EditText edittext = new EditText(CameraActivity.this);

            alert.setMessage("Duljina stranice: ");
            alert.setView(edittext);

            alert.setPositiveButton("U redu", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    lineLength = edittext.getText().toString();
                    selectedLine.color = Color.CYAN;
                    Log.d("ocr", "Nova duljina linije: " + lineLength + " ");
                    selectedLine = getTouchedLine(numberX, numberY);
                    RecognitionMethods.refreshLines(rp.getLineSegments(), selectedLine, lineLength);
                    updateDescription();
                }
            });

            alert.show();

            return true;
        }
    });

    mCameraView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            Camera camera = mCamera;
            camera.cancelAutoFocus();

            touchX = event.getX();
            touchY = event.getY();

            return false;
        }

    });

}

From source file:com.marekscholtz.bluetify.utilities.BluetoothChatService.java

private void showNotification(Friend friend, ChatMessage chatMessage) {
    if (mHandler == null) {
        Intent clickIntent = new Intent(getApplicationContext(), ChatActivity.class);
        clickIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        clickIntent.putExtra("mac_address", friend.getMacAddress());
        PendingIntent clickPendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, clickIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getApplicationContext())
                .setSmallIcon(R.drawable.ic_logo_white_24dp).setPriority(Notification.PRIORITY_HIGH)
                .setColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimary))
                .setContentTitle(friend.getName()).setContentIntent(clickPendingIntent).setAutoCancel(true);

        if (mSharedPreferences.getBoolean("notification_sound", false)) {
            notificationBuilder.setSound(Settings.System.DEFAULT_NOTIFICATION_URI);
        }//from   w  ww  .ja  va 2  s . com

        if (mSharedPreferences.getBoolean("notification_vibration", false)) {
            notificationBuilder.setVibrate(new long[] { 0, 250, 250, 250 });
        }

        if (mSharedPreferences.getBoolean("notification_light", false)) {
            notificationBuilder.setLights(0xff0082fc, 1000, 1000);
        }

        if (!chatMessage.hasPicture()) {
            notificationBuilder.setContentText(new String(chatMessage.getContent()));
        } else {
            if (chatMessage.isSent()) {
                notificationBuilder.setContentText(
                        getApplicationContext().getResources().getString(R.string.you_sent_an_image) + ".");
            } else {
                notificationBuilder.setContentText(friend.getName() + " "
                        + getApplicationContext().getResources().getString(R.string.sent_you_an_image) + ".");
            }
        }

        if (friend.getProfilePhoto() != null) {
            byte[] profilePhotoBytes = friend.getProfilePhoto();
            Bitmap profilePhotoBitmap = BitmapFactory.decodeByteArray(friend.getProfilePhoto(), 0,
                    profilePhotoBytes.length);
            notificationBuilder.setLargeIcon(profilePhotoBitmap);
        }

        //TODO reply in notification
        //            if (android.os.Build.VERSION_CODES.N <= android.os.Build.VERSION.SDK_INT) {
        //                PendingIntent replyPendingIntent =
        //                        PendingIntent.getActivity(
        //                                getApplicationContext(),
        //                                0,
        //                                new Intent("REPLY"),
        //                                PendingIntent.FLAG_UPDATE_CURRENT
        //                        );
        //                RemoteInput remoteInput = new RemoteInput.Builder("message_text")
        //                        .setLabel(getString(R.string.write_a_message))
        //                        .build();
        //
        //                NotificationCompat.Action action = new NotificationCompat.Action.Builder(R.drawable.ic_send_white_24dp,
        //                        getString(R.string.reply), replyPendingIntent)
        //                        .addRemoteInput(remoteInput)
        //                        .build();
        //
        //                getApplicationContext().registerReceiver(new NotificationBroadcastReceiver(), new IntentFilter("REPLY"));
        //                notificationBuilder.addAction(action);
        //            }

        NotificationManager mNotificationManager = (NotificationManager) getApplicationContext()
                .getSystemService(Context.NOTIFICATION_SERVICE);
        mNotificationManager.notify(0, notificationBuilder.build());
    } else {
        Vibrator vibrator = (Vibrator) getApplicationContext().getSystemService(Context.VIBRATOR_SERVICE);
        vibrator.vibrate(125);
    }
}

From source file:com.daiv.android.twitter.ui.compose.Compose.java

public void finishedTweetingNotification() {
    new Handler().postDelayed(new Runnable() {
        @Override//from   w w w.j ava2 s .  c o m
        public void run() {
            try {
                NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
                        .setSmallIcon(R.drawable.ic_stat_icon)
                        .setContentTitle(getResources().getString(R.string.tweet_success)).setOngoing(false)
                        .setTicker(getResources().getString(R.string.tweet_success));

                if (settings.vibrate) {
                    Log.v(TAG + "Test_vibrate", "vibrate on compose");
                    Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
                    long[] pattern = { 0, 50, 500 };
                    v.vibrate(pattern, -1);
                }

                NotificationManager mNotificationManager = (NotificationManager) getSystemService(
                        Context.NOTIFICATION_SERVICE);
                mNotificationManager.notify(6, mBuilder.build());
                // cancel it immediately, the ticker will just go off
                mNotificationManager.cancel(6);

                sendMessage();
            } catch (Exception e) {
                // not attached?
            }
        }
    }, 500);

}

From source file:com.android.incallui.widget.multiwaveview.GlowPadView.java

/**
 * Enable or disable vibrate on touch.//from   w  w  w  .j av  a  2  s.c o  m
 *
 * @param enabled
 */
public void setVibrateEnabled(boolean enabled) {
    if (enabled && mVibrator == null) {
        mVibrator = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
    } else {
        mVibrator = null;
    }
}

From source file:com.klinker.android.twitter.activities.compose.Compose.java

public void finishedTweetingNotification() {
    new Handler().postDelayed(new Runnable() {
        @Override/*ww w  . ja v a  2s .  c  o  m*/
        public void run() {
            try {
                NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
                        .setSmallIcon(R.drawable.ic_stat_icon)
                        .setContentTitle(getResources().getString(R.string.tweet_success)).setOngoing(false)
                        .setTicker(getResources().getString(R.string.tweet_success));

                if (settings.vibrate) {
                    Log.v("talon_vibrate", "vibrate on compose");
                    Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
                    long[] pattern = { 0, 50, 500 };
                    v.vibrate(pattern, -1);
                }

                NotificationManager mNotificationManager = (NotificationManager) getSystemService(
                        Context.NOTIFICATION_SERVICE);
                mNotificationManager.notify(6, mBuilder.build());
                // cancel it immediately, the ticker will just go off
                mNotificationManager.cancel(6);
            } catch (Exception e) {
                // not attached?
            }
        }
    }, 500);

}

From source file:paulscode.android.mupen64plusae.game.GameActivity.java

@SuppressLint("InlinedApi")
private void initControllers(View inputSource) {
    // By default, send Player 1 rumbles through phone vibrator
    final Vibrator vibrator = (Vibrator) this.getSystemService(Context.VIBRATOR_SERVICE);
    CoreInterface.registerVibrator(1, vibrator);

    // Create the touchscreen controls
    if (mGamePrefs.isTouchscreenEnabled) {
        if (!mGamePrefs.sensorAxisX.isEmpty() || !mGamePrefs.sensorAxisY.isEmpty()) {
            // Create the sensor controller
            final SensorManager sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
            mSensorController = new SensorController(sensorManager, mOverlay, mGamePrefs.sensorAxisX,
                    mGamePrefs.sensorSensitivityX, mGamePrefs.sensorAngleX, mGamePrefs.sensorAxisY,
                    mGamePrefs.sensorSensitivityY, mGamePrefs.sensorAngleY);
            mControllers.add(mSensorController);
            if (mGamePrefs.sensorActivateOnStart) {
                mSensorController.setSensorEnabled(true);
                mOverlay.onSensorEnabled(true);
            }//from   w  w w.  ja  v a 2 s  . c om
        }

        // Create the touchscreen controller
        final TouchController touchscreenController = new TouchController(mTouchscreenMap, inputSource,
                mOverlay, vibrator, mGlobalPrefs.touchscreenAutoHold, mGlobalPrefs.isTouchscreenFeedbackEnabled,
                mGamePrefs.touchscreenAutoHoldables, mSensorController);
        mControllers.add(touchscreenController);

        mDrawerLayout.setTouchMap(mTouchscreenMap);
    }

    //Check for controller configuration
    boolean needs1 = false;
    boolean needs2 = false;
    boolean needs3 = false;
    boolean needs4 = false;

    // Popup the multi-player dialog if necessary and abort if any players are unassigned
    final RomDatabase romDatabase = RomDatabase.getInstance();

    if (!romDatabase.hasDatabaseFile()) {
        final AppData appData = new AppData(this);
        romDatabase.setDatabaseFile(appData.mupen64plus_ini);
    }

    final RomDetail romDetail = romDatabase.lookupByMd5WithFallback(mRomMd5, new File(mRomPath), mRomCrc);
    if (romDetail.players > 1 && mGamePrefs.playerMap.isEnabled() && mGlobalPrefs.getPlayerMapReminder()) {
        mGamePrefs.playerMap.removeUnavailableMappings();
        needs1 = mGamePrefs.isControllerEnabled1 && !mGamePrefs.playerMap.isMapped(1);
        needs2 = mGamePrefs.isControllerEnabled2 && !mGamePrefs.playerMap.isMapped(2);
        needs3 = mGamePrefs.isControllerEnabled3 && !mGamePrefs.playerMap.isMapped(3) && romDetail.players > 2;
        needs4 = mGamePrefs.isControllerEnabled4 && !mGamePrefs.playerMap.isMapped(4) && romDetail.players > 3;

        if (needs1 || needs2 || needs3 || needs4) {
            // TODO FIXME
            //                  @SuppressWarnings( "deprecation" )
            //                  PlayerMapPreference pref = (PlayerMapPreference) findPreference( "playerMap" );
            //                  pref.show();
            //                  return;
            Popups.showNeedsPlayerMap(this);
        }
    }

    // Create the input providers shared among all peripheral controllers
    mKeyProvider = new KeyProvider(inputSource, ImeFormula.DEFAULT, mGlobalPrefs.unmappableKeyCodes);
    final MogaProvider mogaProvider = new MogaProvider(mMogaController);
    final AbstractProvider axisProvider = new AxisProvider(inputSource);

    // Create the peripheral controls to handle key/stick presses
    if (mGamePrefs.isControllerEnabled1 && !needs1) {
        final ControllerProfile p = mGamePrefs.controllerProfile1;
        mControllers.add(new PeripheralController(1, mGamePrefs.playerMap, p.getMap(), p.getDeadzone(),
                p.getSensitivity(), mOverlay, mSensorController, mKeyProvider, axisProvider, mogaProvider));
    }
    if (mGamePrefs.isControllerEnabled2 && !needs2) {
        final ControllerProfile p = mGamePrefs.controllerProfile2;
        mControllers.add(new PeripheralController(2, mGamePrefs.playerMap, p.getMap(), p.getDeadzone(),
                p.getSensitivity(), mOverlay, null, mKeyProvider, axisProvider, mogaProvider));
    }
    if (mGamePrefs.isControllerEnabled3 && !needs3) {
        final ControllerProfile p = mGamePrefs.controllerProfile3;
        mControllers.add(new PeripheralController(3, mGamePrefs.playerMap, p.getMap(), p.getDeadzone(),
                p.getSensitivity(), mOverlay, null, mKeyProvider, axisProvider, mogaProvider));
    }
    if (mGamePrefs.isControllerEnabled4 && !needs4) {
        final ControllerProfile p = mGamePrefs.controllerProfile4;
        mControllers.add(new PeripheralController(4, mGamePrefs.playerMap, p.getMap(), p.getDeadzone(),
                p.getSensitivity(), mOverlay, null, mKeyProvider, axisProvider, mogaProvider));
    }
}

From source file:com.b44t.ui.Components.PasscodeView.java

private void showFingerprintError(CharSequence error) {
    fingerprintStatusTextView.setText(error);
    fingerprintStatusTextView.setTextColor(0xfff4511e);
    Vibrator v = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
    if (v != null) {
        v.vibrate(200);/*from  w ww .  j  a  v  a2s  .  c  o m*/
    }
    AndroidUtilities.shakeView(fingerprintStatusTextView, 2, 0);
}

From source file:com.jaus.albertogiunta.justintrain_oraritreni.journeyFavourites.FavouriteJourneysActivity.java

@Override
public boolean onItemClick(int position) {
    analyticsHelper.logScreenEvent(SCREEN_FAVOURITE_JOURNEYS, ACTION_NO_SWIPE_BUT_CLICK);
    Vibrator vibe = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    if (presenter.getRecyclerViewList().get(position) instanceof FavouriteJourneysItem) {
        boolean isFavourite = ((FavouriteJourneysItem) presenter.getRecyclerViewList().get(position))
                .isPreferredInsteadOfRecent();
        Log.d("onItemClick: ", position, presenter.getPreferredJourneys().size());
        vibe.vibrate(25);/*  w w  w .ja v a  2 s  .c om*/
        PreferredJourney preferredJourney = ((FavouriteJourneysItem) presenter.getRecyclerViewList()
                .get(position)).getPreferredJourney();

        AlertDialog.Builder alertDialog = new AlertDialog.Builder(FavouriteJourneysActivity.this);
        View view = LayoutInflater.from(FavouriteJourneysActivity.this)
                .inflate(R.layout.dialog_favourites_click, null);
        alertDialog.setView(view)
                .setPositiveButton("ANNULLA", (dialogInterface, i) -> dialogInterface.dismiss()).create();

        Dialog dialog = alertDialog.show();

        RelativeLayout rlSearchAR = view.findViewById(R.id.rl_search_ar);
        TextView searchAR = view.findViewById(R.id.tv_search_ar);
        RelativeLayout rlSearchRA = view.findViewById(R.id.rl_search_ra);
        TextView searchRA = view.findViewById(R.id.tv_search_ra);
        RelativeLayout rlRemoveFromList = view.findViewById(R.id.rl_remove_from_favourites);
        RelativeLayout rlTransformToFav = view.findViewById(R.id.rl_transform_into_favourites);

        searchAR.setText("Da " + preferredJourney.getStation1().getNameShort() + " a "
                + preferredJourney.getStation2().getNameShort());
        searchRA.setText("Da " + preferredJourney.getStation2().getNameShort() + " a "
                + preferredJourney.getStation1().getNameShort());
        if (!isFavourite)
            apply(rlTransformToFav, VISIBLE);
        else
            apply(rlTransformToFav, GONE);

        rlSearchAR.setOnClickListener(v -> {
            analyticsHelper.logScreenEvent(SCREEN_FAVOURITE_JOURNEYS, ACTION_AR_FROM_POPUP);
            Intent intent = new Intent(FavouriteJourneysActivity.this, JourneySearchActivity.class);
            intent.putExtra(I_STATIONS, gson.toJson(preferredJourney));
            startActivity(intent);
            dialog.dismiss();
        });

        rlSearchRA.setOnClickListener(v -> {
            analyticsHelper.logScreenEvent(SCREEN_FAVOURITE_JOURNEYS, ACTION_RA_FROM_POPUP);
            Intent intent = new Intent(FavouriteJourneysActivity.this, JourneySearchActivity.class);
            intent.putExtra(I_STATIONS, gson.toJson(preferredJourney.swapStations()));
            startActivity(intent);
            dialog.dismiss();
        });

        rlRemoveFromList.setOnClickListener(v -> {
            analyticsHelper.logScreenEvent(SCREEN_FAVOURITE_JOURNEYS, ACTION_REMOVE_FROM_POPUP);
            if (isFavourite) {
                presenter.removeFavourite(preferredJourney.getStation1(), preferredJourney.getStation2());
            } else {
                presenter.removeRecent(preferredJourney.getStation1(), preferredJourney.getStation2());
            }
            updateFavouritesList();
            btnSearch.animate().setInterpolator(new AccelerateDecelerateInterpolator()).translationY(0)
                    .setDuration(0);
            dialog.dismiss();
        });

        rlTransformToFav.setOnClickListener(v -> {
            presenter.removeRecent(preferredJourney.getStation1(), preferredJourney.getStation2());
            analyticsHelper.logScreenEvent(SCREEN_FAVOURITE_JOURNEYS, ACTION_TRANSFORM_TO_FAVS);
            presenter.addNewFavourite(preferredJourney.getStation1(), preferredJourney.getStation2());
            updateFavouritesList();
            btnSearch.animate().setInterpolator(new AccelerateDecelerateInterpolator()).translationY(0)
                    .setDuration(0);
            dialog.dismiss();
        });
    }
    return false;
}

From source file:org.anurag.file.quest.FileQuestHD.java

@Override
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
    // TODO Auto-generated method stub
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        Vibrator vibrate = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
        vibrate.vibrate(10);/* ww w. ja v  a  2 s  .  c  o m*/
        android.os.Process.killProcess(android.os.Process.myPid());
        return true;
    }
    return super.onKeyLongPress(keyCode, event);
}