99import android .content .pm .PackageManager ;
1010import android .os .Bundle ;
1111import android .os .Handler ;
12+ import android .os .Looper ;
1213import android .util .Log ;
1314
1415import com .google .gson .JsonObject ;
@@ -66,7 +67,7 @@ public static void setAccessToken(Activity activity, @Nullable String token) {
6667 if (account != null && token == null ) {
6768 accountManager .removeAccount (account , activity , accountManagerFuture -> {
6869 Log .d (LOG_TAG , "Account removed: " + Constants .ACCOUNT_TYPE );
69- }, new Handler ());
70+ }, new Handler (Looper . getMainLooper () ));
7071 } else if (account == null && token == null ) {
7172 /* This maybe happen when the token loaded from package-meta has expired. */
7273 Intent intent = new Intent (activity , AuthenticatorActivity .class );
@@ -143,13 +144,13 @@ public void onResponse(@NonNull Call<User> call, @NonNull Response<User> respons
143144 }
144145 }
145146 } catch (IOException e ) {
146- if (BuildConfig .DEBUG ) {Log .e (LOG_TAG , "" + e .getMessage ());}
147+ if (BuildConfig .DEBUG ) {Log .e (LOG_TAG , "IOException: " + e .getMessage ());}
147148 }
148149 }
149150 }
150151 @ Override
151152 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 ());
153154 }
154155 });
155156 }
@@ -172,7 +173,7 @@ private static Account getAccount(@NonNull AccountManager accountManager, int in
172173 @ Nullable
173174 public static Account addAccount (AccountManager accountManager , String username , String token ) {
174175 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 );
176177 Bundle extraData = new Bundle ();
177178 extraData .putString ("username" , username );
178179 extraData .putString ("token" , token );
0 commit comments