Skip to content

Commit

Permalink
Fixed ratio parsing, hide ratio if it's 0
Browse files Browse the repository at this point in the history
  • Loading branch information
DSteve595 committed Aug 5, 2014
1 parent 1b230f2 commit 0e6d2d6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ public class PutioTransferLayout implements Parcelable {
public String name;
public long downSpeed;
public long upSpeed;
public float ratio;
public String ratio;
public int percentDone;
public String status;

public PutioTransferLayout(PutioTransferData data) {
name = data.name;
downSpeed = data.downSpeed;
upSpeed = data.upSpeed;
ratio = data.ratio;
ratio = data.currentRatio;
percentDone = data.percentDone;
status = data.status;
}
Expand All @@ -35,7 +35,7 @@ private void readFromParcel(Parcel in) {
this.name = in.readString();
this.downSpeed = in.readLong();
this.upSpeed = in.readLong();
this.ratio = in.readFloat();
this.ratio = in.readString();
this.percentDone = in.readInt();
this.status = in.readString();
}
Expand All @@ -45,7 +45,7 @@ public void writeToParcel(Parcel out, int flags) {
out.writeString(this.name);
out.writeLong(this.downSpeed);
out.writeLong(this.upSpeed);
out.writeFloat(this.ratio);
out.writeString(this.ratio);
out.writeInt(this.percentDone);
out.writeString(this.status);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,12 @@ public View getView(int position, View convertView, ViewGroup parent) {
holder.textMessage.setVisibility(View.GONE);
holder.downHolder.setVisibility(View.GONE);
holder.upHolder.setVisibility(View.VISIBLE);
holder.ratioHolder.setVisibility(View.VISIBLE);
holder.textRatio.setText(getContext().getString(R.string.ratio_is, String.valueOf(transfer.ratio)));
if (Float.valueOf(transfer.ratio) != 0) {
holder.textRatio.setText(getContext().getString(R.string.ratio_is, transfer.ratio));
holder.ratioHolder.setVisibility(View.VISIBLE);
} else {
holder.ratioHolder.setVisibility(View.GONE);
}
holder.textPercent.setText(percentString + "%");
holder.greenBar.setBackgroundColor(Color.parseColor("#2000FF00"));
holder.greenBar.setPivotX(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class PutioTransferData implements Parcelable {
public String estimatedTime;
public String createdTime;
public boolean extract;
public float ratio;
public String currentRatio;
public long downSpeed;
public long upSpeed;
public int percentDone;
Expand All @@ -36,7 +36,7 @@ private void readFromParcel(Parcel in) {
this.estimatedTime = in.readString();
this.createdTime = in.readString();
this.extract = (Boolean) in.readValue(ClassLoader.getSystemClassLoader());
this.ratio = in.readFloat();
this.currentRatio = in.readString();
this.downSpeed = in.readLong();
this.upSpeed = in.readLong();
this.percentDone = in.readInt();
Expand All @@ -54,7 +54,7 @@ public void writeToParcel(Parcel out, int flags) {
out.writeString(this.estimatedTime);
out.writeString(this.createdTime);
out.writeValue(this.extract);
out.writeFloat(this.ratio);
out.writeString(this.currentRatio);
out.writeLong(this.downSpeed);
out.writeLong(this.upSpeed);
out.writeInt(this.percentDone);
Expand Down

0 comments on commit 0e6d2d6

Please sign in to comment.