* limit {t} binding to 150 chars
This commit is contained in:
parent
6613ebe67d
commit
2f0fada72a
|
@ -134,9 +134,12 @@ public class MediaBindingBean {
|
||||||
return getMusic().getTrackTitle() != null ? getMusic().getTrackTitle() : getMusic().getTitle();
|
return getMusic().getTrackTitle() != null ? getMusic().getTrackTitle() : getMusic().getTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// enforce title length limit by default
|
||||||
|
int limit = 150;
|
||||||
|
|
||||||
// single episode format
|
// single episode format
|
||||||
if (getEpisodes().size() == 1) {
|
if (getEpisodes().size() == 1) {
|
||||||
return getEpisode().getTitle();
|
return truncateText(getEpisode().getTitle(), limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
// multi-episode format
|
// multi-episode format
|
||||||
|
@ -144,7 +147,7 @@ public class MediaBindingBean {
|
||||||
for (Episode it : getEpisodes()) {
|
for (Episode it : getEpisodes()) {
|
||||||
title.add(removeTrailingBrackets(it.getTitle()));
|
title.add(removeTrailingBrackets(it.getTitle()));
|
||||||
}
|
}
|
||||||
return join(title, " & ");
|
return truncateText(join(title, " & "), limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Define("d")
|
@Define("d")
|
||||||
|
@ -911,4 +914,22 @@ public class MediaBindingBean {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String truncateText(String title, int limit) {
|
||||||
|
if (title.length() < limit) {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] words = title.split("\\s+");
|
||||||
|
StringBuilder s = new StringBuilder();
|
||||||
|
|
||||||
|
for (int i = 0; i < words.length && s.length() + words[i].length() < limit; i++) {
|
||||||
|
if (i > 0) {
|
||||||
|
s.append(' ');
|
||||||
|
}
|
||||||
|
s.append(words[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.toString().trim();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue