Search in sources :

Example 1 with SubscriptionExtractor

use of org.schabi.newpipe.extractor.subscription.SubscriptionExtractor in project NewPipe by TeamNewPipe.

the class SubscriptionFragment method setupImportFromItems.

private void setupImportFromItems(final ViewGroup listHolder) {
    final View previousBackupItem = addItemView(getString(R.string.previous_export), ThemeHelper.resolveResourceIdFromAttr(getContext(), R.attr.ic_backup), listHolder);
    previousBackupItem.setOnClickListener(item -> onImportPreviousSelected());
    final int iconColor = ThemeHelper.isLightThemeSelected(getContext()) ? Color.BLACK : Color.WHITE;
    final String[] services = getResources().getStringArray(R.array.service_list);
    for (String serviceName : services) {
        try {
            final StreamingService service = NewPipe.getService(serviceName);
            final SubscriptionExtractor subscriptionExtractor = service.getSubscriptionExtractor();
            if (subscriptionExtractor == null)
                continue;
            final List<SubscriptionExtractor.ContentSource> supportedSources = subscriptionExtractor.getSupportedSources();
            if (supportedSources.isEmpty())
                continue;
            final View itemView = addItemView(serviceName, ServiceHelper.getIcon(service.getServiceId()), listHolder);
            final ImageView iconView = itemView.findViewById(android.R.id.icon1);
            iconView.setColorFilter(iconColor, PorterDuff.Mode.SRC_IN);
            itemView.setOnClickListener(selectedItem -> onImportFromServiceSelected(service.getServiceId()));
        } catch (ExtractionException e) {
            throw new RuntimeException("Services array contains an entry that it's not a valid service name (" + serviceName + ")", e);
        }
    }
}
Also used : ExtractionException(org.schabi.newpipe.extractor.exceptions.ExtractionException) SubscriptionExtractor(org.schabi.newpipe.extractor.subscription.SubscriptionExtractor) StreamingService(org.schabi.newpipe.extractor.StreamingService) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) AnimationUtils.animateView(org.schabi.newpipe.util.AnimationUtils.animateView) CollapsibleView(org.schabi.newpipe.views.CollapsibleView) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView)

Example 2 with SubscriptionExtractor

use of org.schabi.newpipe.extractor.subscription.SubscriptionExtractor in project NewPipe by TeamNewPipe.

the class SubscriptionsImportFragment method setupServiceVariables.

// /////////////////////////////////////////////////////////////////////////
// Subscriptions
// /////////////////////////////////////////////////////////////////////////
private void setupServiceVariables() {
    if (currentServiceId != Constants.NO_SERVICE_ID) {
        try {
            final SubscriptionExtractor extractor = NewPipe.getService(currentServiceId).getSubscriptionExtractor();
            supportedSources = extractor.getSupportedSources();
            relatedUrl = extractor.getRelatedUrl();
            instructionsString = ServiceHelper.getImportInstructions(currentServiceId);
            return;
        } catch (ExtractionException ignored) {
        }
    }
    supportedSources = Collections.emptyList();
    relatedUrl = null;
    instructionsString = 0;
}
Also used : ExtractionException(org.schabi.newpipe.extractor.exceptions.ExtractionException) SubscriptionExtractor(org.schabi.newpipe.extractor.subscription.SubscriptionExtractor)

Aggregations

ExtractionException (org.schabi.newpipe.extractor.exceptions.ExtractionException)2 SubscriptionExtractor (org.schabi.newpipe.extractor.subscription.SubscriptionExtractor)2 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 StreamingService (org.schabi.newpipe.extractor.StreamingService)1 AnimationUtils.animateView (org.schabi.newpipe.util.AnimationUtils.animateView)1 CollapsibleView (org.schabi.newpipe.views.CollapsibleView)1