use of com.biglybt.core.history.DownloadHistory in project BiglyBT by BiglySoftware.
the class SBC_DownloadHistoryView method toolBarItemActivated.
@Override
public boolean toolBarItemActivated(ToolBarItem item, long activationType, Object datasource) {
if (tv == null || !tv.isVisible() || dh_manager == null) {
return (false);
}
List<Object> datasources = tv.getSelectedDataSources();
if (datasources.size() > 0) {
List<DownloadHistory> dms = new ArrayList<>(datasources.size());
for (Object o : datasources) {
dms.add((DownloadHistory) o);
}
String id = item.getID();
if (id.equals("remove")) {
dh_manager.removeHistory(dms);
} else if (id.equals("startstop")) {
for (DownloadHistory download : dms) {
download.setRedownloading();
String magnet = UrlUtils.getMagnetURI(download.getTorrentHash(), download.getName(), null);
TorrentOpener.openTorrent(magnet);
}
}
return true;
}
return false;
}
use of com.biglybt.core.history.DownloadHistory in project BiglyBT by BiglySoftware.
the class DownloadHistoryManagerImpl method removeHistory.
@Override
public void removeHistory(List<DownloadHistory> to_remove) {
synchronized (lock) {
List<DownloadHistory> removed = new ArrayList<>(to_remove.size());
int update_type = 0;
Map<Long, DownloadHistoryImpl> active = getActiveHistory();
Map<Long, DownloadHistoryImpl> dead = getDeadHistory();
for (DownloadHistory h : to_remove) {
long uid = h.getUID();
DownloadHistoryImpl r = active.remove(uid);
if (r != null) {
removed.add(r);
update_type |= UPDATE_TYPE_ACTIVE;
} else {
r = dead.remove(uid);
if (r != null) {
removed.add(r);
update_type |= UPDATE_TYPE_DEAD;
}
}
}
if (removed.size() > 0) {
historyUpdated(removed, DownloadHistoryEvent.DHE_HISTORY_REMOVED, update_type);
}
}
}
use of com.biglybt.core.history.DownloadHistory in project BiglyBT by BiglySoftware.
the class ColumnDLHistoryRemoveDate method refresh.
@Override
public void refresh(TableCell cell) {
TableColumn tc = cell.getTableColumn();
if (tc instanceof ColumnDateSizer) {
DownloadHistory dl = (DownloadHistory) cell.getDataSource();
((ColumnDateSizer) tc).refresh(cell, dl.getRemoveTime());
}
}
use of com.biglybt.core.history.DownloadHistory in project BiglyBT by BiglySoftware.
the class ColumnDLHistorySize method refresh.
@Override
public void refresh(TableCell cell) {
DownloadHistory dl = (DownloadHistory) cell.getDataSource();
long size = 0;
if (dl != null) {
size = dl.getSize();
}
if (!cell.setSortValue(size) && cell.isValid()) {
return;
}
if (!cell.isShown()) {
return;
}
cell.setText(size <= 0 ? "" : DisplayFormatters.formatByteCountToKiBEtc(size));
}
use of com.biglybt.core.history.DownloadHistory in project BiglyBT by BiglySoftware.
the class DownloadHistoryManagerImpl method getDates.
@Override
public long[] getDates(byte[] hash) {
List<DownloadHistory> history = getHistory();
for (DownloadHistory dh : history) {
if (Arrays.equals(hash, dh.getTorrentHash())) {
Long rdl = redownload_cache.remove(dh.getUID());
long[] result = { dh.getAddTime(), dh.getCompleteTime(), dh.getRemoveTime(), rdl == null ? 0 : rdl };
return (result);
}
}
return (null);
}
Aggregations