Merge pull request #3278 from ByteHamster/empty-view
Updated empty views
This commit is contained in:
commit
eaa1527fac
|
@ -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);
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import de.danoeh.antennapod.core.feed.Chapter;
|
|||
import de.danoeh.antennapod.core.util.playback.Playable;
|
||||
import de.danoeh.antennapod.core.util.playback.PlaybackController;
|
||||
|
||||
import de.danoeh.antennapod.view.EmptyViewHandler;
|
||||
import io.reactivex.Maybe;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
@ -25,6 +26,7 @@ public class ChaptersFragment extends ListFragment {
|
|||
private ChaptersListAdapter adapter;
|
||||
private PlaybackController controller;
|
||||
private Disposable disposable;
|
||||
private EmptyViewHandler emptyView;
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -36,6 +38,12 @@ public class ChaptersFragment extends ListFragment {
|
|||
final int vertPadding = getResources().getDimensionPixelSize(R.dimen.list_vertical_padding);
|
||||
lv.setPadding(0, vertPadding, 0, vertPadding);
|
||||
|
||||
emptyView = new EmptyViewHandler(getContext());
|
||||
emptyView.attachToListView(lv);
|
||||
emptyView.setIcon(R.attr.ic_bookmark);
|
||||
emptyView.setTitle(R.string.no_chapters_head_label);
|
||||
emptyView.setMessage(R.string.no_chapters_label);
|
||||
|
||||
adapter = new ChaptersListAdapter(getActivity(), 0, pos -> {
|
||||
Chapter chapter = (Chapter) getListAdapter().getItem(pos);
|
||||
controller.seekToChapter(chapter);
|
||||
|
@ -118,10 +126,7 @@ public class ChaptersFragment extends ListFragment {
|
|||
if (adapter != null) {
|
||||
adapter.setMedia(media);
|
||||
adapter.notifyDataSetChanged();
|
||||
if (media == null || media.getChapters() == null || media.getChapters().size() == 0) {
|
||||
setEmptyText(getString(R.string.no_chapters_label));
|
||||
} else {
|
||||
setEmptyText(null);
|
||||
if (media != null && media.getChapters() != null && media.getChapters().size() != 0) {
|
||||
scrollTo(getCurrentChapter(media));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
package de.danoeh.antennapod.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.AttrRes;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
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 +20,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 +42,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);
|
||||
}
|
||||
|
|
|
@ -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>
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:tint="#b4b4b4"
|
||||
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FFb4b4b4" android:pathData="M17,3H7c-1.1,0 -1.99,0.9 -1.99,2L5,21l7,-3 7,3V5c0,-1.1 -0.9,-2 -2,-2z"/>
|
||||
</vector>
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FFFFFFFF" android:pathData="M17,3H7c-1.1,0 -1.99,0.9 -1.99,2L5,21l7,-3 7,3V5c0,-1.1 -0.9,-2 -2,-2z"/>
|
||||
</vector>
|
|
@ -61,6 +61,7 @@
|
|||
<attr name="ic_known_issues" format="reference" />
|
||||
<attr name="master_switch_background" format="color"/>
|
||||
<attr name="currently_playing_background" format="color"/>
|
||||
<attr name="ic_bookmark" format="reference"/>
|
||||
|
||||
<!-- Used in itemdescription -->
|
||||
<attr name="non_transparent_background" format="reference"/>
|
||||
|
|
|
@ -315,7 +315,6 @@
|
|||
<string name="no_items_header_label">No queued episodes</string>
|
||||
<string name="no_items_label">Add an episode by downloading it, or long press an episode and select \"Add to queue\".</string>
|
||||
<string name="no_feeds_label">You haven\'t subscribed to any podcasts yet.</string>
|
||||
<string name="no_chapters_label">This episode has no chapters.</string>
|
||||
<string name="no_shownotes_label">This episode has no shownotes.</string>
|
||||
<string name="no_run_downloads_head_label">No downloads running</string>
|
||||
<string name="no_run_downloads_label">You can download episodes on the podcast details screen.</string>
|
||||
|
@ -331,6 +330,8 @@
|
|||
<string name="no_new_episodes_label">When new episodes arrive, they will be shown here.</string>
|
||||
<string name="no_fav_episodes_head_label">No favorite episodes</string>
|
||||
<string name="no_fav_episodes_label">You can add episodes to the favorites by long-pressing them.</string>
|
||||
<string name="no_chapters_head_label">No chapters</string>
|
||||
<string name="no_chapters_label">This episode has no chapters.</string>
|
||||
|
||||
<!-- Preferences -->
|
||||
<string name="storage_pref">Storage</string>
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
<item name="ic_question_answer">@drawable/ic_forum_grey600_24dp</item>
|
||||
<item name="ic_bug">@drawable/ic_bug_grey600_24dp</item>
|
||||
<item name="ic_known_issues">@drawable/ic_format_list_bulleted_grey600_24dp</item>
|
||||
|
||||
<item name="ic_bookmark">@drawable/ic_bookmark_grey600_24dp</item>
|
||||
<item name="master_switch_background">@color/master_switch_background_light</item>
|
||||
<item name="currently_playing_background">@color/highlight_light</item>
|
||||
|
||||
|
@ -155,6 +155,7 @@
|
|||
<item name="ic_question_answer">@drawable/ic_baseline_question_answer_white_24dp</item>
|
||||
<item name="ic_bug">@drawable/ic_bug_white_24dp</item>
|
||||
<item name="ic_known_issues">@drawable/ic_format_list_bulleted_white_24dp</item>
|
||||
<item name="ic_bookmark">@drawable/ic_bookmark_white_24dp</item>
|
||||
<item name="master_switch_background">@color/master_switch_background_dark</item>
|
||||
<item name="currently_playing_background">@color/highlight_dark</item>
|
||||
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
|
||||
|
|
Loading…
Reference in New Issue