Skip to content

Commit 7e1fd4f

Browse files
committed
some code cleanup.
1 parent 1cdd81b commit 7e1fd4f

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

mobile/src/main/java/io/syslogic/github/fragment/PreferencesFragment.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable S
112112
requireActivity().startActivityFromFragment(this, intent, 100);
113113
return true;
114114
} catch (ActivityNotFoundException e) {
115-
if (mDebug) {Log.e(LOG_TAG, "" + e.getMessage());}
115+
if (mDebug) {Log.e(LOG_TAG, "ActivityNotFoundException: " + e.getMessage());}
116116
return false;
117117
}
118118
});
@@ -182,7 +182,7 @@ private void chooseDirectory() {
182182
try {
183183
requestFileChooserResult.launch(intent);
184184
} catch (ActivityNotFoundException e) {
185-
Log.e(LOG_TAG, "" + e.getMessage());
185+
Log.e(LOG_TAG, "ActivityNotFoundException: " + e.getMessage());
186186
}
187187
}
188188

mobile/src/main/java/io/syslogic/github/network/AccountAuthenticator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public Bundle addAccount(
9999
* The result will contain either:
100100
* <ul>
101101
* <li> {@link AccountManager#KEY_INTENT}, or
102-
* <li> {@link AccountManager#KEY_BOOLEAN_RESULT}, true if the check succeeded, false otherwise
102+
* <li> {@link AccountManager#KEY_BOOLEAN_RESULT}, <code>true</code> if the check succeeded, <code>false</code> otherwise
103103
* <li> {@link AccountManager#KEY_ERROR_CODE} and {@link AccountManager#KEY_ERROR_MESSAGE} to
104104
* indicate an error
105105
* </ul>

mobile/src/main/java/io/syslogic/github/network/TokenHelper.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@
1919

2020
import androidx.annotation.NonNull;
2121
import androidx.annotation.Nullable;
22+
2223
import io.syslogic.github.BuildConfig;
2324
import io.syslogic.github.Constants;
25+
import io.syslogic.github.R;
2426
import io.syslogic.github.activity.AuthenticatorActivity;
2527
import io.syslogic.github.activity.NavHostActivity;
2628
import io.syslogic.github.api.GithubClient;
2729
import io.syslogic.github.api.model.User;
2830
import io.syslogic.github.fragment.HomeScreenFragment;
29-
import io.syslogic.github.fragment.HomeScreenFragmentDirections;
3031

3132
import retrofit2.Call;
3233
import retrofit2.Callback;
@@ -89,6 +90,7 @@ public static String getUsername(@NonNull Context context) {
8990
}
9091
}
9192

93+
@Nullable
9294
private static String loadTokenFromPackageMeta(@NonNull Activity activity, AccountManager accountManager) {
9395
String token = null;
9496
try {
@@ -137,8 +139,7 @@ public void onResponse(@NonNull Call<User> call, @NonNull Response<User> respons
137139
if (activity instanceof NavHostActivity activity2) {
138140
if (activity2.getCurrentFragment() instanceof HomeScreenFragment) {
139141
activity2.getNavController().navigate(
140-
HomeScreenFragmentDirections
141-
.actionHomeScreenFragmentToPreferencesFragment()
142+
R.id.action_homeScreenFragment_to_preferencesFragment
142143
);
143144
}
144145
}
@@ -156,7 +157,8 @@ public void onFailure(@NonNull Call<User> call, @NonNull Throwable t) {
156157
}
157158
}
158159
} catch (NullPointerException | PackageManager.NameNotFoundException e) {
159-
e.printStackTrace();
160+
Log.e(LOG_TAG, e.getClass().getSimpleName() + ": " + e.getMessage());
161+
return null;
160162
}
161163
return token;
162164
}

0 commit comments

Comments
 (0)