Search in sources :

Example 6 with NavigationHelper

use of com.zype.android.ui.NavigationHelper in project zype-android by zype.

the class PaywallPlaylistTvodFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    binding = FragmentPaywallPlaylistTvodBinding.inflate(inflater, container, false);
    final NavigationHelper navigationHelper = NavigationHelper.getInstance(getActivity());
    binding.buttonBuyPlaylist.setOnClickListener(v -> {
        if (AuthHelper.isLoggedIn()) {
            model.setState(PaywallViewModel.State.READY_FOR_PURCHASE);
        } else {
            navigationHelper.switchToConsumerScreen(getActivity());
        }
    });
    binding.buttonSignIn.setOnClickListener(v -> navigationHelper.switchToLoginScreen(getActivity(), null));
    return binding.getRoot();
}
Also used : NavigationHelper(com.zype.android.ui.NavigationHelper)

Example 7 with NavigationHelper

use of com.zype.android.ui.NavigationHelper in project zype-android by zype.

the class VideosActivity method onItemClick.

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    Logger.d("onItemClick()");
    VideosCursorAdapter.VideosViewHolder holder = (VideosCursorAdapter.VideosViewHolder) view.getTag();
    selectedVideoId = holder.videoId;
    NavigationHelper navigationHelper = NavigationHelper.getInstance(this);
    if (AuthHelper.isVideoUnlocked(this, holder.videoId, playlistId)) {
        navigationHelper.switchToVideoDetailsScreen(this, holder.videoId, playlistId, false);
    } else {
        navigationHelper.handleNotAuthorizedVideo(this, holder.videoId, playlistId);
    }
// if (ZypeConfiguration.isUniversalTVODEnabled(this) && holder.purchaseRequired) {
// if (holder.isEntitled) {
// VideoDetailActivity.startActivity(this, holder.videoId, playlistId);
// }
// else {
// if (SettingsProvider.getInstance().isLoggedIn()) {
// requestEntitled(holder.videoId);
// }
// else {
// NavigationHelper.getInstance(this).switchToLoginScreen(this);
// }
// }
// return;
// }
// if (holder.subscriptionRequired) {
// NavigationHelper.getInstance(this).checkSubscription(this, holder.videoId, playlistId, holder.onAir);
// }
// else {
// VideoDetailActivity.startActivity(this, holder.videoId, playlistId);
// }
}
Also used : NavigationHelper(com.zype.android.ui.NavigationHelper)

Example 8 with NavigationHelper

use of com.zype.android.ui.NavigationHelper in project zype-android by zype.

the class SubscribeOrLoginFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_subscribe_or_login, container, false);
    final NavigationHelper navigationHelper = NavigationHelper.getInstance(getActivity());
    TextView textTitle = rootView.findViewById(R.id.textTitle);
    textTitle.setText(String.format(getString(R.string.subscribe_or_login_title), getString(R.string.app_name)));
    Button buttonSubscribe = rootView.findViewById(R.id.buttonSubscribe);
    buttonSubscribe.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (AuthHelper.isLoggedIn()) {
                navigationHelper.switchToSubscriptionScreen(getActivity(), getActivity().getIntent().getExtras());
            } else {
                navigationHelper.switchToConsumerScreen(getActivity());
            }
        }
    });
    Button buttonLogin = rootView.findViewById(R.id.buttonLogin);
    buttonLogin.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            navigationHelper.switchToLoginScreen(getActivity(), null);
        }
    });
    final List<Purchase> purchases = ZypeApp.marketplaceGateway.getBillingManager().getPurchases();
    Button buttonRestorePurchases = rootView.findViewById(R.id.buttonRestorePurchases);
    buttonRestorePurchases.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (AuthHelper.isLoggedIn()) {
                // Get first purchase from the purchase list and try to validate it
                Subscription subscription = ZypeApp.marketplaceGateway.findSubscriptionBySku(purchases.get(0).getSku());
                if (subscription != null) {
                    showProgress(getString(R.string.subscription_verify));
                    ZypeApp.marketplaceGateway.verifySubscription(subscription).observe(SubscribeOrLoginFragment.this, new Observer<Boolean>() {

                        @Override
                        public void onChanged(@Nullable Boolean result) {
                            hideProgress();
                            if (result) {
                                getActivity().setResult(RESULT_OK);
                                getActivity().finish();
                            } else {
                                DialogHelper.showErrorAlert(getActivity(), getString(R.string.subscribe_or_login_error_validation));
                            }
                        }
                    });
                } else {
                    Logger.e("Not found Zype Plan for existing in-app purchase, sku=" + purchases.get(0).getSku());
                    DialogHelper.showErrorAlert(getActivity(), getString(R.string.subscribe_or_login_error_restore_purchase_zype));
                }
            /*for (String itemSku : purchases.get(0).getSkus()){
                        Subscription subscription = ZypeApp.marketplaceGateway.findSubscriptionBySku(itemSku);
                        if (subscription != null) {
                            showProgress(getString(R.string.subscription_verify));
                            ZypeApp.marketplaceGateway.verifySubscription(subscription).observe(SubscribeOrLoginFragment.this, new Observer<Boolean>() {
                                @Override
                                public void onChanged(@Nullable Boolean result) {
                                    hideProgress();
                                    if (result) {
                                        getActivity().setResult(RESULT_OK);
                                        getActivity().finish();
                                    }
                                    else {
                                        DialogHelper.showErrorAlert(getActivity(),
                                                getString(R.string.subscribe_or_login_error_validation));
                                    }
                                }
                            });
                        }
                        else {
                            Logger.e("Not found Zype Plan for existing in-app purchase, sku=" + itemSku);
                            DialogHelper.showErrorAlert(getActivity(), getString(R.string.subscribe_or_login_error_restore_purchase_zype));
                        }
                    }*/
            } else {
                navigationHelper.switchToConsumerScreen(getActivity());
            }
        }
    });
    if (purchases != null && purchases.size() > 0) {
        Logger.d("There are purchases, size=" + purchases.size());
        buttonRestorePurchases.setVisibility(View.VISIBLE);
    } else {
        Logger.d("There are no purchases on the device");
        buttonRestorePurchases.setVisibility(View.GONE);
    }
    api.subscribe(this);
    return rootView;
}
Also used : Purchase(com.android.billingclient.api.Purchase) NavigationHelper(com.zype.android.ui.NavigationHelper) Button(android.widget.Button) Observer(androidx.lifecycle.Observer) TextView(android.widget.TextView) Subscription(com.zype.android.Billing.Subscription) TextView(android.widget.TextView) View(android.view.View) Nullable(androidx.annotation.Nullable)

