Skip to content

Commit

Permalink
update: positionInChapter=0 when next chapter
Browse files Browse the repository at this point in the history
  • Loading branch information
muedsa committed Nov 26, 2021
1 parent bbe0a0c commit 0c47abb
Showing 1 changed file with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ private void setTextContent(){
textContent.setText(text);
noBlankChapterText = text.replaceAll("\\s*", "");
textContent.setCaretPosition(0);
positionInChapter = 0;
}
}

Expand All @@ -370,12 +371,7 @@ public String nextLine(){
int lineSize = (int)lineSizeSpinner.getValue();
if(lineSize > 0){
if(StringUtils.isEmpty(noBlankChapterText) || positionInChapter > noBlankChapterText.length()){
if(nextChapter()){
positionInChapter = 0;
noBlankChapterText = textContent.getText();
}else{
return "end!";
}
nextChapter();
}
String line = StringUtils.mid(noBlankChapterText, positionInChapter, lineSize);
positionInChapter += lineSize;
Expand All @@ -390,15 +386,12 @@ public String nextLine(){
}
}

private boolean nextChapter(){
private void nextChapter(){
int count = titleList.getItemsCount();
int index = titleList.getSelectedIndex() + 1;
if(index + 1 <= count){
titleList.setSelectedIndex(index);
setTextContent();
return true;
}else{
return false;
}
}
}

0 comments on commit 0c47abb

Please sign in to comment.