@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; } }; }
@Inject public ListenerFactory(Map<Class, OnItemViewClickedListener> onItemViewClickedListenerMap, Map<Class, OnItemViewSelectedListener> onItemViewSelectedListenerMap, Map<Class, View.OnClickListener> viewOnClickListenerMap) { mOnItemViewClickedListenerMap = onItemViewClickedListenerMap; mOnItemViewSelectedListenerMap = onItemViewSelectedListenerMap; mViewOnClickListenerMap = viewOnClickListenerMap; }
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); } } }; }
static OnItemViewSelectedListener createOnItemViewSelectedListener(final Activity activity) { notNull(activity); return new OnItemViewSelectedListener() { @Override public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { if (item instanceof Video) { Video video = (Video) item; BackgroundHelper.setBackgroundDelayed(activity, video.getImageUrl()); } } }; }
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(); } } }; }
/** * 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); } } }
/** * Sets an item selection listener. */ public void setOnItemViewSelectedListener(OnItemViewSelectedListener listener) { mOnItemViewSelectedListener = listener; }
public OnItemViewSelectedListener getOnItemViewSelectedListener(Class key) { return mOnItemViewSelectedListenerMap.get(key); }
public void registerListener (OnItemViewSelectedListener listener) { registeredListeners.add(listener); }
public void unRegisterListener (OnItemViewSelectedListener listener) { registeredListeners.remove(listener); }
@Override public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { for (OnItemViewSelectedListener listener : registeredListeners) { listener.onItemSelected(itemViewHolder, item, rowViewHolder, row); } }
/** * Returns an item selection listener. */ public OnItemViewSelectedListener getOnItemViewSelectedListener() { return mOnItemViewSelectedListener; }
private static void setOnItemViewSelectedListener(ItemBridgeAdapter.ViewHolder vh, OnItemViewSelectedListener listener) { ((RowPresenter) vh.getPresenter()).setOnItemViewSelectedListener(listener); }
/** * Sets an item selection listener. */ public void setOnItemViewSelectedListener(OnItemViewSelectedListener listener) { mExternalOnItemViewSelectedListener = listener; }
/** * Returns an item selection listener. */ public OnItemViewSelectedListener getOnItemViewSelectedListener() { return mExternalOnItemViewSelectedListener; }
@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()); }
/** * 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; }