Skip to content
Merged
Show file tree
Hide file tree
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 @@ -93,6 +93,7 @@
import com.owncloud.android.ui.events.ChangeMenuEvent;
import com.owncloud.android.ui.events.SearchEvent;
import com.owncloud.android.ui.fragment.FileDetailsSharingProcessFragment;
import com.owncloud.android.ui.fragment.GalleryFragment;
import com.owncloud.android.ui.fragment.OCFileListFragment;
import com.owncloud.android.ui.navigation.NavigatorActivity;
import com.owncloud.android.ui.navigation.NavigatorScreen;
Expand Down Expand Up @@ -330,6 +331,7 @@ private void openFavoritesTab() {
}

private void openMediaTab(int menuItemId) {
GalleryFragment.setLastMediaItemPosition(null);
resetOnlyPersonalAndOnDevice();
setupToolbar();
startPhotoSearch(menuItemId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ public void onDestroyView() {

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

setLastMediaItemPosition(null);

mAdapter.cleanup();

super.onDestroyView();
Expand Down Expand Up @@ -176,31 +174,37 @@ public void onActivityCreated(Bundle savedInstanceState) {
}

@Override
protected void setAdapter(Bundle args) {
mAdapter = new GalleryAdapter(requireContext(),
accountManager.getUser(),
this,
preferences,
mContainerActivity,
viewThemeUtils,
columnSize,
ThumbnailsCacheManager.getThumbnailDimension());
public void setAdapter(Bundle args) {
final var recyclerView = getRecyclerView();
mAdapter = new GalleryAdapter(
requireContext(),
accountManager.getUser(),
this,
preferences,
mContainerActivity,
viewThemeUtils,
columnSize,
ThumbnailsCacheManager.getThumbnailDimension()
);
mAdapter.setHasStableIds(true);
setRecyclerViewAdapter(mAdapter);

//update the footer as there is no footer shown in media view
if (getRecyclerView() instanceof EmptyRecyclerView) {
((EmptyRecyclerView) getRecyclerView()).setHasFooter(false);
// update the footer as there is no footer shown in media view
if (recyclerView instanceof EmptyRecyclerView emptyRecyclerView) {
emptyRecyclerView.setHasFooter(false);
}

if (getRecyclerView() != null) {
if (recyclerView != null) {
GridLayoutManager layoutManager = new GridLayoutManager(getContext(), 1);
mAdapter.setLayoutManager(layoutManager);
getRecyclerView().setLayoutManager(layoutManager);

if (lastMediaItemPosition != null) {
layoutManager.scrollToPosition(lastMediaItemPosition);
}
recyclerView.setLayoutManager(layoutManager);
recyclerView.post(() -> {
if (lastMediaItemPosition != null) {
RecyclerView.LayoutManager lm = recyclerView.getLayoutManager();
if (lm != null) {
lm.scrollToPosition(lastMediaItemPosition);
}
}
});
}
}

Expand Down
Loading