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

The following examples show how to use android.support.v17.leanback.widget.OnItemViewSelectedListener. 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: ListenerModule.java    From leanback-showcase with Apache License 2.0 6 votes vote down vote up
@PerFragment
@Provides
@IntoMap
@ListenerModuleKey(LiveDataFragment.class)
public OnItemViewSelectedListener provideOnItemViewSelectedListener(final Activity activity,
        final DisplayMetrics metrics, final BackgroundManager backgroundManager,
        final RequestOptions defaultPlaceHolder, final Drawable finalDrawable, final Handler mainHandler) {
    return new OnItemViewSelectedListener() {
        @Override
        public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item,
                RowPresenter.ViewHolder rowViewHolder, Row row) {
            VideoEntity selectedVideo = (VideoEntity) item;
            RunnableClass backgroundRunnable = new RunnableClass(selectedVideo, activity,
                    metrics, backgroundManager, defaultPlaceHolder, finalDrawable);

            if (lastTime != null) {
                mainHandler.removeCallbacks(lastTime);
            }
            mainHandler.postDelayed(backgroundRunnable, BACKGROUND_UPDATE_DELAY);
            lastTime = backgroundRunnable;
        }
    };
}
 
Example #2
Source File: ListenerFactory.java    From leanback-showcase with Apache License 2.0 5 votes vote down vote up
@Inject
public ListenerFactory(Map<Class, OnItemViewClickedListener> onItemViewClickedListenerMap,
        Map<Class, OnItemViewSelectedListener> onItemViewSelectedListenerMap,
        Map<Class, View.OnClickListener> viewOnClickListenerMap) {
    mOnItemViewClickedListenerMap = onItemViewClickedListenerMap;
    mOnItemViewSelectedListenerMap = onItemViewSelectedListenerMap;
    mViewOnClickListenerMap = viewOnClickListenerMap;

}
 
Example #3
Source File: LeanbackBrowseFragment.java    From android-tv-leanback with Apache License 2.0 5 votes vote down vote up
protected OnItemViewSelectedListener getDefaultItemSelectedListener() {

        return new OnItemViewSelectedListener() {
            public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item,
                                       RowPresenter.ViewHolder rowViewHolder, Row row) {
                if (item instanceof Video) {
                    bgHelper.setBackgroundUrl(((Video) item).getThumbUrl());
                    bgHelper.startBackgroundTimer();
                }

            }
        };
    }
 
Example #4
Source File: LeanbackBrowseFragment.java    From android-tv-leanback with Apache License 2.0 5 votes vote down vote up
protected OnItemViewSelectedListener getDefaultItemSelectedListener() {

        return new OnItemViewSelectedListener() {
            public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item,
                                       RowPresenter.ViewHolder rowViewHolder, Row row) {
                if (item instanceof Video) {
                    bgHelper.setBackgroundUrl(((Video) item).getThumbUrl());
                    bgHelper.startBackgroundTimer();
                }

            }
        };
    }
 
Example #5
Source File: DetailsFragment.java    From iview-android-tv with MIT License 5 votes vote down vote up
private OnItemViewSelectedListener getItemSelectedListener() {
    return new OnItemViewSelectedListener() {
        @Override
        public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) {
            Log.d(TAG, "Selected item:" + item);
            if (item instanceof EpisodeBaseModel) {
                selectCurrentEpisode((EpisodeBaseModel) item, false);
            }
        }
    };
}
 
Example #6
Source File: RowsSupportFragment.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
/**
 * Sets an item selection listener.
 */
public void setOnItemViewSelectedListener(OnItemViewSelectedListener listener) {
    mOnItemViewSelectedListener = listener;
    VerticalGridView listView = getVerticalGridView();
    if (listView != null) {
        final int count = listView.getChildCount();
        for (int i = 0; i < count; i++) {
            View view = listView.getChildAt(i);
            ItemBridgeAdapter.ViewHolder vh = (ItemBridgeAdapter.ViewHolder)
                    listView.getChildViewHolder(view);
            setOnItemViewSelectedListener(vh, mOnItemViewSelectedListener);
        }
    }
}
 
Example #7
Source File: RowsFragment.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
/**
 * Sets an item selection listener.
 */
public void setOnItemViewSelectedListener(OnItemViewSelectedListener listener) {
    mOnItemViewSelectedListener = listener;
    VerticalGridView listView = getVerticalGridView();
    if (listView != null) {
        final int count = listView.getChildCount();
        for (int i = 0; i < count; i++) {
            View view = listView.getChildAt(i);
            ItemBridgeAdapter.ViewHolder vh = (ItemBridgeAdapter.ViewHolder)
                    listView.getChildViewHolder(view);
            setOnItemViewSelectedListener(vh, mOnItemViewSelectedListener);
        }
    }
}
 
