Search in sources :

Example 1 with ScheduleAdapter

use of com.lieverandiver.thesisproject.ScheduleAdapter in project classify-system by anverliedoit.

the class Home_Schedule_Slidebar_Fragment method init.

public void init() {
    new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                final List<Schedule> scheduleList = new ArrayList<>();
                TeacherHelper teacherHelper = new TeacherHelper(getContext());
                ClassServiceImpl classService = new ClassServiceImpl();
                Class _class = null;
                for (Class c : classService.getClassList()) {
                    if (c.getTeacher() == null)
                        continue;
                    if (c.getTeacher().getId() == teacherHelper.loadUser().get().getId()) {
                        _class = c;
                        Log.i("myTAG", "id : " + c.getId());
                        break;
                    }
                }
                // test
                _class = classService.getClassById(40);
                if (_class != null) {
                    for (Schedule schedule : classService.getScheduleList(_class.getId())) scheduleList.add(schedule);
                }
                handler.post(new Runnable() {

                    @Override
                    public void run() {
                        scheduleRecyclerView = (RecyclerView) customView.findViewById(R.id.shedule_recyclerview);
                        ScheduleAdapter scheduleAdapter = new ScheduleAdapter(getContext(), scheduleList);
                        scheduleRecyclerView.setAdapter(scheduleAdapter);
                        LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
                        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
                        scheduleRecyclerView.setLayoutManager(layoutManager);
                        scheduleRecyclerView.setItemAnimator(new DefaultItemAnimator());
                    }
                });
            } catch (ClassException e) {
                e.printStackTrace();
            }
        }
    }).start();
}
Also used : ScheduleAdapter(com.lieverandiver.thesisproject.ScheduleAdapter) ArrayList(java.util.ArrayList) ClassException(com.remswork.project.alice.exception.ClassException) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) Schedule(com.remswork.project.alice.model.Schedule) ClassServiceImpl(com.remswork.project.alice.service.impl.ClassServiceImpl) Class(com.remswork.project.alice.model.Class) RecyclerView(android.support.v7.widget.RecyclerView) TeacherHelper(com.lieverandiver.thesisproject.helper.TeacherHelper)

Aggregations

DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 ScheduleAdapter (com.lieverandiver.thesisproject.ScheduleAdapter)1 TeacherHelper (com.lieverandiver.thesisproject.helper.TeacherHelper)1 ClassException (com.remswork.project.alice.exception.ClassException)1 Class (com.remswork.project.alice.model.Class)1 Schedule (com.remswork.project.alice.model.Schedule)1 ClassServiceImpl (com.remswork.project.alice.service.impl.ClassServiceImpl)1 ArrayList (java.util.ArrayList)1