use of com.shu.studentmanager.entity.CourseTeacher in project student-manager by SYYANI.
the class ManageCourseFragment method setCourseOpenListRecycleview.
private void setCourseOpenListRecycleview() {
course_manage_list_recycleview.setHasFixedSize(true);
course_manage_list_recycleview.setLayoutManager(new LinearLayoutManager(getActivity()));
courseManageAdapter = new CourseManageAdapter(getActivity());
course_manage_list_recycleview.setAdapter(courseManageAdapter);
manageCourseViewModel.getMutableLiveData_course_list().observe(getActivity(), new Observer<ArrayList<CourseTeacher>>() {
@Override
public void onChanged(ArrayList<CourseTeacher> courseTeachers) {
courseManageAdapter.updateCourseList(courseTeachers);
}
});
}
use of com.shu.studentmanager.entity.CourseTeacher in project student-manager by SYYANI.
the class ManageCourseFragment method initCourseList.
private void initCourseList() throws IOException, JSONException {
MediaType JSON = MediaType.parse("application/json;charset=utf-8");
JSONObject json = new JSONObject();
json.put("cid", manageCourseFragmentBinding.manageCourseFragmentInputClassNumber.getText().toString());
json.put("cname", manageCourseFragmentBinding.manageCourseFragmentCourseName.getText().toString());
json.put("fuzzy", manageCourseFragmentBinding.manageCourseCheckboxIsFuzzy.isChecked());
json.put("highBound", manageCourseFragmentBinding.manageCourseFragmentCourseCreditHigh.getText().toString());
json.put("lowBound", manageCourseFragmentBinding.manageCourseFragmentCourseCreditLow.getText().toString());
// Log.d(TAG, "initCourseList: "+ 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/course/findBySearch").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<CourseTeacher> tlist = null;
try {
// Log.d(TAG, "run: "+response.body().string());
tlist = new Gson().fromJson(response.body().string(), new TypeToken<ArrayList<CourseTeacher>>() {
}.getType());
// mlist.addAll(tlist);
manageCourseViewModel.setMutableLiveData_course_list(tlist);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}.start();
}
use of com.shu.studentmanager.entity.CourseTeacher in project student-manager by SYYANI.
the class OpenClassFragment method initCourseList.
private void initCourseList() throws IOException, JSONException {
MediaType JSON = MediaType.parse("application/json;charset=utf-8");
JSONObject json = new JSONObject();
json.put("cid", openClassFragmentBinding.openClassFragmentInputClassNumber.getText().toString());
json.put("cname", openClassFragmentBinding.openClassFragmentCourseName.getText().toString());
json.put("fuzzy", openClassFragmentBinding.checkboxIsFuzzy.isChecked());
json.put("highBound", openClassFragmentBinding.openClassFragmentCourseCreditHigh.getText().toString());
json.put("lowBound", openClassFragmentBinding.openClassFragmentCourseCreditLow.getText().toString());
// Log.d(TAG, "initCourseList: "+ 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/course/findBySearch").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<CourseTeacher> tlist = null;
try {
// Log.d(TAG, "run: "+response.body().string());
tlist = new Gson().fromJson(response.body().string(), new TypeToken<ArrayList<CourseTeacher>>() {
}.getType());
// mlist.addAll(tlist);
openClassViewModel.setMutableLiveData_course_list(tlist);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}.start();
}
use of com.shu.studentmanager.entity.CourseTeacher in project student-manager by SYYANI.
the class OpenClassFragment method setCourseOpenListRecycleview.
private void setCourseOpenListRecycleview() {
course_open_list_recycleview.setHasFixedSize(true);
course_open_list_recycleview.setLayoutManager(new LinearLayoutManager(getActivity()));
courseOpenAdapter = new CourseOpenAdapter(getActivity());
course_open_list_recycleview.setAdapter(courseOpenAdapter);
openClassViewModel.getMutableLiveData_course_list().observe(getActivity(), new Observer<ArrayList<CourseTeacher>>() {
@Override
public void onChanged(ArrayList<CourseTeacher> courseTeachers) {
courseOpenAdapter.updateCourseList(courseTeachers);
}
});
}
use of com.shu.studentmanager.entity.CourseTeacher in project student-manager by SYYANI.
the class CourseOpenAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(@NonNull CourseOpenAdapter.ViewHolder holder, @SuppressLint("RecyclerView") int position) {
if (courseOpenList != null && courseOpenList.size() > 0) {
CourseTeacher courseEntity = courseOpenList.get(position);
holder.course_id_cid.setText(courseEntity.getCid());
holder.course_name_cname.setText(courseEntity.getCname());
holder.course_credit_ccredit.setText(courseEntity.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);
enSureOpen(courseOpenList.get(position));
}
}).show();
}
});
} else {
return;
}
}
Aggregations