Java Code Examples for android.support.v17.leanback.widget.RowPresenter#ViewHolder

The following examples show how to use android.support.v17.leanback.widget.RowPresenter#ViewHolder . 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: MainFragment.java    From alltv with MIT License 6 votes vote down vote up
@Override
public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
                          RowPresenter.ViewHolder rowViewHolder, Row row) {

    if (item instanceof String) {
        if (((String) item).contains(getString(R.string.preferences))) {

            Intent intent = new Intent(getActivity(), SettingsActivity.class);
            intent.putExtra(getStringById(R.string.SETTINGSDATA_STR), mGson.toJson(mSettingsData));
            getActivity().startActivityForResult(intent, Utils.Code.SettingsRequestCode.ordinal());

        } else if (((String) item).contains(getString(R.string.opensource))) {
            showLicensesDialogFragment();
        }
    }

}
 
Example 2
Source File: MovieDetailsFragment.java    From BuildingForAndroidTV with MIT License 6 votes vote down vote up
@Override
public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
                          RowPresenter.ViewHolder rowViewHolder, Row row) {

    if (item instanceof Movie) {
        Movie movie = (Movie) item;
        Log.d(TAG, "Item: " + item.toString());
        Intent intent = new Intent(getActivity(), MovieDetailsActivity.class);
        intent.putExtra(MovieDetailsActivity.MOVIE, movie);

        Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(
                getActivity(),
                ((ImageCardView) itemViewHolder.view).getMainImageView(),
                MovieDetailsActivity.SHARED_ELEMENT_NAME).toBundle();
        getActivity().startActivity(intent, bundle);
    }
}
 
Example 3
Source File: FullWidthDetailsPresenter.java    From leanback-showcase with Apache License 2.0 5 votes vote down vote up
@Override
protected RowPresenter.ViewHolder createRowViewHolder(ViewGroup parent) {
  // Customize Actionbar and Content by using custom colors.
  RowPresenter.ViewHolder viewHolder = super.createRowViewHolder(parent);

  View actionsView = viewHolder.view.
      findViewById(R.id.details_overview_actions_background);
  actionsView.setBackgroundColor(SampleApplication.getInstance().
      getColor(R.color.detail_view_actionbar_background));

  View detailsView = viewHolder.view.findViewById(R.id.details_frame);
  detailsView.setBackgroundColor(
      SampleApplication.getInstance().getResources().getColor(R.color.detail_view_background));
  return viewHolder;
}
 
Example 4
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 5
Source File: RowsSupportFragment.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
private void freezeRows(boolean freeze) {
    VerticalGridView verticalView = getVerticalGridView();
    if (verticalView != null) {
        final int count = verticalView.getChildCount();
        for (int i = 0; i < count; i++) {
            ItemBridgeAdapter.ViewHolder ibvh = (ItemBridgeAdapter.ViewHolder)
                verticalView.getChildViewHolder(verticalView.getChildAt(i));
            RowPresenter rowPresenter = (RowPresenter) ibvh.getPresenter();
            RowPresenter.ViewHolder vh = rowPresenter.getRowViewHolder(ibvh.getViewHolder());
            rowPresenter.freeze(vh, freeze);
        }
    }
}
 
Example 6
Source File: DynamicRowsFragment.java    From leanback-showcase with Apache License 2.0 5 votes vote down vote up
@Override
public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item,
                           RowPresenter.ViewHolder rowViewHolder, Row row) {
    if (item instanceof VideoContent) {
        mBackgroundURI = ((VideoContent) item).getBackgroundImageURI();
        startBackgroundTimer();
    } else {
        /**
         * make sure the background of other items are removed so the setting icon can be
         * seen clearly
         */
        mHandler.removeCallbacks(mBackgroudUpdateRunnable);
        mBackgroundManager.setDrawable(null);
    }
}
 
Example 7
Source File: CategoryFragment.java    From iview-android-tv with MIT License 5 votes vote down vote up
private OnItemViewClickedListener getItemClickedListener() {
    return new OnItemViewClickedListener() {
        @Override
        public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) {
            if (item instanceof EpisodeBaseModel) {
                Intent intent = new Intent(getActivity(), getDetailsActivityClass());
                intent.putExtra(ContentManagerBase.CONTENT_ID, (EpisodeBaseModel) item);
                startActivity(intent);
            }
        }
    };
}
 
Example 8
Source File: MainFragment.java    From leanback-extensions with Apache License 2.0 5 votes vote down vote up
@Override
public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item,
                           RowPresenter.ViewHolder rowViewHolder, Row row) {
	if (item instanceof Movie) {
		mBackgroundURI = ((Movie) item).getBackgroundImageURI();
		startBackgroundTimer();
	}

}
 
Example 9
Source File: SearchFragment.java    From VCL-Android with Apache License 2.0 5 votes vote down vote up
protected OnItemViewClickedListener getDefaultItemClickedListener() {
    return new OnItemViewClickedListener() {
        @Override
        public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) {
            if (item instanceof MediaWrapper) {
                TvUtil.openMedia(mActivity, (MediaWrapper) item, row);
            }
        }
    };
}
 
