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();
}
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);
// }
}
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;
}
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);
}
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);
}
}
Aggregations