Search in sources :

Example 1 with MainActivity

use of com.shu.studentmanager.activity.MainActivity in project student-manager by SYYANI.

the class CourseAdapter method enSureDelete.

private void enSureDelete(CourseTeacher courseTeacher) {
    Log.d(TAG, "enSureDelete: " + courseTeacher.toString());
    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();
}
Also used : Response(okhttp3.Response) OkHttpClient(okhttp3.OkHttpClient) Message(android.os.Message) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) Request(okhttp3.Request) Handler(android.os.Handler) MainActivity(com.shu.studentmanager.activity.MainActivity) IOException(java.io.IOException)

Example 2 with MainActivity

use of com.shu.studentmanager.activity.MainActivity in project student-manager by SYYANI.

the class CourseOpenAdapter method enSureOpen.

private void enSureOpen(CourseTeacher courseTeacher) {
    Log.d(TAG, "enSureOpen: " + courseTeacher.toString());
    StudentManagerApplication application = (StudentManagerApplication) context.getApplicationContext();
    String url = "http://101.35.20.64:10086/courseTeacher/insert/" + courseTeacher.getCid() + "/" + 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();
                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();
}
Also used : OkHttpClient(okhttp3.OkHttpClient) Message(android.os.Message) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) Request(okhttp3.Request) Handler(android.os.Handler) MainActivity(com.shu.studentmanager.activity.MainActivity) IOException(java.io.IOException) Response(okhttp3.Response) StudentManagerApplication(com.shu.studentmanager.StudentManagerApplication)

Example 3 with MainActivity

use of com.shu.studentmanager.activity.MainActivity in project student-manager by SYYANI.

the class CourseOpenedAdapter method enSureDelete.

private void enSureDelete(CourseStudent courseStudent) {
    Log.d(TAG, "enSureDelete: select course");
    Log.d(TAG, "enSureDelete: " + courseStudent.toString());
    StudentManagerApplication application = (StudentManagerApplication) context.getApplicationContext();
    String url = "http://101.35.20.64:10086/course/deleteById/" + courseStudent.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();
}
Also used : OkHttpClient(okhttp3.OkHttpClient) Message(android.os.Message) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) Request(okhttp3.Request) Handler(android.os.Handler) MainActivity(com.shu.studentmanager.activity.MainActivity) IOException(java.io.IOException) Response(okhttp3.Response) StudentManagerApplication(com.shu.studentmanager.StudentManagerApplication)

Example 4 with MainActivity

use of com.shu.studentmanager.activity.MainActivity in project student-manager by SYYANI.

the class ScoreTeacherAdapter method enSureChange.

private void enSureChange(String input, ScoreTeacher scoreTeacher) {
    String url = "http://101.35.20.64:10086/SCT/updateById/" + scoreTeacher.getSid() + '/' + scoreTeacher.getCid() + '/' + scoreTeacher.getTid() + '/' + scoreTeacher.getTerm() + '/' + input;
    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();
}
Also used : Response(okhttp3.Response) OkHttpClient(okhttp3.OkHttpClient) Message(android.os.Message) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) Request(okhttp3.Request) Handler(android.os.Handler) MainActivity(com.shu.studentmanager.activity.MainActivity) IOException(java.io.IOException)

Example 5 with MainActivity

use of com.shu.studentmanager.activity.MainActivity 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();
}
Also used : OkHttpClient(okhttp3.OkHttpClient) Message(android.os.Message) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) Request(okhttp3.Request) Handler(android.os.Handler) MainActivity(com.shu.studentmanager.activity.MainActivity) IOException(java.io.IOException) Response(okhttp3.Response) StudentManagerApplication(com.shu.studentmanager.StudentManagerApplication)

Aggregations

Handler (android.os.Handler)5 Message (android.os.Message)5 MaterialAlertDialogBuilder (com.google.android.material.dialog.MaterialAlertDialogBuilder)5 MainActivity (com.shu.studentmanager.activity.MainActivity)5 IOException (java.io.IOException)5 OkHttpClient (okhttp3.OkHttpClient)5 Request (okhttp3.Request)5 Response (okhttp3.Response)5 StudentManagerApplication (com.shu.studentmanager.StudentManagerApplication)3