Search in sources :

Example 1 with SubscriptionEntity

use of org.schabi.newpipe.database.subscription.SubscriptionEntity in project NewPipe by TeamNewPipe.

the class SelectChannelFragment method clickedItem.

private void clickedItem(int position) {
    if (onSelectedLisener != null) {
        SubscriptionEntity entry = subscriptions.get(position);
        onSelectedLisener.onChannelSelected(entry.getUrl(), entry.getName(), entry.getServiceId());
    }
    dismiss();
}
Also used : SubscriptionEntity(org.schabi.newpipe.database.subscription.SubscriptionEntity)

Example 2 with SubscriptionEntity

use of org.schabi.newpipe.database.subscription.SubscriptionEntity in project NewPipe by TeamNewPipe.

the class SubscriptionFragment method getSubscriptionItems.

private List<InfoItem> getSubscriptionItems(List<SubscriptionEntity> subscriptions) {
    List<InfoItem> items = new ArrayList<>();
    for (final SubscriptionEntity subscription : subscriptions) items.add(subscription.toChannelInfoItem());
    Collections.sort(items, (InfoItem o1, InfoItem o2) -> o1.getName().compareToIgnoreCase(o2.getName()));
    return items;
}
Also used : ChannelInfoItem(org.schabi.newpipe.extractor.channel.ChannelInfoItem) InfoItem(org.schabi.newpipe.extractor.InfoItem) ArrayList(java.util.ArrayList) SubscriptionEntity(org.schabi.newpipe.database.subscription.SubscriptionEntity)

Example 3 with SubscriptionEntity

use of org.schabi.newpipe.database.subscription.SubscriptionEntity in project NewPipe by TeamNewPipe.

the class SubscriptionsImportService method getSubscriber.

private Subscriber<List<SubscriptionEntity>> getSubscriber() {
    return new Subscriber<List<SubscriptionEntity>>() {

        @Override
        public void onSubscribe(Subscription s) {
            subscription = s;
            s.request(Long.MAX_VALUE);
        }

        @Override
        public void onNext(List<SubscriptionEntity> successfulInserted) {
            if (DEBUG)
                Log.d(TAG, "startImport() " + successfulInserted.size() + " items successfully inserted into the database");
        }

        @Override
        public void onError(Throwable error) {
            handleError(error);
        }

        @Override
        public void onComplete() {
            LocalBroadcastManager.getInstance(SubscriptionsImportService.this).sendBroadcast(new Intent(IMPORT_COMPLETE_ACTION));
            showToast(R.string.import_complete_toast);
            stopService();
        }
    };
}
Also used : Subscriber(org.reactivestreams.Subscriber) SubscriptionEntity(org.schabi.newpipe.database.subscription.SubscriptionEntity) ArrayList(java.util.ArrayList) List(java.util.List) Intent(android.content.Intent) Subscription(org.reactivestreams.Subscription)

Example 4 with SubscriptionEntity

use of org.schabi.newpipe.database.subscription.SubscriptionEntity in project NewPipe by TeamNewPipe.

the class SubscriptionsExportService method startExport.

private void startExport() {
    showToast(R.string.export_ongoing);
    subscriptionService.subscriptionTable().getAll().take(1).map(subscriptionEntities -> {
        final List<SubscriptionItem> result = new ArrayList<>(subscriptionEntities.size());
        for (SubscriptionEntity entity : subscriptionEntities) {
            result.add(new SubscriptionItem(entity.getServiceId(), entity.getUrl(), entity.getName()));
        }
        return result;
    }).map(exportToFile()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(getSubscriber());
}
Also used : SubscriptionItem(org.schabi.newpipe.extractor.subscription.SubscriptionItem) ArrayList(java.util.ArrayList) SubscriptionEntity(org.schabi.newpipe.database.subscription.SubscriptionEntity)

Example 5 with SubscriptionEntity

use of org.schabi.newpipe.database.subscription.SubscriptionEntity in project NewPipe by TeamNewPipe.

the class ChannelFragment method getSubscribeUpdateMonitor.

private Consumer<List<SubscriptionEntity>> getSubscribeUpdateMonitor(final ChannelInfo info) {
    return new Consumer<List<SubscriptionEntity>>() {

        @Override
        public void accept(List<SubscriptionEntity> subscriptionEntities) throws Exception {
            if (DEBUG)
                Log.d(TAG, "subscriptionService.subscriptionTable.doOnNext() called with: subscriptionEntities = [" + subscriptionEntities + "]");
            if (subscribeButtonMonitor != null)
                subscribeButtonMonitor.dispose();
            if (subscriptionEntities.isEmpty()) {
                if (DEBUG)
                    Log.d(TAG, "No subscription to this channel!");
                SubscriptionEntity channel = new SubscriptionEntity();
                channel.setServiceId(info.getServiceId());
                channel.setUrl(info.getUrl());
                channel.setData(info.getName(), info.getAvatarUrl(), info.getDescription(), info.getSubscriberCount());
                subscribeButtonMonitor = monitorSubscribeButton(headerSubscribeButton, mapOnSubscribe(channel));
            } else {
                if (DEBUG)
                    Log.d(TAG, "Found subscription to this channel!");
                final SubscriptionEntity subscription = subscriptionEntities.get(0);
                subscribeButtonMonitor = monitorSubscribeButton(headerSubscribeButton, mapOnUnsubscribe(subscription));
            }
        }
    };
}
Also used : Consumer(io.reactivex.functions.Consumer) SubscriptionEntity(org.schabi.newpipe.database.subscription.SubscriptionEntity) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

SubscriptionEntity (org.schabi.newpipe.database.subscription.SubscriptionEntity)5 ArrayList (java.util.ArrayList)4 List (java.util.List)2 Intent (android.content.Intent)1 Consumer (io.reactivex.functions.Consumer)1 Subscriber (org.reactivestreams.Subscriber)1 Subscription (org.reactivestreams.Subscription)1 InfoItem (org.schabi.newpipe.extractor.InfoItem)1 ChannelInfoItem (org.schabi.newpipe.extractor.channel.ChannelInfoItem)1 SubscriptionItem (org.schabi.newpipe.extractor.subscription.SubscriptionItem)1