android.support.v17.leanback.widget.ObjectAdapter Java Examples

The following examples show how to use android.support.v17.leanback.widget.ObjectAdapter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SearchSupportFragment.java    From adt-leanback-support with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
    // Retrieve the result adapter
    ObjectAdapter adapter = mProvider.getResultsAdapter();
    if (adapter != mResultAdapter) {
        boolean firstTime = mResultAdapter == null;
        releaseAdapter();
        mResultAdapter = adapter;
        if (mResultAdapter != null) {
            mResultAdapter.registerObserver(mAdapterObserver);
        }
        if (null != mRowsSupportFragment) {
            // delay the first time to avoid setting a empty result adapter
            // until we got first onChange() from the provider
            if (!(firstTime && (mResultAdapter == null || mResultAdapter.size() == 0))) {
                mRowsSupportFragment.setAdapter(mResultAdapter);
            }
            executePendingQuery();
        }
        updateSearchBarNextFocusId();
    }
}
 
Example #2
Source File: SearchFragment.java    From adt-leanback-support with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
    // Retrieve the result adapter
    ObjectAdapter adapter = mProvider.getResultsAdapter();
    if (adapter != mResultAdapter) {
        boolean firstTime = mResultAdapter == null;
        releaseAdapter();
        mResultAdapter = adapter;
        if (mResultAdapter != null) {
            mResultAdapter.registerObserver(mAdapterObserver);
        }
        if (null != mRowsFragment) {
            // delay the first time to avoid setting a empty result adapter
            // until we got first onChange() from the provider
            if (!(firstTime && (mResultAdapter == null || mResultAdapter.size() == 0))) {
                mRowsFragment.setAdapter(mResultAdapter);
            }
            executePendingQuery();
        }
        updateSearchBarNextFocusId();
    }
}
 
Example #3
Source File: LeanbackBrowseFragment.java    From android-tv-leanback with Apache License 2.0 6 votes vote down vote up
public void init() {
    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    setAdapter(mRowsAdapter);

    setBrandColor(ContextCompat.getColor(getContext(), R.color.primary));
    setBadgeDrawable(ContextCompat.getDrawable(getContext(), R.drawable.filmi));

    for (int position = 0; position < HEADERS.length; position++) {
        ObjectAdapter rowContents = new CursorObjectAdapter((new SinglePresenterSelector(new CardPresenter())));
        VideoDataManager manager = new VideoDataManager(getActivity(), getLoaderManager(), VideoItemContract.VideoItem.buildDirUri(), rowContents);
        manager.startDataLoading();

        HeaderItem headerItem = new HeaderItem(position, HEADERS[position]);
        mRowsAdapter.add(new ListRow(headerItem, manager.getItemList()));
    }

    setOnItemViewClickedListener(getDefaultItemViewClickedListener());

}
 
Example #4
Source File: LeanbackBrowseFragment.java    From android-tv-leanback with Apache License 2.0 6 votes vote down vote up
public void init() {
    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    setAdapter(mRowsAdapter);

    setBrandColor(ContextCompat.getColor(getContext(), R.color.primary));
    setBadgeDrawable(ContextCompat.getDrawable(getContext(), R.drawable.filmi));

    for (int position = 0; position < HEADERS.length; position++) {
        ObjectAdapter rowContents = new CursorObjectAdapter((new SinglePresenterSelector(new CardPresenter())));
        VideoDataManager manager = new VideoDataManager(getActivity(), getLoaderManager(), VideoItemContract.VideoItem.buildDirUri(), rowContents);
        manager.startDataLoading();

        HeaderItem headerItem = new HeaderItem(position, HEADERS[position]);
        mRowsAdapter.add(new ListRow(headerItem, manager.getItemList()));
    }

}
 
Example #5
Source File: LeanbackBrowseFragment.java    From android-tv-leanback with Apache License 2.0 6 votes vote down vote up
public void init() {
    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    setAdapter(mRowsAdapter);

    setBrandColor(ContextCompat.getColor(getContext(), R.color.primary));
    setBadgeDrawable(ContextCompat.getDrawable(getContext(), R.drawable.filmi));

    for (int position = 0; position < HEADERS.length; position++) {
        ObjectAdapter rowContents = new CursorObjectAdapter((new SinglePresenterSelector(new CardPresenter())));
        VideoDataManager manager = new VideoDataManager(getActivity(), getLoaderManager(), VideoItemContract.VideoItem.buildDirUri(), rowContents);
        manager.startDataLoading();

        HeaderItem headerItem = new HeaderItem(position, HEADERS[position]);
        mRowsAdapter.add(new ListRow(headerItem, manager.getItemList()));
    }

    setOnItemViewClickedListener(getDefaultItemViewClickedListener());
    setOnItemViewSelectedListener(getDefaultItemSelectedListener());

    bgHelper = new BackgroundHelper(getActivity());
    bgHelper.prepareBackgroundManager();

}
 
