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