package com.thebluealliance.androidclient.fragments; import com.thebluealliance.androidclient.R; import com.thebluealliance.androidclient.adapters.ListViewAdapter; import com.thebluealliance.androidclient.binders.ListViewBinder; import com.thebluealliance.androidclient.listitems.ListItem; import com.thebluealliance.androidclient.subscribers.BaseAPISubscriber; import com.thebluealliance.androidclient.views.NoDataView; import android.os.Bundle; import android.os.Parcelable; import android.support.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ListView; import android.widget.ProgressBar; import java.util.List; public abstract class ListViewFragment<T, S extends BaseAPISubscriber<T, List<ListItem>>> extends DatafeedFragment<T, List<ListItem>, S, ListViewBinder> { private Parcelable mListState; private ListViewAdapter mAdapter; protected ListView mListView; @Override public @Nullable View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.list_view_with_spinner, null); mBinder.setRootView(v); mListView = (ListView) v.findViewById(R.id.list); ProgressBar progressBar = (ProgressBar) v.findViewById(R.id.progress); if (mAdapter != null) { mListView.setAdapter(mAdapter); mListView.onRestoreInstanceState(mListState); progressBar.setVisibility(View.GONE); } mBinder.setNoDataView((NoDataView) v.findViewById(R.id.no_data)); return v; } @Override public void onPause() { super.onPause(); if (mListView != null) { mAdapter = (ListViewAdapter) mListView.getAdapter(); mListState = mListView.onSaveInstanceState(); } } }