public static TrackSessionFragment newInstance( Session session, CompletedWorkout completedWorkout, int position) { TrackSessionFragment fragment = new TrackSessionFragment(); Bundle args = new Bundle(); args.putLong("sessionId", session.getId()); args.putLong("completedWorkoutId", completedWorkout.getId()); args.putInt("position", position); fragment.setArguments(args); return fragment; }
@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"); } }