Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New feature fastfilter #6847

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -37,10 +37,12 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
final View root = super.onCreateView(inflater, container, savedInstanceState);
toolbar.inflateMenu(R.menu.episodes);
toolbar.setTitle(R.string.episodes_label);
activateFAB();
updateToolbar();
updateFilterUi();
txtvInformation.setOnClickListener(
v -> AllEpisodesFilterDialog.newInstance(getFilter()).show(getChildFragmentManager(), null));

return root;
}

Expand Down
Expand Up @@ -21,6 +21,7 @@
import androidx.recyclerview.widget.SimpleItemAnimator;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import com.leinardi.android.speeddial.SpeedDialView;
import de.danoeh.antennapod.R;
Expand All @@ -30,6 +31,7 @@
import de.danoeh.antennapod.core.menuhandler.MenuItemUtils;
import de.danoeh.antennapod.core.util.FeedItemUtil;
import de.danoeh.antennapod.core.util.download.FeedUpdateManager;
import de.danoeh.antennapod.dialog.AllEpisodesFilterDialog;
import de.danoeh.antennapod.event.EpisodeDownloadEvent;
import de.danoeh.antennapod.event.FeedItemEvent;
import de.danoeh.antennapod.event.FeedListUpdateEvent;
Expand Down Expand Up @@ -57,6 +59,7 @@

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;

/**
Expand All @@ -76,6 +79,8 @@ public abstract class EpisodesListFragment extends Fragment
EpisodeItemListAdapter listAdapter;
EmptyViewHandler emptyView;
SpeedDialView speedDialView;

FloatingActionButton fab;
MaterialToolbar toolbar;
SwipeActions swipeActions;
private ProgressBar progressBar;
Expand Down Expand Up @@ -172,6 +177,8 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
setupLoadMoreScrollListener();
recyclerView.addOnScrollListener(new LiftOnScrollListener(root.findViewById(R.id.appbar)));

fab = root.findViewById(R.id.filterEpisodesFAB);

swipeActions = new SwipeActions(this, getFragmentTag()).attachTo(recyclerView);
swipeActions.setFilter(getFilter());

Expand Down Expand Up @@ -255,6 +262,30 @@ public void onConfirmButtonPressed(DialogInterface dialog) {
return root;
}

public void activateFab() {
fab.setVisibility(View.VISIBLE);
fab.setOnClickListener(view -> {
AllEpisodesFilterDialog.newInstance(getFilter()).show(getChildFragmentManager(), null);
});
fab.setOnLongClickListener(view -> {
//reset on long click
EventBus.getDefault().post(new AllEpisodesFilterDialog.AllEpisodesFilterChangedEvent(new HashSet<>()));
return true;
});
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
//hide on scrolling down
if (dy > 10 && fab.isShown()) {
fab.hide();
} else if (dy < -10 && !fab.isShown()) {
fab.show();
}
}
});
}

private void performMultiSelectAction(int actionItemId) {
EpisodeMultiSelectActionHandler handler =
new EpisodeMultiSelectActionHandler(((MainActivity) getActivity()), actionItemId);
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/res/layout/episodes_list_fragment.xml
Expand Up @@ -48,6 +48,20 @@

</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/filterEpisodesFAB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:clickable="true"
android:visibility="gone"
app:layout_behavior="com.google.android.material.behavior.HideBottomViewOnScrollBehavior"
app:layout_gravity="bottom|end"
app:srcCompat="@drawable/ic_filter" />

<ProgressBar
android:id="@+id/progressBar"
android:layout_width="wrap_content"
Expand Down