Do not display empty listview message while loading
This commit is contained in:
parent
ca795a3fdc
commit
3f5e2faff9
|
@ -19,7 +19,6 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:text="@string/no_feeds_label" />
|
||||
android:gravity="center"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -16,7 +16,6 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:text="@string/no_items_label" />
|
||||
android:gravity="center"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -15,7 +15,5 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/no_feeds_label" />
|
||||
|
||||
android:layout_gravity="center"/>
|
||||
</LinearLayout>
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue