Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public class GalleryFragment extends OCFileListFragment implements GalleryFragme
private static final int SELECT_LOCATION_REQUEST_CODE = 212;
private GalleryFragmentBottomSheetDialog galleryFragmentBottomSheetDialog;

@Inject FileDataStorageManager fileDataStorageManager;
private final static int maxColumnSizeLandscape = 5;
private final static int maxColumnSizePortrait = 2;
private int columnSize;
Expand Down Expand Up @@ -119,9 +118,17 @@ public static void setLastMediaItemPosition(Integer position) {

@Override
public void onDestroyView() {
if (photoSearchTask != null) {
photoSearchTask.cancel(true);
photoSearchTask = null;
}

LocalBroadcastManager.getInstance(requireContext()).unregisterReceiver(refreshSearchEventReceiver);

setLastMediaItemPosition(null);

mAdapter.cleanup();

super.onDestroyView();
}

Expand Down Expand Up @@ -264,6 +271,8 @@ private void searchAndDisplay() {
}

public void searchCompleted(boolean emptySearch, long lastTimeStamp) {
if (!isAdded()) return;

this.setPhotoSearchQueryRunning(false);

if (lastTimeStamp > -1) {
Expand Down Expand Up @@ -407,7 +416,12 @@ public void showAllGalleryItems() {
}

private void updateSubtitle(GalleryFragmentBottomSheetDialog.MediaState mediaState) {
requireActivity().runOnUiThread(() -> {
final var activity = getActivity();
if (!isAdded() || activity == null) {
return;
}

activity.runOnUiThread(() -> {
if (!isAdded()) {
return;
}
Expand All @@ -419,7 +433,7 @@ private void updateSubtitle(GalleryFragmentBottomSheetDialog.MediaState mediaSta
subTitle = getResources().getString(R.string.subtitle_videos_only);
}

if (requireActivity() instanceof ToolbarActivity toolbarActivity) {
if (activity instanceof ToolbarActivity toolbarActivity) {
toolbarActivity.updateToolbarSubtitle(subTitle);
}
});
Expand Down
Loading