SearchSupportFragment.java revision 57ac90cf3fc528ac56b6b83718541624173b1368
1cc671dd3caac1d0cbf3f6999ab063c9ff1f297b2Dake Gu// CHECKSTYLE:OFF Generated code
271e7e67f320b23feac784b629db17b3bcce08722Dake Gu/* This file is auto-generated from SearchFragment.java.  DO NOT MODIFY. */
371e7e67f320b23feac784b629db17b3bcce08722Dake Gu
471e7e67f320b23feac784b629db17b3bcce08722Dake Gupackage com.example.android.leanback;
571e7e67f320b23feac784b629db17b3bcce08722Dake Gu
6b7087e036a48f5a3db28d02ff7f9b97fbbc46c4fDake Guimport android.content.Context;
771e7e67f320b23feac784b629db17b3bcce08722Dake Guimport android.content.Intent;
871e7e67f320b23feac784b629db17b3bcce08722Dake Guimport android.os.Bundle;
971e7e67f320b23feac784b629db17b3bcce08722Dake Guimport android.os.Handler;
1071e7e67f320b23feac784b629db17b3bcce08722Dake Guimport android.support.v17.leanback.widget.ArrayObjectAdapter;
1157ac90cf3fc528ac56b6b83718541624173b1368jingjiangliimport android.support.v17.leanback.widget.DiffCallback;
1271e7e67f320b23feac784b629db17b3bcce08722Dake Guimport android.support.v17.leanback.widget.HeaderItem;
1371e7e67f320b23feac784b629db17b3bcce08722Dake Guimport android.support.v17.leanback.widget.ImageCardView;
1471e7e67f320b23feac784b629db17b3bcce08722Dake Guimport android.support.v17.leanback.widget.ListRow;
1571e7e67f320b23feac784b629db17b3bcce08722Dake Guimport android.support.v17.leanback.widget.ListRowPresenter;
1671e7e67f320b23feac784b629db17b3bcce08722Dake Guimport android.support.v17.leanback.widget.ObjectAdapter;
1771e7e67f320b23feac784b629db17b3bcce08722Dake Guimport android.support.v17.leanback.widget.OnItemViewClickedListener;
1871e7e67f320b23feac784b629db17b3bcce08722Dake Guimport android.support.v17.leanback.widget.Presenter;
1971e7e67f320b23feac784b629db17b3bcce08722Dake Guimport android.support.v17.leanback.widget.Row;
2071e7e67f320b23feac784b629db17b3bcce08722Dake Guimport android.support.v17.leanback.widget.RowPresenter;
21b7087e036a48f5a3db28d02ff7f9b97fbbc46c4fDake Guimport android.support.v4.app.ActivityOptionsCompat;
22b7087e036a48f5a3db28d02ff7f9b97fbbc46c4fDake Guimport android.support.v4.content.res.ResourcesCompat;
2371e7e67f320b23feac784b629db17b3bcce08722Dake Guimport android.text.TextUtils;
2471e7e67f320b23feac784b629db17b3bcce08722Dake Guimport android.util.Log;
2571e7e67f320b23feac784b629db17b3bcce08722Dake Gu
2657ac90cf3fc528ac56b6b83718541624173b1368jingjiangliimport java.util.ArrayList;
2757ac90cf3fc528ac56b6b83718541624173b1368jingjiangli
2871e7e67f320b23feac784b629db17b3bcce08722Dake Gupublic class SearchSupportFragment extends android.support.v17.leanback.app.SearchSupportFragment
2957ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        implements android.support.v17.leanback.app.SearchSupportFragment.SearchResultProvider {
3071e7e67f320b23feac784b629db17b3bcce08722Dake Gu    private static final String TAG = "leanback.SearchSupportFragment";
3171e7e67f320b23feac784b629db17b3bcce08722Dake Gu    private static final int NUM_ROWS = 3;
3271e7e67f320b23feac784b629db17b3bcce08722Dake Gu    private static final int SEARCH_DELAY_MS = 1000;
3371e7e67f320b23feac784b629db17b3bcce08722Dake Gu
3471e7e67f320b23feac784b629db17b3bcce08722Dake Gu    private ArrayObjectAdapter mRowsAdapter;
3571e7e67f320b23feac784b629db17b3bcce08722Dake Gu    private Handler mHandler = new Handler();
3671e7e67f320b23feac784b629db17b3bcce08722Dake Gu    private String mQuery;
3771e7e67f320b23feac784b629db17b3bcce08722Dake Gu
3857ac90cf3fc528ac56b6b83718541624173b1368jingjiangli    // Flag to represent if data set one is presented in the fragment
3957ac90cf3fc528ac56b6b83718541624173b1368jingjiangli    private boolean mIsDataSetOnePresented;
4057ac90cf3fc528ac56b6b83718541624173b1368jingjiangli
4157ac90cf3fc528ac56b6b83718541624173b1368jingjiangli    // Adapter for first row
4257ac90cf3fc528ac56b6b83718541624173b1368jingjiangli    private ArrayObjectAdapter mFirstRowAdapter;
4357ac90cf3fc528ac56b6b83718541624173b1368jingjiangli
4457ac90cf3fc528ac56b6b83718541624173b1368jingjiangli    // The diff callback which defines the standard to judge if two items are the same or if
4557ac90cf3fc528ac56b6b83718541624173b1368jingjiangli    // two items have the same content.
4657ac90cf3fc528ac56b6b83718541624173b1368jingjiangli    private DiffCallback<PhotoItem> mDiffCallback = new DiffCallback<PhotoItem>() {
4757ac90cf3fc528ac56b6b83718541624173b1368jingjiangli
4857ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        // when two photo items have the same id, they are the same from adapter's
4957ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        // perspective
5057ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        @Override
5157ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        public boolean areItemsTheSame(PhotoItem oldItem, PhotoItem newItem) {
5257ac90cf3fc528ac56b6b83718541624173b1368jingjiangli            return oldItem.getId() == newItem.getId();
5357ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        }
5457ac90cf3fc528ac56b6b83718541624173b1368jingjiangli
5557ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        // when two photo items is equal to each other (based on the equal method defined in
5657ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        // PhotoItem), they have the same content.
5757ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        @Override
5857ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        public boolean areContentsTheSame(PhotoItem oldItem, PhotoItem newItem) {
5957ac90cf3fc528ac56b6b83718541624173b1368jingjiangli            return oldItem.equals(newItem);
6057ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        }
6157ac90cf3fc528ac56b6b83718541624173b1368jingjiangli    };
6257ac90cf3fc528ac56b6b83718541624173b1368jingjiangli
6371e7e67f320b23feac784b629db17b3bcce08722Dake Gu    @Override
6471e7e67f320b23feac784b629db17b3bcce08722Dake Gu    public void onCreate(Bundle savedInstanceState) {
6571e7e67f320b23feac784b629db17b3bcce08722Dake Gu        super.onCreate(savedInstanceState);
6671e7e67f320b23feac784b629db17b3bcce08722Dake Gu
6771e7e67f320b23feac784b629db17b3bcce08722Dake Gu        mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
6871e7e67f320b23feac784b629db17b3bcce08722Dake Gu
69b7087e036a48f5a3db28d02ff7f9b97fbbc46c4fDake Gu        final Context context = getActivity();
70b7087e036a48f5a3db28d02ff7f9b97fbbc46c4fDake Gu        setBadgeDrawable(ResourcesCompat.getDrawable(context.getResources(),
71b7087e036a48f5a3db28d02ff7f9b97fbbc46c4fDake Gu                R.drawable.ic_title, context.getTheme()));
7271e7e67f320b23feac784b629db17b3bcce08722Dake Gu        setTitle("Leanback Sample App");
7371e7e67f320b23feac784b629db17b3bcce08722Dake Gu        setSearchResultProvider(this);
7471e7e67f320b23feac784b629db17b3bcce08722Dake Gu        setOnItemViewClickedListener(new ItemViewClickedListener());
7571e7e67f320b23feac784b629db17b3bcce08722Dake Gu    }
7671e7e67f320b23feac784b629db17b3bcce08722Dake Gu
7771e7e67f320b23feac784b629db17b3bcce08722Dake Gu    @Override
7871e7e67f320b23feac784b629db17b3bcce08722Dake Gu    public ObjectAdapter getResultsAdapter() {
7971e7e67f320b23feac784b629db17b3bcce08722Dake Gu        return mRowsAdapter;
8071e7e67f320b23feac784b629db17b3bcce08722Dake Gu    }
8171e7e67f320b23feac784b629db17b3bcce08722Dake Gu
8271e7e67f320b23feac784b629db17b3bcce08722Dake Gu    @Override
8371e7e67f320b23feac784b629db17b3bcce08722Dake Gu    public boolean onQueryTextChange(String newQuery) {
8471e7e67f320b23feac784b629db17b3bcce08722Dake Gu        Log.i(TAG, String.format("Search Query Text Change %s", newQuery));
8571e7e67f320b23feac784b629db17b3bcce08722Dake Gu        mRowsAdapter.clear();
8671e7e67f320b23feac784b629db17b3bcce08722Dake Gu        loadQuery(newQuery);
8771e7e67f320b23feac784b629db17b3bcce08722Dake Gu        return true;
8871e7e67f320b23feac784b629db17b3bcce08722Dake Gu    }
8971e7e67f320b23feac784b629db17b3bcce08722Dake Gu
9071e7e67f320b23feac784b629db17b3bcce08722Dake Gu    @Override
9171e7e67f320b23feac784b629db17b3bcce08722Dake Gu    public boolean onQueryTextSubmit(String query) {
9271e7e67f320b23feac784b629db17b3bcce08722Dake Gu        Log.i(TAG, String.format("Search Query Text Submit %s", query));
9371e7e67f320b23feac784b629db17b3bcce08722Dake Gu        mRowsAdapter.clear();
9471e7e67f320b23feac784b629db17b3bcce08722Dake Gu        loadQuery(query);
9571e7e67f320b23feac784b629db17b3bcce08722Dake Gu        return true;
9671e7e67f320b23feac784b629db17b3bcce08722Dake Gu    }
9771e7e67f320b23feac784b629db17b3bcce08722Dake Gu
9871e7e67f320b23feac784b629db17b3bcce08722Dake Gu    private void loadQuery(String query) {
9971e7e67f320b23feac784b629db17b3bcce08722Dake Gu        mQuery = query;
10071e7e67f320b23feac784b629db17b3bcce08722Dake Gu        mHandler.removeCallbacks(mDelayedLoad);
10171e7e67f320b23feac784b629db17b3bcce08722Dake Gu        if (!TextUtils.isEmpty(query) && !query.equals("nil")) {
10271e7e67f320b23feac784b629db17b3bcce08722Dake Gu            mHandler.postDelayed(mDelayedLoad, SEARCH_DELAY_MS);
10371e7e67f320b23feac784b629db17b3bcce08722Dake Gu        }
10471e7e67f320b23feac784b629db17b3bcce08722Dake Gu    }
10571e7e67f320b23feac784b629db17b3bcce08722Dake Gu
10671e7e67f320b23feac784b629db17b3bcce08722Dake Gu    private void loadRows() {
10757ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        HeaderItem header = new HeaderItem(0, mQuery + " results row " + 0);
10857ac90cf3fc528ac56b6b83718541624173b1368jingjiangli
10957ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        // Every time when the query event is fired, we will update the fake search result in the
11057ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        // first row based on the flag mIsDataSetOnePresented flag.
11157ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        // Also the first row adapter will only be created once so the animation will be triggered
11257ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        // when the items in the adapter changed.
11357ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        if (!mIsDataSetOnePresented) {
11457ac90cf3fc528ac56b6b83718541624173b1368jingjiangli            if (mFirstRowAdapter == null) {
11557ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                mFirstRowAdapter = createFirstListRowAdapter();
11657ac90cf3fc528ac56b6b83718541624173b1368jingjiangli            } else {
11757ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                mFirstRowAdapter.setItems(createDataSetOne(), mDiffCallback);
11857ac90cf3fc528ac56b6b83718541624173b1368jingjiangli            }
11957ac90cf3fc528ac56b6b83718541624173b1368jingjiangli            mIsDataSetOnePresented = true;
12057ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        } else {
12157ac90cf3fc528ac56b6b83718541624173b1368jingjiangli            mFirstRowAdapter.setItems(createDataSetTwo(), mDiffCallback);
12257ac90cf3fc528ac56b6b83718541624173b1368jingjiangli            mIsDataSetOnePresented = false;
12357ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        }
12457ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        mRowsAdapter.add(new ListRow(header, mFirstRowAdapter));
12557ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        for (int i = 1; i < NUM_ROWS + 1; ++i) {
12671e7e67f320b23feac784b629db17b3bcce08722Dake Gu            ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new CardPresenter());
12771e7e67f320b23feac784b629db17b3bcce08722Dake Gu            listRowAdapter.add(new PhotoItem("Hello world", R.drawable.gallery_photo_1));
12871e7e67f320b23feac784b629db17b3bcce08722Dake Gu            listRowAdapter.add(new PhotoItem("This is a test", R.drawable.gallery_photo_2));
12957ac90cf3fc528ac56b6b83718541624173b1368jingjiangli            header = new HeaderItem(i, mQuery + " results row " + i);
13071e7e67f320b23feac784b629db17b3bcce08722Dake Gu            mRowsAdapter.add(new ListRow(header, listRowAdapter));
13171e7e67f320b23feac784b629db17b3bcce08722Dake Gu        }
13271e7e67f320b23feac784b629db17b3bcce08722Dake Gu    }
13371e7e67f320b23feac784b629db17b3bcce08722Dake Gu
13471e7e67f320b23feac784b629db17b3bcce08722Dake Gu    private Runnable mDelayedLoad = new Runnable() {
13571e7e67f320b23feac784b629db17b3bcce08722Dake Gu        @Override
13671e7e67f320b23feac784b629db17b3bcce08722Dake Gu        public void run() {
13771e7e67f320b23feac784b629db17b3bcce08722Dake Gu            loadRows();
13871e7e67f320b23feac784b629db17b3bcce08722Dake Gu        }
13971e7e67f320b23feac784b629db17b3bcce08722Dake Gu    };
14071e7e67f320b23feac784b629db17b3bcce08722Dake Gu
14171e7e67f320b23feac784b629db17b3bcce08722Dake Gu    private final class ItemViewClickedListener implements OnItemViewClickedListener {
14271e7e67f320b23feac784b629db17b3bcce08722Dake Gu        @Override
14371e7e67f320b23feac784b629db17b3bcce08722Dake Gu        public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
14471e7e67f320b23feac784b629db17b3bcce08722Dake Gu                RowPresenter.ViewHolder rowViewHolder, Row row) {
14571e7e67f320b23feac784b629db17b3bcce08722Dake Gu            Intent intent = new Intent(getActivity(), DetailsSupportActivity.class);
14671e7e67f320b23feac784b629db17b3bcce08722Dake Gu            intent.putExtra(DetailsSupportActivity.EXTRA_ITEM, (PhotoItem) item);
14771e7e67f320b23feac784b629db17b3bcce08722Dake Gu
14871e7e67f320b23feac784b629db17b3bcce08722Dake Gu            Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(
14971e7e67f320b23feac784b629db17b3bcce08722Dake Gu                    getActivity(),
15057ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                    ((ImageCardView) itemViewHolder.view).getMainImageView(),
15171e7e67f320b23feac784b629db17b3bcce08722Dake Gu                    DetailsSupportActivity.SHARED_ELEMENT_NAME).toBundle();
15271e7e67f320b23feac784b629db17b3bcce08722Dake Gu            getActivity().startActivity(intent, bundle);
15371e7e67f320b23feac784b629db17b3bcce08722Dake Gu        }
15471e7e67f320b23feac784b629db17b3bcce08722Dake Gu    }
15557ac90cf3fc528ac56b6b83718541624173b1368jingjiangli
15657ac90cf3fc528ac56b6b83718541624173b1368jingjiangli
15757ac90cf3fc528ac56b6b83718541624173b1368jingjiangli    private ArrayObjectAdapter createFirstListRowAdapter() {
15857ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new CardPresenter());
15957ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        listRowAdapter.setItems(createDataSetOne(), mDiffCallback);
16057ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        mIsDataSetOnePresented = true;
16157ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        return listRowAdapter;
16257ac90cf3fc528ac56b6b83718541624173b1368jingjiangli    }
16357ac90cf3fc528ac56b6b83718541624173b1368jingjiangli
16457ac90cf3fc528ac56b6b83718541624173b1368jingjiangli    /**
16557ac90cf3fc528ac56b6b83718541624173b1368jingjiangli     * Create a data set (data set one) for the last row of this browse fragment. It will be
16657ac90cf3fc528ac56b6b83718541624173b1368jingjiangli     * changed by another set of data when user click one of the photo items in the list.
16757ac90cf3fc528ac56b6b83718541624173b1368jingjiangli     * Different with other rows in the browsing fragment, the photo item in last row all have been
16857ac90cf3fc528ac56b6b83718541624173b1368jingjiangli     * allocated with a unique id. And the id will be used to jduge if two photo items are the same
16957ac90cf3fc528ac56b6b83718541624173b1368jingjiangli     * or not.
17057ac90cf3fc528ac56b6b83718541624173b1368jingjiangli     *
17157ac90cf3fc528ac56b6b83718541624173b1368jingjiangli     * @return List of photoItem
17257ac90cf3fc528ac56b6b83718541624173b1368jingjiangli     */
17357ac90cf3fc528ac56b6b83718541624173b1368jingjiangli    private ArrayList<PhotoItem> createDataSetOne() {
17457ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        ArrayList<PhotoItem> photoItems = new ArrayList<>();
17557ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        photoItems.add(new PhotoItem(
17657ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "Hello world",
17757ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                R.drawable.gallery_photo_1,
17857ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                1));
17957ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        photoItems.add(new PhotoItem(
18057ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "This is a test",
18157ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "Only a test",
18257ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                R.drawable.gallery_photo_2,
18357ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                2));
18457ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        photoItems.add(new PhotoItem(
18557ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "Android TV",
18657ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "by Google",
18757ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                R.drawable.gallery_photo_3,
18857ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                3));
18957ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        photoItems.add(new PhotoItem(
19057ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "Leanback",
19157ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                R.drawable.gallery_photo_4,
19257ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                4));
19357ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        photoItems.add(new PhotoItem(
19457ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "GuidedStep (Slide left/right)",
19557ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                R.drawable.gallery_photo_5,
19657ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                5));
19757ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        photoItems.add(new PhotoItem(
19857ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "GuidedStep (Slide bottom up)",
19957ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "Open GuidedStepFragment",
20057ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                R.drawable.gallery_photo_6,
20157ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                6));
20257ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        photoItems.add(new PhotoItem(
20357ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "Android TV",
20457ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "open RowsActivity",
20557ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                R.drawable.gallery_photo_7,
20657ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                7));
20757ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        photoItems.add(new PhotoItem(
20857ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "Leanback",
20957ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "open BrowseActivity",
21057ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                R.drawable.gallery_photo_8,
21157ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                8));
21257ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        photoItems.add(new PhotoItem(
21357ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "Hello world",
21457ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                R.drawable.gallery_photo_1,
21557ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                1));
21657ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        photoItems.add(new PhotoItem(
21757ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "This is a test",
21857ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "Only a test",
21957ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                R.drawable.gallery_photo_2,
22057ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                2));
22157ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        photoItems.add(new PhotoItem(
22257ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "Android TV",
22357ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "by Google",
22457ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                R.drawable.gallery_photo_3,
22557ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                3));
22657ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        photoItems.add(new PhotoItem(
22757ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "Leanback",
22857ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                R.drawable.gallery_photo_4,
22957ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                4));
23057ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        return photoItems;
23157ac90cf3fc528ac56b6b83718541624173b1368jingjiangli    }
23257ac90cf3fc528ac56b6b83718541624173b1368jingjiangli
23357ac90cf3fc528ac56b6b83718541624173b1368jingjiangli    /**
23457ac90cf3fc528ac56b6b83718541624173b1368jingjiangli     * Create a new data set (data set one) for the last row of this browse fragment. It will be
23557ac90cf3fc528ac56b6b83718541624173b1368jingjiangli     * changed by another set of data when user click one of the photo items in the list.
23657ac90cf3fc528ac56b6b83718541624173b1368jingjiangli     * Different with other rows in the browsing fragment, the photo item in last row all have been
23757ac90cf3fc528ac56b6b83718541624173b1368jingjiangli     * allocated with a unique id. And the id will be used to jduge if two photo items are the same
23857ac90cf3fc528ac56b6b83718541624173b1368jingjiangli     * or not.
23957ac90cf3fc528ac56b6b83718541624173b1368jingjiangli     *
24057ac90cf3fc528ac56b6b83718541624173b1368jingjiangli     * @return List of photoItem
24157ac90cf3fc528ac56b6b83718541624173b1368jingjiangli     */
24257ac90cf3fc528ac56b6b83718541624173b1368jingjiangli    private ArrayList<PhotoItem> createDataSetTwo() {
24357ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        ArrayList<PhotoItem> photoItems = new ArrayList<>();
24457ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        photoItems.add(new PhotoItem(
24557ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "This is a test",
24657ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "Only a test",
24757ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                R.drawable.gallery_photo_2,
24857ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                2));
24957ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        photoItems.add(new PhotoItem(
25057ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "Hello world",
25157ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                R.drawable.gallery_photo_1,
25257ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                1));
25357ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        photoItems.add(new PhotoItem(
25457ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "Leanback",
25557ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                R.drawable.gallery_photo_4,
25657ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                4));
25757ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        photoItems.add(new PhotoItem(
25857ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "Android TV",
25957ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "by Google",
26057ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                R.drawable.gallery_photo_3,
26157ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                3));
26257ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        photoItems.add(new PhotoItem(
26357ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "change title",
26457ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                R.drawable.gallery_photo_5,
26557ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                5));
26657ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        photoItems.add(new PhotoItem(
26757ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "GuidedStep (Slide bottom up)",
26857ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "change comment",
26957ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                R.drawable.gallery_photo_6,
27057ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                6));
27157ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        photoItems.add(new PhotoItem(
27257ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "Android TV",
27357ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                R.drawable.gallery_photo_7,
27457ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                7));
27557ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        photoItems.add(new PhotoItem(
27657ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "Leanback",
27757ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "open BrowseActivity",
27857ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                R.drawable.gallery_photo_7,
27957ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                8));
28057ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        photoItems.add(new PhotoItem(
28157ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "Hello world",
28257ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                R.drawable.gallery_photo_1,
28357ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                10));
28457ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        photoItems.add(new PhotoItem(
28557ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "This is a test",
28657ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "Only a test",
28757ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                R.drawable.gallery_photo_2,
28857ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                20));
28957ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        photoItems.add(new PhotoItem(
29057ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "Android TV",
29157ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "by Google",
29257ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                R.drawable.gallery_photo_3,
29357ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                30));
29457ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        photoItems.add(new PhotoItem(
29557ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                "Leanback",
29657ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                R.drawable.gallery_photo_4,
29757ac90cf3fc528ac56b6b83718541624173b1368jingjiangli                40));
29857ac90cf3fc528ac56b6b83718541624173b1368jingjiangli        return photoItems;
29957ac90cf3fc528ac56b6b83718541624173b1368jingjiangli    }
30057ac90cf3fc528ac56b6b83718541624173b1368jingjiangli
30171e7e67f320b23feac784b629db17b3bcce08722Dake Gu}
302