Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b58a557d authored by Aditya's avatar Aditya
Browse files

Add null check for context in onRefresh.

* Added null check as a precaution to prevent the app from crashing.
* Removed call to checkUriAndScheduleCheckIfNeeded on receiving private
  profile available broadcast, to prevent call to onRefresh from getting
  added to the Handler.

Bug: 374276432
Test: Manual
Flag: EXEMPT bugfix
Change-Id: I12f6c838f044b2baaa501d527b93ba5ac7f891c0
parent e307c509
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -321,8 +321,6 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On
                }
                mActivity.refreshCurrentRootAndDirectory(AnimationView.ANIM_NONE);
            }
        } else {
            checkUriAndScheduleCheckIfNeeded(userId);
        }
    }

@@ -1387,12 +1385,17 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On
        // Remove thumbnail cache. We do this not because we're worried about stale thumbnails as it
        // should be covered by last modified value we store in thumbnail cache, but rather to give
        // the user a greater sense that contents are being reloaded.
        ThumbnailCache cache = DocumentsApplication.getThumbnailCache(getContext());
        Context context = getContext();
        if (context == null) {
            Log.w(TAG, "Fragment is not attached to an activity.");
        } else {
            ThumbnailCache cache = DocumentsApplication.getThumbnailCache(context);
            String[] ids = mModel.getModelIds();
            int numOfEvicts = Math.min(ids.length, CACHE_EVICT_LIMIT);
            for (int i = 0; i < numOfEvicts; ++i) {
                cache.removeUri(mModel.getItemUri(ids[i]), mModel.getItemUserId(ids[i]));
            }
        }

        final DocumentInfo doc = mActivity.getCurrentDirectory();
        if (doc == null && !mActivity.getSelectedUser().isQuietModeEnabled(mActivity)) {