use of com.shu.studentmanager.entity.Teacher in project student-manager by SYYANI.
the class ManageTeacherFragment method setTeacherListRecycleview.
private void setTeacherListRecycleview() {
teacher_list_recyclerview.setHasFixedSize(true);
teacher_list_recyclerview.setLayoutManager(new LinearLayoutManager(getActivity()));
teacherAdapter = new TeacherAdapter(getActivity());
teacher_list_recyclerview.setAdapter(teacherAdapter);
manageTeacherViewModel.getMutableLiveData_manage_teacher_list().observe(getActivity(), new Observer<ArrayList<Teacher>>() {
@Override
public void onChanged(ArrayList<Teacher> teachers) {
teacherAdapter.updateStudentList(teachers);
}
});
}
use of com.shu.studentmanager.entity.Teacher in project student-manager by SYYANI.
the class TeacherAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(@NonNull TeacherAdapter.ViewHolder holder, @SuppressLint("RecyclerView") int position) {
if (teacherList != null && teacherList.size() > 0) {
Teacher teacherEntity = teacherList.get(position);
holder.teacher_id.setText(teacherEntity.getTid());
holder.teacher_name.setText(teacherEntity.getTname());
holder.teacher_password.setText(teacherEntity.getPassword());
holder.itemView.setOnClickListener(new View.OnClickListener() {
@RequiresApi(api = Build.VERSION_CODES.P)
@Override
public void onClick(View view) {
showAlertDialogMode(position, holder.teacher_password);
}
});
holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
showAlertDialoDelete(position);
return true;
}
});
}
}
use of com.shu.studentmanager.entity.Teacher in project student-manager by SYYANI.
the class ManageTeacherFragment method initTeacherList.
private void initTeacherList() throws JSONException, IOException {
MediaType JSON = MediaType.parse("application/json;charset=utf-8");
JSONObject json = new JSONObject();
json.put("tid", manageTeacherFragmentBinding.manageTeacherFragmentTeacherNumberTid.getText().toString());
json.put("tname", manageTeacherFragmentBinding.manageTeacherFragmentTeacherNameTname.getText().toString());
json.put("password", manageTeacherFragmentBinding.manageTeacherCheckboxIsFuzzy.isChecked());
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/teacher/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<Teacher> tlist = null;
try {
// Log.d(TAG, "run: "+response.body().string());
tlist = new Gson().fromJson(response.body().string(), new TypeToken<ArrayList<Teacher>>() {
}.getType());
// mlist.addAll(tlist);
manageTeacherViewModel.setMutableLiveData_manage_teacher_list(tlist);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}.start();
}
use of com.shu.studentmanager.entity.Teacher in project student-manager by SYYANI.
the class LoginActivity method load.
private void load(String username) throws IOException {
String url = "http://101.35.20.64:10086/" + user_kind + "/findById/" + username;
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder().url(url).method("GET", null).build();
Response response = client.newCall(request).execute();
if (response.isSuccessful()) {
if (user_kind == "student") {
Student student = new Gson().fromJson(response.body().string(), Student.class);
Log.d(TAG, "load: " + student.toString());
StudentManagerApplication application = (StudentManagerApplication) getApplication();
application.setId(student.getSid());
application.setName(student.getSname());
application.setToken(true);
application.setType("student");
} else if (user_kind == "teacher") {
Teacher teacher = new Gson().fromJson(response.body().string(), Teacher.class);
Log.d(TAG, "load: " + teacher.toString());
StudentManagerApplication application = (StudentManagerApplication) getApplication();
application.setId(teacher.getTid());
application.setName(teacher.getTname());
application.setToken(true);
application.setType("teacher");
}
}
load_select_ok();
load_current_term();
}
Aggregations