app/src/main/java/com/kedrad/selftherapyball/ExercisePlanActivity.java
@Override
    protected void onCreate(Bundle savedInstanceState) {
        AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_exercise_plan);
        ButterKnife.bind(this);

        toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        //Getting string array of the menu items for setting a title in the toolbar
        String[] titles = getResources().getStringArray(R.array.menu_pain);

        //Loading image into the background
        imageViewBackground = findViewById(R.id.iv_background);
        GlideApp.with(this).load(R.drawable.front_plan_activity).fitCenter().into(imageViewBackground);

        selectedPlanId = getIntent().getIntExtra(MainActivity.SELECTED_PLAN_ID, 0);

        //Loading array of strings from resources into the ListView
        listViewExercises = findViewById(R.id.listViewExercises);
        String[] exerciseslistArray;

        switch (selectedPlanId){
            case 0:
                this.setTitle(titles[0]);
                exerciseslistArray = getResources().getStringArray(R.array.neck);
                break;
            case 1:
                this.setTitle(titles[1]);
                exerciseslistArray = getResources().getStringArray(R.array.shoulder);
                break;
            case 2:
                this.setTitle(titles[2]);
                exerciseslistArray = getResources().getStringArray(R.array.thoracic_spine);
                break;
            case 3:
                this.setTitle(titles[3]);
                exerciseslistArray = getResources().getStringArray(R.array.lumbar_spine);
                break;
            case 4:
                this.setTitle(titles[4]);
                exerciseslistArray = getResources().getStringArray(R.array.hips);
                break;
            case 5:
                this.setTitle(titles[5]);
                exerciseslistArray = getResources().getStringArray(R.array.knee);
                break;
            case 6:
                this.setTitle(titles[6]);
                exerciseslistArray = getResources().getStringArray(R.array.achilles_and_ankle_joint);
                break;
            default:
                this.setTitle(titles[0]);
                exerciseslistArray = getResources().getStringArray(R.array.neck);
                break;
        }

        listViewExercises.setAdapter(new ExercisePlanListAdapter(this, exerciseslistArray));

        //Setting OnItemClickListner for the list
        listViewExercises.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position,
                                    long id) {
                Intent intent = new Intent(ExercisePlanActivity.this, BallLocationActivity.class);

                intent.putExtra(MainActivity.SELECTED_MUSCLE_ID, position);
                intent.putExtra(MainActivity.SELECTED_PLAN_ID, selectedPlanId);
                startActivity(intent);
            }
        });



        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(ExercisePlanActivity.this, ExerciseActivity.class);
                intent.putExtra(MainActivity.SELECTED_MUSCLE_ID, 0);
                intent.putExtra(MainActivity.SELECTED_PLAN_ID, selectedPlanId);
                startActivity(intent);
                finish();
            }
        });

        //Show the next showcase when activity was started from the showcase in the previous activity
        if(getIntent().getBooleanExtra(MainActivity.STARTED_FROM_SHOWCASE, false))
            showShowcase();

    }
//ID of selected exercise plan from the menu activity
ID of selected exercise plan from the menu activity
ID of selected exercise plan from the menu activity
@Override
    protected void onCreate(Bundle savedInstanceState) {
        AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_exercise_plan);
        ButterKnife.bind(this);
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        String[] titles = getResources().getStringArray(R.array.menu_pain);
        imageViewBackground = findViewById(R.id.iv_background);
        GlideApp.with(this).load(R.drawable.front_plan_activity).fitCenter().into(imageViewBackground);
        selectedPlanId = getIntent().getIntExtra(MainActivity.SELECTED_PLAN_ID, 0);
        listViewExercises = findViewById(R.id.listViewExercises);
        String[] exerciseslistArray;
        switch (selectedPlanId){
            case 0:
                this.setTitle(titles[0]);
                exerciseslistArray = getResources().getStringArray(R.array.neck);
                break;
            case 1:
                this.setTitle(titles[1]);
                exerciseslistArray = getResources().getStringArray(R.array.shoulder);
                break;
            case 2:
                this.setTitle(titles[2]);
                exerciseslistArray = getResources().getStringArray(R.array.thoracic_spine);
                break;
            case 3:
                this.setTitle(titles[3]);
                exerciseslistArray = getResources().getStringArray(R.array.lumbar_spine);
                break;
            case 4:
                this.setTitle(titles[4]);
                exerciseslistArray = getResources().getStringArray(R.array.hips);
                break;
            case 5:
                this.setTitle(titles[5]);
                exerciseslistArray = getResources().getStringArray(R.array.knee);
                break;
            case 6:
                this.setTitle(titles[6]);
                exerciseslistArray = getResources().getStringArray(R.array.achilles_and_ankle_joint);
                break;
            default:
                this.setTitle(titles[0]);
                exerciseslistArray = getResources().getStringArray(R.array.neck);
                break;
        }
        listViewExercises.setAdapter(new ExercisePlanListAdapter(this, exerciseslistArray));
        listViewExercises.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position,
                                    long id) {
                Intent intent = new Intent(ExercisePlanActivity.this, BallLocationActivity.class);
                intent.putExtra(MainActivity.SELECTED_MUSCLE_ID, position);
                intent.putExtra(MainActivity.SELECTED_PLAN_ID, selectedPlanId);
                startActivity(intent);
            }
        });
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(ExercisePlanActivity.this, ExerciseActivity.class);
                intent.putExtra(MainActivity.SELECTED_MUSCLE_ID, 0);
                intent.putExtra(MainActivity.SELECTED_PLAN_ID, selectedPlanId);
                startActivity(intent);
                finish();
            }
        });
        if(getIntent().getBooleanExtra(MainActivity.STARTED_FROM_SHOWCASE, false))
            showShowcase();
    }
