Skip to content

Commit

Permalink
GalleryFragment: force refresh on create, prevent unneeded refresh an…
Browse files Browse the repository at this point in the history
…imations

This fixes bugs with double-loading and weird animations

Signed-off-by: Álvaro Brey Vilas <alvaro.brey@nextcloud.com>
  • Loading branch information
AlvaroBrey authored and backportbot[bot] committed Jan 27, 2022
1 parent 8cd28c3 commit 52e3fae
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ protected void onNewIntent(Intent intent) {
if (SearchRemoteOperation.SearchType.PHOTO_SEARCH.equals(searchEvent.searchType)) {
Log_OC.d(this, "Switch to photo search fragment");

GalleryFragment photoFragment = new GalleryFragment(true);
GalleryFragment photoFragment = new GalleryFragment();
Bundle bundle = new Bundle();
bundle.putParcelable(OCFileListFragment.SEARCH_EVENT, Parcels.wrap(searchEvent));
photoFragment.setArguments(bundle);
Expand Down Expand Up @@ -2071,7 +2071,7 @@ public void run() {

OCFileListFragment fragment = getListOfFilesFragment();

if (fragment != null) {
if (fragment != null && !(fragment instanceof GalleryFragment)) {
fragment.setLoading(true);
}

Expand Down Expand Up @@ -2341,7 +2341,7 @@ public void onMessageEvent(final SearchEvent event) {
if (SearchRemoteOperation.SearchType.PHOTO_SEARCH == event.searchType) {
Log_OC.d(this, "Switch to photo search fragment");

setLeftFragment(new GalleryFragment(true));
setLeftFragment(new GalleryFragment());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,6 @@ public class GalleryFragment extends OCFileListFragment {
private SearchEvent searchEvent;
private boolean refresh;

public GalleryFragment() {
this.refresh = false;
}

public GalleryFragment(boolean refresh) {
this.refresh = refresh;
}

private void createOperation() {
if(searchEvent == null) {
searchEvent = new SearchEvent("", SearchRemoteOperation.SearchType.GALLERY_SEARCH);
Expand All @@ -77,6 +69,12 @@ private void createOperation() {
}
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
refresh = true;
}

@Override
public void onPause() {
super.onPause();
Expand Down Expand Up @@ -127,6 +125,12 @@ public void onRefresh() {
handleSearchEvent();
}

@Override
public void onResume() {
super.onResume();
setLoading(photoSearchQueryRunning);
}

@Override
public void onMessageEvent(ChangeMenuEvent changeMenuEvent) {
super.onMessageEvent(changeMenuEvent);
Expand Down

0 comments on commit 52e3fae

Please sign in to comment.