mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 05:35:39 +03:00
hardening on possible NPE due to null account/activity
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
parent
f321cedb24
commit
832e525f09
2 changed files with 18 additions and 3 deletions
|
@ -292,13 +292,27 @@ public class FileDetailActivitiesFragment extends Fragment implements
|
|||
* @param lastGiven int; -1 to disable
|
||||
*/
|
||||
private void fetchAndSetData(int lastGiven) {
|
||||
final Account currentAccount = accountManager.getCurrentAccount();
|
||||
final Context context = MainApp.getAppContext();
|
||||
final FragmentActivity activity = getActivity();
|
||||
|
||||
if (activity == null) {
|
||||
Log_OC.e(this, "Activity is null, aborting!");
|
||||
return;
|
||||
}
|
||||
|
||||
final SwipeRefreshLayout empty = swipeEmptyListRefreshLayout;
|
||||
final SwipeRefreshLayout list = swipeListRefreshLayout;
|
||||
final Account currentAccount = accountManager.getCurrentAccount();
|
||||
|
||||
if (currentAccount == null) {
|
||||
activity.runOnUiThread(() -> {
|
||||
setEmptyContent(getString(R.string.common_error), getString(R.string.file_detail_activity_error));
|
||||
list.setVisibility(View.GONE);
|
||||
empty.setVisibility(View.VISIBLE);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
final Context context = MainApp.getAppContext();
|
||||
|
||||
Thread t = new Thread(() -> {
|
||||
OwnCloudAccount ocAccount;
|
||||
|
@ -372,7 +386,7 @@ public class FileDetailActivitiesFragment extends Fragment implements
|
|||
|
||||
hideRefreshLayoutLoader(activity);
|
||||
} catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException | IOException |
|
||||
OperationCanceledException | AuthenticatorException e) {
|
||||
OperationCanceledException | AuthenticatorException | NullPointerException e) {
|
||||
Log_OC.e(TAG, "Error fetching file details activities", e);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -895,4 +895,5 @@
|
|||
<string name="download_latest_dev_version">Download latest dev version</string>
|
||||
<string name="changelog_dev_version">Changelog dev version</string>
|
||||
<string name="could_not_download_image">Could not download full image</string>
|
||||
<string name="file_detail_activity_error">Error retrieving activities for file</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue