Skip to content

Instantly share code, notes, and snippets.

@keyboardr
Last active January 6, 2018 23:37

Revisions

  1. keyboardr revised this gist Mar 28, 2013. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions ContentListFragment.java
    Original file line number Diff line number Diff line change
    @@ -18,10 +18,10 @@ public void onLoadFinished(Loader<List<Content>> loader, List<Content> content){

    @Override
    public Loader<List<Content>> onCreateLoader(int arg0, Bundle arg1) {
    return new ContentLoader(getActivity());
    }
    @Override
    public void onLoaderReset(Loader<List<Episode>> arg0) {
    }
    return new ContentLoader(getActivity());
    }
    @Override
    public void onLoaderReset(Loader<List<Episode>> arg0) {
    }
    }
  2. keyboardr created this gist Mar 28, 2013.
    27 changes: 27 additions & 0 deletions ContentListFragment.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    public class ContentListFragment extends ListFragment implements LoaderCallbacks<List<Content>>{
    @Override
    public void onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
    return inflater.inflate(R.layout.layout, container, false);
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState){
    super.onViewCreated(view, savedInstanceState);
    getLoaderManager().initLoader(0, null, this);
    }

    @Override
    public void onLoadFinished(Loader<List<Content>> loader, List<Content> content){
    setListAdapter(new ContentListAdapter(content);
    ((ViewSwitcher) getView().findViewById(R.id.empty)).setDisplayedChild(1);
    }

    @Override
    public Loader<List<Content>> onCreateLoader(int arg0, Bundle arg1) {
    return new ContentLoader(getActivity());
    }

    @Override
    public void onLoaderReset(Loader<List<Episode>> arg0) {
    }
    }
    29 changes: 29 additions & 0 deletions layout.xml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ListView
    android:id="@android:id/list"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    </ListView>

    <ViewSwitcher
    android:id="@android:id/empty"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ProgressBar
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center" />

    <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:text="@string/content_empty" />

    </ViewSwitcher>

    </FrameLayout>