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);
}
});
}
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();
}
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);
}
});
}
Aggregations