@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_workout);

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    TextView toolbarTitle = (TextView) toolbar.findViewById(R.id.toolbar_title);
    toolbarTitle.setVisibility(View.GONE);

    //        ActionBar actionbar = getSupportActionBar();
    //        actionbar.setDisplayHomeAsUpEnabled(true);

    FrameLayout container = (FrameLayout) findViewById(R.id.fragment_container);

    ExerciseModel workout = (ExerciseModel) getIntent().getExtras().getSerializable("Model");

    WorkoutIntroFragment introfragment = new WorkoutIntroFragment();
    Bundle newBundle = new Bundle();
    newBundle.putSerializable("Model", workout);
    introfragment.setArguments(newBundle);
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.setCustomAnimations(R.anim.fragment_enter_anim, R.anim.fragment_exit_anim);
    ft.replace(R.id.fragment_container, introfragment, "intro");
    //   ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
    ft.commit();

    Hub hub = Hub.getInstance();
    //        if (!hub.init(this, getPackageName())) {
    //            // We can't do anything with the Myo device if the Hub can't be initialized, so
    // exit.
    //            Toast.makeText(this, "Couldn't initialize Hub", Toast.LENGTH_SHORT).show();
    //            finish();
    //            return;
    //        }

    // Next, register for DeviceListener callbacks.
    hub.addListener(mListener);
    hub.setLockingPolicy(Hub.LockingPolicy.NONE);
  }
Beispiel #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.counter_activity);
    tvCounter = (TextView) findViewById(R.id.tvCounter);
    cflCounter = (CounterFrameLayout) findViewById(R.id.cflCounter);
    tvCounter.setText("" + mRepCounter);

    mHub = Hub.getInstance();
    if (!mHub.init(this, getPackageName())) {
      // We can't do anything with the Myo device if the Hub can't be initialized, so exit.
      Toast.makeText(this, "Couldn't initialize Hub", Toast.LENGTH_SHORT).show();
      finish();
      return;
    }

    mTextToSpeech =
        new TextToSpeech(
            getApplicationContext(),
            new TextToSpeech.OnInitListener() {
              @Override
              public void onInit(int status) {}
            });
    mTextToSpeech.setLanguage(Locale.US);

    Intent intent = getIntent();
    mWorkout = intent.getParcelableExtra(Workout.TAG);

    mHub.setLockingPolicy(Hub.LockingPolicy.NONE);
    mHub.addListener(mWorkout);

    float peak = intent.getFloatExtra(CalibrationActivity.KEY_PEAK, 0);
    float dip = intent.getFloatExtra(CalibrationActivity.KEY_DIP, 0);
    mWorkout.setRange(dip, peak);
    mWorkout.setCallback(this);

    Log.e(TAG, "PEAK: " + dip);
    Log.e(TAG, "DIP: " + peak);
  }