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