Search in sources :

Example 1 with LogoutAsyncTask

use of com.instructure.parentapp.asynctask.LogoutAsyncTask in project instructure-android by instructure.

the class BaseParentActivity method showMismatchedRegionDialog.

private void showMismatchedRegionDialog(final String regionString, final Context context) {
    new AlertDialog.Builder(context).setTitle(R.string.unauthorizedRegion).setMessage(getString(R.string.mismatchedRegionMessage, getReadableRegion(this, regionString))).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            Prefs prefs = new Prefs(BaseParentActivity.this, getString(R.string.app_name_parent));
            String parentId = prefs.load(Const.ID, "");
            UserManager.getStudentsForParentAirwolf(ApiPrefs.getAirwolfDomain(), parentId, new StatusCallback<List<Student>>() {

                @Override
                public void onResponse(@NonNull Response<List<Student>> response, @NonNull LinkHeaders linkHeaders, @NonNull ApiType type) {
                    if (response.body() != null && !response.body().isEmpty()) {
                        // They have students that they are observing, take them to that activity
                        startActivity(StudentViewActivity.createIntent(BaseParentActivity.this, response.body()));
                        overridePendingTransition(0, 0);
                        finish();
                    } else {
                        // Log the user out
                        new LogoutAsyncTask(BaseParentActivity.this, "").execute();
                    }
                }
            });
        }
    }).setCancelable(false).show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) LinkHeaders(com.instructure.canvasapi2.utils.LinkHeaders) StatusCallback(com.instructure.canvasapi2.StatusCallback) Prefs(com.instructure.pandautils.utils.Prefs) ApiPrefs(com.instructure.canvasapi2.utils.ApiPrefs) Student(com.instructure.canvasapi2.models.Student) RevokedTokenResponse(com.instructure.canvasapi2.models.RevokedTokenResponse) Response(retrofit2.Response) MismatchedRegionResponse(com.instructure.canvasapi2.models.MismatchedRegionResponse) BlockedStudentResponse(com.instructure.canvasapi2.models.BlockedStudentResponse) LogoutAsyncTask(com.instructure.parentapp.asynctask.LogoutAsyncTask) NonNull(android.support.annotation.NonNull) ApiType(com.instructure.canvasapi2.utils.ApiType)

Example 2 with LogoutAsyncTask

use of com.instructure.parentapp.asynctask.LogoutAsyncTask in project instructure-android by instructure.

the class SettingsActivity method logoutWarning.

private void logoutWarning() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(R.string.logout_warning);
    builder.setPositiveButton(R.string.logout_yes, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            AnalyticUtils.trackButtonPressed(AnalyticUtils.LOG_OUT);
            new LogoutAsyncTask(SettingsActivity.this, "").execute();
            dialog.dismiss();
        }
    });
    builder.setNegativeButton(R.string.logout_no, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    final AlertDialog logoutWarningDialog = builder.create();
    logoutWarningDialog.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) LogoutAsyncTask(com.instructure.parentapp.asynctask.LogoutAsyncTask)

Aggregations

DialogInterface (android.content.DialogInterface)2 AlertDialog (android.support.v7.app.AlertDialog)2 LogoutAsyncTask (com.instructure.parentapp.asynctask.LogoutAsyncTask)2 NonNull (android.support.annotation.NonNull)1 StatusCallback (com.instructure.canvasapi2.StatusCallback)1 BlockedStudentResponse (com.instructure.canvasapi2.models.BlockedStudentResponse)1 MismatchedRegionResponse (com.instructure.canvasapi2.models.MismatchedRegionResponse)1 RevokedTokenResponse (com.instructure.canvasapi2.models.RevokedTokenResponse)1 Student (com.instructure.canvasapi2.models.Student)1 ApiPrefs (com.instructure.canvasapi2.utils.ApiPrefs)1 ApiType (com.instructure.canvasapi2.utils.ApiType)1 LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)1 Prefs (com.instructure.pandautils.utils.Prefs)1 Response (retrofit2.Response)1