|
|
@ -9,14 +9,13 @@ import android.content.Context; |
|
|
|
import android.view.View; |
|
|
|
import android.view.View; |
|
|
|
import android.widget.ImageView; |
|
|
|
import android.widget.ImageView; |
|
|
|
import android.widget.TextView; |
|
|
|
import android.widget.TextView; |
|
|
|
import fr.marvinlabs.widget.CheckableRelativeLayout; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* View that represents some {@link Torrent} object and displays progress, status, speeds, etc. |
|
|
|
* View that represents some {@link Torrent} object and displays progress, status, speeds, etc. |
|
|
|
* @author Eric Kok |
|
|
|
* @author Eric Kok |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@EViewGroup(resName="list_item_torrent") |
|
|
|
@EViewGroup(resName = "list_item_torrent2") |
|
|
|
public class TorrentView extends CheckableRelativeLayout { |
|
|
|
public class TorrentView extends TorrentStatusLayout { |
|
|
|
|
|
|
|
|
|
|
|
@ViewById |
|
|
|
@ViewById |
|
|
|
protected ImageView priorityImage; |
|
|
|
protected ImageView priorityImage; |
|
|
@ -31,16 +30,29 @@ public class TorrentView extends CheckableRelativeLayout { |
|
|
|
|
|
|
|
|
|
|
|
public void bind(Torrent torrent) { |
|
|
|
public void bind(Torrent torrent) { |
|
|
|
LocalTorrent local = LocalTorrent.fromTorrent(torrent); |
|
|
|
LocalTorrent local = LocalTorrent.fromTorrent(torrent); |
|
|
|
|
|
|
|
setStatus(torrent.getStatusCode()); |
|
|
|
nameText.setText(torrent.getName()); |
|
|
|
nameText.setText(torrent.getName()); |
|
|
|
ratioText.setText(local.getProgressEtaRatioText(getResources())); |
|
|
|
|
|
|
|
progressText.setText(local.getProgressSizeText(getResources(), false)); |
|
|
|
progressText.setText(local.getProgressSizeText(getResources(), false)); |
|
|
|
speedText.setText(local.getProgressSpeedText(getResources())); |
|
|
|
ratioText.setText(local.getProgressEtaRatioText(getResources())); |
|
|
|
peersText.setText(local.getProgressConnectionText(getResources())); |
|
|
|
|
|
|
|
torrentProgressbar.setProgress((int) (torrent.getDownloadedPercentage() * 100)); |
|
|
|
|
|
|
|
torrentProgressbar.setActive(torrent.canPause());; |
|
|
|
|
|
|
|
torrentProgressbar.setError(torrent.getStatusCode() == TorrentStatus.Error); |
|
|
|
|
|
|
|
// TODO: Implement per-torrent priority and set priorityImage
|
|
|
|
// TODO: Implement per-torrent priority and set priorityImage
|
|
|
|
priorityImage.setVisibility(View.INVISIBLE); |
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|