当前位置: 首页>>代码示例>>Java>>正文


Java TorrentStatus类代码示例

本文整理汇总了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;
}
 
开发者ID:proninyaroslav,项目名称:libretorrent,代码行数:19,代码来源:TorrentTaskService.java

示例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();
}
 
开发者ID:proninyaroslav,项目名称:libretorrent,代码行数:21,代码来源:PeerStateParcel.java

示例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;
}
 
开发者ID:proninyaroslav,项目名称:libretorrent,代码行数:23,代码来源:PeerStateParcel.java

示例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;
}
 
开发者ID:proninyaroslav,项目名称:libretorrent,代码行数:20,代码来源:TorrentDownload.java

示例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;
}
 
开发者ID:proninyaroslav,项目名称:libretorrent,代码行数:38,代码来源:TorrentDownload.java

示例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());
	}
 
开发者ID:dessalines,项目名称:torrenttunes-client,代码行数:16,代码来源:Tools.java

示例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;
}
 
开发者ID:Teg79,项目名称:Wave,代码行数:20,代码来源:StateUpdateAlert.java

示例8: getTorrentStatus

import com.frostwire.jlibtorrent.TorrentStatus; //导入依赖的package包/类
public TorrentStatus getTorrentStatus()
{
    return th.status();
}
 
开发者ID:proninyaroslav,项目名称:libretorrent,代码行数:5,代码来源:TorrentDownload.java

示例9: isPaused

import com.frostwire.jlibtorrent.TorrentStatus; //导入依赖的package包/类
private static boolean isPaused(TorrentStatus s)
{
    return s.flags().and_(TorrentFlags.PAUSED).nonZero();
}
 
开发者ID:proninyaroslav,项目名称:libretorrent,代码行数:5,代码来源:TorrentDownload.java

示例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());
}
 
开发者ID:Teg79,项目名称:Wave,代码行数:9,代码来源:StateChangedAlert.java

示例11: getPrevState

import com.frostwire.jlibtorrent.TorrentStatus; //导入依赖的package包/类
/**
 * The previous state.
 *
 * @return
 */
public TorrentStatus.State getPrevState() {
    return TorrentStatus.State.fromSwig(alert.getPrev_state().swigValue());
}
 
开发者ID:Teg79,项目名称:Wave,代码行数:9,代码来源:StateChangedAlert.java


注:本文中的com.frostwire.jlibtorrent.TorrentStatus类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。