Java 类android.support.v17.leanback.widget.PresenterSelector 实例源码

项目:androidtv-sample    文件:MainFragment.java   
private void setupUIElements() {
    setBadgeDrawable(
            getActivity().getResources().getDrawable(R.drawable.nejcz, null));
    setTitle(getString(R.string.browse_title)); // Badge, when set, takes precedent over title
    setHeadersState(HEADERS_ENABLED);
    setHeadersTransitionOnBackEnabled(true);

    // Set fastLane (or headers) background color
    setBrandColor(ContextCompat.getColor(getActivity(), R.color.fastlane_background));

    // Set search icon color.
    setSearchAffordanceColor(ContextCompat.getColor(getActivity(), R.color.search_opaque));

    setHeaderPresenterSelector(new PresenterSelector() {
        @Override
        public Presenter getPresenter(Object o) {
            return new IconHeaderItemPresenter();
        }
    });
}
项目:chilly    文件:MainFragment.java   
private void setupUIElements() {
    setBadgeDrawable(
            getActivity().getResources().getDrawable(R.drawable.app_icon_chilly_transparent, null));
    setTitle(getString(R.string.browse_title)); // Badge, when set, takes precedent over title
    setHeadersState(HEADERS_DISABLED);
    setHeadersTransitionOnBackEnabled(true);

    // Set fastLane (or headers) background color
    setBrandColor(ContextCompat.getColor(getActivity(), R.color.fastlane_background));

    // Set search icon color.
    setSearchAffordanceColor(ContextCompat.getColor(getActivity(), R.color.search_opaque));

    setHeaderPresenterSelector(new PresenterSelector() {
        @Override
        public Presenter getPresenter(Object o) {
            return new IconHeaderItemPresenter();
        }
    });
}
项目:webradio-tv-app    文件:RadioFragment.java   
private void setupRowAdapter() {
    VerticalGridPresenter gridPresenter = new VerticalGridPresenter(ZOOM_FACTOR);
    gridPresenter.setNumberOfColumns(COLUMNS);
    setGridPresenter(gridPresenter);

    PresenterSelector cardPresenterSelector = new CardPresenterSelector(getActivity());
    mAdapter = new ArrayObjectAdapter(cardPresenterSelector);
    setAdapter(mAdapter);

    prepareEntranceTransition();
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            createRows();
            startEntranceTransition();
        }
    }, 1000);
}
项目:LeanbackCards    文件:CardAdapter.java   
public CardAdapter(Context context) {
    mLoadingPresenter = new LoadingPresenter();
    mIconItemPresenter = new IconItemPresenter();
    mTagItemPresenter = new TagItemPresenter();
    mLiveCardPresenter = new LiveCardPresenter(context);
    setPresenterSelector(new PresenterSelector() {
        @Override
        public Presenter getPresenter(Object item) {
            if (item instanceof LoadingCardView) {
                return mLoadingPresenter;
            } else if (item instanceof IconCardView) {
                return mIconItemPresenter;
            } else if (item instanceof TagCardView) {
                return mTagItemPresenter;
            } else if (item instanceof Post) {
                return mLiveCardPresenter;
            }
            return null;
        }
    });
}
项目:popcorn-android    文件:PTVPlaybackOverlayFragment.java   
private void setupSecondaryRowPlaybackControl(@NonNull PresenterSelector presenterSelector) {
    mSecondaryActionsAdapter = new ArrayObjectAdapter(presenterSelector);
    mPlaybackControlsRow.setSecondaryActionsAdapter(mSecondaryActionsAdapter);

    Activity activity = getActivity();

    mScaleVideoAction = new ScaleVideoAction(activity);
    mClosedCaptioningAction = new ClosedCaptioningAction(activity);
    mClosedCaptioningAction.setIcon(getResources().getDrawable(R.drawable.ic_av_subs, null));

    if (mStreamInfo!= null && mStreamInfo.getSubtitleLanguage() != null && !mStreamInfo.getSubtitleLanguage().equals(SubsProvider.SUBTITLE_LANGUAGE_NONE)) {
        mClosedCaptioningAction.setIndex(ClosedCaptioningAction.ON);
    } else {
        mClosedCaptioningAction.setIndex(ClosedCaptioningAction.OFF);
    }

    // Add rest of controls to secondary adapter.
    mSecondaryActionsAdapter.add(mScaleVideoAction);
    if(mSubsButtonEnabled)
    mSecondaryActionsAdapter.add(mClosedCaptioningAction);
}
项目:leanback-showcase    文件:VideoGridExampleFragment.java   
private void setupRowAdapter() {
    VerticalGridPresenter videoGridPresenter = new VerticalGridPresenter(ZOOM_FACTOR);
    videoGridPresenter.setNumberOfColumns(COLUMNS);
    // note: The click listeners must be called before setGridPresenter for the event listeners
    // to be properly registered on the viewholders.
    setOnItemViewSelectedListener(this);
    setOnItemViewClickedListener(this);
    setGridPresenter(videoGridPresenter);

    PresenterSelector cardPresenterSelector = new CardPresenterSelector(getActivity());
    // VideoCardViewPresenter videoCardViewPresenter = new VideoCardViewPresenter(getActivity());
    mAdapter = new ArrayObjectAdapter(cardPresenterSelector);
    setAdapter(mAdapter);

    prepareEntranceTransition();
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            createRows();
        }
    }, 1000);
}
项目:leanback-showcase    文件:GridExampleFragment.java   
private void setupRowAdapter() {
    VerticalGridPresenter gridPresenter = new VerticalGridPresenter(ZOOM_FACTOR);
    gridPresenter.setNumberOfColumns(COLUMNS);
    setGridPresenter(gridPresenter);

    PresenterSelector cardPresenterSelector = new CardPresenterSelector(getActivity());
    mAdapter = new ArrayObjectAdapter(cardPresenterSelector);
    setAdapter(mAdapter);

    prepareEntranceTransition();
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            createRows();
            startEntranceTransition();
        }
    }, 1000);
}
项目:leanback-showcase    文件:CardExampleFragment.java   
private Row createCardRow(final CardRow cardRow) {
    switch (cardRow.getType()) {
        case CardRow.TYPE_SECTION_HEADER:
            return new SectionRow(new HeaderItem(cardRow.getTitle()));
        case CardRow.TYPE_DIVIDER:
            return new DividerRow();
        case CardRow.TYPE_DEFAULT:
        default:
            // Build main row using the ImageCardViewPresenter.
            PresenterSelector presenterSelector = new CardPresenterSelector(getActivity());
            ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(presenterSelector);
            for (Card card : cardRow.getCards()) {
                listRowAdapter.add(card);
            }
            return new CardListRow(new HeaderItem(cardRow.getTitle()), listRowAdapter, cardRow);
    }
}
项目:leanback-showcase    文件:LiveDataDetailFragmentUiModule.java   
@Provides
@PerFragment
public FullWidthDetailsOverviewSharedElementHelper provideHelper(Activity activity,
        PresenterSelector mPs, DetailsOverviewRow row, OnActionClickedListener listener) {
    FullWidthDetailsOverviewSharedElementHelper mHelper =
            new FullWidthDetailsOverviewSharedElementHelper();
    mHelper.setSharedElementEnterTransition(activity,
            LiveDataDetailActivity.SHARED_ELEMENT_NAME);

    ((FullWidthDetailsOverviewRowPresenter) mPs.getPresenter(row))
            .setListener(mHelper);
    ((FullWidthDetailsOverviewRowPresenter) mPs.getPresenter(row))
            .setParticipatingEntranceTransition(false);
    ((FullWidthDetailsOverviewRowPresenter) mPs.getPresenter(row))
            .setOnActionClickedListener(listener);
    return mHelper;

}
项目:leanback-showcase    文件:PresenterModule.java   
@PerFragment
@Provides
PresenterSelector providePresenterSelector(final Map<Class<?>, Presenter> map) {

    return new PresenterSelector() {
        @Override
        public Presenter getPresenter(Object item) {
            Class<?> cls = item.getClass();
            return map.get(cls);
        }

        @Override
        public Presenter[] getPresenters() {
            return map.values().toArray(new Presenter[map.size()]);
        }
    };
}
项目:youtubetv    文件:YoutubeTvFragment.java   
private void setupRowAdapter() {
    VerticalGridPresenter gridPresenter = new VerticalGridPresenter(ZOOM_FACTOR);
    gridPresenter.setNumberOfColumns(COLUMNS);
    setGridPresenter(gridPresenter);

    PresenterSelector cardPresenterSelector = new CardPresenterSelector(getActivity());
    mAdapter = new ArrayObjectAdapter(cardPresenterSelector);
    setAdapter(mAdapter);

    prepareEntranceTransition();
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            createRows();
            startEntranceTransition();
        }
    }, 1000);
}
项目:androidtv-Leanback    文件:MainFragment.java   
private void setupUIElements() {
    setBadgeDrawable(
            getActivity().getResources().getDrawable(R.drawable.videos_by_google_banner, null));
    setTitle(getString(R.string.browse_title)); // Badge, when set, takes precedent over title
    setHeadersState(HEADERS_ENABLED);
    setHeadersTransitionOnBackEnabled(true);

    // Set fastLane (or headers) background color
    setBrandColor(ContextCompat.getColor(getActivity(), R.color.fastlane_background));

    // Set search icon color.
    setSearchAffordanceColor(ContextCompat.getColor(getActivity(), R.color.search_opaque));

    setHeaderPresenterSelector(new PresenterSelector() {
        @Override
        public Presenter getPresenter(Object o) {
            return new IconHeaderItemPresenter();
        }
    });
}
项目:BuildingForAndroidTV    文件:MainFragment.java   
private void setupUIElements() {
    setBadgeDrawable(getActivity().getResources().getDrawable(R.drawable.videos_by_google_banner));
    setTitle(getString(R.string.browse_title)); // Badge, when set, takes precedent over title
    setHeadersState(HEADERS_ENABLED);
    setHeadersTransitionOnBackEnabled(true);
    // set fastLane (or headers) background color
    setBrandColor(getResources().getColor(R.color.fastlane_background));
    // set search icon color
    setSearchAffordanceColor(getResources().getColor(R.color.search_opaque));

    setHeaderPresenterSelector(new PresenterSelector() {
        @Override
        public Presenter getPresenter(Object o) {
            return new IconHeaderItemPresenter();
        }
    });
}
项目:android_packages_apps_tv    文件:SeriesRecordingDetailsFragment.java   
@Override
protected PresenterSelector onCreatePresenterSelector(
        DetailsOverviewRowPresenter rowPresenter) {
    ClassPresenterSelector presenterSelector = new ClassPresenterSelector();
    presenterSelector.addClassPresenter(DetailsOverviewRow.class, rowPresenter);
    presenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter());
    return presenterSelector;
}
项目:android_packages_apps_tv    文件:DvrDetailsFragment.java   
/**
 * Creates and returns presenter selector will be used by rows adaptor.
 */
