本文整理汇总了Java中com.frostwire.jlibtorrent.TorrentStatus类的典型用法代码示例。如果您正苦于以下问题:Java TorrentStatus类的具体用法?Java TorrentStatus怎么用?Java TorrentStatus使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TorrentStatus类属于com.frostwire.jlibtorrent包,在下文中一共展示了TorrentStatus类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makePeerStateParcelList
import com.frostwire.jlibtorrent.TorrentStatus; //导入依赖的package包/类
private ArrayList<PeerStateParcel> makePeerStateParcelList(TorrentDownload task)
{
if (task == null) {
return null;
}
ArrayList<PeerStateParcel> states = new ArrayList<>();
ArrayList<PeerInfo> peers = task.getPeers();
TorrentStatus status = task.getTorrentStatus();
for (PeerInfo peer : peers) {
PeerStateParcel state = new PeerStateParcel(peer.swig(), status);
states.add(state);
}
return states;
}
示例2: PeerStateParcel
import com.frostwire.jlibtorrent.TorrentStatus; //导入依赖的package包/类
public PeerStateParcel(peer_info peer, TorrentStatus torrentStatus)
{
super(new Address(peer.getIp().address()).toString());
ip = new Address(peer.getIp().address()).toString();
byte[] clientBytes = Vectors.byte_vector2bytes(peer.get_client());
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
client = new String(clientBytes, Charset.forName("UTF-8"));
} else {
client = new String(clientBytes, StandardCharsets.UTF_8);
}
totalDownload = peer.getTotal_download();
totalUpload = peer.getTotal_upload();
relevance = calcRelevance(peer, torrentStatus);
connectionType = getConnectionType(peer);
port = peer.getIp().port();
progress = (int) (peer.getProgress() * 100);
payloadDownSpeed = peer.getPayload_down_speed();
payloadUpSpeed = peer.getPayload_up_speed();
}
示例3: calcRelevance
import com.frostwire.jlibtorrent.TorrentStatus; //导入依赖的package包/类
private double calcRelevance(peer_info peer, TorrentStatus torrentStatus)
{
double relevance = 0.0;
piece_index_bitfield allPieces = torrentStatus.pieces().swig();
piece_index_bitfield peerPieces = peer.getPieces();
if (peerPieces == null)
return relevance;
int remoteHaves = 0;
int localMissing = 0;
for (int i = 0; i < allPieces.size(); i++) {
if (!allPieces.get_bit(i)) {
++localMissing;
if (peerPieces.get_bit(i))
++remoteHaves;
}
}
if (localMissing != 0)
relevance = (double) remoteHaves / (double) localMissing;
return relevance;
}
示例4: getETA
import com.frostwire.jlibtorrent.TorrentStatus; //导入依赖的package包/类
public long getETA() {
if (!th.isValid())
return 0;
if (getStateCode() != TorrentStateCode.DOWNLOADING)
return 0;
TorrentInfo ti = th.torrentFile();
if (ti == null)
return 0;
TorrentStatus status = th.status();
long left = ti.totalSize() - status.totalDone();
long rate = status.downloadPayloadRate();
if (left <= 0)
return 0;
if (rate <= 0)
return -1;
return left / rate;
}
示例5: getProgress
import com.frostwire.jlibtorrent.TorrentStatus; //导入依赖的package包/类
public int getProgress()
{
if (th == null || !th.isValid()) {
return 0;
}
if (th.torrentFile() == null) {
return 0;
}
if (th.status() == null) {
return 0;
}
float fp = th.status().progress();
TorrentStatus.State state = th.status().state();
if (Float.compare(fp, 1f) == 0 && state != TorrentStatus.State.CHECKING_FILES) {
return 100;
}
int p = (int) (th.status().progress() * 100);
if (p > 0 && state != TorrentStatus.State.CHECKING_FILES) {
return Math.min(p, 100);
}
final long received = getTotalReceivedBytes();
final long size = getSize();
if (size == received) {
return 100;
}
if (size > 0) {
p = (int) ((received * 100) / size);
return Math.min(p, 100);
}
return 0;
}
示例6: printTorrentStatus
import com.frostwire.jlibtorrent.TorrentStatus; //导入依赖的package包/类
public static void printTorrentStatus(TorrentStatus ts) {
StringBuilder s = new StringBuilder();
s.append("Torrent status for name: " + ts.getName() + "\n");
s.append("info_hash: " + ts.getInfoHash() + "\n");
s.append("state: " + ts.getState().toString() + "\n");
s.append("error: " + ts.errorCode() + "\n");
s.append("progress: " + ts.getProgress() + "\n");
s.append("Queue position: " + ts.getQueuePosition() + "\n");
// ts.getHandle().forceRecheck();
// ts.getHandle().queuePositionTop();
log.info(s.toString());
}
示例7: getStatus
import com.frostwire.jlibtorrent.TorrentStatus; //导入依赖的package包/类
/**
* contains the torrent status of all torrents that changed since last time
* this message was posted. Note that you can map a torrent status to a specific torrent
* via its ``handle`` member. The receiving end is suggested to have all torrents sorted
* by the torrent_handle or hashed by it, for efficient updates.
*
* @return
*/
public List<TorrentStatus> getStatus() {
torrent_status_vector v = alert.getStatus();
int size = (int) v.size();
List<TorrentStatus> l = new ArrayList<TorrentStatus>(size);
for (int i = 0; i < size; i++) {
l.add(new TorrentStatus(v.get(i)));
}
return l;
}
示例8: getTorrentStatus
import com.frostwire.jlibtorrent.TorrentStatus; //导入依赖的package包/类
public TorrentStatus getTorrentStatus()
{
return th.status();
}
示例9: isPaused
import com.frostwire.jlibtorrent.TorrentStatus; //导入依赖的package包/类
private static boolean isPaused(TorrentStatus s)
{
return s.flags().and_(TorrentFlags.PAUSED).nonZero();
}
示例10: getState
import com.frostwire.jlibtorrent.TorrentStatus; //导入依赖的package包/类
/**
* The new state of the torrent.
*
* @return
*/
public TorrentStatus.State getState() {
return TorrentStatus.State.fromSwig(alert.getState().swigValue());
}
示例11: getPrevState
import com.frostwire.jlibtorrent.TorrentStatus; //导入依赖的package包/类
/**
* The previous state.
*
* @return
*/
public TorrentStatus.State getPrevState() {
return TorrentStatus.State.fromSwig(alert.getPrev_state().swigValue());
}