diff --git a/Android/app/src/main/java/tw/edu/kuas/wifiautologin/libs/LoginHelper.java b/Android/app/src/main/java/tw/edu/kuas/wifiautologin/libs/LoginHelper.java index 28a46cc..9f4354e 100644 --- a/Android/app/src/main/java/tw/edu/kuas/wifiautologin/libs/LoginHelper.java +++ b/Android/app/src/main/java/tw/edu/kuas/wifiautologin/libs/LoginHelper.java @@ -61,6 +61,7 @@ public static void login(final Context context, final UserModel model, @Override public void onFailure(Call call, IOException e) { + call.cancel(); loginFail(context, context.getString(R.string.login_timeout), callback); } @@ -113,11 +114,13 @@ private static void login(final Context context, final String location, @Override public void onFailure(Call call, IOException e) { + call.cancel(); loginFail(context, context.getString(R.string.login_timeout), callback); } @Override public void onResponse(Call call, Response response) { + call.cancel(); try { String _response = response.body().string(); if (_response.contains("login_online_detail.php")) { @@ -164,6 +167,7 @@ public static void logout(final Context context, final boolean recheck, @Override public void onFailure(Call call, IOException e) { + call.cancel(); callback.onFail(context, context.getString(R.string.failed_to_logout)); } @@ -210,11 +214,13 @@ private static void logout(final Context context, String location, @Override public void onFailure(Call call, IOException e) { + call.cancel(); callback.onFail(context, context.getString(R.string.failed_to_logout)); } @Override public void onResponse(Call call, Response response) { + call.cancel(); if (response.code() == 200) { callback.onSuccess(context, context.getString(R.string.logout_successful)); NotificationHelper.cancelNotification(context, Constant.NOTIFICATION_LOGIN_ID); @@ -274,12 +280,15 @@ private static void loginSuccess(Context context, String location, private static void loginFail(Context context, String reason, @NonNull GeneralCallback callback) { - NotificationHelper.cancelNotification(context, Constant.NOTIFICATION_LOGIN_ID); - callback.onFail(context, reason); if (!(context instanceof MainActivity)) { NotificationHelper.createNotification(context, reason, false, true, Constant.NOTIFICATION_FAIL_ID); } + NotificationHelper.cancelNotification(context, Constant.NOTIFICATION_LOGIN_ID); + NotificationHelper.cancelNotification(context, Constant.NOTIFICATION_FAIL_ID); + NotificationHelper.cancelNotification(context, Constant.NOTIFICATION_ALREADY_ID); + + callback.onFail(context, reason); } } diff --git a/Android/build.gradle b/Android/build.gradle index d06d2c2..b905bb1 100644 --- a/Android/build.gradle +++ b/Android/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.3' + classpath 'com.android.tools.build:gradle:2.3.0' classpath 'com.google.gms:google-services:3.0.0' // NOTE: Do not place your application dependencies here; they belong diff --git a/Android/gradle/wrapper/gradle-wrapper.properties b/Android/gradle/wrapper/gradle-wrapper.properties index c3ff205..a0124af 100644 --- a/Android/gradle/wrapper/gradle-wrapper.properties +++ b/Android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Feb 27 00:19:18 GMT+08:00 2017 +#Tue Mar 07 13:23:34 GMT+08:00 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip