9
9
import android .content .pm .PackageManager ;
10
10
import android .os .Bundle ;
11
11
import android .os .Handler ;
12
+ import android .os .Looper ;
12
13
import android .util .Log ;
13
14
14
15
import com .google .gson .JsonObject ;
@@ -66,7 +67,7 @@ public static void setAccessToken(Activity activity, @Nullable String token) {
66
67
if (account != null && token == null ) {
67
68
accountManager .removeAccount (account , activity , accountManagerFuture -> {
68
69
Log .d (LOG_TAG , "Account removed: " + Constants .ACCOUNT_TYPE );
69
- }, new Handler ());
70
+ }, new Handler (Looper . getMainLooper () ));
70
71
} else if (account == null && token == null ) {
71
72
/* This maybe happen when the token loaded from package-meta has expired. */
72
73
Intent intent = new Intent (activity , AuthenticatorActivity .class );
@@ -143,13 +144,13 @@ public void onResponse(@NonNull Call<User> call, @NonNull Response<User> respons
143
144
}
144
145
}
145
146
} catch (IOException e ) {
146
- if (BuildConfig .DEBUG ) {Log .e (LOG_TAG , "" + e .getMessage ());}
147
+ if (BuildConfig .DEBUG ) {Log .e (LOG_TAG , "IOException: " + e .getMessage ());}
147
148
}
148
149
}
149
150
}
150
151
@ Override
151
152
public void onFailure (@ NonNull Call <User > call , @ NonNull Throwable t ) {
152
- Log .e (LOG_TAG , "" + t .getMessage ());
153
+ Log .e (LOG_TAG , "onFailure: " + t .getMessage ());
153
154
}
154
155
});
155
156
}
@@ -172,7 +173,7 @@ private static Account getAccount(@NonNull AccountManager accountManager, int in
172
173
@ Nullable
173
174
public static Account addAccount (AccountManager accountManager , String username , String token ) {
174
175
if (getAccount (accountManager , 0 ) == null ) {
175
- Account account = new Account ("" + username + "@github.com" , Constants .ACCOUNT_TYPE );
176
+ Account account = new Account (username + "@github.com" , Constants .ACCOUNT_TYPE );
176
177
Bundle extraData = new Bundle ();
177
178
extraData .putString ("username" , username );
178
179
extraData .putString ("token" , token );
0 commit comments