diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2013-08-05 10:45:17 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2013-08-05 10:45:17 +0200 |
commit | 3f5e2faff941f220c7a882bfba4f86e85219d7ba (patch) | |
tree | ef72e4a84f92b74b7478b62f43652b13bf683530 /src/de | |
parent | ca795a3fdc109804ddc73f65e57584a94812bf8b (diff) | |
download | AntennaPod-3f5e2faff941f220c7a882bfba4f86e85219d7ba.zip |
Do not display empty listview message while loading
Diffstat (limited to 'src/de')
-rw-r--r-- | src/de/danoeh/antennapod/fragment/FeedlistFragment.java | 30 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/fragment/ItemlistFragment.java | 13 |
2 files changed, 35 insertions, 8 deletions
diff --git a/src/de/danoeh/antennapod/fragment/FeedlistFragment.java b/src/de/danoeh/antennapod/fragment/FeedlistFragment.java index ef9994649..95fdc92da 100644 --- a/src/de/danoeh/antennapod/fragment/FeedlistFragment.java +++ b/src/de/danoeh/antennapod/fragment/FeedlistFragment.java @@ -3,6 +3,7 @@ package de.danoeh.antennapod.fragment; import java.util.List; import android.annotation.SuppressLint; +import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.os.AsyncTask; @@ -11,10 +12,7 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.GridView; -import android.widget.ListView; -import android.widget.TextView; +import android.widget.*; import com.actionbarsherlock.app.SherlockFragment; import com.actionbarsherlock.view.ActionMode; @@ -56,7 +54,7 @@ public class FeedlistFragment extends SherlockFragment implements private GridView gridView; private ListView listView; - private TextView txtvEmpty; + private TextView emptyView; private FeedlistAdapter.ItemAccess itemAccess = new FeedlistAdapter.ItemAccess() { @@ -105,12 +103,15 @@ public class FeedlistFragment extends SherlockFragment implements DBReader.getFeedStatisticsList(getActivity())}; } + + @Override protected void onPostExecute(List[] result) { super.onPostExecute(result); if (result != null) { feeds = result[0]; feedItemStatistics = result[1]; + setEmptyViewIfListIsEmpty(); if (fla != null) { fla.notifyDataSetChanged(); } @@ -128,7 +129,7 @@ public class FeedlistFragment extends SherlockFragment implements View result = inflater.inflate(R.layout.feedlist, container, false); listView = (ListView) result.findViewById(android.R.id.list); gridView = (GridView) result.findViewById(R.id.grid); - txtvEmpty = (TextView) result.findViewById(android.R.id.empty); + emptyView = (TextView) result.findViewById(android.R.id.empty); return result; @@ -141,17 +142,18 @@ public class FeedlistFragment extends SherlockFragment implements listView.setOnItemClickListener(this); listView.setOnItemLongClickListener(this); listView.setAdapter(fla); - listView.setEmptyView(txtvEmpty); + listView.setEmptyView(emptyView); if (AppConfig.DEBUG) Log.d(TAG, "Using ListView"); } else { gridView.setOnItemClickListener(this); gridView.setOnItemLongClickListener(this); gridView.setAdapter(fla); - gridView.setEmptyView(txtvEmpty); + gridView.setEmptyView(emptyView); if (AppConfig.DEBUG) Log.d(TAG, "Using GridView"); } + setEmptyViewIfListIsEmpty(); } @Override @@ -272,4 +274,16 @@ public class FeedlistFragment extends SherlockFragment implements } return true; } + + private AbsListView getMainView() { + return (listView != null) ? listView : gridView; + } + + private void setEmptyViewIfListIsEmpty() { + if (getMainView() != null && emptyView != null && feeds != null) { + if (feeds.isEmpty()) { + emptyView.setText(R.string.no_feeds_label); + } + } + } } diff --git a/src/de/danoeh/antennapod/fragment/ItemlistFragment.java b/src/de/danoeh/antennapod/fragment/ItemlistFragment.java index 6aca04073..1ebb2ba29 100644 --- a/src/de/danoeh/antennapod/fragment/ItemlistFragment.java +++ b/src/de/danoeh/antennapod/fragment/ItemlistFragment.java @@ -14,6 +14,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.ListView; +import android.widget.TextView; import com.actionbarsherlock.app.SherlockListFragment; import de.danoeh.antennapod.AppConfig; @@ -154,6 +155,9 @@ public class ItemlistFragment extends SherlockListFragment { } else { Log.e(TAG, "Could not load queue"); } + if (result.getItems().isEmpty()) { + } + setEmptyViewIfListIsEmpty(); if (fila != null) { fila.notifyDataSetChanged(); } @@ -169,6 +173,14 @@ public class ItemlistFragment extends SherlockListFragment { loadTask.execute(feedId); } + private void setEmptyViewIfListIsEmpty() { + if (getListView() != null && feed != null && feed.getItems() != null) { + if (feed.getItems().isEmpty()) { + ((TextView) getActivity().findViewById(android.R.id.empty)).setText(R.string.no_items_label); + } + } + } + protected InternalFeedItemlistAdapter createListAdapter() { return new InternalFeedItemlistAdapter(getActivity(), itemAccess(), adapterCallback, showFeedtitle); @@ -261,6 +273,7 @@ public class ItemlistFragment extends SherlockListFragment { getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE); registerForContextMenu(getListView()); getListView().setOnItemLongClickListener(null); + setEmptyViewIfListIsEmpty(); } @Override |