use of com.shu.studentmanager.StudentManagerApplication in project student-manager by SYYANI.
the class MainActivity method initUi.
private void initUi() {
StudentManagerApplication application = (StudentManagerApplication) getApplication();
View header = binding.navView.getHeaderView(0);
TextView text_user_name = header.findViewById(R.id.user_name_text);
TextView text_user_id = header.findViewById(R.id.user_id_text);
TextView text_current_term = header.findViewById(R.id.current_term_text);
text_user_name.setText(application.getName());
text_user_id.setText(application.getId());
text_current_term.setText(application.getCurrentTerm());
}
use of com.shu.studentmanager.StudentManagerApplication in project student-manager by SYYANI.
the class CourseManageAdapter method enSureDelete.
private void enSureDelete(CourseTeacher courseTeacher) {
Log.d(TAG, "enSureDelete: " + courseTeacher.toString());
StudentManagerApplication application = (StudentManagerApplication) context.getApplicationContext();
String url = "http://101.35.20.64:10086/course/deleteById/" + courseTeacher.getCid();
new Thread() {
@Override
public void run() {
super.run();
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder().url(url).method("GET", null).build();
try {
Response response = client.newCall(request).execute();
if (response.isSuccessful()) {
// Log.d(TAG, "run: "+response.body().string());
Boolean insert_true = Boolean.parseBoolean(response.body().string());
final MainActivity mainActivity;
mainActivity = (MainActivity) context;
if (insert_true) {
Handler handler = mainActivity.getHandler_main_activity();
Message message = handler.obtainMessage();
message.what = RequestConstant.REQUEST_SUCCESS;
handler.sendMessage(message);
} else {
Handler handler = mainActivity.getHandler_main_activity();
Message message = handler.obtainMessage();
message.what = RequestConstant.REQUEST_FAILURE;
handler.sendMessage(message);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}.start();
}
use of com.shu.studentmanager.StudentManagerApplication in project student-manager by SYYANI.
the class ScoreReviewFragment method initScoreReviewList.
private void initScoreReviewList() {
StudentManagerApplication application = (StudentManagerApplication) getActivity().getApplication();
String url = "http://101.35.20.64:10086/SCT/findBySid/" + application.getId() + "/" + application.getCurrentTerm();
new Thread() {
@Override
public void run() {
super.run();
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder().url(url).method("GET", null).build();
Response response;
try {
response = client.newCall(request).execute();
if (response.isSuccessful()) {
ArrayList<Course> slist = null;
slist = new Gson().fromJson(response.body().string(), new TypeToken<ArrayList<Course>>() {
}.getType());
scoreReviewViewModel.setMutableLiveData_score_review_score_list(slist);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}.start();
}
use of com.shu.studentmanager.StudentManagerApplication in project student-manager by SYYANI.
the class StudentFragment method initStudentCourseList.
private void initStudentCourseList() throws IOException {
StudentManagerApplication application = (StudentManagerApplication) getActivity().getApplication();
String url = "http://101.35.20.64:10086/SCT/findBySid/" + application.getId() + "/" + application.getCurrentTerm();
new Thread() {
@Override
public void run() {
super.run();
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder().url(url).method("GET", null).build();
try {
Response response = client.newCall(request).execute();
// Log.d(TAG, "run: "+response.body().string());
if (response.isSuccessful()) {
ArrayList<CourseStudent> tlist = new Gson().fromJson(response.body().string(), new TypeToken<ArrayList<CourseStudent>>() {
}.getType());
// mlist.addAll(tlist);
studentViewModel.setMutableLiveData_student_course_list(tlist);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}.start();
}
use of com.shu.studentmanager.StudentManagerApplication in project student-manager by SYYANI.
the class StudentFragment method onCreateView.
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
studentViewModel = new ViewModelProvider(this).get(StudentViewModel.class);
studentFragmentBinding = DataBindingUtil.inflate(inflater, R.layout.student_fragment, container, false);
studentFragmentBinding.setStudentViewModel(studentViewModel);
studentFragmentBinding.setLifecycleOwner(getActivity());
StudentManagerApplication application = (StudentManagerApplication) getActivity().getApplication();
studentFragmentBinding.studentFragmentStudentId.setText(application.getId());
studentFragmentBinding.studentFragmentStudentName.setText(application.getName());
student_course_list_recyclerview = studentFragmentBinding.studentFragmentCourseListRecycleview;
setStudentCoureListRecycleView();
View root = studentFragmentBinding.getRoot();
try {
initStudentCourseList();
} catch (IOException e) {
e.printStackTrace();
}
return root;
// return inflater.inflate(R.layout.student_fragment, container, false);
}
Aggregations