protected PresenterSelector onCreatePresenterSelector(
        DetailsOverviewRowPresenter rowPresenter) {
    ClassPresenterSelector presenterSelector = new ClassPresenterSelector();
    presenterSelector.addClassPresenter(DetailsOverviewRow.class, rowPresenter);
    return presenterSelector;
}
项目:LeanbackCards    文件:MainFragment.java   
private void setupUIElements() {
    setTitle(getString(R.string.app_name));
    setHeadersState(HEADERS_ENABLED);
    setHeadersTransitionOnBackEnabled(true);
    setBrandColor(ContextCompat.getColor(getActivity(), R.color.primary));
    setSearchAffordanceColor(ContextCompat.getColor(getActivity(), R.color.accent));
    setHeaderPresenterSelector(new PresenterSelector() {
        @Override
        public Presenter getPresenter(Object o) {
            return new HeaderItemPresenter();
        }
    });
}
项目:LeanbackCards    文件:OptionsAdapter.java   
public OptionsAdapter(Context context) {
    mOptionsItemPresenter = new IconItemPresenter();
    setPresenterSelector(new PresenterSelector() {
        @Override
        public Presenter getPresenter(Object item) {
            return mOptionsItemPresenter;
        }
    });
}
项目:LeanbackCards    文件:PostAdapter.java   
public PostAdapter(Context context) {
    mOptionsItemPresenter = new LiveCardPresenter(context);
    setPresenterSelector(new PresenterSelector() {
        @Override
        public Presenter getPresenter(Object item) {
            return mOptionsItemPresenter;
        }
    });
}
项目:AndroidTV-workshop    文件:BrowseViewImp.java   
@Override
public void configureItemHeader(int numberOfCategories) {
    if(numberOfCategories > 5) {
        setBrandColor(getResources().getColor(R.color.primary_brand));
        setHeaderPresenterSelector(new PresenterSelector() {
            @Override
            public Presenter getPresenter(Object item) {
                return new HeaderItemPresenter();
            }
        });
    } else {
        setHeadersState(HEADERS_DISABLED);
    }
}
项目:AndroidTV-workshop    文件:BrowseViewImp.java   
@Override
public void configureItemHeader(int numberOfCategories) {
    if(numberOfCategories > 5) {
        setBrandColor(getResources().getColor(R.color.primary_brand));
        setHeaderPresenterSelector(new PresenterSelector() {
            @Override
            public Presenter getPresenter(Object item) {
                return new HeaderItemPresenter();
            }
        });
    } else {
        setHeadersState(HEADERS_DISABLED);
    }
}
项目:AndroidTV-workshop    文件:BrowseViewImp.java   
@Override
public void configureItemHeader(int numberOfCategories) {
    if(numberOfCategories > 5) {
        setBrandColor(getResources().getColor(R.color.primary_brand));
        setHeaderPresenterSelector(new PresenterSelector() {
            @Override
            public Presenter getPresenter(Object item) {
                return new HeaderItemPresenter();
            }
        });
    } else {
        setHeadersState(HEADERS_DISABLED);
    }
}
项目:leanback-showcase    文件:MainFragment.java   
private ListRow createCardRow(CardRow cardRow) {
    PresenterSelector presenterSelector = new CardPresenterSelector(getActivity());
    ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(presenterSelector);
    for (Card card : cardRow.getCards()) {
        listRowAdapter.add(card);
    }
    return new ListRow(listRowAdapter);
}
项目:leanback-showcase    文件:AdapterModule.java   
@DetailFragmentArrayObjectAdapterForRowsQualifier
@PerFragment
@Provides
ArrayObjectAdapter provideRowsArrayObjectAdapter(DetailsOverviewRow detailsOverviewRow, ListRow relatedRow, PresenterSelector mps) {
    ArrayObjectAdapter rowsAdapter = new ArrayObjectAdapter(mps);
    rowsAdapter.add(detailsOverviewRow);
    rowsAdapter.add(relatedRow);
    return rowsAdapter;
}
项目:leanback-showcase    文件:AdapterModule.java   
@SearchFragmentArrayObjectAdapterForRowsQualifier
@PerFragment
@Provides
ArrayObjectAdapter provideRowsArrayObjectAdapterInSearchFragment( ListRow relatedRow, PresenterSelector mps) {
    ArrayObjectAdapter rowsAdapter = new ArrayObjectAdapter(mps.getPresenter(relatedRow));

    rowsAdapter.add(relatedRow);
    return rowsAdapter;
}
项目:leanback-showcase    文件:PageAndListRowFragment.java   
private Row createCardRow(CardRow cardRow) {
    PresenterSelector presenterSelector = new CardPresenterSelector(getActivity());
    ArrayObjectAdapter adapter = new ArrayObjectAdapter(presenterSelector);
    for (Card card : cardRow.getCards()) {
        adapter.add(card);
    }

    HeaderItem headerItem = new HeaderItem(cardRow.getTitle());
    return new CardListRow(headerItem, adapter, cardRow);
}
项目:Vineyard    文件:MainFragment.java   
private void setupUIElements() {
    setBadgeDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.banner_shadow));
    setHeadersState(HEADERS_ENABLED);
    setHeadersTransitionOnBackEnabled(true);
    setBrandColor(ContextCompat.getColor(getActivity(), R.color.primary));
    setSearchAffordanceColor(ContextCompat.getColor(getActivity(), R.color.accent));

    setHeaderPresenterSelector(new PresenterSelector() {
        @Override
        public Presenter getPresenter(Object o) {
            return new IconHeaderItemPresenter();
        }
    });

    boolean shouldAutoLoop = mPreferencesHelper.getShouldAutoLoop();
    String optionValue = shouldAutoLoop
            ? getString(R.string.text_auto_loop_enabled)
            : getString(R.string.text_auto_loop_disabled);

    mAutoLoopOption = new Option(
            getString(R.string.text_auto_loop_title),
            optionValue,
            R.drawable.lopp);


    HeaderItem gridHeader =
            new HeaderItem(mRowsAdapter.size(), getString(R.string.header_text_options));
    mOptionsAdapter = new OptionsAdapter(getActivity());
    mOptionsAdapter.addOption(mAutoLoopOption);
    mRowsAdapter.add(new ListRow(gridHeader, mOptionsAdapter));
}
项目:Vineyard    文件:PaginationAdapter.java   
public void setPresenterSelector() {
    setPresenterSelector(new PresenterSelector() {
        @Override
        public Presenter getPresenter(Object item) {
            if (item instanceof LoadingCardView) {
                return mLoadingPresenter;
            } else if (item instanceof Option) {
                return mIconItemPresenter;
            }
            return mPresenter;
        }
    });
}
项目:Vineyard    文件:OptionsAdapter.java   
public OptionsAdapter(Context context) {
    mOptionsItemPresenter = new IconItemPresenter();
    setPresenterSelector(new PresenterSelector() {
        @Override
        public Presenter getPresenter(Object item) {
            return mOptionsItemPresenter;
        }
    });
}
项目:ring-client-android    文件:MainFragment.java   
private Row createRow(String titleSection, List<Card> cards, boolean shadow) {
    CardRow row = new CardRow(
            CardRow.TYPE_DEFAULT,
            shadow,
            titleSection,
            cards);

    PresenterSelector presenterSelector = new CardPresenterSelector(getActivity());
    ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(presenterSelector);
    for (Card card : cards) {
        listRowAdapter.add(card);
    }

    return new CardListRow(new HeaderItem(HEADER_MISC, titleSection), listRowAdapter, row);
}
项目:adt-leanback-support    文件:BrowseFragment.java   
/**
 * Sets the {@link PresenterSelector} used to render the row headers.
 *
 * @param headerPresenterSelector The PresenterSelector that will determine
 *        the Presenter for each row header.
 */