Example #8
Source File: PlaybackOverlayFragment.java    From BuildingForAndroidTV with MIT License 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "onCreate");
    super.onCreate(savedInstanceState);
    
    mItems = new ArrayList<Movie>();
    mSelectedMovie = (Movie) getActivity()
            .getIntent().getParcelableExtra(MovieDetailsActivity.MOVIE);

    HashMap<String, List<Movie>> movies = VideoProvider.getMovieList();

    if (movies != null) {
        for (Map.Entry<String, List<Movie>> entry : movies.entrySet()) {
            if (mSelectedMovie.getCategory().contains(entry.getKey())) {
                List<Movie> list = entry.getValue();
                if (list != null && !list.isEmpty()) {
                    for (int j = 0; j < list.size(); j++) {
                        mItems.add(list.get(j));
                        if (mSelectedMovie.getTitle().contentEquals(list.get(j).getTitle())) {
                            mCurrentItem = j;
                        }
                    }
                }
            }
        }
    }

    mHandler = new Handler();

    setBackgroundType(BACKGROUND_TYPE);
    setFadingEnabled(false);

    setupRows();

    setOnItemViewSelectedListener(new OnItemViewSelectedListener() {
        @Override
        public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item,
                                   RowPresenter.ViewHolder rowViewHolder, Row row) {
            Log.i(TAG, "onItemSelected: " + item + " row " + row);
        }
    });
    setOnItemViewClickedListener(new ItemViewClickedListener());
}
 
Example #9
Source File: VerticalGridFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Sets an item selection listener.
 */
public void setOnItemViewSelectedListener(OnItemViewSelectedListener listener) {
    mOnItemViewSelectedListener = listener;
}
 
Example #10
Source File: BrowseSupportFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Returns an item selection listener.
 */
public OnItemViewSelectedListener getOnItemViewSelectedListener() {
    return mExternalOnItemViewSelectedListener;
}
 
Example #11
Source File: BrowseSupportFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Sets an item selection listener.
 */
public void setOnItemViewSelectedListener(OnItemViewSelectedListener listener) {
    mExternalOnItemViewSelectedListener = listener;
}
 
Example #12
Source File: BrowseFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Returns an item selection listener.
 */
public OnItemViewSelectedListener getOnItemViewSelectedListener() {
    return mExternalOnItemViewSelectedListener;
}
 
Example #13
Source File: BrowseFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Sets an item selection listener.
 */
public void setOnItemViewSelectedListener(OnItemViewSelectedListener listener) {
    mExternalOnItemViewSelectedListener = listener;
}
 
Example #14
Source File: RowsFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
private static void setOnItemViewSelectedListener(ItemBridgeAdapter.ViewHolder vh,
        OnItemViewSelectedListener listener) {
    ((RowPresenter) vh.getPresenter()).setOnItemViewSelectedListener(listener);
}
 
Example #15
Source File: RowsFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Returns an item selection listener.
 */
public OnItemViewSelectedListener getOnItemViewSelectedListener() {
    return mOnItemViewSelectedListener;
}
 
Example #16
Source File: DetailsFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Sets an item selection listener.
 */
public void setOnItemViewSelectedListener(OnItemViewSelectedListener listener) {
    mExternalOnItemViewSelectedListener = listener;
}
 
Example #17
Source File: DetailsSupportFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Sets an item selection listener.
 */
public void setOnItemViewSelectedListener(OnItemViewSelectedListener listener) {
    mExternalOnItemViewSelectedListener = listener;
}
 
Example #18
Source File: RowsSupportFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
private static void setOnItemViewSelectedListener(ItemBridgeAdapter.ViewHolder vh,
        OnItemViewSelectedListener listener) {
    ((RowPresenter) vh.getPresenter()).setOnItemViewSelectedListener(listener);
}
 
Example #19
Source File: RowsSupportFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Returns an item selection listener.
 */
public OnItemViewSelectedListener getOnItemViewSelectedListener() {
    return mOnItemViewSelectedListener;
}
 
Example #20
Source File: VerticalGridSupportFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
/**
 * Sets an item selection listener.
 */
public void setOnItemViewSelectedListener(OnItemViewSelectedListener listener) {
    mOnItemViewSelectedListener = listener;
}
 
Example #21
Source File: GridFragment.java    From leanback-showcase with Apache License 2.0 4 votes vote down vote up
/**
 * Sets an item selection listener.
 */
public void setOnItemViewSelectedListener(OnItemViewSelectedListener listener) {
    mOnItemViewSelectedListener = listener;
}
 
Example #22
Source File: ListenerFactory.java    From leanback-showcase with Apache License 2.0 4 votes vote down vote up
public OnItemViewSelectedListener getOnItemViewSelectedListener(Class key) {
    return mOnItemViewSelectedListenerMap.get(key);
}
 
Example #23
Source File: SearchFragment.java    From adt-leanback-support with Apache License 2.0 2 votes vote down vote up
/**
 * Sets an item selection listener for the results.
 *
 * @param listener The item selection listener to be invoked when an item in
 *        the search results is selected.
 */
public void setOnItemViewSelectedListener(OnItemViewSelectedListener listener) {
    mOnItemViewSelectedListener = listener;
}
 
Example #24
Source File: SearchSupportFragment.java    From adt-leanback-support with Apache License 2.0 2 votes vote down vote up
/**
 * Sets an item selection listener for the results.
 *
 * @param listener The item selection listener to be invoked when an item in
 *        the search results is selected.
 */
public void setOnItemViewSelectedListener(OnItemViewSelectedListener listener) {
    mOnItemViewSelectedListener = listener;
}