Example 9 with NavigationHelper

use of com.zype.android.ui.NavigationHelper in project zype-android by zype.

the class FavoritesFragment method onItemClick.

// //////////
// UI
// 
// private void updateTextEmpty() {
// if (SettingsProvider.getInstance().isLoggedIn()) {
// textEmpty.setText(SettingsProvider.getInstance().getNoFavoritesMessage());
// }
// else {
// textEmpty.setText(SettingsProvider.getInstance().getNoFavoritesMessageNotLoggedIn());
// }
// }
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    VideosCursorAdapter.VideosViewHolder holder = (VideosCursorAdapter.VideosViewHolder) view.getTag();
    // listener.onFavoriteVideoClick(holder.videoId, holder.isFavorite);
    NavigationHelper navigationHelper = NavigationHelper.getInstance(getActivity());
    Video video = DataRepository.getInstance(getActivity().getApplication()).getVideoSync(holder.videoId);
    navigationHelper.handleVideoClick(getActivity(), video, null, false);
}
Also used : NavigationHelper(com.zype.android.ui.NavigationHelper) ConsumerFavoriteVideo(com.zype.android.webapi.model.consumers.ConsumerFavoriteVideo) Video(com.zype.android.Db.Entity.Video) VideosCursorAdapter(com.zype.android.ui.main.fragments.videos.VideosCursorAdapter)

Example 10 with NavigationHelper

use of com.zype.android.ui.NavigationHelper in project zype-android by zype.

the class MainActivity method onDownloadedVideoClick.

@Override
public void onDownloadedVideoClick(String videoId, int mediaType) {
    // if (SettingsProvider.getInstance().getSubscriptionCount() == 0) {
    // onRequestSubscription();
    // } else {
    // VideoDetailActivity.startActivity(this, videoId, null, mediaType);
    // }
    NavigationHelper navigationHelper = NavigationHelper.getInstance(this);
    Video video = DataRepository.getInstance(this.getApplication()).getVideoSync(videoId);
    if (video != null) {
        navigationHelper.handleVideoClick(this, video, null, false);
    }
}
Also used : NavigationHelper(com.zype.android.ui.NavigationHelper) Video(com.zype.android.Db.Entity.Video)

Aggregations

NavigationHelper (com.zype.android.ui.NavigationHelper)13 Video (com.zype.android.Db.Entity.Video)4 View (android.view.View)3 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 Playlist (com.zype.android.Db.Entity.Playlist)2 VideosCursorAdapter (com.zype.android.ui.main.fragments.videos.VideosCursorAdapter)2 Activity (android.app.Activity)1 Button (android.widget.Button)1 Nullable (androidx.annotation.Nullable)1 SearchView (androidx.appcompat.widget.SearchView)1 Toolbar (androidx.appcompat.widget.Toolbar)1 Observer (androidx.lifecycle.Observer)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 Purchase (com.android.billingclient.api.Purchase)1 Subscription (com.zype.android.Billing.Subscription)1 VideosAdapter (com.zype.android.ui.v2.videos.VideosAdapter)1 ConsumerFavoriteVideo (com.zype.android.webapi.model.consumers.ConsumerFavoriteVideo)1