public void onEvent(SetCompleted event) { if (event.position != position) return; if (firstSet) { completedSession.order = TrackWorkoutAct.getSessionOrder(); completedSession.save(); currentWorkoutAdapter = new SessionInfoAdapter(getActivity(), completedSession); sessionInfoLv.setAdapter(currentWorkoutAdapter); firstSet = false; // currentWorkoutAdapter.setCompletedSession(completedSession); } CompletedSet completedSet = new CompletedSet(); completedSet.reps = event.reps; completedSet.weight = event.weight; completedSet.order = currentWorkoutAdapter.getCount(); completedSet.completedSession = completedSession; completedSet.save(); currentWorkoutAdapter.update(); replaceToTimerFragment(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null) { // CompletedWorkout completedWorkout = getCompletedWorkout(); long sessionId = getArguments().getLong("sessionId", -1); session = Session.load(Session.class, sessionId); completedSession = new CompletedSession(); completedSession.session = session; Log.d(LOG_TAG, "order: " + completedSession.order); CompletedWorkout completedWorkout = CompletedWorkout.load( CompletedWorkout.class, getArguments().getLong("completedWorkoutId", -1)); completedSession.completedWorkout = completedWorkout; position = getArguments().getInt("position"); } }