use of com.shu.studentmanager.entity.ScoreTeacher in project student-manager by SYYANI.
the class ScoreManageFragment method initScoreList.
private void initScoreList() throws JSONException {
MediaType JSON = MediaType.parse("application/json;charset=utf-8");
StudentManagerApplication application = (StudentManagerApplication) getActivity().getApplication();
JSONObject json = new JSONObject();
json.put("cid", scoreManageFragmentBinding.scoreManageFragmentCourseNumber.getText().toString());
json.put("cname", scoreManageFragmentBinding.scoreManageFragmentCourseName.getText().toString());
json.put("cFuzzy", scoreManageFragmentBinding.scoreManageFragmentFuzzySearch.isChecked());
json.put("highBound", scoreManageFragmentBinding.scoreManageFragmentHigh.getText().toString());
json.put("lowBound", scoreManageFragmentBinding.scoreManageFragmentLow.getText().toString());
json.put("sid", scoreManageFragmentBinding.scoreManageFragmentStudentNumber.getText().toString());
json.put("sname", scoreManageFragmentBinding.scoreManageFragmentStudentName.getText().toString());
json.put("sFuzzy", scoreManageFragmentBinding.scoreManageFragmentFuzzySearch.isChecked());
json.put("term", scoreManageFragmentBinding.scoreManageTermSelect.getText().toString());
if (application.getName().equals("admin")) {
json.put("tid", "");
json.put("tname", "");
} else {
json.put("tid", application.getId());
json.put("tname", application.getName());
}
json.put("tFuzzy", scoreManageFragmentBinding.scoreManageFragmentFuzzySearch.isChecked());
// 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/SCT/findBySearch").method("POST", body).addHeader("Content-Type", "application/json").build();
Response response;
try {
response = client.newCall(request).execute();
if (response.isSuccessful()) {
ArrayList<ScoreTeacher> slist = null;
slist = new Gson().fromJson(response.body().string(), new TypeToken<ArrayList<ScoreTeacher>>() {
}.getType());
scoreManageViewModel.setMutableLiveData_score_list(slist);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}.start();
}
use of com.shu.studentmanager.entity.ScoreTeacher in project student-manager by SYYANI.
the class ScoreTeacherAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(@NonNull ScoreTeacherAdapter.ViewHolder holder, @SuppressLint("RecyclerView") int position) {
if (scoreTeacherArrayList != null && scoreTeacherArrayList.size() > 0) {
ScoreTeacher scoreTeacherEntity = scoreTeacherArrayList.get(position);
holder.score_manage_study_term.setText(scoreTeacherEntity.getTerm());
holder.score_manage_student_grade.setText(scoreTeacherEntity.getGrade());
holder.score_manage_student_sname.setText(scoreTeacherEntity.getSname());
holder.score_manage_student_sid.setText(scoreTeacherEntity.getSid());
holder.score_manage_course_id_cid.setText(scoreTeacherEntity.getCid());
holder.score_manage_course_name_cname.setText(scoreTeacherEntity.getCname());
holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
@RequiresApi(api = Build.VERSION_CODES.P)
@Override
public boolean onLongClick(View view) {
showAlertDialog(position, holder.score_manage_student_grade);
return true;
}
});
}
}
use of com.shu.studentmanager.entity.ScoreTeacher in project student-manager by SYYANI.
the class ScoreManageFragment method setScoreListRecyclerview.
private void setScoreListRecyclerview() {
score_list_recyclerview.setHasFixedSize(true);
score_list_recyclerview.setLayoutManager(new LinearLayoutManager(getActivity()));
scoreTeacherAdapter = new ScoreTeacherAdapter(getActivity());
score_list_recyclerview.setAdapter(scoreTeacherAdapter);
scoreManageViewModel.getMutableLiveData_score_list().observe(getActivity(), new Observer<ArrayList<ScoreTeacher>>() {
@Override
public void onChanged(ArrayList<ScoreTeacher> scoreTeachers) {
scoreTeacherAdapter.updateScoreTeacherList(scoreTeachers);
}
});
}
Aggregations