Updated appearance of empty view

This commit is contained in:
ByteHamster 2019-07-22 12:30:01 +02:00
parent 11ccecca34
commit a409f439ac
9 changed files with 58 additions and 23 deletions

View File

@ -310,6 +310,7 @@ public class AllEpisodesFragment extends Fragment {
emptyView = new EmptyViewHandler(getContext());
emptyView.attachToRecyclerView(recyclerView);
emptyView.setIcon(R.attr.feed);
emptyView.setTitle(R.string.no_all_episodes_head_label);
emptyView.setMessage(R.string.no_all_episodes_label);

View File

@ -101,6 +101,7 @@ public class CompletedDownloadsFragment extends ListFragment {
private void addEmptyView() {
EmptyViewHandler emptyView = new EmptyViewHandler(getActivity());
emptyView.setIcon(R.attr.av_download);
emptyView.setTitle(R.string.no_comp_downloads_head_label);
emptyView.setMessage(R.string.no_comp_downloads_label);
emptyView.attachToListView(getListView());

View File

@ -70,6 +70,7 @@ public class DownloadLogFragment extends ListFragment {
lv.setPadding(0, vertPadding, 0, vertPadding);
EmptyViewHandler emptyView = new EmptyViewHandler(getActivity());
emptyView.setIcon(R.attr.av_download);
emptyView.setTitle(R.string.no_log_downloads_head_label);
emptyView.setMessage(R.string.no_log_downloads_label);
emptyView.attachToListView(getListView());

View File

@ -50,6 +50,7 @@ public class FavoriteEpisodesFragment extends AllEpisodesFragment {
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View root = super.onCreateView(inflater, container, savedInstanceState);
emptyView.setIcon(R.attr.ic_unfav);
emptyView.setTitle(R.string.no_fav_episodes_head_label);
emptyView.setMessage(R.string.no_fav_episodes_label);

View File

@ -68,6 +68,7 @@ public class PlaybackHistoryFragment extends ListFragment {
lv.setPadding(0, vertPadding, 0, vertPadding);
EmptyViewHandler emptyView = new EmptyViewHandler(getActivity());
emptyView.setIcon(R.attr.ic_history);
emptyView.setTitle(R.string.no_history_head_label);
emptyView.setMessage(R.string.no_history_label);
emptyView.attachToListView(getListView());

View File

@ -511,6 +511,7 @@ public class QueueFragment extends Fragment {
emptyView = new EmptyViewHandler(getContext());
emptyView.attachToRecyclerView(recyclerView);
emptyView.setIcon(R.attr.stat_playlist);
emptyView.setTitle(R.string.no_items_header_label);
emptyView.setMessage(R.string.no_items_label);

View File

@ -50,6 +50,7 @@ public class RunningDownloadsFragment extends ListFragment {
setListAdapter(adapter);
EmptyViewHandler emptyView = new EmptyViewHandler(getActivity());
emptyView.setIcon(R.attr.av_download);
emptyView.setTitle(R.string.no_run_downloads_head_label);
emptyView.setMessage(R.string.no_run_downloads_label);
emptyView.attachToListView(getListView());

View File

@ -1,9 +1,17 @@
package de.danoeh.antennapod.view;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.annotation.AttrRes;
import android.support.annotation.DrawableRes;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.RecyclerView;
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;
@ -15,14 +23,18 @@ public class EmptyViewHandler {
private RecyclerView recyclerView;
private RecyclerView.Adapter adapter;
private final Context context;
private final View emptyView;
private final TextView tvTitle;
private final TextView tvMessage;
private final ImageView ivIcon;
public EmptyViewHandler(Context context) {
emptyView = View.inflate(context, R.layout.empty_view_layout, null);
this.context = context;
tvTitle = emptyView.findViewById(R.id.emptyViewTitle);
tvMessage = emptyView.findViewById(R.id.emptyViewMessage);
ivIcon = emptyView.findViewById(R.id.emptyViewIcon);
}
public void setTitle(int title) {
@ -33,6 +45,14 @@ public class EmptyViewHandler {
tvMessage.setText(message);
}
public void setIcon(@AttrRes int iconAttr) {
TypedValue typedValue = new TypedValue();
context.getTheme().resolveAttribute(iconAttr, typedValue, true);
Drawable d = ContextCompat.getDrawable(context, typedValue.resourceId);
ivIcon.setImageDrawable(d);
ivIcon.setVisibility(View.VISIBLE);
}
public void hide() {
emptyView.setVisibility(View.GONE);
}

View File

@ -1,31 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
android:layout_centerInParent="true"
xmlns:tools="http://schemas.android.com/tools">
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
android:layout_centerInParent="true"
android:paddingLeft="40dp"
android:paddingRight="40dp"
xmlns:tools="http://schemas.android.com/tools">
<ImageView
android:id="@+id/emptyViewIcon"
android:layout_width="40dp"
android:layout_height="40dp"
android:paddingBottom="8dp"
android:visibility="gone"
tools:src="@drawable/ic_feed_grey600_24dp"
tools:visibility="visible"/>
<TextView
android:id="@+id/emptyViewTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp"
tools:text="empty"
android:textSize="20sp"
android:textStyle="bold"
android:paddingBottom="10dp"/>
android:id="@+id/emptyViewTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="Title"
android:textSize="16sp"
android:textStyle="bold"
android:paddingBottom="8dp"/>
<TextView
android:id="@+id/emptyViewMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
tools:text="empty"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:textAlignment="center"/>
android:id="@+id/emptyViewMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
tools:text="Message"
android:textAlignment="center"/>
</LinearLayout>