use of com.zype.android.Db.Entity.Playlist in project zype-android by zype.
the class AuthHelper method isPaywalledVideo.
public static boolean isPaywalledVideo(Context context, String videoId, String playlistId) {
Video video = DataRepository.getInstance((Application) context.getApplicationContext()).getVideoSync(videoId);
if (video == null) {
Log.e(TAG, "isPaywalledVideo(): Video not found " + videoId);
return false;
}
Playlist playlist = null;
if (!TextUtils.isEmpty(playlistId)) {
playlist = DataRepository.getInstance((Application) context.getApplicationContext()).getPlaylistSync(playlistId);
}
if (playlist != null) {
if (playlist.purchaseRequired == 1) {
return true;
}
}
if (Integer.valueOf(video.purchaseRequired) == 1) {
return true;
}
if (Integer.valueOf(video.subscriptionRequired) == 1) {
return true;
}
return false;
}
use of com.zype.android.Db.Entity.Playlist in project zype-android by zype.
the class DbHelper method playlistDataToEntity.
public static List<Playlist> playlistDataToEntity(List<PlaylistData> playlists) {
List<Playlist> result = new ArrayList<>(playlists.size());
for (PlaylistData item : playlists) {
Playlist playlistEntity = new Playlist();
playlistEntity.id = item.getId();
playlistEntity.active = item.active ? 1 : 0;
playlistEntity.createdAt = item.getCreatedAt();
playlistEntity.deletedAt = item.getDeletedAt();
playlistEntity.images = new Gson().toJson(item.getImages());
playlistEntity.marketplaceIds = new Gson().toJson(item.marketplaceIds);
playlistEntity.purchasePrice = item.purchasePrice;
playlistEntity.purchaseRequired = item.purchaseRequired ? 1 : 0;
playlistEntity.parentId = item.getParentId();
playlistEntity.playlistItemCount = item.getPlaylistItemCount();
playlistEntity.priority = item.getPriority();
playlistEntity.thumbnails = new Gson().toJson(item.getThumbnails());
playlistEntity.thumbnailLayout = item.getThumbnailLayout();
playlistEntity.title = item.getTitle();
playlistEntity.updatedAt = item.getUpdatedAt();
result.add(playlistEntity);
}
return result;
}
use of com.zype.android.Db.Entity.Playlist in project zype-android by zype.
the class NavigationHelper method findPurchaseRequiredPlaylist.
private Playlist findPurchaseRequiredPlaylist(Video video) {
Type type = new TypeToken<List<String>>() {
}.getType();
List<String> playlistIds = new Gson().fromJson(video.serializedPlaylistIds, type);
if (playlistIds != null) {
for (String id : playlistIds) {
Playlist playlist = repo.getPlaylistSync(id);
if (playlist != null && playlist.purchaseRequired == 1) {
return playlist;
}
}
}
return null;
}
use of com.zype.android.Db.Entity.Playlist in project zype-android by zype.
the class PaywallViewModel method isItemPurchased.
private boolean isItemPurchased(List<Purchase> purchases) {
if (paywallType == null)
return false;
switch(paywallType) {
case PLAYLIST_TVOD:
Playlist playlist = repo.getPlaylistSync(playlistId);
if (playlist != null) {
String marketplaceId = getPlaylistMarketplaceId(playlist);
Log.d(TAG, "isItemPurchased(): sku=" + marketplaceId);
for (Purchase purchase : purchases) {
if (purchase.getSku().equals(marketplaceId)) {
return true;
}
/*for (String itemSku : purchase.getSkus()){
if (itemSku.equals(marketplaceId)) {
return true;
}
}*/
}
}
break;
case VIDEO_TVOD:
{
Video video = getVideo();
if (video != null) {
String marketplaceId = getVideoMarketplaceId(video);
Log.d(TAG, "isItemPurchased(): sku=" + marketplaceId);
for (Purchase purchase : purchases) {
if (!TextUtils.isEmpty(marketplaceId) && purchase.getSku().equals(marketplaceId)) {
return true;
}
/*for (String itemSku : purchase.getSkus()){
if (!TextUtils.isEmpty(marketplaceId) && itemSku.equals(marketplaceId)) {
return true;
}
}*/
}
}
break;
}
}
return false;
}
use of com.zype.android.Db.Entity.Playlist in project zype-android by zype.
the class PaywallPlaylistTvodFragment method onActivityCreated.
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
model = ViewModelProviders.of(getActivity()).get(PaywallViewModel.class);
Playlist playlist = model.getPlaylist();
if (playlist != null) {
binding.setNumberOfVideos(playlist.playlistItemCount);
binding.setPlaylistPrice(playlist.purchasePrice);
}
binding.setIsSignedIn(model.getState().getValue() == PaywallViewModel.State.SIGNED_IN);
}
Aggregations