Skip to content

Commit

Permalink
some code cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
syslogic committed Jul 12, 2024
1 parent 1cdd81b commit 7e1fd4f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable S
requireActivity().startActivityFromFragment(this, intent, 100);
return true;
} catch (ActivityNotFoundException e) {
if (mDebug) {Log.e(LOG_TAG, "" + e.getMessage());}
if (mDebug) {Log.e(LOG_TAG, "ActivityNotFoundException: " + e.getMessage());}
return false;
}
});
Expand Down Expand Up @@ -182,7 +182,7 @@ private void chooseDirectory() {
try {
requestFileChooserResult.launch(intent);
} catch (ActivityNotFoundException e) {
Log.e(LOG_TAG, "" + e.getMessage());
Log.e(LOG_TAG, "ActivityNotFoundException: " + e.getMessage());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public Bundle addAccount(
* The result will contain either:
* <ul>
* <li> {@link AccountManager#KEY_INTENT}, or
* <li> {@link AccountManager#KEY_BOOLEAN_RESULT}, true if the check succeeded, false otherwise
* <li> {@link AccountManager#KEY_BOOLEAN_RESULT}, <code>true</code> if the check succeeded, <code>false</code> otherwise
* <li> {@link AccountManager#KEY_ERROR_CODE} and {@link AccountManager#KEY_ERROR_MESSAGE} to
* indicate an error
* </ul>
Expand Down
10 changes: 6 additions & 4 deletions mobile/src/main/java/io/syslogic/github/network/TokenHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import io.syslogic.github.BuildConfig;
import io.syslogic.github.Constants;
import io.syslogic.github.R;
import io.syslogic.github.activity.AuthenticatorActivity;
import io.syslogic.github.activity.NavHostActivity;
import io.syslogic.github.api.GithubClient;
import io.syslogic.github.api.model.User;
import io.syslogic.github.fragment.HomeScreenFragment;
import io.syslogic.github.fragment.HomeScreenFragmentDirections;

import retrofit2.Call;
import retrofit2.Callback;
Expand Down Expand Up @@ -89,6 +90,7 @@ public static String getUsername(@NonNull Context context) {
}
}

@Nullable
private static String loadTokenFromPackageMeta(@NonNull Activity activity, AccountManager accountManager) {
String token = null;
try {
Expand Down Expand Up @@ -137,8 +139,7 @@ public void onResponse(@NonNull Call<User> call, @NonNull Response<User> respons
if (activity instanceof NavHostActivity activity2) {
if (activity2.getCurrentFragment() instanceof HomeScreenFragment) {
activity2.getNavController().navigate(
HomeScreenFragmentDirections
.actionHomeScreenFragmentToPreferencesFragment()
R.id.action_homeScreenFragment_to_preferencesFragment
);
}
}
Expand All @@ -156,7 +157,8 @@ public void onFailure(@NonNull Call<User> call, @NonNull Throwable t) {
}
}
} catch (NullPointerException | PackageManager.NameNotFoundException e) {
e.printStackTrace();
Log.e(LOG_TAG, e.getClass().getSimpleName() + ": " + e.getMessage());
return null;
}
return token;
}
Expand Down

0 comments on commit 7e1fd4f

Please sign in to comment.