From 9b55abc78146483729e7589b62a49e693d3e4f57 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Sun, 1 Nov 2020 13:16:05 +0100 Subject: [PATCH] Fixed empty view in downloads fragment --- .../de/danoeh/antennapod/view/EmptyViewHandler.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/de/danoeh/antennapod/view/EmptyViewHandler.java b/app/src/main/java/de/danoeh/antennapod/view/EmptyViewHandler.java index 89d9e26c7..eaad11d1a 100644 --- a/app/src/main/java/de/danoeh/antennapod/view/EmptyViewHandler.java +++ b/app/src/main/java/de/danoeh/antennapod/view/EmptyViewHandler.java @@ -3,7 +3,9 @@ package de.danoeh.antennapod.view; import android.content.Context; import android.database.DataSetObserver; import android.graphics.drawable.Drawable; +import android.view.Gravity; import android.widget.AbsListView; +import android.widget.FrameLayout; import android.widget.ListAdapter; import androidx.annotation.AttrRes; import androidx.core.content.ContextCompat; @@ -21,7 +23,7 @@ public class EmptyViewHandler { private boolean layoutAdded = false; private View list; private ListAdapter listAdapter; - private RecyclerView.Adapter recyclerAdapter; + private RecyclerView.Adapter recyclerAdapter; private final Context context; private final View emptyView; @@ -92,12 +94,19 @@ public class EmptyViewHandler { layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); emptyView.setLayoutParams(layoutParams); break; + } else if (parent instanceof FrameLayout) { + parent.addView(emptyView); + FrameLayout.LayoutParams layoutParams = + (FrameLayout.LayoutParams) emptyView.getLayoutParams(); + layoutParams.gravity = Gravity.CENTER; + emptyView.setLayoutParams(layoutParams); + break; } parent = (ViewGroup) parent.getParent(); } } - public void updateAdapter(RecyclerView.Adapter adapter) { + public void updateAdapter(RecyclerView.Adapter adapter) { if (this.recyclerAdapter != null) { this.recyclerAdapter.unregisterAdapterDataObserver(adapterObserver); }