Example #6
Source File: LeanbackBrowseFragment.java    From android-tv-leanback with Apache License 2.0 6 votes vote down vote up
public void init() {
    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    setAdapter(mRowsAdapter);

    setBrandColor(ContextCompat.getColor(getContext(), R.color.primary));
    setBadgeDrawable(ContextCompat.getDrawable(getContext(), R.drawable.filmi));

    for (int position = 0; position < HEADERS.length; position++) {
        ObjectAdapter rowContents = new CursorObjectAdapter((new SinglePresenterSelector(new CardPresenter())));
        VideoDataManager manager = new VideoDataManager(getActivity(), getLoaderManager(), VideoItemContract.VideoItem.buildDirUri(), rowContents);
        manager.startDataLoading();

        HeaderItem headerItem = new HeaderItem(position, HEADERS[position]);
        mRowsAdapter.add(new ListRow(headerItem, manager.getItemList()));
    }

    setOnItemViewClickedListener(getDefaultItemViewClickedListener());

}
 
Example #7
Source File: LeanbackBrowseFragment.java    From android-tv-leanback with Apache License 2.0 6 votes vote down vote up
public void init() {
    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    setAdapter(mRowsAdapter);

    setBrandColor(ContextCompat.getColor(getContext(), R.color.primary));
    setBadgeDrawable(ContextCompat.getDrawable(getContext(), R.drawable.filmi));

    for (int position = 0; position < HEADERS.length; position++) {
        ObjectAdapter rowContents = new CursorObjectAdapter((new SinglePresenterSelector(new CardPresenter())));
        VideoDataManager manager = new VideoDataManager(getActivity(), getLoaderManager(), VideoItemContract.VideoItem.buildDirUri(), rowContents);
        manager.startDataLoading();

        HeaderItem headerItem = new HeaderItem(position, HEADERS[position]);
        mRowsAdapter.add(new ListRow(headerItem, manager.getItemList()));
    }

    setOnItemViewClickedListener(getDefaultItemViewClickedListener());
    setOnItemViewSelectedListener(getDefaultItemSelectedListener());

    bgHelper = new BackgroundHelper(getActivity());
    bgHelper.prepareBackgroundManager();

}
 
Example #8
Source File: PlaybackOverlayFragment.java    From android-tv-leanback with Apache License 2.0 5 votes vote down vote up
private void addOtherRows() {
    ObjectAdapter rowContents = new CursorObjectAdapter((new SinglePresenterSelector(new CardPresenter())));
    VideoDataManager manager = new VideoDataManager(getActivity(), getLoaderManager(), VideoItemContract.VideoItem.buildDirUri(), rowContents);
    manager.startDataLoading();

    HeaderItem headerItem = new HeaderItem(0, "You may also like");
    mRowsAdapter.add(new ListRow(headerItem, manager.getItemList()));
}
 
Example #9
Source File: VideoDataManager.java    From android-tv-leanback with Apache License 2.0 5 votes vote down vote up
public VideoDataManager(Context mContext, LoaderManager mLoaderManager, Uri mRowUri, ObjectAdapter rowContents) {
    this.mLoaderManager = mLoaderManager;
    this.mRowUri = mRowUri;
    this.mContext = mContext;
    mItemList = rowContents;
    LOADER_ID = Double.valueOf(Math.random() * Integer.MAX_VALUE).intValue();
    mMapper = new VideoItemMapper();
    ((CursorObjectAdapter) mItemList).setMapper(mMapper);

}
 
Example #10
Source File: BrowseFragment.java    From Amphitheatre with Apache License 2.0 5 votes vote down vote up
private void reloadAdapters() {
    for (int i = 0; i < mAdapter.size(); i++) {
        ListRow listRow = (ListRow) mAdapter.get(i);
        ObjectAdapter objectAdapter = listRow.getAdapter();
        if (objectAdapter instanceof ArrayObjectAdapter) {
            ArrayObjectAdapter arrayObjectAdapter = ((ArrayObjectAdapter) objectAdapter);
            arrayObjectAdapter.notifyArrayItemRangeChanged(0, arrayObjectAdapter.size());
        }
    }
}
 
Example #11
Source File: VideoDataManager.java    From android-tv-leanback with Apache License 2.0 5 votes vote down vote up
public VideoDataManager(Context mContext, LoaderManager mLoaderManager, Uri mRowUri, ObjectAdapter rowContents) {
    this.mLoaderManager = mLoaderManager;
    this.mRowUri = mRowUri;
    this.mContext = mContext;
    mItemList = rowContents;
    LOADER_ID = Double.valueOf(Math.random() * Integer.MAX_VALUE).intValue();
    mMapper = new VideoItemMapper();
    ((CursorObjectAdapter) mItemList).setMapper(mMapper);

}
 
Example #12
Source File: VideoDataManager.java    From android-tv-leanback with Apache License 2.0 5 votes vote down vote up
public VideoDataManager(Context mContext, LoaderManager mLoaderManager, Uri mRowUri, ObjectAdapter rowContents) {
    this.mLoaderManager = mLoaderManager;
    this.mRowUri = mRowUri;
    this.mContext = mContext;
    mItemList = rowContents;
    LOADER_ID = Double.valueOf(Math.random() * Integer.MAX_VALUE).intValue();
    mMapper = new VideoItemMapper();
    ((CursorObjectAdapter) mItemList).setMapper(mMapper);

}
 
