use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.
the class ZypeContentDetailsPlaylistFragment method loadContentContainer.
private void loadContentContainer(ArrayObjectAdapter rowsAdapter) {
Log.d(TAG, "loadRootContentContainer()");
rowsAdapter.clear();
Content video = ContentBrowser.getInstance(getActivity()).getLastSelectedContent();
if (video != null) {
String playlistId = video.getExtraValueAsString(Content.EXTRA_PLAYLIST_ID);
ContentContainer playlist = ContentBrowser.getInstance(getActivity()).getPlayList(playlistId);
if (playlist == null) {
isDataLoaded = true;
mCallback.onItemSelected(video, null, -1, 0);
Handler handler = new Handler();
handler.postDelayed(() -> {
LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(new Intent(BROADCAST_DATA_LOADED));
}, 1000L);
return;
}
CardPresenter cardPresenter = new CardPresenter();
PosterCardPresenter posterCardPresenter = new PosterCardPresenter();
HeaderItem header = new HeaderItem(0, playlist.getName());
ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(cardPresenter);
if (playlist.getExtraStringValue(ContentContainer.EXTRA_THUMBNAIL_LAYOUT).equals("poster")) {
listRowAdapter = new ArrayObjectAdapter(posterCardPresenter);
}
if (playlist.getContents() != null) {
try {
for (Content content : playlist.getContents()) {
if (playlist.getExtraValueAsInt(ExtraKeys.NEXT_PAGE) > 0 && playlist.getContents().indexOf(content) == playlist.getContentCount() - 1) {
content.setExtraValue(ContentBrowser.NEXT_PAGE, true);
content.setExtraValue(Content.EXTRA_PLAYLIST_ID, playlist.getExtraStringValue(Recipe.KEY_DATA_TYPE_TAG));
}
listRowAdapter.add(content);
}
} catch (Exception e) {
}
}
rowsAdapter.add(new ListRow(header, listRowAdapter));
isDataLoaded = true;
}
}
use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.
the class ZypePlaylistContentBrowseFragment method loadRootContentContainer.
private void loadRootContentContainer(ArrayObjectAdapter rowsAdapter) {
Log.d(TAG, "loadRootContentContainer()");
rowsAdapter.clear();
ContentContainer rootContentContainer = ContentBrowser.getInstance(getActivity()).getLastSelectedContentContainer();
boolean isMyLibrary = rootContentContainer.getExtraStringValue(Recipe.KEY_DATA_TYPE_TAG).equals(ZypeSettings.ROOT_MY_LIBRARY_PLAYLIST_ID);
boolean isFavorites = rootContentContainer.getExtraStringValue(Recipe.KEY_DATA_TYPE_TAG).equals(ZypeSettings.ROOT_FAVORITES_PLAYLIST_ID);
CardPresenter cardPresenter = new CardPresenter();
PosterCardPresenter posterCardPresenter = new PosterCardPresenter();
for (ContentContainer contentContainer : rootContentContainer.getContentContainers()) {
if (isMyLibrary && contentContainer.getContents().isEmpty() && isDataLoaded) {
dialogError = ErrorDialogFragment.newInstance(getActivity(), ErrorUtils.ERROR_CATEGORY.ZYPE_MY_LIBRARY_ERROR_EMPTY, (ErrorDialogFragment.ErrorDialogFragmentListener) getActivity());
dialogError.show(getFragmentManager(), ErrorDialogFragment.FRAGMENT_TAG_NAME);
break;
}
if (isFavorites) {
if (contentContainer.getContents().isEmpty() && ContentBrowser.getInstance(getActivity()).isFavoritesLoaded()) {
showEmptyFavorites();
break;
}
}
HeaderItem header = new HeaderItem(0, contentContainer.getName());
ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(cardPresenter);
if (contentContainer.getExtraStringValue(ContentContainer.EXTRA_THUMBNAIL_LAYOUT).equals("poster")) {
listRowAdapter = new ArrayObjectAdapter(posterCardPresenter);
}
for (ContentContainer innerContentContainer : contentContainer.getContentContainers()) {
listRowAdapter.add(innerContentContainer);
}
for (Content content : contentContainer.getContents()) {
listRowAdapter.add(content);
}
if (isMyLibrary) {
if (rootContentContainer.getExtraValueAsInt(ExtraKeys.NEXT_PAGE) > 0) {
PlaylistAction action = new PlaylistAction();
action.setAction(ContentBrowser.NEXT_PAGE).setIconResourceId(com.amazon.android.contentbrowser.R.drawable.ic_add_white_48dp).setLabel1(getString(R.string.action_load_more));
listRowAdapter.add(action);
}
} else if (isFavorites) {
} else {
if (contentContainer.getExtraValueAsInt(ExtraKeys.NEXT_PAGE) > 0) {
PlaylistAction action = new PlaylistAction();
action.setAction(ContentBrowser.NEXT_PAGE).setIconResourceId(com.amazon.android.contentbrowser.R.drawable.ic_add_white_48dp).setLabel1(getString(R.string.action_load_more));
action.setExtraValue(PlaylistAction.EXTRA_PLAYLIST_ID, contentContainer.getExtraStringValue(Recipe.KEY_DATA_TYPE_TAG));
listRowAdapter.add(action);
}
}
rowsAdapter.add(new ListRow(header, listRowAdapter));
}
// addSettingsActionsToRowAdapter(rowsAdapter);
// isDataLoaded = false;
addStubRow(rowsAdapter);
}
use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.
the class BuyVideoActivity method checkVideoEntitlement.
private void checkVideoEntitlement() {
if (ZypeConfiguration.isUniversalTVODEnabled(this)) {
Content content = contentBrowser.getLastSelectedContent();
ContentContainer playlist = ContentBrowser.getInstance(this).getRootContentContainer().findContentContainerById(content.getExtraValueAsString(Content.EXTRA_PLAYLIST_ID));
if (content.getExtraValueAsBoolean(Content.EXTRA_PURCHASE_REQUIRED) || (playlist != null && playlist.getExtraValueAsBoolean(ContentContainer.EXTRA_PURCHASE_REQUIRED))) {
String accessToken = Preferences.getString(ZypeAuthentication.ACCESS_TOKEN);
HashMap<String, String> params = new HashMap<>();
params.put(ZypeApi.ACCESS_TOKEN, accessToken);
ZypeApi.getInstance().getApi().checkVideoEntitlement(content.getId(), params).enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
Log.i(TAG, "checkVideoEntitlement(): code=" + response.code());
if (response.isSuccessful()) {
content.setExtraValue(Content.EXTRA_ENTITLED, true);
closeScreen();
contentBrowser.actionTriggered(BuyVideoActivity.this, contentBrowser.getLastSelectedContent(), ContentBrowser.CONTENT_ACTION_WATCH_NOW, null, null);
} else {
content.setExtraValue(Content.EXTRA_ENTITLED, false);
}
}
@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
Log.e(TAG, "checkVideoEntitlement(): failed");
}
});
}
}
}
use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.
the class BuyVideoActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_buy_video);
contentBrowser = ContentBrowser.getInstance(this);
layoutConfirm = (LinearLayout) findViewById(R.id.layoutConfirm);
textVideo = (TextView) findViewById(R.id.textVideo);
layoutLogin = (LinearLayout) findViewById(R.id.layoutLogin);
buttonLogin = (Button) findViewById(R.id.buttonLogin);
buttonLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onLogin();
}
});
layoutLoggedIn = (LinearLayout) findViewById(R.id.layoutLoggeIn);
textConsumerEmail = (TextView) findViewById(R.id.textConsumerEmail);
buttonConfirm = (Button) findViewById(R.id.buttonConfirm);
buttonConfirm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onConfirm();
}
});
buttonRestore = (Button) findViewById(R.id.buttonRestore);
buttonRestore.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onRestore();
}
});
buttonCancel = (Button) findViewById(R.id.buttonCancel);
buttonCancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onCancel();
}
});
Set<String> skuSet;
if (getIntent().getExtras() != null && getIntent().getExtras().containsKey(ExtraKeys.PLAYLIST_ID)) {
// Buy playlist
mode = MODE_PLAYLIST;
try {
Content content = ContentBrowser.getInstance(this).getLastSelectedContent();
ContentContainer playlist = contentBrowser.getRootContentContainer().findContentContainerById(content.getExtraValueAsString(Content.EXTRA_PLAYLIST_ID));
skuSet = ContentBrowser.getInstance(this).getPurchaseHelper().getPlaylistSKU(playlist);
ContentBrowser.getInstance(this).getPurchaseHelper().handleProductsChain(this, skuSet);
} catch (Exception e) {
// TODO: Handle error
}
} else {
// Buy video
mode = MODE_VIDEO;
// ContentBrowser.getInstance(this).getPurchaseHelper().handleProductsChain(this, skuSet);
try {
Content video = ContentBrowser.getInstance(this).getLastSelectedContent();
skuSet = ContentBrowser.getInstance(this).getPurchaseHelper().getVideoSku(video);
ContentBrowser.getInstance(this).getPurchaseHelper().handleProductsChain(this, skuSet);
} catch (Exception e) {
// TODO: Handle error
}
}
updateViews();
bindViews();
}
use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.
the class PlaybackActivity method onCreate.
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/* Zype, Evgney Cherkasov */
if (CookieHandler.getDefault() != DEFAULT_COOKIE_MANAGER) {
CookieHandler.setDefault(DEFAULT_COOKIE_MANAGER);
}
// flag for onResume to know this is being called at activity creation
mResumeOnCreation = true;
// Create video position tracking handler.
mVideoPositionTrackingHandler = new Handler();
// Create a runnable for video position tracking.
mVideoPositionTrackingRunnable = new Runnable() {
@Override
public void run() {
try {
// If player exists and playing then set video position to ads implementation.
if (mPlayer != null && isPlaying()) {
if (mAdsImplementation != null) {
mAdsImplementation.setCurrentVideoPosition(mPlayer.getCurrentPosition());
}
}
} catch (Exception e) {
Log.e(TAG, "Video position tracking failed.", e);
}
mVideoPositionTrackingHandler.postDelayed(this, VIDEO_POSITION_TRACKING_POLL_TIME_MS);
}
};
// Trigger GC to clean up prev player.
// In regular Java vm this is not advised but for Android we need this.
// This will let things going as CC became a must and this code will be handled out of
// TenFootUI in a different way.
System.gc();
setContentView(R.layout.playback_controls);
mWindow = getWindow();
mProgressBar = (ProgressBar) findViewById(R.id.playback_progress);
TextView messageTextView = (TextView) findViewById(R.id.autoplayMessage);
messageTextView.setText(getString(R.string.autoplay_message));
CalligraphyUtils.applyFontToTextView(TenFootApp.getInstance(), messageTextView, ConfigurationManager.getInstance(this).getTypefacePath(ConfigurationConstants.BOLD_FONT));
messageView = findViewById(R.id.messageView);
mPlaybackOverlayFragment = (PlaybackOverlayFragment) getFragmentManager().findFragmentById(R.id.playback_controls_fragment);
mSelectedContent = (Content) getIntent().getSerializableExtra(Content.class.getSimpleName());
isAutoPlay = getIntent().getBooleanExtra(SHOW_PLAYLIST_AUTOPLAY, false);
if (mSelectedContent == null || TextUtils.isEmpty(mSelectedContent.getUrl())) {
AnalyticsHelper.trackError(TAG, "Received an Intent to play content without a " + "content object or content URL");
finish();
}
loadViews();
createPlayerAndInitializeListeners();
mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
mCaptioningHelper = new CaptioningHelper(this, mSubtitleLayout);
mCurrentPlaybackPosition = 0;
mTransportControlsUpdateHandler = new Handler(Looper.getMainLooper());
mContinualFwdUpdater = new ContinualFwdUpdater();
mContinualRewindUpdater = new ContinualRewindUpdater();
mIsLongPress = false;
mIsNetworkError = false;
// Auto-play the selected content.
mAutoPlay = true;
// initialize the media session
initMediaSession();
mCaptioningHelper = new CaptioningHelper(this, mSubtitleLayout);
mCaptioningChangeListener = new CaptioningManager.CaptioningChangeListener() {
@Override
public void onEnabledChanged(boolean enabled) {
Log.d(TAG, "onEnabledChanged: " + enabled);
super.onEnabledChanged(enabled);
if (mCaptioningHelper.useGlobalSetting()) {
mIsClosedCaptionEnabled = enabled;
modifyClosedCaptionState(mIsClosedCaptionEnabled);
}
}
@Override
public void onUserStyleChanged(@NonNull CaptioningManager.CaptionStyle userStyle) {
Log.d(TAG, "onUserStyleChanged");
super.onUserStyleChanged(userStyle);
mSubtitleLayout.setStyle(CaptionStyleCompat.createFromCaptionStyle(userStyle));
}
@Override
public void onLocaleChanged(Locale locale) {
Log.d(TAG, "onLocaleChanged");
super.onLocaleChanged(locale);
}
@Override
public void onFontScaleChanged(float fontScale) {
Log.d(TAG, "onFontScaleChanged");
super.onFontScaleChanged(fontScale);
mSubtitleLayout.setFractionalTextSize(fontScale * SubtitleLayout.DEFAULT_TEXT_SIZE_FRACTION);
}
};
mCaptioningHelper.setCaptioningManagerListener(mCaptioningChangeListener);
}
Aggregations