use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.
the class CardPresenter method onBindViewHolder.
@Override
public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
ImageCardView cardView = (ImageCardView) viewHolder.view;
if (item instanceof Content) {
Content content = (Content) item;
if (content.getCardImageUrl() != null) {
if (SHOW_TITLE) {
String title = ContentHelper.getCardViewSubtitle(mContext, content);
if (titleText != null) {
if (TextUtils.isEmpty(title)) {
titleText.setVisibility(View.GONE);
} else {
titleText.setVisibility(View.VISIBLE);
}
}
cardView.setTitleText(title);
cardView.setContentText(content.getTitle());
} else {
cardView.setTitleText("");
cardView.setContentText("");
}
cardView.setMainImageDimensions(mCardWidthDp, mCardHeightDp);
/* Zype, Evgeny Cherkasov */
double playbackPercentage = content.getExtraValueAsDouble(Content.EXTRA_PLAYBACK_POSITION_PERCENTAGE);
if (ZypeConfiguration.displayWatchedBarOnVideoThumbnails() && playbackPercentage > 0) {
SimpleTarget<Bitmap> bitmapTarget = new SimpleTarget<Bitmap>(mCardWidthDp, mCardHeightDp) {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
// cardView.setInfoAreaBackground(infoFieldWithProgressBarBackground);
Bitmap bitmap = Helpers.addProgressToThumbnail((Activity) mContext, resource, playbackPercentage, 0);
cardView.getMainImageView().setImageBitmap(bitmap);
}
};
GlideHelper.loadImageIntoSimpleTargetBitmap(viewHolder.view.getContext(), content.getCardImageUrl(), new GlideHelper.LoggingListener<>(), R.drawable.movie, bitmapTarget);
} else {
GlideHelper.loadImageIntoView(cardView.getMainImageView(), viewHolder.view.getContext(), content.getCardImageUrl(), new GlideHelper.LoggingListener<>(), R.drawable.movie);
cardView.setInfoAreaBackground(sFocusedFadeMask);
}
/* Zype, Evgeny Cherkasov */
// Display lock icon for paywalled video
ImageView mBadgeImage = (ImageView) cardView.findViewById(R.id.extra_badge);
if (contentBrowser.getPurchaseHelper().isVideoPaywalled(content)) {
if (contentBrowser.getPurchaseHelper().isVideoLocked(content)) {
mBadgeImage.setVisibility(View.VISIBLE);
mBadgeImage.setBackgroundColor(mContext.getResources().getColor(R.color.lock_color));
mBadgeImage.setImageResource(R.drawable.locked);
} else {
if (ZypeSettings.UNLOCK_TRANSPARENT) {
mBadgeImage.setVisibility(View.GONE);
} else {
mBadgeImage.setVisibility(View.VISIBLE);
mBadgeImage.setBackgroundColor(mContext.getResources().getColor(R.color.unlock_color));
mBadgeImage.setImageResource(R.drawable.unlocked);
}
}
} else {
mBadgeImage.setVisibility(View.GONE);
}
}
} else if (item instanceof ContentContainer) {
ContentContainer contentContainer = (ContentContainer) item;
// }
if (SHOW_TITLE) {
String title = "";
if (titleText != null) {
if (TextUtils.isEmpty(title)) {
titleText.setVisibility(View.GONE);
} else {
titleText.setVisibility(View.VISIBLE);
}
}
cardView.setTitleText(title);
cardView.setContentText(contentContainer.getName());
} else {
cardView.setTitleText("");
cardView.setContentText("");
}
cardView.setMainImageDimensions(mCardWidthDp, mCardHeightDp);
// Show image for playlist
if (contentContainer.getExtraStringValue(Content.CARD_IMAGE_URL_FIELD_NAME) != null) {
GlideHelper.loadImageIntoView(cardView.getMainImageView(), viewHolder.view.getContext(), contentContainer.getExtraStringValue(Content.CARD_IMAGE_URL_FIELD_NAME), new GlideHelper.LoggingListener<>(), R.drawable.movie);
// Glide.with(viewHolder.view.getContext())
// .load(contentContainer.getExtraStringValue(Content.CARD_IMAGE_URL_FIELD_NAME))
// .listener(new GlideHelper.LoggingListener<>())
// .centerCrop()
// .error(mDefaultCardImage)
// .into(cardView.getMainImageView());
} else {
cardView.getMainImageView().setImageDrawable(mDefaultCardImage);
}
cardView.setInfoAreaBackground(sFocusedFadeMask);
} else /* Zype, Evgeny CHerkasov */
if (item instanceof Action) {
Action action = (Action) item;
cardView.setContentText(action.getLabel1());
cardView.setMainImageScaleType(ImageView.ScaleType.CENTER);
cardView.setMainImageDimensions(mCardWidthDp, mCardHeightDp);
try {
Drawable iconDrawable = ContextCompat.getDrawable(TenFootApp.getInstance().getApplicationContext(), action.getIconResourceId());
DrawableCompat.setTint(iconDrawable, ContextCompat.getColor(mContext, R.color.primary_text));
cardView.setMainImage(iconDrawable);
} catch (Resources.NotFoundException e) {
Log.e(TAG, "Resource not found", e);
throw e;
}
}
}
use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.
the class DetailsDescriptionPresenter method onBindDescription.
private void onBindDescription(ViewHolder viewHolder, Object item) {
Log.v(TAG, "onBindDescription called.");
Content content = (Content) item;
if (content != null) {
populateViewHolder(viewHolder, content);
} else {
Log.e(TAG, "Content is null in onBindDescription");
}
}
use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.
the class PosterCardPresenter method onBindViewHolder.
@Override
public void onBindViewHolder(ViewHolder viewHolder, Object item) {
ImageCardView cardView = (ImageCardView) viewHolder.view;
if (item instanceof Content) {
Content content = (Content) item;
if (content.getCardImageUrl() != null) {
if (SHOW_TITLE) {
cardView.setContentText(content.getTitle());
cardView.setTitleText(ContentHelper.getCardViewSubtitle(mContext, content));
} else {
cardView.setContentText("");
cardView.setTitleText("");
}
cardView.setMainImageDimensions(mCardWidthDp, mCardHeightDp);
String url = content.getExtraValueAsString(Content.EXTRA_IMAGE_POSTER_URL);
if (TextUtils.isEmpty(url) || url.equals("null")) {
url = content.getExtraValueAsString(Content.EXTRA_THUMBNAIL_POSTER_URL);
}
double playbackPercentage = content.getExtraValueAsDouble(Content.EXTRA_PLAYBACK_POSITION_PERCENTAGE);
if (ZypeConfiguration.displayWatchedBarOnVideoThumbnails() && playbackPercentage > 0) {
SimpleTarget<Bitmap> bitmapTarget = new SimpleTarget<Bitmap>(mCardWidthDp, mCardHeightDp) {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
cardView.setInfoAreaBackground(infoFieldWithProgressBarBackground);
Bitmap bitmap = Helpers.addProgressToThumbnail((Activity) mContext, resource, playbackPercentage, 0);
cardView.getMainImageView().setImageBitmap(bitmap);
}
};
GlideHelper.loadImageIntoSimpleTargetBitmap(viewHolder.view.getContext(), url, new GlideHelper.LoggingListener<>(), R.drawable.movie, bitmapTarget);
} else {
GlideHelper.loadImageIntoView(cardView.getMainImageView(), viewHolder.view.getContext(), url, new GlideHelper.LoggingListener<>(), R.drawable.movie);
cardView.setInfoAreaBackground(sFocusedFadeMask);
}
// Display lock icon for subscription video
ImageView mBadgeImage = (ImageView) cardView.findViewById(R.id.extra_badge);
if (contentBrowser.getPurchaseHelper().isVideoPaywalled(content)) {
if (contentBrowser.getPurchaseHelper().isVideoLocked(content)) {
mBadgeImage.setVisibility(View.VISIBLE);
mBadgeImage.setBackgroundColor(mContext.getResources().getColor(R.color.lock_color));
mBadgeImage.setImageResource(R.drawable.locked);
} else {
if (ZypeSettings.UNLOCK_TRANSPARENT) {
mBadgeImage.setVisibility(View.GONE);
} else {
mBadgeImage.setVisibility(View.VISIBLE);
mBadgeImage.setBackgroundColor(mContext.getResources().getColor(R.color.unlock_color));
mBadgeImage.setImageResource(R.drawable.unlocked);
}
}
} else {
mBadgeImage.setVisibility(View.GONE);
}
}
} else if (item instanceof ContentContainer) {
ContentContainer contentContainer = (ContentContainer) item;
if (SHOW_TITLE) {
cardView.setContentText(contentContainer.getName());
} else {
cardView.setContentText("");
}
cardView.setMainImageDimensions(mCardWidthDp, mCardHeightDp);
// Show image for playlist
String url = contentContainer.getExtraStringValue(ContentContainer.EXTRA_IMAGE_POSTER_URL);
if (TextUtils.isEmpty(url) || url.equals("null")) {
url = contentContainer.getExtraStringValue(ContentContainer.EXTRA_THUMBNAIL_POSTER_URL);
}
if (url != null) {
GlideHelper.loadImageIntoView(cardView.getMainImageView(), viewHolder.view.getContext(), url, new GlideHelper.LoggingListener<>(), R.drawable.movie);
} else {
cardView.getMainImageView().setImageDrawable(mDefaultCardImage);
}
} else if (item instanceof Action) {
Action action = (Action) item;
cardView.setContentText(action.getLabel1());
cardView.setMainImageScaleType(ImageView.ScaleType.CENTER);
cardView.setMainImageDimensions(mCardWidthDp, mCardHeightDp);
try {
cardView.setMainImage(ContextCompat.getDrawable(TenFootApp.getInstance().getApplicationContext(), action.getIconResourceId()));
} catch (Resources.NotFoundException e) {
Log.e(TAG, "Resource not found", e);
throw e;
}
}
}
use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.
the class AuthHelper method isAuthorized.
/**
* Is authorized Observable.
*
* @return RX Observable.
*/
public Observable<Bundle> isAuthorized() {
// get the requested content
Content content = mContentBrowser.getLastSelectedContent();
AnalyticsHelper.trackAuthorizationRequest(content);
return Observable.create(subscriber -> {
// Check if user is logged in. If not, show authentication activity.
mIAuthentication.isResourceAuthorized(mAppContext, "", new IAuthentication.ResponseHandler() {
@Override
public void onSuccess(Bundle extras) {
Log.d(TAG, "Resource Authorization " + "success");
AnalyticsHelper.trackAuthorizationResultSuccess(content);
handleSuccessCase(subscriber, extras);
}
@Override
public void onFailure(Bundle extras) {
Log.e(TAG, "Resource Authorization " + "failed");
AnalyticsHelper.trackAuthorizationResultFailure(content, retrieveErrorCategory(extras));
handleFailureCase(subscriber, extras);
}
});
});
}
use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.
the class RecommendationSender method getContentFromRoot.
/**
* Finds the content within the root content container.
*
* @param contentId The id of the content to find.
* @return The content, or null if it was not found.
*/
Content getContentFromRoot(String contentId) {
Content content;
if (mRootContentContainer == null) {
Log.e(TAG, "Cannot find content from empty root.");
return null;
}
content = mRootContentContainer.findContentById(contentId);
return content;
}
Aggregations