Search in sources :

Example 6 with CourseStudent

use of com.shu.studentmanager.entity.CourseStudent in project student-manager by SYYANI.

the class OpenedFragment method setCourseSelectListRecycleview.

private void setCourseSelectListRecycleview() {
    course_opened_list_recycleview.setHasFixedSize(true);
    course_opened_list_recycleview.setLayoutManager(new LinearLayoutManager(getActivity()));
    courseOpenedAdapter = new CourseOpenedAdapter(getActivity());
    course_opened_list_recycleview.setAdapter(courseOpenedAdapter);
    openedViewModel.getMutableLiveData_student_select_course_list().observe(getActivity(), new Observer<ArrayList<CourseStudent>>() {

        @Override
        public void onChanged(ArrayList<CourseStudent> courseStudents) {
            courseOpenedAdapter.updateCourseSelectList(courseStudents);
        }
    });
}
Also used : CourseOpenedAdapter(com.shu.studentmanager.adpater.CourseOpenedAdapter) CourseStudent(com.shu.studentmanager.entity.CourseStudent) ArrayList(java.util.ArrayList) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager)

Example 7 with CourseStudent

use of com.shu.studentmanager.entity.CourseStudent in project student-manager by SYYANI.

the class OpenedFragment method initCourseSelectList.

private void initCourseSelectList() throws JSONException, IOException {
    MediaType JSON = MediaType.parse("application/json;charset=utf-8");
    JSONObject json = new JSONObject();
    json.put("cid", openedFragmentBinding.openedCourseFragmentInputClassNumber.getText().toString());
    json.put("cname", openedFragmentBinding.openedCourseFragmentCourseName.getText().toString());
    json.put("tid", openedFragmentBinding.openedCourseFragmentTeacherNumberTid.getText().toString());
    json.put("tname", openedFragmentBinding.openedCourseFragmentTeacherNameTname.getText().toString());
    json.put("tFuzzy", openedFragmentBinding.openedCourseCheckboxIsFuzzy.isChecked());
    json.put("cFuzzy", openedFragmentBinding.openedCourseCheckboxIsFuzzy.isChecked());
    Log.d(TAG, "initCourseSelectList: " + json.toString());
    new Thread() {

        @Override
        public void run() {
            super.run();
            OkHttpClient client = new OkHttpClient().newBuilder().build();
            MediaType mediaType = MediaType.parse("application/json");
            RequestBody body = RequestBody.create(JSON, json.toString());
            Request request = new Request.Builder().url("http://101.35.20.64:10086/courseTeacher/findCourseTeacherInfo").method("POST", body).addHeader("Content-Type", "application/json").build();
            Response response = null;
            try {
                response = client.newCall(request).execute();
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (response.isSuccessful()) {
                ArrayList<CourseStudent> tlist = null;
                try {
                    // Log.d(TAG, "run: "+response.body().string());
                    tlist = new Gson().fromJson(response.body().string(), new TypeToken<ArrayList<CourseStudent>>() {
                    }.getType());
                    // mlist.addAll(tlist);
                    openedViewModel.setMutableLiveData_student_select_course_list(tlist);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }.start();
}
Also used : OkHttpClient(okhttp3.OkHttpClient) Request(okhttp3.Request) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) IOException(java.io.IOException) Response(okhttp3.Response) JSONObject(org.json.JSONObject) TypeToken(com.google.gson.reflect.TypeToken) CourseStudent(com.shu.studentmanager.entity.CourseStudent) MediaType(okhttp3.MediaType) RequestBody(okhttp3.RequestBody)

Example 8 with CourseStudent

use of com.shu.studentmanager.entity.CourseStudent in project student-manager by SYYANI.

the class StudentFragment method setStudentCoureListRecycleView.

private void setStudentCoureListRecycleView() {
    student_course_list_recyclerview.setHasFixedSize(true);
    student_course_list_recyclerview.setLayoutManager(new LinearLayoutManager(getActivity()));
    studentCourseAdapter = new StudentCourseAdapter(getActivity());
    student_course_list_recyclerview.setAdapter(studentCourseAdapter);
    // studentViewModel.get
    studentViewModel.getMutableLiveData_student_course_list().observe(getActivity(), new Observer<ArrayList<CourseStudent>>() {

        @Override
        public void onChanged(ArrayList<CourseStudent> courseStudents) {
            // Log.d(TAG, "onChanged: update");
            studentFragmentBinding.studentFragmentStudentClassNumber.setText("本学期共有 " + String.valueOf(courseStudents.size()) + " 门课");
            studentCourseAdapter.updateCourseList(courseStudents);
        }
    });
}
Also used : StudentCourseAdapter(com.shu.studentmanager.adpater.StudentCourseAdapter) CourseStudent(com.shu.studentmanager.entity.CourseStudent) ArrayList(java.util.ArrayList) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager)

Aggregations

CourseStudent (com.shu.studentmanager.entity.CourseStudent)8 ArrayList (java.util.ArrayList)5 SuppressLint (android.annotation.SuppressLint)3 DialogInterface (android.content.DialogInterface)3 View (android.view.View)3 TextView (android.widget.TextView)3 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)3 RecyclerView (androidx.recyclerview.widget.RecyclerView)3 MaterialAlertDialogBuilder (com.google.android.material.dialog.MaterialAlertDialogBuilder)3 Gson (com.google.gson.Gson)2 TypeToken (com.google.gson.reflect.TypeToken)2 IOException (java.io.IOException)2 MediaType (okhttp3.MediaType)2 OkHttpClient (okhttp3.OkHttpClient)2 Request (okhttp3.Request)2 RequestBody (okhttp3.RequestBody)2 Response (okhttp3.Response)2 JSONObject (org.json.JSONObject)2 CourseOpenedAdapter (com.shu.studentmanager.adpater.CourseOpenedAdapter)1 StudentCourseAdapter (com.shu.studentmanager.adpater.StudentCourseAdapter)1