diff options
author | ByteHamster <info@bytehamster.com> | 2019-11-05 15:50:56 +0100 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2019-11-05 23:34:16 +0100 |
commit | cbc4e9dc36faf680828d1b97cae2a93c34e6e7e1 (patch) | |
tree | f947e3a814cae271609532c37e3633f82b555213 /app/src/main/java/de/danoeh/antennapod/view | |
parent | 363c3614f8ff80a1c48d0a59735656dde76b2da9 (diff) | |
download | AntennaPod-cbc4e9dc36faf680828d1b97cae2a93c34e6e7e1.zip |
Added empty view to subscription list
Diffstat (limited to 'app/src/main/java/de/danoeh/antennapod/view')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/view/EmptyViewHandler.java | 21 |
1 files changed, 12 insertions, 9 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 1516c4eb6..0bfd0247f 100644 --- a/app/src/main/java/de/danoeh/antennapod/view/EmptyViewHandler.java +++ b/app/src/main/java/de/danoeh/antennapod/view/EmptyViewHandler.java @@ -2,6 +2,7 @@ package de.danoeh.antennapod.view; import android.content.Context;
import android.graphics.drawable.Drawable;
+import android.widget.AbsListView;
import androidx.annotation.AttrRes;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
@@ -9,7 +10,6 @@ import android.util.TypedValue; import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
-import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
@@ -54,28 +54,31 @@ public class EmptyViewHandler { emptyView.setVisibility(View.GONE);
}
- public void attachToListView(ListView listView) {
+ public void attachToListView(AbsListView listView) {
if (layoutAdded) {
- throw new IllegalStateException("Can not attach to ListView multiple times");
+ throw new IllegalStateException("Can not attach EmptyView multiple times");
}
+ addToParentView(listView);
layoutAdded = true;
- ((ViewGroup) listView.getParent()).addView(emptyView);
listView.setEmptyView(emptyView);
}
public void attachToRecyclerView(RecyclerView recyclerView) {
if (layoutAdded) {
- throw new IllegalStateException("Can not attach to ListView multiple times");
+ throw new IllegalStateException("Can not attach EmptyView multiple times");
}
+ addToParentView(recyclerView);
layoutAdded = true;
this.recyclerView = recyclerView;
- ViewGroup parent = ((ViewGroup) recyclerView.getParent());
- parent.addView(emptyView);
updateAdapter(recyclerView.getAdapter());
+ }
+ private void addToParentView(View view) {
+ ViewGroup parent = ((ViewGroup) view.getParent());
+ parent.addView(emptyView);
if (parent instanceof RelativeLayout) {
RelativeLayout.LayoutParams layoutParams =
- (RelativeLayout.LayoutParams)emptyView.getLayoutParams();
+ (RelativeLayout.LayoutParams) emptyView.getLayoutParams();
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
emptyView.setLayoutParams(layoutParams);
}
@@ -99,7 +102,7 @@ public class EmptyViewHandler { }
};
- private void updateVisibility() {
+ public void updateVisibility() {
boolean empty;
if (adapter == null) {
empty = true;
|