FileDocCategorySizeDatePackage
BrowserListFragment.javaAPI DocAndroid 5.1 API6696Thu Mar 12 22:22:44 GMT 2015com.example.android.musicbrowserdemo

BrowserListFragment

public class BrowserListFragment extends android.support.v4.app.ListFragment

Fields Summary
private static final String
TAG
public static final String
HINT_DISPLAY
public static final String
ARG_COMPONENT
public static final String
ARG_ID
private Adapter
mAdapter
private List
mItems
private android.content.ComponentName
mComponent
private String
mNodeId
private android.media.browse.MediaBrowser
mBrowser
final MediaBrowser.ConnectionCallback
mConnectionCallbacks
Constructors Summary
public BrowserListFragment()

    
Methods Summary
public voidonActivityCreated(android.os.Bundle savedInstanceState)

        super.onActivityCreated(savedInstanceState);
        Log.d(TAG, "onActivityCreated -- " + hashCode());
        mAdapter = new Adapter();
        setListAdapter(mAdapter);

        // Get our arguments
        final Bundle args = getArguments();
        mComponent = args.getParcelable(ARG_COMPONENT);
        mNodeId = args.getString(ARG_ID);

        // A hint about who we are, so the service can customize the results if it wants to.
        final Bundle rootHints = new Bundle();
        rootHints.putBoolean(HINT_DISPLAY, true);

        mBrowser = new MediaBrowser(getActivity(), mComponent, mConnectionCallbacks, rootHints);
    
public voidonListItemClick(android.widget.ListView l, android.view.View v, int position, long id)

        final Item item = mItems.get(position);

        Log.i("BrowserListFragment", "Item clicked: " + position + " -- "
                + mAdapter.getItem(position).media.getDescription().getIconUri());

        final BrowserListFragment fragment = new BrowserListFragment();

        final Bundle args = new Bundle();
        args.putParcelable(BrowserListFragment.ARG_COMPONENT, mComponent);
        args.putParcelable(BrowserListFragment.ARG_ID, item.media.getDescription().getIconUri());
        fragment.setArguments(args);

        getFragmentManager().beginTransaction()
                .replace(android.R.id.content, fragment)
                .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
                .addToBackStack(null)
                .commit();

    
public voidonStart()

        super.onStart();
        mBrowser.connect();
    
public voidonStop()

        super.onStop();
        mBrowser.disconnect();