Search in sources :

Example 1 with StudentAdapter

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

the class GradeViewActivity method initRView.

public void initRView(final long classId) {
    final Handler handler = new Handler(getMainLooper());
    new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                final ClassServiceImpl classService = new ClassServiceImpl();
                final List<Student> studenList = new ArrayList<>();
                final Set<Student> studentSet = classService.getStudentList(classId);
                for (Student student : studentSet) studenList.add(student);
                final StudentAdapter studentAdapter = new StudentAdapter(GradeViewActivity.this, studenList);
                final LinearLayoutManager layoutManager = new LinearLayoutManager(GradeViewActivity.this);
                layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
                handler.post(new Runnable() {

                    @Override
                    public void run() {
                        recyclerView.setAdapter(studentAdapter);
                        recyclerView.setLayoutManager(layoutManager);
                        recyclerView.setItemAnimator(new DefaultItemAnimator());
                        if (studenList.size() < 1)
                            txtMsgContent.setVisibility(View.VISIBLE);
                    }
                });
            } catch (ClassException e) {
                e.printStackTrace();
            }
        }
    }).start();
}
Also used : ArrayList(java.util.ArrayList) StudentAdapter(com.lieverandiver.thesisproject.adapter.StudentAdapter) Handler(android.os.Handler) ClassException(com.remswork.project.alice.exception.ClassException) Student(com.remswork.project.alice.model.Student) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) ClassServiceImpl(com.remswork.project.alice.service.impl.ClassServiceImpl)

Example 2 with StudentAdapter

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

the class StudentViewActivity method initRView.

public void initRView(final long classId) {
    final Handler handler = new Handler(getMainLooper());
    new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                final ClassServiceImpl classService = new ClassServiceImpl();
                final List<Student> studenList = new ArrayList<>();
                final Set<Student> studentSet = classService.getStudentList(classId);
                for (Student student : studentSet) studenList.add(student);
                Collections.sort(studenList, new Comparator<Student>() {

                    @Override
                    public int compare(final Student object1, final Student object2) {
                        return object1.getLastName().compareTo(object2.getLastName());
                    }
                });
                final StudentAdapter studentAdapter = new StudentAdapter(StudentViewActivity.this, studenList);
                final LinearLayoutManager layoutManager = new LinearLayoutManager(StudentViewActivity.this);
                layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
                handler.post(new Runnable() {

                    @Override
                    public void run() {
                        recyclerView.setAdapter(studentAdapter);
                        recyclerView.setLayoutManager(layoutManager);
                        recyclerView.setItemAnimator(new DefaultItemAnimator());
                        if (studenList.size() < 1)
                            txtMsgContent.setVisibility(View.VISIBLE);
                    }
                });
            } catch (ClassException e) {
                e.printStackTrace();
            }
        }
    }).start();
}
Also used : ArrayList(java.util.ArrayList) StudentAdapter(com.lieverandiver.thesisproject.adapter.StudentAdapter) Handler(android.os.Handler) ClassException(com.remswork.project.alice.exception.ClassException) Student(com.remswork.project.alice.model.Student) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) ClassServiceImpl(com.remswork.project.alice.service.impl.ClassServiceImpl)

Aggregations

Handler (android.os.Handler)2 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 StudentAdapter (com.lieverandiver.thesisproject.adapter.StudentAdapter)2 ClassException (com.remswork.project.alice.exception.ClassException)2 Student (com.remswork.project.alice.model.Student)2 ClassServiceImpl (com.remswork.project.alice.service.impl.ClassServiceImpl)2 ArrayList (java.util.ArrayList)2