* fix episode number padding
This commit is contained in:
parent
c8303655bf
commit
3689f65612
|
@ -2,7 +2,6 @@
|
||||||
package net.sourceforge.filebot.ui.panel.list;
|
package net.sourceforge.filebot.ui.panel.list;
|
||||||
|
|
||||||
|
|
||||||
import static java.lang.Math.log;
|
|
||||||
import static java.lang.Math.max;
|
import static java.lang.Math.max;
|
||||||
import static java.lang.Math.min;
|
import static java.lang.Math.min;
|
||||||
import static java.lang.Math.signum;
|
import static java.lang.Math.signum;
|
||||||
|
@ -113,7 +112,7 @@ public class ListPanel extends FileBotPanel {
|
||||||
|
|
||||||
// pad episode numbers with zeros (e.g. %02d) so all episode numbers have the same number of digits
|
// pad episode numbers with zeros (e.g. %02d) so all episode numbers have the same number of digits
|
||||||
NumberFormat numberFormat = NumberFormat.getIntegerInstance();
|
NumberFormat numberFormat = NumberFormat.getIntegerInstance();
|
||||||
numberFormat.setMinimumIntegerDigits(max(2, (int) (log(max(from, to)) / log(10))));
|
numberFormat.setMinimumIntegerDigits(max(2, Integer.toString(max(from, to)).length()));
|
||||||
numberFormat.setGroupingUsed(false);
|
numberFormat.setGroupingUsed(false);
|
||||||
|
|
||||||
List<String> names = new ArrayList<String>();
|
List<String> names = new ArrayList<String>();
|
||||||
|
|
|
@ -87,10 +87,10 @@ public class Episode implements Serializable {
|
||||||
// find max. episode number length
|
// find max. episode number length
|
||||||
for (Episode episode : episodes) {
|
for (Episode episode : episodes) {
|
||||||
try {
|
try {
|
||||||
int n = Integer.parseInt(episode.getEpisodeNumber());
|
String episodeNumber = episode.getEpisodeNumber();
|
||||||
|
|
||||||
if (n > 0) {
|
if (episodeNumber.length() > minDigits && Integer.parseInt(episodeNumber) > 0) {
|
||||||
minDigits = Math.max(minDigits, (int) (Math.log(n) / Math.log(10)));
|
minDigits = episodeNumber.length();
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
// ignore
|
// ignore
|
||||||
|
|
Loading…
Reference in New Issue