Merge pull request #3060 from jatinkumarg/issue-3052
Added empty views to the PlayBack History, Queue,and Downloads
This commit is contained in:
commit
b6e50c61d6
|
@ -20,6 +20,7 @@ import android.view.MenuItem;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.yqritc.recyclerviewflexibledivider.HorizontalDividerItemDecoration;
|
||||
|
@ -74,6 +75,7 @@ public class AllEpisodesFragment extends Fragment {
|
|||
RecyclerView recyclerView;
|
||||
AllEpisodesRecycleAdapter listAdapter;
|
||||
private ProgressBar progLoading;
|
||||
private View emptyView;
|
||||
|
||||
List<FeedItem> episodes;
|
||||
private List<Downloader> downloaderList;
|
||||
|
@ -331,6 +333,11 @@ public class AllEpisodesFragment extends Fragment {
|
|||
onFragmentLoaded();
|
||||
}
|
||||
|
||||
emptyView = (View) root.findViewById(R.id.emptyView);
|
||||
emptyView.setVisibility(View.GONE);
|
||||
((TextView)emptyView.findViewById(R.id.emptyViewTitle)).setText(R.string.no_all_episodes_head_label);
|
||||
((TextView)emptyView.findViewById(R.id.emptyViewMessage)).setText(R.string.no_all_episodes_label);
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
|
@ -342,6 +349,14 @@ public class AllEpisodesFragment extends Fragment {
|
|||
listAdapter.setHasStableIds(true);
|
||||
recyclerView.setAdapter(listAdapter);
|
||||
}
|
||||
if (episodes == null || episodes.size() == 0) {
|
||||
recyclerView.setVisibility(View.GONE);
|
||||
emptyView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
emptyView.setVisibility(View.GONE);
|
||||
recyclerView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
listAdapter.notifyDataSetChanged();
|
||||
restoreScrollPosition();
|
||||
getActivity().supportInvalidateOptionsMenu();
|
||||
|
@ -473,6 +488,7 @@ public class AllEpisodesFragment extends Fragment {
|
|||
}
|
||||
if (viewsCreated && !itemsLoaded) {
|
||||
recyclerView.setVisibility(View.GONE);
|
||||
emptyView.setVisibility(View.GONE);
|
||||
progLoading.setVisibility(View.VISIBLE);
|
||||
}
|
||||
disposable = Observable.fromCallable(this::loadData)
|
||||
|
|
|
@ -21,6 +21,7 @@ import de.danoeh.antennapod.core.storage.DBReader;
|
|||
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
import de.danoeh.antennapod.core.util.FeedItemUtil;
|
||||
import de.danoeh.antennapod.dialog.EpisodesApplyActionFragment;
|
||||
import de.danoeh.antennapod.view.EmptyViewHandler;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
@ -106,6 +107,11 @@ public class CompletedDownloadsFragment extends ListFragment {
|
|||
if (items != null && getActivity() != null) {
|
||||
onFragmentLoaded();
|
||||
}
|
||||
|
||||
EmptyViewHandler emptyView = new EmptyViewHandler(getActivity());
|
||||
emptyView.setTitle(R.string.no_comp_downloads_head_label);
|
||||
emptyView.setMessage(R.string.no_comp_downloads_label);
|
||||
emptyView.attachToListView(getListView());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,6 +24,7 @@ import de.danoeh.antennapod.core.feed.FeedMedia;
|
|||
import de.danoeh.antennapod.core.service.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
import de.danoeh.antennapod.view.EmptyViewHandler;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
@ -75,6 +76,12 @@ public class DownloadLogFragment extends ListFragment {
|
|||
if (itemsLoaded) {
|
||||
onFragmentLoaded();
|
||||
}
|
||||
|
||||
EmptyViewHandler emptyView = new EmptyViewHandler(getActivity());
|
||||
emptyView.setTitle(R.string.no_log_downloads_head_label);
|
||||
emptyView.setMessage(R.string.no_log_downloads_label);
|
||||
emptyView.attachToListView(getListView());
|
||||
|
||||
}
|
||||
|
||||
private void onFragmentLoaded() {
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.util.Log;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -50,6 +51,8 @@ public class FavoriteEpisodesFragment extends AllEpisodesFragment {
|
|||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View root = super.onCreateViewHelper(inflater, container, savedInstanceState,
|
||||
R.layout.all_episodes_fragment);
|
||||
((TextView)root.findViewById(R.id.emptyViewTitle)).setText(R.string.no_fav_episodes_head_label);
|
||||
((TextView)root.findViewById(R.id.emptyViewMessage)).setText(R.string.no_fav_episodes_label);
|
||||
|
||||
ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {
|
||||
@Override
|
||||
|
|
|
@ -7,9 +7,8 @@ import android.util.Log;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import android.widget.TextView;
|
||||
import java.util.List;
|
||||
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.adapter.AllEpisodesRecycleAdapter;
|
||||
import de.danoeh.antennapod.core.event.FeedItemEvent;
|
||||
|
@ -26,9 +25,7 @@ import de.danoeh.antennapod.core.util.FeedItemUtil;
|
|||
public class NewEpisodesFragment extends AllEpisodesFragment {
|
||||
|
||||
public static final String TAG = "NewEpisodesFragment";
|
||||
|
||||
private static final String PREF_NAME = "PrefNewEpisodesFragment";
|
||||
|
||||
@Override
|
||||
protected boolean showOnlyNewEpisodes() { return true; }
|
||||
|
||||
|
@ -49,6 +46,8 @@ public class NewEpisodesFragment extends AllEpisodesFragment {
|
|||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View root = super.onCreateViewHelper(inflater, container, savedInstanceState,
|
||||
R.layout.all_episodes_fragment);
|
||||
((TextView)root.findViewById(R.id.emptyViewTitle)).setText(R.string.no_new_episodes_head_label);
|
||||
((TextView)root.findViewById(R.id.emptyViewMessage)).setText(R.string.no_new_episodes_label);
|
||||
|
||||
ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {
|
||||
@Override
|
||||
|
|
|
@ -29,6 +29,7 @@ import de.danoeh.antennapod.core.storage.DBReader;
|
|||
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
import de.danoeh.antennapod.core.util.FeedItemUtil;
|
||||
import de.danoeh.antennapod.core.util.LongList;
|
||||
import de.danoeh.antennapod.view.EmptyViewHandler;
|
||||
import de.greenrobot.event.EventBus;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
|
@ -81,6 +82,12 @@ public class PlaybackHistoryFragment extends ListFragment {
|
|||
if (itemsLoaded) {
|
||||
onFragmentLoaded();
|
||||
}
|
||||
|
||||
EmptyViewHandler emptyView = new EmptyViewHandler(getActivity());
|
||||
emptyView.setTitle(R.string.no_history_head_label);
|
||||
emptyView.setMessage(R.string.no_history_label);
|
||||
emptyView.attachToListView(getListView());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ public class QueueFragment extends Fragment {
|
|||
private TextView infoBar;
|
||||
private RecyclerView recyclerView;
|
||||
private QueueRecyclerAdapter recyclerAdapter;
|
||||
private TextView txtvEmpty;
|
||||
private View emptyView;
|
||||
private ProgressBar progLoading;
|
||||
|
||||
private List<FeedItem> queue;
|
||||
|
@ -493,9 +493,12 @@ public class QueueFragment extends Fragment {
|
|||
}
|
||||
);
|
||||
itemTouchHelper.attachToRecyclerView(recyclerView);
|
||||
//empty view
|
||||
emptyView = (View) root.findViewById(R.id.emptyView);
|
||||
emptyView.setVisibility(View.GONE);
|
||||
((TextView)emptyView.findViewById(R.id.emptyViewTitle)).setText(R.string.no_items_header_label);
|
||||
((TextView)emptyView.findViewById(R.id.emptyViewMessage)).setText(R.string.no_items_label);
|
||||
|
||||
txtvEmpty = root.findViewById(android.R.id.empty);
|
||||
txtvEmpty.setVisibility(View.GONE);
|
||||
progLoading = root.findViewById(R.id.progLoading);
|
||||
progLoading.setVisibility(View.VISIBLE);
|
||||
|
||||
|
@ -512,9 +515,9 @@ public class QueueFragment extends Fragment {
|
|||
}
|
||||
if(queue == null || queue.size() == 0) {
|
||||
recyclerView.setVisibility(View.GONE);
|
||||
txtvEmpty.setVisibility(View.VISIBLE);
|
||||
emptyView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
txtvEmpty.setVisibility(View.GONE);
|
||||
emptyView.setVisibility(View.GONE);
|
||||
recyclerView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
@ -628,7 +631,7 @@ public class QueueFragment extends Fragment {
|
|||
}
|
||||
if (queue == null) {
|
||||
recyclerView.setVisibility(View.GONE);
|
||||
txtvEmpty.setVisibility(View.GONE);
|
||||
emptyView.setVisibility(View.GONE);
|
||||
progLoading.setVisibility(View.VISIBLE);
|
||||
}
|
||||
disposable = Observable.fromCallable(DBReader::getQueue)
|
||||
|
|
|
@ -20,6 +20,7 @@ import de.danoeh.antennapod.core.service.download.Downloader;
|
|||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
import de.danoeh.antennapod.core.storage.DownloadRequester;
|
||||
import de.danoeh.antennapod.view.EmptyViewHandler;
|
||||
import de.greenrobot.event.EventBus;
|
||||
|
||||
/**
|
||||
|
@ -44,6 +45,12 @@ public class RunningDownloadsFragment extends ListFragment {
|
|||
|
||||
adapter = new DownloadlistAdapter(getActivity(), itemAccess);
|
||||
setListAdapter(adapter);
|
||||
|
||||
EmptyViewHandler emptyView = new EmptyViewHandler(getActivity());
|
||||
emptyView.setTitle(R.string.no_run_downloads_head_label);
|
||||
emptyView.setMessage(R.string.no_run_downloads_label);
|
||||
emptyView.attachToListView(getListView());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
package de.danoeh.antennapod.view;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import de.danoeh.antennapod.R;
|
||||
|
||||
public class EmptyViewHandler extends View {
|
||||
private Activity activity;
|
||||
private int title;
|
||||
private int message;
|
||||
|
||||
public EmptyViewHandler(Context context) {
|
||||
super(context);
|
||||
this.setActivity((Activity) context);
|
||||
}
|
||||
|
||||
public int getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(int title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public int getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(int message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public void attachToListView(ListView listView){
|
||||
|
||||
View emptyView = getActivity().getLayoutInflater().inflate(R.layout.empty_view_layout, null);
|
||||
((ViewGroup) listView.getParent()).addView(emptyView);
|
||||
listView.setEmptyView(emptyView);
|
||||
|
||||
TextView tvTitle = (TextView) emptyView.findViewById(R.id.emptyViewTitle);
|
||||
tvTitle.setText(title);
|
||||
|
||||
TextView tvMessage = (TextView) emptyView.findViewById(R.id.emptyViewMessage);
|
||||
tvMessage.setText(message);
|
||||
|
||||
}
|
||||
|
||||
public Activity getActivity() {
|
||||
return activity;
|
||||
}
|
||||
|
||||
public void setActivity(Activity activity) {
|
||||
this.activity = activity;
|
||||
}
|
||||
}
|
|
@ -17,6 +17,10 @@
|
|||
tools:itemCount="13"
|
||||
tools:listitem="@layout/new_episodes_listitem" />
|
||||
|
||||
<include
|
||||
android:id="@+id/emptyView"
|
||||
layout="@layout/empty_view_layout"/>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progLoading"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<?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"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<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"/>
|
||||
|
||||
<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"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -27,13 +27,9 @@
|
|||
android:layout_below="@id/divider"
|
||||
android:scrollbars="vertical"/>
|
||||
|
||||
<TextView
|
||||
android:id="@id/android:empty"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerInParent="true"
|
||||
android:gravity="center"
|
||||
android:text="@string/no_items_label" />
|
||||
<include
|
||||
android:id="@+id/emptyView"
|
||||
layout="@layout/empty_view_layout"/>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progLoading"
|
||||
|
|
|
@ -314,10 +314,25 @@
|
|||
<string name="enable_sonic">Enable Sonic</string>
|
||||
|
||||
<!-- Empty list labels -->
|
||||
<string name="no_items_label">There are no items in this list.</string>
|
||||
<string name="no_items_header_label">No queued episodes</string>
|
||||
<string name="no_items_label">You can add episodes to the queue by long-pressing or downloading them.</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>
|
||||
<string name="no_comp_downloads_head_label">No downloaded episodes</string>
|
||||
<string name="no_comp_downloads_label">You can download episodes on the podcast details screen.</string>
|
||||
<string name="no_log_downloads_head_label">No download log</string>
|
||||
<string name="no_log_downloads_label">Download logs will appear here when available.</string>
|
||||
<string name="no_history_head_label">No History</string>
|
||||
<string name="no_history_label">After you listen to an episode, it will appear here.</string>
|
||||
<string name="no_all_episodes_head_label">No Episodes</string>
|
||||
<string name="no_all_episodes_label">When you add a podcast, the episodes will be shown here.</string>
|
||||
<string name="no_new_episodes_head_label">No new episodes</string>
|
||||
<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>
|
||||
|
||||
<!-- Preferences -->
|
||||
<string name="storage_pref">Storage</string>
|
||||
|
|
Loading…
Reference in New Issue