Hide info views in multi-select (#7095)

Still not perfect because the toolbar is visible behind the action menu.
However, it fixes the jumping when entering multi-select mode.
This commit is contained in:
ByteHamster 2024-04-14 11:43:50 +02:00 committed by GitHub
parent f3bca9d9e4
commit d6b2a49caa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 43 additions and 12 deletions

View File

@ -33,14 +33,9 @@ public abstract class SelectableAdapter<T extends RecyclerView.ViewHolder> exten
endSelectMode();
}
if (onSelectModeListener != null) {
onSelectModeListener.onStartSelectMode();
}
shouldSelectLazyLoadedItems = false;
selectedIds.clear();
selectedIds.add(getItemId(pos));
notifyDataSetChanged();
actionMode = activity.startActionMode(new ActionMode.Callback() {
@Override
@ -72,14 +67,19 @@ public abstract class SelectableAdapter<T extends RecyclerView.ViewHolder> exten
@Override
public void onDestroyActionMode(ActionMode mode) {
callOnEndSelectMode();
actionMode = null;
shouldSelectLazyLoadedItems = false;
selectedIds.clear();
callOnEndSelectMode();
notifyDataSetChanged();
}
});
updateTitle();
if (onSelectModeListener != null) {
onSelectModeListener.onStartSelectMode();
}
notifyDataSetChanged();
}
/**
@ -87,8 +87,9 @@ public abstract class SelectableAdapter<T extends RecyclerView.ViewHolder> exten
*/
public void endSelectMode() {
if (inActionMode()) {
callOnEndSelectMode();
actionMode.finish();
actionMode = null;
callOnEndSelectMode();
}
}
@ -130,7 +131,7 @@ public abstract class SelectableAdapter<T extends RecyclerView.ViewHolder> exten
setSelected(pos, !isSelected(pos));
notifyItemChanged(pos);
if (selectedIds.size() == 0) {
if (selectedIds.isEmpty()) {
endSelectMode();
}
}

View File

@ -113,7 +113,9 @@ public class AllEpisodesFragment extends EpisodesListFragment {
private void updateFilterUi() {
swipeActions.setFilter(getFilter());
if (getFilter().getValues().length > 0) {
if (listAdapter.inActionMode()) {
txtvInformation.setVisibility(View.INVISIBLE);
} else if (getFilter().getValues().length > 0) {
txtvInformation.setVisibility(View.VISIBLE);
emptyView.setMessage(R.string.no_all_episodes_filtered_label);
} else {
@ -124,6 +126,18 @@ public class AllEpisodesFragment extends EpisodesListFragment {
getFilter().showIsFavorite ? R.drawable.ic_star : R.drawable.ic_star_border);
}
@Override
public void onStartSelectMode() {
super.onStartSelectMode();
updateFilterUi();
}
@Override
public void onEndSelectMode() {
super.onEndSelectMode();
updateFilterUi();
}
public static class AllEpisodesSortDialog extends ItemSortDialog {
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {

View File

@ -492,6 +492,14 @@ public class QueueFragment extends Fragment implements MaterialToolbar.OnMenuIte
info += Converter.getDurationStringLocalized(getResources(), timeLeft, false);
}
infoBar.setText(info);
if (recyclerAdapter.inActionMode()) {
infoBar.setVisibility(View.INVISIBLE);
} else if (UserPreferences.getSubscriptionsFilter().isEnabled()) {
infoBar.setVisibility(View.VISIBLE);
} else {
infoBar.setVisibility(View.GONE);
}
}
private void loadItems(final boolean restoreScrollPosition) {
@ -522,15 +530,15 @@ public class QueueFragment extends Fragment implements MaterialToolbar.OnMenuIte
swipeActions.detach();
speedDialView.setVisibility(View.VISIBLE);
refreshToolbarState();
infoBar.setVisibility(View.GONE);
refreshInfoBar();
}
@Override
public void onEndSelectMode() {
speedDialView.close();
speedDialView.setVisibility(View.GONE);
infoBar.setVisibility(View.VISIBLE);
swipeActions.attachTo(recyclerView);
refreshInfoBar();
}
public static class QueueSortDialog extends ItemSortDialog {

View File

@ -301,7 +301,13 @@ public class SubscriptionFragment extends Fragment
Log.e(TAG, Log.getStackTraceString(error));
});
if (UserPreferences.getSubscriptionsFilter().isEnabled()) {
updateFilterVisibility();
}
private void updateFilterVisibility() {
if (subscriptionAdapter.inActionMode()) {
feedsFilteredMsg.setVisibility(View.INVISIBLE);
} else if (UserPreferences.getSubscriptionsFilter().isEnabled()) {
feedsFilteredMsg.setVisibility(View.VISIBLE);
} else {
feedsFilteredMsg.setVisibility(View.GONE);
@ -347,6 +353,7 @@ public class SubscriptionFragment extends Fragment
speedDialView.setVisibility(View.GONE);
subscriptionAddButton.setVisibility(View.VISIBLE);
subscriptionAdapter.setItems(listItems);
updateFilterVisibility();
}
@Override
@ -360,5 +367,6 @@ public class SubscriptionFragment extends Fragment
subscriptionAdapter.setItems(feedsOnly);
speedDialView.setVisibility(View.VISIBLE);
subscriptionAddButton.setVisibility(View.GONE);
updateFilterVisibility();
}
}