Skip to content

Commit

Permalink
Try to fix notification not dismiss
Browse files Browse the repository at this point in the history
  • Loading branch information
hearsilent committed Mar 7, 2017
1 parent 348bf1d commit b1434b5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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")) {
Expand Down Expand Up @@ -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));
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

}
2 changes: 1 addition & 1 deletion Android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b1434b5

Please sign in to comment.