use of com.reprezen.kaizen.oasparser.model3.MediaType in project student-manager by SYYANI.
the class ManageCourseFragment method initCourseList.
private void initCourseList() throws IOException, JSONException {
MediaType JSON = MediaType.parse("application/json;charset=utf-8");
JSONObject json = new JSONObject();
json.put("cid", manageCourseFragmentBinding.manageCourseFragmentInputClassNumber.getText().toString());
json.put("cname", manageCourseFragmentBinding.manageCourseFragmentCourseName.getText().toString());
json.put("fuzzy", manageCourseFragmentBinding.manageCourseCheckboxIsFuzzy.isChecked());
json.put("highBound", manageCourseFragmentBinding.manageCourseFragmentCourseCreditHigh.getText().toString());
json.put("lowBound", manageCourseFragmentBinding.manageCourseFragmentCourseCreditLow.getText().toString());
// 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/course/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<CourseTeacher> tlist = null;
try {
// Log.d(TAG, "run: "+response.body().string());
tlist = new Gson().fromJson(response.body().string(), new TypeToken<ArrayList<CourseTeacher>>() {
}.getType());
// mlist.addAll(tlist);
manageCourseViewModel.setMutableLiveData_course_list(tlist);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}.start();
}
use of com.reprezen.kaizen.oasparser.model3.MediaType 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.reprezen.kaizen.oasparser.model3.MediaType in project student-manager by SYYANI.
the class OpenClassFragment method initCourseList.
private void initCourseList() throws IOException, JSONException {
MediaType JSON = MediaType.parse("application/json;charset=utf-8");
JSONObject json = new JSONObject();
json.put("cid", openClassFragmentBinding.openClassFragmentInputClassNumber.getText().toString());
json.put("cname", openClassFragmentBinding.openClassFragmentCourseName.getText().toString());
json.put("fuzzy", openClassFragmentBinding.checkboxIsFuzzy.isChecked());
json.put("highBound", openClassFragmentBinding.openClassFragmentCourseCreditHigh.getText().toString());
json.put("lowBound", openClassFragmentBinding.openClassFragmentCourseCreditLow.getText().toString());
// 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/course/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<CourseTeacher> tlist = null;
try {
// Log.d(TAG, "run: "+response.body().string());
tlist = new Gson().fromJson(response.body().string(), new TypeToken<ArrayList<CourseTeacher>>() {
}.getType());
// mlist.addAll(tlist);
openClassViewModel.setMutableLiveData_course_list(tlist);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}.start();
}
use of com.reprezen.kaizen.oasparser.model3.MediaType 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.reprezen.kaizen.oasparser.model3.MediaType 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();
}
Aggregations