use of com.shu.studentmanager.entity.CourseStudent in project student-manager by SYYANI.
the class CourseSelectFragment method initCourseSelectList.
private void initCourseSelectList() throws JSONException, IOException {
MediaType JSON = MediaType.parse("application/json;charset=utf-8");
JSONObject json = new JSONObject();
json.put("cid", courseSelectFragmentBinding.selectCourseFragmentInputClassNumber.getText().toString());
json.put("cname", courseSelectFragmentBinding.selectCourseFragmentCourseName.getText().toString());
json.put("tid", courseSelectFragmentBinding.selectCourseFragmentTeacherNumberTid.getText().toString());
json.put("tname", courseSelectFragmentBinding.selectCourseFragmentTeacherNameTname.getText().toString());
json.put("tFuzzy", courseSelectFragmentBinding.selectCourseCheckboxIsFuzzy.isChecked());
json.put("cFuzzy", courseSelectFragmentBinding.selectCourseCheckboxIsFuzzy.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);
courseSelectViewModel.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 CourseSelectFragment method setCourseSelectListRecycleview.
private void setCourseSelectListRecycleview() {
course_select_list_recycleview.setHasFixedSize(true);
course_select_list_recycleview.setLayoutManager(new LinearLayoutManager(getActivity()));
studentCourseSelectAdapter = new StudentCourseSelectAdapter(getActivity());
course_select_list_recycleview.setAdapter(studentCourseSelectAdapter);
courseSelectViewModel.getMutableLiveData_student_select_course_list().observe(getActivity(), new Observer<ArrayList<CourseStudent>>() {
@Override
public void onChanged(ArrayList<CourseStudent> courseStudents) {
studentCourseSelectAdapter.updateCourseSelectList(courseStudents);
}
});
}
use of com.shu.studentmanager.entity.CourseStudent in project student-manager by SYYANI.
the class CourseOpenedAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(@NonNull CourseOpenedAdapter.ViewHolder holder, @SuppressLint("RecyclerView") int position) {
if (courseOpenedList != null && courseOpenedList.size() > 0) {
CourseStudent courseStudentEntity = courseOpenedList.get(position);
holder.student_opened_course_cid.setText(courseStudentEntity.getCid());
holder.student_opened_course_cname.setText(courseStudentEntity.getCname());
holder.student_opened_course_tid.setText(courseStudentEntity.getTid());
holder.student_opened_course_tname.setText(courseStudentEntity.getTname());
holder.student_opened_course_ccredit.setText(courseStudentEntity.getCcredit());
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new MaterialAlertDialogBuilder(context).setTitle("确认").setMessage("确定删除该课程?").setNeutralButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}).setPositiveButton("确认", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Log.d(TAG, "onClick: " + which + " " + position);
enSureDelete(courseOpenedList.get(position));
courseOpenedList.remove(courseOpenedList.get(position));
}
}).show();
}
});
}
}
use of com.shu.studentmanager.entity.CourseStudent in project student-manager by SYYANI.
the class StudentCourseAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(@NonNull StudentCourseAdapter.ViewHolder holder, @SuppressLint("RecyclerView") int position) {
if (courseStudentList != null && courseStudentList.size() > 0) {
CourseStudent courseStudentEntity = courseStudentList.get(position);
holder.student_course_cid.setText(courseStudentEntity.getCid());
holder.student_course_cname.setText(courseStudentEntity.getCname());
holder.student_course_tid.setText(courseStudentEntity.getTid());
holder.student_course_tname.setText(courseStudentEntity.getTname());
holder.student_course_ccredit.setText(courseStudentEntity.getCcredit());
holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
new MaterialAlertDialogBuilder(context).setTitle("确认").setMessage("确定不选该课程?").setNeutralButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}).setPositiveButton("确认", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Log.d(TAG, "onClick: " + which + " " + position);
enSureDelete(courseStudentList.get(position));
}
}).show();
return false;
}
});
} else {
return;
}
}
use of com.shu.studentmanager.entity.CourseStudent in project student-manager by SYYANI.
the class StudentCourseSelectAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(@NonNull StudentCourseSelectAdapter.ViewHolder holder, @SuppressLint("RecyclerView") int position) {
if (courseSelectList != null && courseSelectList.size() > 0) {
CourseStudent courseStudentEntity = courseSelectList.get(position);
holder.student_select_course_cid.setText(courseStudentEntity.getCid());
holder.student_select_course_cname.setText(courseStudentEntity.getCname());
holder.student_select_course_tid.setText(courseStudentEntity.getTid());
holder.student_select_course_tname.setText(courseStudentEntity.getTname());
holder.student_select_course_ccredit.setText(courseStudentEntity.getCcredit());
holder.button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new MaterialAlertDialogBuilder(context).setTitle("确认").setMessage("确定选择该课程?").setNeutralButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}).setPositiveButton("确认", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Log.d(TAG, "onClick: " + which + " " + position);
try {
enSureSelect(courseSelectList.get(position));
} catch (JSONException e) {
e.printStackTrace();
}
}
}).show();
}
});
}
}
Aggregations