package mn.devfest.schedule;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import mn.devfest.R;
import mn.devfest.api.DevFestDataSource;
import mn.devfest.api.model.Session;
import mn.devfest.sessions.SessionListAdapter;
import mn.devfest.view.decoration.DividerItemDecoration;

/**
 * Fragment that displays the user's schedule
 *
 * @author bherbst
 */
public class ScheduleFragment extends Fragment {

    @Bind(R.id.schedule_recyclerview)
    RecyclerView mScheduleRecyclerView;

    private SessionListAdapter mAdapter;
    private LinearLayoutManager mLinearLayoutManager;

    private List<Session> mSessions = new ArrayList<>();

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_schedule, container, false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        ButterKnife.bind(this, view);

        mAdapter = new SessionListAdapter();
        mAdapter.setSessions(mSessions);
        mScheduleRecyclerView.setAdapter(mAdapter);
        mLinearLayoutManager = new LinearLayoutManager(getActivity());
        mScheduleRecyclerView.setLayoutManager(mLinearLayoutManager);
        mScheduleRecyclerView.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL_LIST));
    }
}

@@ -23,16 +23,48 @@
 edule;%0A%0A
+import android.content.Context;%0A
 import a
@@ -77,24 +77,24 @@
 .os.Bundle;%0A
-
 import andro
@@ -469,16 +469,54 @@
 rKnife;%0A
+import mn.devfest.DevFestApplication;%0A
 import m
@@ -602,24 +602,61 @@
 el.Session;%0A
+import mn.devfest.api.model.Speaker;%0A
 import mn.de
@@ -871,16 +871,64 @@
 ragment 
+implements DevFestDataSource.DataSourceListener 
 %7B%0A%0A    @
@@ -1153,16 +1153,393 @@
 ist%3C%3E();
+%0A    private DevFestDataSource mDataSource;%0A%0A    @Override%0A    public void onAttach(Context context) %7B%0A        super.onAttach(context);%0A        if (mDataSource == null) %7B%0A            mDataSource = DevFestApplication.get(getActivity()).component().datasource();%0A        %7D%0A        mDataSource.setDataSourceListener(this);%0A        setSessions(mDataSource.getUserSchedule());%0A    %7D
 %0A%0A    @N
@@ -2213,24 +2213,24 @@
 utManager);%0A
-
         mSch
@@ -2349,11 +2349,717 @@
 );%0A    %7D
+%0A%0A    /**%0A     * Updates the data set, and notifies the adapter of the data set change%0A     * @param sessions the sessions to update the UI with%0A     */%0A    public void setSessions(List%3CSession%3E sessions) %7B%0A        mSessions = sessions;%0A        if (mAdapter != null) %7B%0A            mAdapter.notifyDataSetChanged();%0A        %7D%0A    %7D%0A%0A    @Override%0A    public void onSessionsUpdate(List%3CSession%3E sessions) %7B%0A        setSessions(sessions);%0A    %7D%0A%0A    @Override%0A    public void onSpeakersUpdate(List%3CSpeaker%3E speakers) %7B%0A        //Intentionally left blank; no action currently needed%0A    %7D%0A%0A    @Override%0A    public void onUserScheduleUpdate(List%3CSession%3E userSchedule) %7B%0A        setSessions(userSchedule);%0A    %7D
 %0A%7D%0A

Add data source