Search in sources :

Example 1 with TripArrayAdapter

use of com.example.androidforios.app.adapters.TripArrayAdapter in project AndroidForiOS by smbarne.

the class TripListFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mViewHolder.populate(view);
    mTripArrayAdapter = new TripArrayAdapter(getActivity());
    mViewHolder.tripListView.setAdapter(mTripArrayAdapter);
    mViewHolder.tripListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (mListener != null) {
                mListener.onTripSelected(mTripArrayAdapter.getItem(position));
            }
        }
    });
    getLoaderManager().initLoader(0, savedInstanceState, new LoaderManager.LoaderCallbacks<TripList>() {

        @Override
        public Loader<TripList> onCreateLoader(int id, Bundle args) {
            return new DataManager.SubwayLineLoader(getActivity(), mLineType);
        }

        @Override
        public void onLoadFinished(Loader<TripList> loader, TripList data) {
            setTripList(data);
            if (mViewHolder != null) {
                int displayIndex = mViewHolder.viewFlipper.indexOfChild(mViewHolder.tripListView);
                mViewHolder.viewFlipper.setDisplayedChild(displayIndex);
            }
        }

        @Override
        public void onLoaderReset(Loader<TripList> loader) {
        }
    }).forceLoad();
}
Also used : Bundle(android.os.Bundle) TripList(com.example.androidforios.app.data.model.TripList) Loader(android.support.v4.content.Loader) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) AdapterView(android.widget.AdapterView) TripArrayAdapter(com.example.androidforios.app.adapters.TripArrayAdapter)

Aggregations

Bundle (android.os.Bundle)1 Loader (android.support.v4.content.Loader)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ListView (android.widget.ListView)1 TripArrayAdapter (com.example.androidforios.app.adapters.TripArrayAdapter)1 TripList (com.example.androidforios.app.data.model.TripList)1