use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.
the class PlaybackOverlayFragment method addOtherRows.
private void addOtherRows() {
ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new CardPresenter());
for (Content content : mRelatedContentList) {
// Do not show the selected content under recommendation list.
if (!StringManipulation.areStringsEqual(content.getId(), mSelectedContent.getId())) {
listRowAdapter.add(content);
}
}
HeaderItem header = new HeaderItem(0, getString(R.string.related_contents));
mRowsAdapter.add(new ListRow(header, listRowAdapter));
}
use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.
the class PlaybackOverlayFragment method onCreate.
/**
* {@inheritDoc}
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mSelectedContent = (Content) getActivity().getIntent().getSerializableExtra(Content.class.getSimpleName());
isAutoPlay = getActivity().getIntent().getBooleanExtra(SHOW_PLAYLIST_AUTOPLAY, false);
boolean trailerMode = false;
if (mSelectedContent == null) {
mSelectedContent = (Content) getActivity().getIntent().getSerializableExtra("play_trailer");
trailerMode = true;
mHideMoreActions = true;
} else {
mShowRelatedContent = ContentBrowser.getInstance(getActivity()).isShowRelatedContent();
mHideMoreActions = true;
}
mCurrentItem = -1;
if (mShowRelatedContent) {
mRelatedContentList = ContentBrowser.getInstance(getActivity()).getRecommendedListOfAContentAsAContainer(mSelectedContent).getContents();
// Find the index of the selected content in the related content list only if
// recommendations are enabled.
mCurrentItem = getCurrentContentIndex(mSelectedContent);
} else {
Log.d(TAG, "Recommendation is turned off");
// Initializing to empty list to avoid null checks later.
mRelatedContentList = new ArrayList<>();
}
mHandler = new Handler();
setBackgroundType(BACKGROUND_TYPE);
setFadingEnabled(false);
setupRows();
mRunnable = new Runnable() {
@Override
public void run() {
int updatePeriod = getUpdatePeriod();
if (!mFadeOutComplete) {
updateUI();
}
mHandler.postDelayed(this, updatePeriod);
}
};
setOnItemViewClickedListener(new ItemViewClickedListener());
setFadeCompleteListener(new OnFadeCompleteListener() {
@Override
public void onFadeOutComplete() {
mFadeOutComplete = true;
}
@Override
public void onFadeInComplete() {
mFadeOutComplete = false;
updateUI();
}
});
if (trailerMode) {
updateCCButtonState(false, false);
}
}
use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.
the class PlaybackOverlayFragment method updatePlaybackRow.
private void updatePlaybackRow(int index) {
if (mPlaybackControlsRow.getItem() != null) {
Content item = (Content) mPlaybackControlsRow.getItem();
if (!mRelatedContentList.isEmpty() && mCurrentItem >= 0) {
item.setTitle(mRelatedContentList.get(mCurrentItem).getTitle());
item.setStudio(mRelatedContentList.get(mCurrentItem).getStudio());
}
} else {
Log.e(TAG, "mPlaybackControlRow.getItem() is null in updatePlaybackRow");
}
if (SHOW_IMAGE) {
if (!mRelatedContentList.isEmpty() && mCurrentItem >= 0) {
updateVideoImage(mRelatedContentList.get(mCurrentItem).getCardImageUrl());
}
}
mRowsAdapter.notifyArrayItemRangeChanged(0, 1);
mDuration = mCallback.getDuration();
mPlaybackControlsRow.setTotalTime(mDuration);
mPlaybackControlsRow.setCurrentTime(0);
mPlaybackControlsRow.setBufferedProgress(0);
}
use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.
the class HeroSliderFragment method loadRows.
private void loadRows() {
CustomListRowPresenter customListRowPresenter = new CustomListRowPresenter();
customListRowPresenter.setShadowEnabled(false);
rowsAdapter = new ArrayObjectAdapter(customListRowPresenter);
cardPresenter = new HeroCardPresenter();
List<ZobjectTopPlaylist> sliderList = HeroSlider.getInstance().getSliders();
cardPresenter.setSingleImage(sliderList.size() == 1);
listRowAdapter = new HeroCardAdapter(cardPresenter);
List<Slider> sliders = new ArrayList<>();
for (ZobjectTopPlaylist sliderData : sliderList) {
for (Image image : sliderData.images) {
Slider slider = Slider.create(sliderData.id, sliderData.videoid, sliderData.playlistid, image.url, sliderData.friendlyTitle, sliderData.autoplay);
sliders.add(slider);
}
}
listRowAdapter.addAll(0, sliders);
final ListRow listRow = new ListRow(listRowAdapter);
rowsAdapter.add(listRow);
setAdapter(rowsAdapter);
setOnItemViewSelectedListener((itemViewHolder, item, rowViewHolder, row) -> {
if (item != null) {
int newSelectedIndex = ((HeroCardPresenter.ViewHolder) itemViewHolder).getIndex();
if (selectedIndex != newSelectedIndex) {
selectedIndex = newSelectedIndex;
registerNextScroll();
listRowAdapter.reset();
((HeroCardPresenter.ViewHolder) itemViewHolder).getSlider().setSelected(true);
listRowAdapter.notifyChanges(selectedIndex);
}
}
});
setOnItemViewClickedListener((itemViewHolder, item, rowViewHolder, row) -> {
if (item != null && item instanceof Slider) {
ContentBrowser contentBrowser = ContentBrowser.getInstance(getActivity());
Slider slider = (Slider) item;
if (TextUtils.isEmpty(slider.getVideoId())) {
if (!TextUtils.isEmpty(slider.getPlayListId())) {
// load the playlist
ContentContainer contentContainer = contentBrowser.getPlayList(slider.getPlayListId());
if (contentContainer != null) {
processContentContainer(contentContainer, slider);
} else {
// load the playlist
mCompositeSubscription.add(contentBrowser.getContentLoader().loadPlayList(contentBrowser.getRootContentContainer(), slider.getPlayListId()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(container -> {
contentBrowser.rootSliders().addContentContainer(container);
processContentContainer(container, slider);
}, throwable -> {
}));
}
}
} else {
// load the videoId
mCompositeSubscription.add(contentBrowser.getContentById(slider.getVideoId()).subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread()).subscribe(content -> {
openVideo(content, slider);
}, throwable -> {
}));
}
}
});
if (sliderList.size() > 0) {
// run the timer to toggle the positions
Handler handler = new Handler(Looper.getMainLooper());
handler.postDelayed(() -> {
int initialIndex = listRowAdapter.size() / 2;
int offset = initialIndex % listRowAdapter.realSize();
selectedIndex = initialIndex - offset - 1;
scrollToNextItem(false);
}, WAIT_BEFORE_FOCUS_REQUEST_MS);
}
}
use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.
the class ContentBrowseFragment method onContentUpdateEvent.
@Subscribe
public void onContentUpdateEvent(ContentUpdateEvent event) {
for (int rowIndex = 0; rowIndex < mRowsAdapter.size(); rowIndex++) {
ArrayObjectAdapter rowAdapter = (ArrayObjectAdapter) ((ListRow) mRowsAdapter.get(rowIndex)).getAdapter();
for (int i = 0; i < rowAdapter.size(); i++) {
Content content = (Content) rowAdapter.get(i);
if (content.getId().equals(event.videoId)) {
content.setExtraValue(Content.EXTRA_PLAYBACK_POSITION_PERCENTAGE, ContentBrowser.getInstance(getActivity()).getContentLoader().getContentPlaybackPositionPercentage(content));
}
rowAdapter.notifyArrayItemRangeChanged(i, i + 1);
}
}
}
Aggregations