
com.marvinlabs.widget.floatinglabel.itempicker.ItemPrinter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of android-floatinglabel-widgets Show documentation
Show all versions of android-floatinglabel-widgets Show documentation
A set of input widgets to show a floating label when not empty.
The newest version!
package com.marvinlabs.widget.floatinglabel.itempicker;
import java.util.Collection;
/**
* Created by Vincent Mimoun-Prat @ MarvinLabs, 29/08/2014.
*/
public interface ItemPrinter {
public String print(ItemT item);
public String printCollection(Collection items);
public static class ToStringItemPrinter implements ItemPrinter {
public String print(ItemT item) {
return item==null ? "" : item.toString();
}
public String printCollection(Collection items) {
if (items.size() == 0) return "";
StringBuilder sb = new StringBuilder();
boolean prependSeparator = false;
for (ItemT item : items) {
if (prependSeparator) {
sb.append(", ");
} else {
prependSeparator = true;
}
sb.append(print(item));
}
return sb.toString();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy