use of com.shu.studentmanager.StudentManagerApplication 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.StudentManagerApplication in project student-manager by SYYANI.
the class AdminFragment method onCreateView.
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
adminViewModel = new ViewModelProvider(this).get(AdminViewModel.class);
adminFragmentBinding = DataBindingUtil.inflate(inflater, R.layout.admin_fragment, container, false);
adminFragmentBinding.setAdminViewModel(adminViewModel);
adminFragmentBinding.setLifecycleOwner(getActivity());
StudentManagerApplication application = (StudentManagerApplication) getActivity().getApplication();
adminFragmentBinding.adminFramentTeacherId.setText(application.getId());
adminFragmentBinding.adminFragmentTeacherName.setText(application.getName());
View root = adminFragmentBinding.getRoot();
return root;
// return inflater.inflate(R.layout.student_fragment, container, false);
}
use of com.shu.studentmanager.StudentManagerApplication in project student-manager by SYYANI.
the class TeacherFragment method initCourseList.
private void initCourseList() throws IOException {
StudentManagerApplication application = (StudentManagerApplication) getActivity().getApplication();
String url = "http://101.35.20.64:10086/courseTeacher/findMyCourse/" + 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<CourseTeacher> tlist = new Gson().fromJson(response.body().string(), new TypeToken<ArrayList<CourseTeacher>>() {
}.getType());
// mlist.addAll(tlist);
teacherViewModel.setMutableLiveData_course_list(tlist);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}.start();
}
use of com.shu.studentmanager.StudentManagerApplication in project student-manager by SYYANI.
the class StudentCourseSelectAdapter method enSureSelect.
private void enSureSelect(CourseStudent courseStudent) throws JSONException {
Log.d(TAG, "enSureSelect: select course");
StudentManagerApplication application = (StudentManagerApplication) context.getApplicationContext();
Toast.makeText(context, "选课成功", Toast.LENGTH_SHORT);
MediaType JSON = MediaType.parse("application/json;charset=utf-8");
JSONObject json = new JSONObject();
json.put("cid", courseStudent.getCid());
json.put("tid", courseStudent.getTid());
json.put("sid", application.getId());
json.put("term", application.getCurrentTerm());
Log.d(TAG, "initCourseSelectList: " + 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/save").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<CourseStudent> tlist = null;
try {
Log.d(TAG, "run: " + response.body().string());
// tlist = new Gson().fromJson(response.body().string(), new TypeToken<ArrayList<CourseStudent>>() {}.getType());
// mlist.addAll(tlist);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}.start();
}
use of com.shu.studentmanager.StudentManagerApplication in project student-manager by SYYANI.
the class LoginActivity method load_select_ok.
private void load_select_ok() throws IOException {
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder().url("http://101.35.20.64:10086/info/getCurrentTerm").method("GET", null).build();
Response response = client.newCall(request).execute();
if (response.isSuccessful()) {
// Log.d(TAG, "run: "+response.body().string());
Boolean forbidCourseSelection = Boolean.parseBoolean(response.body().string());
StudentManagerApplication application = (StudentManagerApplication) getApplication();
application.setForbidCourseSelection(forbidCourseSelection);
}
}
Aggregations