@Override public void onHandEvent(HandEvent handEvent) { Log.i(TAG, "Ari " + handEvent.type); String eventType = handEvent.type.toString(); if (eventType.equals("OPEN_HAND")) { playSuccessSound(); if (foodItem.isLastStep()) { resetTraining(); } else { mAri.stop(); finish(); } } else if (eventType.equals("CLOSED_HAND")) { playSuccessSound(); if (foodItem.isLastStep()) { starGetIdActivity(); } else { if (play) pauseTraining(); } } else if (eventType.equals("V_SIGN")) { playSuccessSound(); if (!play) startTraining(); } else if (eventType.equals("LEFT_SWIPE")) { playSuccessSound(); manualNextStep(); } else if (eventType.equals("RIGHT_SWIPE")) { playSuccessSound(); previousStep(); } }
@Override protected void onPause() { super.onPause(); if (mAri != null) { mAri.stop(); } }
@Override public void onAriStart() { // Enabling and disabling gestures is only available with Indie Developer and // Enterprise licenses. mAri.disable(HandEvent.Type.SWIPE_PROGRESS) .enable( HandEvent.Type.OPEN_HAND, HandEvent.Type.CLOSED_HAND, HandEvent.Type.LEFT_SWIPE, HandEvent.Type.RIGHT_SWIPE, HandEvent.Type.UP_SWIPE, HandEvent.Type.DOWN_SWIPE, HandEvent.Type.V_SIGN); }
@Override protected void onCreate(Bundle savedInstanceState) { // Requests a voice menu on this activity. getWindow().requestFeature(WindowUtils.FEATURE_VOICE_COMMANDS); super.onCreate(savedInstanceState); setContentView(R.layout.activity_training); // init audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); // textSpeaker = TextSpeaker(getApplicationContext()); timerTextView = (TextView) findViewById(R.id.timer_texview); playPauseImageView = (ImageView) findViewById(R.id.play_pause_imageview); countDownTimer = new CountDownTimer(STEP_DISPLAY_TIME + 1000, 1000) { public void onTick(long millisUntilFinished) { if (play) { currentTime = millisUntilFinished / 1000; timerTextView.setText(currentTime + "S"); } } public void onFinish() {} }; Intent mIntent = getIntent(); currentFoodItemNumber = mIntent.getIntExtra("currentFoodItemNumber", 0); trainingLayout = (RelativeLayout) findViewById(R.id.training_layout); if (currentFoodItemNumber != 0) { initializeFoodItem(); displayStepImage(); } try { mAri = ActiveAri.getInstance(getString(R.string.ari_license_key), this) .addListeners(this) .addErrorCallback(this); } catch (final KeyDecodingException e) { Log.e(TAG, "Failed to init Ari: ", e); finish(); } startTraining(); }
@Override protected void onResume() { super.onResume(); mAri.start(this); }