use of com.biglybt.core.subs.SubscriptionException in project BiglyBT by BiglySoftware.
the class SubscriptionListWindow method complete.
@Override
public void complete(final byte[] hash, final Subscription[] subscriptions) {
if (!(subscriptions.length > 0)) {
failed(hash, null);
} else {
if (display != null && !display.isDisposed()) {
display.asyncExec(new Runnable() {
@Override
public void run() {
if (mainComposite.isDisposed()) {
return;
}
subscriptionItems = new SubscriptionItemModel[subscriptions.length];
for (int i = 0; i < subscriptions.length; i++) {
final SubscriptionItemModel subscriptionItem = new SubscriptionItemModel();
subscriptionItems[i] = subscriptionItem;
subscriptionItem.name = subscriptions[i].getName();
subscriptionItem.popularity = -1;
subscriptionItem.popularityDisplay = MessageText.getString("subscriptions.listwindow.popularity.reading");
subscriptionItem.subscription = subscriptions[i];
try {
subscriptions[i].getPopularity(new SubscriptionPopularityListener() {
@Override
public void gotPopularity(long popularity) {
update(subscriptionItem, popularity, popularity + "");
}
@Override
public void failed(SubscriptionException error) {
update(subscriptionItem, -2, MessageText.getString("subscriptions.listwindow.popularity.unknown"));
}
});
} catch (SubscriptionException e) {
update(subscriptionItem, -2, MessageText.getString("subscriptions.listwindow.popularity.unknown"));
}
}
animatedImage.stop();
mainLayout.topControl = listPanel;
mainComposite.layout();
sortAndRefresh();
subscriptionsList.setSelection(0);
action.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event arg0) {
if (subscriptionsList != null && !subscriptionsList.isDisposed()) {
int selectedIndex = subscriptionsList.getSelectionIndex();
if (selectedIndex >= 0 && selectedIndex < subscriptionItems.length) {
Subscription subscription = (Subscription) subscriptionItems[selectedIndex].subscription;
if (subscription != null) {
subscription.setSubscribed(true);
subscription.requestAttention();
}
}
}
}
});
}
});
}
}
}
Aggregations