Example #13
Source File: PlaybackOverlaySupportFragment.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the list of rows for the fragment.
 */
@Override
public void setAdapter(ObjectAdapter adapter) {
    if (getAdapter() != null) {
        getAdapter().unregisterObserver(mObserver);
    }
    super.setAdapter(adapter);
    if (adapter != null) {
        adapter.registerObserver(mObserver);
    }
}
 
Example #14
Source File: VideoDataManager.java    From android-tv-leanback with Apache License 2.0 5 votes vote down vote up
public VideoDataManager(Context mContext, LoaderManager mLoaderManager, Uri mRowUri, ObjectAdapter rowContents) {
    this.mLoaderManager = mLoaderManager;
    this.mRowUri = mRowUri;
    this.mContext = mContext;
    mItemList = rowContents;
    LOADER_ID = Double.valueOf(Math.random() * Integer.MAX_VALUE).intValue();
    mMapper = new VideoItemMapper();
    ((CursorObjectAdapter) mItemList).setMapper(mMapper);

}
 
Example #15
Source File: PlaybackOverlayFragment.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the list of rows for the fragment.
 */
@Override
public void setAdapter(ObjectAdapter adapter) {
    if (getAdapter() != null) {
        getAdapter().unregisterObserver(mObserver);
    }
    super.setAdapter(adapter);
    if (adapter != null) {
        adapter.registerObserver(mObserver);
    }
}
 
Example #16
Source File: VideoDataManager.java    From android-tv-leanback with Apache License 2.0 5 votes vote down vote up
public VideoDataManager(Context mContext, LoaderManager mLoaderManager, Uri mRowUri, ObjectAdapter rowContents) {
    this.mLoaderManager = mLoaderManager;
    this.mRowUri = mRowUri;
    this.mContext = mContext;
    mItemList = rowContents;
    LOADER_ID = Double.valueOf(Math.random() * Integer.MAX_VALUE).intValue();
    mMapper = new VideoItemMapper();
    ((CursorObjectAdapter) mItemList).setMapper(mMapper);

}
 
Example #17
Source File: DetailsFragment.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the list of rows for the fragment.
 */
public void setAdapter(ObjectAdapter adapter) {
    mAdapter = adapter;
    if (mRowsFragment != null) {
        mRowsFragment.setAdapter(adapter);
    }
}
 
Example #18
Source File: DetailsSupportFragment.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the list of rows for the fragment.
 */
public void setAdapter(ObjectAdapter adapter) {
    mAdapter = adapter;
    if (mRowsSupportFragment != null) {
        mRowsSupportFragment.setAdapter(adapter);
    }
}
 
Example #19
Source File: DetailsSupportFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the list of rows.
 */
public ObjectAdapter getAdapter() {
    return mAdapter;
}
 
Example #20
Source File: BaseRowSupportFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Sets the adapter for the fragment.
 */
public final void setAdapter(ObjectAdapter rowsAdapter) {
    mAdapter = rowsAdapter;
    updateAdapter();
}
 
Example #21
Source File: BaseRowSupportFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the list of rows.
 */
public final ObjectAdapter getAdapter() {
    return mAdapter;
}
 
Example #22
Source File: VerticalGridFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Sets the object adapter for the fragment.
 */
public void setAdapter(ObjectAdapter adapter) {
    mAdapter = adapter;
    updateAdapter();
}
 
Example #23
Source File: DetailsFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the list of rows.
 */
public ObjectAdapter getAdapter() {
    return mAdapter;
}
 
Example #24
Source File: BrowseFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the adapter containing the rows for the fragment.
 */
public ObjectAdapter getAdapter() {
    return mAdapter;
}
 
Example #25
Source File: BrowseSupportFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the adapter containing the rows for the fragment.
 */
public ObjectAdapter getAdapter() {
    return mAdapter;
}
 
Example #26
Source File: BaseRowFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Sets the adapter for the fragment.
 */
public final void setAdapter(ObjectAdapter rowsAdapter) {
    mAdapter = rowsAdapter;
    updateAdapter();
}
 
Example #27
Source File: VerticalGridFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the object adapter.
 */
public ObjectAdapter getAdapter() {
    return mAdapter;
}
 
Example #28
Source File: SearchFragment.java    From Amphitheatre with Apache License 2.0 4 votes vote down vote up
@Override
public ObjectAdapter getResultsAdapter() {
    return mRowsAdapter;
}
 
Example #29
Source File: TVSearchFragment.java    From BuildingForAndroidTV with MIT License 4 votes vote down vote up
@Override
public ObjectAdapter getResultsAdapter() {
	return mRowsAdapter;
}
 
Example #30
Source File: TVSearchFragment.java    From BuildingForAndroidTV with MIT License 4 votes vote down vote up
@Override
public ObjectAdapter getResultsAdapter() {
	return mRowsAdapter;
}