mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-10-29 19:59:22 +00:00
Collapse subscriptions filter when scrolling down (#7990)
This commit is contained in:
parent
c92e2f4f07
commit
de0f09f1e2
@ -18,6 +18,8 @@ import androidx.recyclerview.widget.GridLayoutManager;
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
|
import com.google.android.material.appbar.AppBarLayout;
|
||||||
|
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||||
import com.google.android.material.appbar.MaterialToolbar;
|
import com.google.android.material.appbar.MaterialToolbar;
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
import de.danoeh.antennapod.R;
|
import de.danoeh.antennapod.R;
|
||||||
@ -83,6 +85,7 @@ public class SubscriptionFragment extends Fragment
|
|||||||
private MaterialToolbar toolbar;
|
private MaterialToolbar toolbar;
|
||||||
private SwipeRefreshLayout swipeRefreshLayout;
|
private SwipeRefreshLayout swipeRefreshLayout;
|
||||||
private ProgressBar progressBar;
|
private ProgressBar progressBar;
|
||||||
|
private CollapsingToolbarLayout collapsingContainer;
|
||||||
private boolean displayUpArrow;
|
private boolean displayUpArrow;
|
||||||
|
|
||||||
private Disposable disposable;
|
private Disposable disposable;
|
||||||
@ -132,9 +135,11 @@ public class SubscriptionFragment extends Fragment
|
|||||||
}
|
}
|
||||||
refreshToolbarState();
|
refreshToolbarState();
|
||||||
|
|
||||||
|
collapsingContainer = root.findViewById(R.id.collapsing_container);
|
||||||
subscriptionRecycler = root.findViewById(R.id.subscriptions_grid);
|
subscriptionRecycler = root.findViewById(R.id.subscriptions_grid);
|
||||||
registerForContextMenu(subscriptionRecycler);
|
registerForContextMenu(subscriptionRecycler);
|
||||||
subscriptionRecycler.addOnScrollListener(new LiftOnScrollListener(root.findViewById(R.id.appbar)));
|
subscriptionRecycler.addOnScrollListener(new LiftOnScrollListener(root.findViewById(R.id.appbar)));
|
||||||
|
subscriptionRecycler.addOnScrollListener(new LiftOnScrollListener(collapsingContainer));
|
||||||
subscriptionAdapter = new SubscriptionsRecyclerAdapter((MainActivity) getActivity()) {
|
subscriptionAdapter = new SubscriptionsRecyclerAdapter((MainActivity) getActivity()) {
|
||||||
@Override
|
@Override
|
||||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
|
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
|
||||||
@ -428,12 +433,21 @@ public class SubscriptionFragment extends Fragment
|
|||||||
loadSubscriptionsAndTags();
|
loadSubscriptionsAndTags();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setCollapsingToolbarFlags(int flags) {
|
||||||
|
AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) collapsingContainer.getLayoutParams();
|
||||||
|
params.setScrollFlags(flags);
|
||||||
|
collapsingContainer.setLayoutParams(params);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEndSelectMode() {
|
public void onEndSelectMode() {
|
||||||
floatingSelectMenu.setVisibility(View.GONE);
|
floatingSelectMenu.setVisibility(View.GONE);
|
||||||
subscriptionAddButton.setVisibility(View.VISIBLE);
|
subscriptionAddButton.setVisibility(View.VISIBLE);
|
||||||
tagsRecycler.setVisibility(tagAdapter.getItemCount() > 1 ? View.VISIBLE : View.GONE);
|
tagsRecycler.setVisibility(tagAdapter.getItemCount() > 1 ? View.VISIBLE : View.GONE);
|
||||||
updateFilterVisibility();
|
updateFilterVisibility();
|
||||||
|
setCollapsingToolbarFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL
|
||||||
|
| AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS
|
||||||
|
| AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -442,6 +456,8 @@ public class SubscriptionFragment extends Fragment
|
|||||||
subscriptionAddButton.setVisibility(View.GONE);
|
subscriptionAddButton.setVisibility(View.GONE);
|
||||||
tagsRecycler.setVisibility(tagAdapter.getItemCount() > 1 ? View.INVISIBLE : View.GONE);
|
tagsRecycler.setVisibility(tagAdapter.getItemCount() > 1 ? View.INVISIBLE : View.GONE);
|
||||||
updateFilterVisibility();
|
updateFilterVisibility();
|
||||||
|
setCollapsingToolbarFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL
|
||||||
|
| AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Pair<Integer, Integer> getScrollPosition() {
|
public Pair<Integer, Integer> getScrollPosition() {
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
android:id="@+id/appbar"
|
android:id="@+id/appbar"
|
||||||
@ -16,15 +17,34 @@
|
|||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
app:layout_collapseMode="pin"
|
||||||
app:title="@string/subscriptions_label"
|
app:title="@string/subscriptions_label"
|
||||||
app:navigationContentDescription="@string/toolbar_back_button_content_description"
|
app:navigationContentDescription="@string/toolbar_back_button_content_description"
|
||||||
app:navigationIcon="?homeAsUpIndicator" />
|
app:navigationIcon="?homeAsUpIndicator" />
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||||
|
android:id="@+id/collapsing_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:titleEnabled="false"
|
||||||
|
app:contentScrim="#00000000"
|
||||||
|
app:layout_scrollFlags="scroll|snap|enterAlways|exitUntilCollapsed">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="-16dp"
|
android:orientation="vertical"
|
||||||
android:orientation="vertical">
|
app:layout_collapseMode="pin">
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/tags_recycler"
|
android:id="@+id/tags_recycler"
|
||||||
@ -34,6 +54,7 @@
|
|||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:visibility="visible"
|
android:visibility="visible"
|
||||||
tools:orientation="horizontal"
|
tools:orientation="horizontal"
|
||||||
|
tools:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||||
tools:listitem="@layout/item_tag_chip" />
|
tools:listitem="@layout/item_tag_chip" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -47,13 +68,15 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||||
|
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
android:id="@+id/swipeRefresh"
|
android:id="@+id/swipeRefresh"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_below="@id/appbar">
|
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/subscriptions_grid"
|
android:id="@+id/subscriptions_grid"
|
||||||
@ -71,7 +94,7 @@
|
|||||||
android:id="@+id/progressBar"
|
android:id="@+id/progressBar"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerInParent="true"
|
android:layout_gravity="center"
|
||||||
android:indeterminateOnly="true"
|
android:indeterminateOnly="true"
|
||||||
android:visibility="visible" />
|
android:visibility="visible" />
|
||||||
|
|
||||||
@ -80,9 +103,7 @@
|
|||||||
android:layout_width="56dp"
|
android:layout_width="56dp"
|
||||||
android:layout_height="56dp"
|
android:layout_height="56dp"
|
||||||
android:layout_margin="16dp"
|
android:layout_margin="16dp"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_gravity="bottom|end"
|
||||||
android:layout_alignParentEnd="true"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:contentDescription="@string/add_feed_label"
|
android:contentDescription="@string/add_feed_label"
|
||||||
app:srcCompat="@drawable/ic_add" />
|
app:srcCompat="@drawable/ic_add" />
|
||||||
|
|
||||||
@ -90,6 +111,8 @@
|
|||||||
android:id="@+id/floatingSelectMenu"
|
android:id="@+id/floatingSelectMenu"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentBottom="true" />
|
android:layout_gravity="bottom" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user