Remove Redundant Flip Section

This commit is contained in:
Olof Larsson 2015-09-08 17:00:36 +02:00
parent cfda6796e4
commit a364395042

View File

@ -541,18 +541,12 @@ public class Txt
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static List<Mson> getPage(List<?> lines, int pageHumanBased, String title, int pageheight, MassiveCommand command, List<String> args) public static List<Mson> getPage(List<?> lines, int pageHumanBased, String title, int pageheight, MassiveCommand command, List<String> args)
{ {
// Check if command is present // Create Ret
boolean flipPage = command != null; List<Mson> ret = new ArrayList<Mson>();
// If command is present, reduce pageheight in favor of flipsection
if (flipPage) pageheight--;
// Create ret
ArrayList<Mson> ret = new ArrayList<Mson>();
int pageZeroBased = pageHumanBased - 1; int pageZeroBased = pageHumanBased - 1;
int pagecount = (int)Math.ceil(((double)lines.size()) / pageheight); int pagecount = (int)Math.ceil(((double)lines.size()) / pageheight);
// Add title // Add Title
Mson msonTitle = Txt.titleizeMson(title, pagecount, pageHumanBased, command, args); Mson msonTitle = Txt.titleizeMson(title, pagecount, pageHumanBased, command, args);
ret.add(msonTitle); ret.add(msonTitle);
@ -568,7 +562,7 @@ public class Txt
return ret; return ret;
} }
// Get lines // Get Lines
int from = pageZeroBased * pageheight; int from = pageZeroBased * pageheight;
int to = from + pageheight; int to = from + pageheight;
if (to > lines.size()) if (to > lines.size())
@ -595,10 +589,7 @@ public class Txt
throw new IllegalArgumentException("The lines must be either String or Mson."); throw new IllegalArgumentException("The lines must be either String or Mson.");
} }
// Add flipsection if command is present // Return Ret
if (flipPage) ret.add(getFlipSection(pagecount, pageHumanBased, args, command));
// Return ret
return ret; return ret;
} }