super("seed_to_peer_ratio", ALIGN_TRAIL, POSITION_INVISIBLE, 70, sTableID); setRefreshInterval(INTERVAL_LIVE); setMinWidthAuto(true);
float ratio = -1; DownloadManager dm = (DownloadManager)cell.getDataSource(); if( dm != null ) { TRTrackerScraperResponse response = dm.getTrackerScrapeResponse(); int seeds; int peers; if( response != null && response.isValid() ) { seeds = Math.max( dm.getNbSeeds(), response.getSeeds() ); int trackerPeerCount = response.getPeers(); peers = dm.getNbPeers(); if (peers == 0 || trackerPeerCount > peers) { if (trackerPeerCount <= 0) { peers = dm.getActivationCount(); } else { peers = trackerPeerCount; } } } else { seeds = dm.getNbSeeds(); peers = dm.getNbPeers(); } if (peers < 0 || seeds < 0) { ratio = 0; } else { if (peers == 0) { if (seeds == 0) ratio = 0; else ratio = Float.POSITIVE_INFINITY; } else { ratio = (float)seeds / peers; } } } if( !cell.setSortValue( ratio ) && cell.isValid() ) { return; } if (ratio == -1) { cell.setText(""); } else if (ratio == 0) { cell.setText("??"); } else { cell.setText(DisplayFormatters.formatDecimal(ratio, 3)); }