@ Override protected void onCreate ( Bundle savedInstanceState ) { AppCompatDelegate . setCompatVectorFromResourcesEnabled ( true ) ; super . onCreate ( savedInstanceState ) ; setContentView ( R . layout . activity_exercise_plan ) ; ButterKnife . bind ( this ) ; toolbar = ( Toolbar ) findViewById ( R . id . toolbar ) ; setSupportActionBar ( toolbar ) ; getSupportActionBar ( ) . setDisplayHomeAsUpEnabled ( true ) ; String [ ] titles = getResources ( ) . getStringArray ( R . array . menu_pain ) ; imageViewBackground = findViewById ( R . id . iv_background ) ; GlideApp . with ( this ) . load ( R . drawable . front_plan_activity ) . fitCenter ( ) . into ( imageViewBackground ) ; selectedPlanId = getIntent ( ) . getIntExtra ( MainActivity . SELECTED_PLAN_ID , 0 ) ; listViewExercises = findViewById ( R . id . listViewExercises ) ; String [ ] exerciseslistArray ; switch ( selectedPlanId ) { case 0 : this . setTitle ( titles [ 0 ] ) ; exerciseslistArray = getResources ( ) . getStringArray ( R . array . neck ) ; break ; case 1 : this . setTitle ( titles [ 1 ] ) ; exerciseslistArray = getResources ( ) . getStringArray ( R . array . shoulder ) ; break ; case 2 : this . setTitle ( titles [ 2 ] ) ; exerciseslistArray = getResources ( ) . getStringArray ( R . array . thoracic_spine ) ; break ; case 3 : this . setTitle ( titles [ 3 ] ) ; exerciseslistArray = getResources ( ) . getStringArray ( R . array . lumbar_spine ) ; break ; case 4 : this . setTitle ( titles [ 4 ] ) ; exerciseslistArray = getResources ( ) . getStringArray ( R . array . hips ) ; break ; case 5 : this . setTitle ( titles [ 5 ] ) ; exerciseslistArray = getResources ( ) . getStringArray ( R . array . knee ) ; break ; case 6 : this . setTitle ( titles [ 6 ] ) ; exerciseslistArray = getResources ( ) . getStringArray ( R . array . achilles_and_ankle_joint ) ; break ; default : this . setTitle ( titles [ 0 ] ) ; exerciseslistArray = getResources ( ) . getStringArray ( R . array . neck ) ; break ; } listViewExercises . setAdapter ( new ExercisePlanListAdapter ( this , exerciseslistArray ) ) ; listViewExercises . setOnItemClickListener ( new AdapterView . OnItemClickListener ( ) { @ Override public void onItemClick ( AdapterView < ? > parent , View view , int position , long id ) { Intent intent = new Intent ( ExercisePlanActivity . this , BallLocationActivity . class ) ; intent . putExtra ( MainActivity . SELECTED_MUSCLE_ID , position ) ; intent . putExtra ( MainActivity . SELECTED_PLAN_ID , selectedPlanId ) ; startActivity ( intent ) ; } } ) ; fab . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View view ) { Intent intent = new Intent ( ExercisePlanActivity . this , ExerciseActivity . class ) ; intent . putExtra ( MainActivity . SELECTED_MUSCLE_ID , 0 ) ; intent . putExtra ( MainActivity . SELECTED_PLAN_ID , selectedPlanId ) ; startActivity ( intent ) ; finish ( ) ; } } ) ; if ( getIntent ( ) . getBooleanExtra ( MainActivity . STARTED_FROM_SHOWCASE , false ) ) showShowcase ( ) ; }
ID of selected exercise plan from the menu activity
ID of selected exercise plan from the menu activity
//Getting string array of the menu items for setting a title in the toolbar //Loading image into the background //Loading array of strings from resources into the ListView //Setting OnItemClickListner for the list //Show the next showcase when activity was started from the showcase in the previous activity