Search in sources :

Example 6 with Playlist

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;
}
Also used : Playlist(com.zype.android.Db.Entity.Playlist) Video(com.zype.android.Db.Entity.Video) Application(android.app.Application)

Example 7 with Playlist

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;
}
Also used : Playlist(com.zype.android.Db.Entity.Playlist) PlaylistData(com.zype.android.webapi.model.playlist.PlaylistData) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson)

Example 8 with Playlist

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;
}
Also used : Type(java.lang.reflect.Type) PaywallType(com.zype.android.ui.monetization.PaywallType) Playlist(com.zype.android.Db.Entity.Playlist) Gson(com.google.gson.Gson) List(java.util.List)

Example 9 with Playlist

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;
}
Also used : Playlist(com.zype.android.Db.Entity.Playlist) Purchase(com.android.billingclient.api.Purchase) Video(com.zype.android.Db.Entity.Video)

Example 10 with Playlist

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);
}
Also used : Playlist(com.zype.android.Db.Entity.Playlist)

Aggregations

Playlist (com.zype.android.Db.Entity.Playlist)13 Video (com.zype.android.Db.Entity.Video)7 ArrayList (java.util.ArrayList)7 Gson (com.google.gson.Gson)4 List (java.util.List)4 Type (java.lang.reflect.Type)3 View (android.view.View)2 ImageView (android.widget.ImageView)2 GalleryRow (com.zype.android.ui.Gallery.Model.GalleryRow)2 NavigationHelper (com.zype.android.ui.NavigationHelper)2 IZypeApiListener (com.zype.android.zypeapi.IZypeApiListener)2 ZypeApiResponse (com.zype.android.zypeapi.ZypeApiResponse)2 PlaylistsResponse (com.zype.android.zypeapi.model.PlaylistsResponse)2 HashMap (java.util.HashMap)2 Activity (android.app.Activity)1 Application (android.app.Application)1 TextView (android.widget.TextView)1 Nullable (androidx.annotation.Nullable)1 LiveData (androidx.lifecycle.LiveData)1 MediatorLiveData (androidx.lifecycle.MediatorLiveData)1