public void setHeaderPresenterSelector(PresenterSelector headerPresenterSelector) {
    mHeaderPresenterSelector = headerPresenterSelector;
    if (mHeadersFragment != null) {
        mHeadersFragment.setPresenterSelector(mHeaderPresenterSelector);
    }
}
项目:adt-leanback-support    文件:BrowseSupportFragment.java   
/**
 * Sets the {@link PresenterSelector} used to render the row headers.
 *
 * @param headerPresenterSelector The PresenterSelector that will determine
 *        the Presenter for each row header.
 */
public void setHeaderPresenterSelector(PresenterSelector headerPresenterSelector) {
    mHeaderPresenterSelector = headerPresenterSelector;
    if (mHeadersSupportFragment != null) {
        mHeadersSupportFragment.setPresenterSelector(mHeaderPresenterSelector);
    }
}
项目:android_packages_apps_tv    文件:SeriesRecordingDetailsFragment.java   
SeasonRowAdapter(PresenterSelector selector, Comparator<RecordedProgram> comparator,
        String seasonNumber) {
    super(selector, comparator);
    mSeasonNumber = seasonNumber;
}
项目:android_packages_apps_tv    文件:SortedArrayAdapter.java   
SortedArrayAdapter(PresenterSelector presenterSelector, Comparator<T> comparator) {
    this(presenterSelector, comparator, Integer.MAX_VALUE);
}
项目:android_packages_apps_tv    文件:SortedArrayAdapter.java   
SortedArrayAdapter(PresenterSelector presenterSelector, Comparator<T> comparator,
        int maxItemCount) {
    super(presenterSelector);
    mComparator = comparator;
    mMaxItemCount = maxItemCount;
}
项目:popcorn-android    文件:PTVBaseDetailsFragment.java   
protected ArrayObjectAdapter createAdapter(PresenterSelector selector) {
    return new ArrayObjectAdapter(selector);
}
项目:popcorn-android    文件:PTVShowDetailsFragment.java   
@Override
protected ArrayObjectAdapter createAdapter(PresenterSelector selector) {
    return new ArrayObjectAdapter(selector);
}
项目:leanback-showcase    文件:AdapterModule.java   
@ListAdapterForRelatedRowQualifier
@PerFragment
@Provides
ListAdapter<VideoEntity> provideRelatedAdapter(PresenterSelector mps) {
    return new ListAdapter<>(mps.getPresenter(new VideoEntity()));
}
项目:leanback-showcase    文件:ListAdapter.java   
/**
 * Constructs an adapter with the given {@link PresenterSelector}.
 */
public ListAdapter(PresenterSelector presenterSelector) {
    super(presenterSelector);
}
项目:sbs-android-tv    文件:BaseArrayAdapter.java   
public BaseArrayAdapter(PresenterSelector selector) {
    super(selector);
}
项目:sagetv-miniclient    文件:SortedObjectAdapter.java   
public SortedObjectAdapter(Comparator comparator, PresenterSelector presenterSelector) {
    super(presenterSelector);
    mSortedItems = new TreeSet<Object>(comparator);
}