use of com.shu.studentmanager.entity.Student in project student-manager by SYYANI.
the class ManageStudentFragment method setStudentListRecycleview.
private void setStudentListRecycleview() {
student_list_recyclerview.setHasFixedSize(true);
student_list_recyclerview.setLayoutManager(new LinearLayoutManager(getActivity()));
studentAdapter = new StudentAdapter(getActivity());
student_list_recyclerview.setAdapter(studentAdapter);
manageStudentViewModel.getMutableLiveData_manage_student_list().observe(getActivity(), new Observer<ArrayList<Student>>() {
@Override
public void onChanged(ArrayList<Student> students) {
studentAdapter.updateStudentList(students);
}
});
}
use of com.shu.studentmanager.entity.Student in project student-manager by SYYANI.
the class ManageStudentFragment method initStudentList.
private void initStudentList() throws JSONException, IOException {
MediaType JSON = MediaType.parse("application/json;charset=utf-8");
JSONObject json = new JSONObject();
json.put("sid", manageStudentFragmentBinding.manageStudentFragmentStudentNumberSid.getText().toString());
json.put("sname", manageStudentFragmentBinding.manageStudentFragmentStudentNameSname.getText().toString());
json.put("password", manageStudentFragmentBinding.manageStudentCheckboxIsFuzzy.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/student/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<Student> tlist = null;
try {
// Log.d(TAG, "run: "+response.body().string());
tlist = new Gson().fromJson(response.body().string(), new TypeToken<ArrayList<Student>>() {
}.getType());
// mlist.addAll(tlist);
manageStudentViewModel.setMutableLiveData_manage_student_list(tlist);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}.start();
}
use of com.shu.studentmanager.entity.Student in project student-manager by SYYANI.
the class StudentAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(@NonNull StudentAdapter.ViewHolder holder, @SuppressLint("RecyclerView") int position) {
if (studentList != null && studentList.size() > 0) {
Student studentEntity = studentList.get(position);
holder.student_id.setText(studentEntity.getSid());
holder.student_name.setText(studentEntity.getSname());
holder.student_password.setText(studentEntity.getPassword());
holder.itemView.setOnClickListener(new View.OnClickListener() {
@RequiresApi(api = Build.VERSION_CODES.P)
@Override
public void onClick(View view) {
showAlertDialogMode(position, holder.student_password);
}
});
holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
showAlertDialoDelete(position);
return true;
}
});
}
}
use of com.shu.studentmanager.entity.Student 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