mirror of
https://github.com/nextcloud/android.git
synced 2024-11-22 13:15:35 +03:00
Merge pull request #9427 from nextcloud/fix/triplicated-search-events
Fix issue where favorites where loaded by triplicate when opening from Media or other search
This commit is contained in:
commit
143455b42a
2 changed files with 19 additions and 34 deletions
|
@ -526,36 +526,30 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||||
SearchEvent searchEvent = new SearchEvent("image/%", SearchRemoteOperation.SearchType.PHOTO_SEARCH);
|
SearchEvent searchEvent = new SearchEvent("image/%", SearchRemoteOperation.SearchType.PHOTO_SEARCH);
|
||||||
MainApp.showOnlyFilesOnDevice(false);
|
MainApp.showOnlyFilesOnDevice(false);
|
||||||
|
|
||||||
Intent intent = new Intent(getApplicationContext(), FileDisplayActivity.class);
|
launchActivityForSearch(searchEvent, menuItem.getItemId());
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
||||||
intent.setAction(Intent.ACTION_SEARCH);
|
|
||||||
intent.putExtra(OCFileListFragment.SEARCH_EVENT, Parcels.wrap(searchEvent));
|
|
||||||
intent.putExtra(FileDisplayActivity.DRAWER_MENU_ID, menuItem.getItemId());
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleSearchEvents(SearchEvent searchEvent, int menuItemId) {
|
private void handleSearchEvents(SearchEvent searchEvent, int menuItemId) {
|
||||||
if (this instanceof FileDisplayActivity) {
|
if (this instanceof FileDisplayActivity) {
|
||||||
if (((FileDisplayActivity) this).getListOfFilesFragment() instanceof GalleryFragment) {
|
if (((FileDisplayActivity) this).getLeftFragment() instanceof GalleryFragment) {
|
||||||
Intent intent = new Intent(getApplicationContext(), FileDisplayActivity.class);
|
launchActivityForSearch(searchEvent, menuItemId);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
||||||
intent.setAction(Intent.ACTION_SEARCH);
|
|
||||||
intent.putExtra(OCFileListFragment.SEARCH_EVENT, Parcels.wrap(searchEvent));
|
|
||||||
intent.putExtra(FileDisplayActivity.DRAWER_MENU_ID, menuItemId);
|
|
||||||
startActivity(intent);
|
|
||||||
} else {
|
} else {
|
||||||
EventBus.getDefault().post(searchEvent);
|
EventBus.getDefault().post(searchEvent);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Intent intent = new Intent(getApplicationContext(), FileDisplayActivity.class);
|
launchActivityForSearch(searchEvent, menuItemId);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
||||||
intent.setAction(Intent.ACTION_SEARCH);
|
|
||||||
intent.putExtra(OCFileListFragment.SEARCH_EVENT, Parcels.wrap(searchEvent));
|
|
||||||
intent.putExtra(FileDisplayActivity.DRAWER_MENU_ID, menuItemId);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void launchActivityForSearch(SearchEvent searchEvent, int menuItemId) {
|
||||||
|
Intent intent = new Intent(getApplicationContext(), FileDisplayActivity.class);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
|
intent.setAction(Intent.ACTION_SEARCH);
|
||||||
|
intent.putExtra(OCFileListFragment.SEARCH_EVENT, Parcels.wrap(searchEvent));
|
||||||
|
intent.putExtra(FileDisplayActivity.DRAWER_MENU_ID, menuItemId);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sets the new/current account and restarts. In case the given account equals the actual/current account the call
|
* sets the new/current account and restarts. In case the given account equals the actual/current account the call
|
||||||
* will be ignored.
|
* will be ignored.
|
||||||
|
|
|
@ -237,7 +237,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||||
|
|
||||||
if (intent.getParcelableExtra(OCFileListFragment.SEARCH_EVENT) != null) {
|
if (intent.getParcelableExtra(OCFileListFragment.SEARCH_EVENT) != null) {
|
||||||
searchEvent = Parcels.unwrap(intent.getParcelableExtra(OCFileListFragment.SEARCH_EVENT));
|
searchEvent = Parcels.unwrap(intent.getParcelableExtra(OCFileListFragment.SEARCH_EVENT));
|
||||||
onMessageEvent(searchEvent);
|
handleSearchEvent(searchEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
@ -747,19 +747,6 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||||
((FileActivity) getActivity()).addDrawerListener(mMultiChoiceModeListener);
|
((FileActivity) getActivity()).addDrawerListener(mMultiChoiceModeListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onViewStateRestored(@Nullable Bundle savedInstanceState) {
|
|
||||||
super.onViewStateRestored(savedInstanceState);
|
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
|
||||||
searchEvent = Parcels.unwrap(savedInstanceState.getParcelable(SEARCH_EVENT));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isSearchEventSet(searchEvent)) {
|
|
||||||
onMessageEvent(searchEvent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the current listed folder.
|
* Saves the current listed folder.
|
||||||
*/
|
*/
|
||||||
|
@ -1489,6 +1476,10 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.BACKGROUND)
|
@Subscribe(threadMode = ThreadMode.BACKGROUND)
|
||||||
public void onMessageEvent(final SearchEvent event) {
|
public void onMessageEvent(final SearchEvent event) {
|
||||||
|
handleSearchEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleSearchEvent(SearchEvent event) {
|
||||||
if (SearchRemoteOperation.SearchType.PHOTO_SEARCH == event.searchType) {
|
if (SearchRemoteOperation.SearchType.PHOTO_SEARCH == event.searchType) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1663,7 +1654,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||||
@Override
|
@Override
|
||||||
public void onRefresh() {
|
public void onRefresh() {
|
||||||
if (isSearchEventSet(searchEvent) && searchFragment) {
|
if (isSearchEventSet(searchEvent) && searchFragment) {
|
||||||
onMessageEvent(searchEvent);
|
handleSearchEvent(searchEvent);
|
||||||
|
|
||||||
mRefreshListLayout.setRefreshing(false);
|
mRefreshListLayout.setRefreshing(false);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue