@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (getView() != null) { Routine routine = DataManager.getCurrentPatient().getSelectedRoutine(); TextView routineName = (TextView) getView().findViewById(R.id.routine_name); routineName.setText(routine.getRoutineTitle()); } }
private void loadExerciseData() { final List<Routine> routines = DataManager.getCurrentPatient().getRoutines(); // no routines to get data for, proceed to landing screen if (routines.isEmpty()) { dataIsAvailable(); } for (final Routine routine : routines) { WLProcedureCaller wlProcedureCaller = new WLProcedureCaller("HealthcareAdapter", "getExercisesForRoutine"); Object[] params = new Object[] {routine.getId()}; wlProcedureCaller.invoke( params, new WLResponseListener() { @Override public void onSuccess(final WLResponse wlResponse) { runOnUiThread( new Runnable() { @Override public void run() { Exercise[] exercises = getExercisesFromJson(wlResponse.getResponseJSON()); DataManager.getCurrentPatient() .addExercises(routine, Arrays.asList(exercises)); // check to see if all exercise data has been retrieved int exerciseSets = DataManager.getCurrentPatient().getNumberOfExerciseSets(); if (exerciseSets == routines.size()) { dataIsAvailable(); } } }); } @Override public void onFailure(WLFailResponse wlFailResponse) { Log.i(TAG, "Could not load exercise data!"); runOnUiThread( new Runnable() { @Override public void run() { dataIsAvailable(); } }); } }); } }