Example 10
Source File: GridFragment.java    From leanback-showcase with Apache License 2.0 5 votes vote down vote up
@Override
public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item,
                           RowPresenter.ViewHolder rowViewHolder, Row row) {
    int position = mGridViewHolder.getGridView().getSelectedPosition();
    if (DEBUG) Log.v(TAG, "grid selected position " + position);
    gridOnItemSelected(position);
    if (mOnItemViewSelectedListener != null) {
        mOnItemViewSelectedListener.onItemSelected(itemViewHolder, item,
                rowViewHolder, row);
    }
}
 
Example 11
Source File: BrowseFragment.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
@Override
public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item,
        RowPresenter.ViewHolder rowViewHolder, Row row) {
    int position = mRowsFragment.getVerticalGridView().getSelectedPosition();
    if (DEBUG) Log.v(TAG, "row selected position " + position);
    onRowSelected(position);
    if (mExternalOnItemViewSelectedListener != null) {
        mExternalOnItemViewSelectedListener.onItemSelected(itemViewHolder, item,
                rowViewHolder, row);
    }
}
 
Example 12
Source File: MainFragment.java    From leanback-assistant with Apache License 2.0 5 votes vote down vote up
@Override
public void onItemClicked(
        Presenter.ViewHolder itemViewHolder,
        Object item,
        RowPresenter.ViewHolder rowViewHolder,
        Row row) {
    Movie movie = (Movie) item;

    startActivity(VideoDetailsActivity.createIntent(getContext(), movie));
}
 
Example 13
Source File: OksusuRowSupportFragment.java    From alltv with MIT License 5 votes vote down vote up
@Override
public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
                          RowPresenter.ViewHolder rowViewHolder, Row row) {
    if (item instanceof ChannelData) {
        String authKey = ((ChannelData) item).getAuthkey();;
        if (authKey == null || authKey.length() < 10) {
            Utils.showToast(getContext(), getStringById(R.string.nologin_error));
            return;
        }
        playVideo(mChannels.get(mType).indexOf(item));
    }
}
 
Example 14
Source File: FavoriteRowSupportFragment.java    From alltv with MIT License 5 votes vote down vote up
@Override
public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
                          RowPresenter.ViewHolder rowViewHolder, Row row) {
    if (item instanceof ChannelData) {
        String authKey = ((ChannelData) item).getAuthkey();;
        if (authKey == null || authKey.length() < 10) {
            Utils.showToast(getContext(), getStringById(R.string.nologin_error));
            return;
        }
        playVideo(mChannels.get(mType).indexOf(item));
    }
}
 
Example 15
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 16
Source File: MainFragment.java    From alltv with MIT License 5 votes vote down vote up
@Override
public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item,
                           RowPresenter.ViewHolder rowViewHolder, Row row) {

    if (item instanceof String) {
        //mPicassoBackgroundManager.updateBackgroundWithDelay("http://blabla/blabla.jpg");
    } else if (item instanceof ChannelData) {
        //mPicassoBackgroundManager.updateBackgroundWithDelay(((ChannelData) item).getStillImageUrl());
    }
}
 
Example 17
Source File: MainTvActivity.java    From VCL-Android with Apache License 2.0 4 votes vote down vote up
@Override
public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) {
    mSelectedItem = item;
}
 
Example 18
Source File: BrowserGridFragment.java    From VCL-Android with Apache License 2.0 4 votes vote down vote up
@Override
public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) {
    mItemSelected = (MediaWrapper)item;
}
 
Example 19
Source File: AppDetailsFragment.java    From TvAppRepo with Apache License 2.0 4 votes vote down vote up
@Override
public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
                          RowPresenter.ViewHolder rowViewHolder, Row row) {

    if (item instanceof Apk) {
        Apk application = (Apk) item;
        Log.d(TAG, "Item: " + item.toString());
        Intent intent = new Intent(getActivity(), DetailsActivity.class);
        intent.putExtra(getResources().getString(R.string.apk_string), mSelectedApk.toString());
        intent.putExtra(getResources().getString(R.string.should_start), true);
        startActivity(intent);


        Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(
                getActivity(),
                ((ImageCardView) itemViewHolder.view).getMainImageView(),
                DetailsActivity.SHARED_ELEMENT_NAME).toBundle();
        getActivity().startActivity(intent, bundle);
    } else if (item instanceof Action) {
        Log.d(TAG, "Item: " + item.toString());
        Action action = (Action) item;
        if (action.getId() == ACTION_INSTALL || action.getId() == ACTION_UPDATE) {
            if (mSelectedApk.getDownloadCount() > 1) {
                // Display picker
                new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.dialog_theme))
                        .setTitle(R.string.title_apk_variants)
                        .setItems(mSelectedApk.getDownloadTitleArray(), new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int i) {
                                download(mSelectedApk.getDownloadUrlArray()[i]);
                            }
                        })
                        .show();
            } else {
                download(mSelectedApk.getDefaultDownloadUrl());
            }
        } else if (action.getId() == ACTION_UNINSTALL) {
            if (mSelectedApk.getPackageName() == null) {
                Toast.makeText(getActivity(), R.string.warn_null_package_name, Toast.LENGTH_SHORT).show();
            } else {
                PackageInstallerUtils.uninstallApp(getActivity(), mSelectedApk.getPackageName());
            }
        }
    }
}
 
Example 20
Source File: NetworkBrowserFragment.java    From VCL-Android with Apache License 2.0 4 votes vote down vote up
@Override
public void onItemClicked(Presenter.ViewHolder viewHolder, Object item, RowPresenter.ViewHolder viewHolder1, Row row) {
    TvUtil.openMedia(getActivity(), item, null);
}