@ -9,14 +9,13 @@ import android.content.Context;
@@ -9,14 +9,13 @@ import android.content.Context;
import android.view.View ;
import android.widget.ImageView ;
import android.widget.TextView ;
import fr.marvinlabs.widget.CheckableRelativeLayout ;
/ * *
* View that represents some { @link Torrent } object and displays progress , status , speeds , etc .
* @author Eric Kok
* /
@EViewGroup ( resName = "list_item_torrent" )
public class TorrentView extends CheckableRelative Layout {
@EViewGroup ( resName = "list_item_torrent2 " )
public class TorrentView extends TorrentStatus Layout {
@ViewById
protected ImageView priorityImage ;
@ -31,16 +30,29 @@ public class TorrentView extends CheckableRelativeLayout {
@@ -31,16 +30,29 @@ public class TorrentView extends CheckableRelativeLayout {
public void bind ( Torrent torrent ) {
LocalTorrent local = LocalTorrent . fromTorrent ( torrent ) ;
setStatus ( torrent . getStatusCode ( ) ) ;
nameText . setText ( torrent . getName ( ) ) ;
ratioText . setText ( local . getProgressEtaRatioText ( getResources ( ) ) ) ;
progressText . setText ( local . getProgressSizeText ( getResources ( ) , false ) ) ;
speedText . setText ( local . getProgressSpeedText ( getResources ( ) ) ) ;
peersText . setText ( local . getProgressConnectionText ( getResources ( ) ) ) ;
torrentProgressbar . setProgress ( ( int ) ( torrent . getDownloadedPercentage ( ) * 100 ) ) ;
torrentProgressbar . setActive ( torrent . canPause ( ) ) ; ;
torrentProgressbar . setError ( torrent . getStatusCode ( ) = = TorrentStatus . Error ) ;
ratioText . setText ( local . getProgressEtaRatioText ( getResources ( ) ) ) ;
// TODO: Implement per-torrent priority and set priorityImage
priorityImage . setVisibility ( View . INVISIBLE ) ;
// Only show status bar, peers and speed fields if relevant, i.e. when downloading or actively seeding
if ( torrent . getStatusCode ( ) = = TorrentStatus . Downloading
| | ( torrent . getStatusCode ( ) = = TorrentStatus . Seeding & & torrent . getRateUpload ( ) > 0 ) ) {
torrentProgressbar . setVisibility ( View . VISIBLE ) ;
torrentProgressbar . setProgress ( ( int ) ( torrent . getDownloadedPercentage ( ) * 100 ) ) ;
torrentProgressbar . setActive ( torrent . canPause ( ) ) ;
torrentProgressbar . setError ( torrent . getStatusCode ( ) = = TorrentStatus . Error ) ;
peersText . setVisibility ( View . VISIBLE ) ;
peersText . setText ( local . getProgressConnectionText ( getResources ( ) ) ) ;
speedText . setVisibility ( View . VISIBLE ) ;
speedText . setText ( local . getProgressSpeedText ( getResources ( ) ) ) ;
} else {
torrentProgressbar . setVisibility ( View . GONE ) ;
peersText . setVisibility ( View . GONE ) ;
speedText . setVisibility ( View . GONE ) ;
}
}
}