|
|
@ -35,12 +35,18 @@ public class Label implements SimpleListItem, NavigationFilter, Comparable<Label |
|
|
|
|
|
|
|
|
|
|
|
private static String unnamedLabelText = null; |
|
|
|
private static String unnamedLabelText = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final boolean isEmptyLabel; |
|
|
|
private final String name; |
|
|
|
private final String name; |
|
|
|
private final int count; |
|
|
|
private final int count; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Label(String name, int count, boolean isEmptyLabel) { |
|
|
|
|
|
|
|
this.name = name; |
|
|
|
|
|
|
|
this.count = count; |
|
|
|
|
|
|
|
this.isEmptyLabel = isEmptyLabel; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Label(org.transdroid.daemon.Label daemonLabel) { |
|
|
|
public Label(org.transdroid.daemon.Label daemonLabel) { |
|
|
|
this.name = daemonLabel.getName(); |
|
|
|
this(daemonLabel.getName(), daemonLabel.getCount(), false); |
|
|
|
this.count = daemonLabel.getCount(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -54,11 +60,17 @@ public class Label implements SimpleListItem, NavigationFilter, Comparable<Label |
|
|
|
return count; |
|
|
|
return count; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isEmptyLabel() { |
|
|
|
|
|
|
|
return isEmptyLabel; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns true if the torrent label's name matches this (selected) label's name, false otherwise |
|
|
|
* Returns true if the torrent label's name matches this (selected) label's name, false otherwise |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean matches(Torrent torrent) { |
|
|
|
public boolean matches(Torrent torrent) { |
|
|
|
|
|
|
|
if (isEmptyLabel) |
|
|
|
|
|
|
|
return TextUtils.isEmpty(torrent.getLabelName()); |
|
|
|
return torrent.getLabelName() != null && torrent.getLabelName().equals(name); |
|
|
|
return torrent.getLabelName() != null && torrent.getLabelName().equals(name); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -78,8 +90,9 @@ public class Label implements SimpleListItem, NavigationFilter, Comparable<Label |
|
|
|
String unnamedLabel) { |
|
|
|
String unnamedLabel) { |
|
|
|
if (daemonLabels == null) |
|
|
|
if (daemonLabels == null) |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
unnamedLabelText = unnamedLabel; |
|
|
|
|
|
|
|
ArrayList<Label> localLabels = new ArrayList<Label>(); |
|
|
|
ArrayList<Label> localLabels = new ArrayList<Label>(); |
|
|
|
|
|
|
|
unnamedLabelText = unnamedLabel; |
|
|
|
|
|
|
|
localLabels.add(new Label(unnamedLabel, -1, true)); |
|
|
|
for (org.transdroid.daemon.Label label : daemonLabels) { |
|
|
|
for (org.transdroid.daemon.Label label : daemonLabels) { |
|
|
|
localLabels.add(new Label(label)); |
|
|
|
localLabels.add(new Label(label)); |
|
|
|
} |
|
|
|
} |
|
|
@ -90,6 +103,7 @@ public class Label implements SimpleListItem, NavigationFilter, Comparable<Label |
|
|
|
private Label(Parcel in) { |
|
|
|
private Label(Parcel in) { |
|
|
|
this.name = in.readString(); |
|
|
|
this.name = in.readString(); |
|
|
|
this.count = in.readInt(); |
|
|
|
this.count = in.readInt(); |
|
|
|
|
|
|
|
this.isEmptyLabel = in.readInt() == 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static final Parcelable.Creator<Label> CREATOR = new Parcelable.Creator<Label>() { |
|
|
|
public static final Parcelable.Creator<Label> CREATOR = new Parcelable.Creator<Label>() { |
|
|
@ -111,6 +125,7 @@ public class Label implements SimpleListItem, NavigationFilter, Comparable<Label |
|
|
|
public void writeToParcel(Parcel dest, int flags) { |
|
|
|
public void writeToParcel(Parcel dest, int flags) { |
|
|
|
dest.writeString(name); |
|
|
|
dest.writeString(name); |
|
|
|
dest.writeInt(count); |
|
|
|
dest.writeInt(count); |
|
|
|
|
|
|
|
dest.writeInt(isEmptyLabel? 1: 0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|