working on txt import
This commit is contained in:
parent
0c77fe2756
commit
37e87afbbe
|
@ -126,12 +126,13 @@ public class BookUtil {
|
|||
}
|
||||
char wordChar = (char) word;
|
||||
if ((wordChar + "").equals("\n") ){ // if ((wordChar + "").equals("\n") && (((char)pre(true)) + "").equals("\r")){
|
||||
pre(false);
|
||||
// pre(false); // /r/n ->/n 不需要再往前读一个字符了
|
||||
// line = "\r\n" + line;
|
||||
break;
|
||||
}
|
||||
line = wordChar + line;
|
||||
}
|
||||
|
||||
return line.toCharArray();
|
||||
}
|
||||
|
||||
|
|
|
@ -390,7 +390,13 @@ public class PageFactory {
|
|||
cancelPage = currentPage;
|
||||
onDraw(mBookPageWidget.getCurPage(),currentPage.getLines(),true);
|
||||
currentPage = getPrePage();
|
||||
onDraw(mBookPageWidget.getNextPage(),currentPage.getLines(),true);
|
||||
onDraw(mBookPageWidget.getNextPage(),currentPage.getLines(),true);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//向后翻页
|
||||
|
@ -526,6 +532,7 @@ public class PageFactory {
|
|||
return trPage;
|
||||
}
|
||||
|
||||
boolean showChapTitleOnTopWhenNextPage =false;
|
||||
public List<String> getNextLines(){
|
||||
List<String> lines = new ArrayList<>();
|
||||
float width = 0;
|
||||
|
@ -536,10 +543,10 @@ public class PageFactory {
|
|||
//判断是否换行
|
||||
if ((word + "" ).equals("\n") ){// if ((word + "" ).equals("\r") && (((char) mBookUtil.next(true)) + "").equals("\n")){
|
||||
mBookUtil.next(false);
|
||||
if (!line.isEmpty()){
|
||||
if (mBookUtil.isChapterTitle(line)) {
|
||||
if ( !line.isEmpty()){
|
||||
if (showChapTitleOnTopWhenNextPage && lines.size() >0 && mBookUtil.isChapterTitle(line)) {
|
||||
Log.e(TAG,String.format("title is %s\n,size is %s ,position is %s" ,line,line.length(),mBookUtil.getPosition() ));
|
||||
// break;
|
||||
break;
|
||||
}
|
||||
lines.add(line);
|
||||
line = "";
|
||||
|
@ -554,9 +561,6 @@ public class PageFactory {
|
|||
width += widthChar;
|
||||
if (width > mVisibleWidth) {
|
||||
width = widthChar;
|
||||
if (mBookUtil.isChapterTitle(line)) {
|
||||
// break;
|
||||
}
|
||||
lines.add(line);
|
||||
line = word + "";
|
||||
} else {
|
||||
|
@ -573,13 +577,14 @@ public class PageFactory {
|
|||
}
|
||||
|
||||
if (!line.isEmpty() && lines.size() < mLineCount){
|
||||
/* if (!mBookUtil.isChapterTitle(line)) {
|
||||
|
||||
if (!(showChapTitleOnTopWhenNextPage && mBookUtil.isChapterTitle(line) ) ) {
|
||||
lines.add(line);
|
||||
}else
|
||||
{
|
||||
mBookUtil.setPostition(mBookUtil.getPosition() - line.length());
|
||||
}*/
|
||||
lines.add(line);
|
||||
mBookUtil.setPostition(mBookUtil.getPosition() - line.length()-2);
|
||||
}
|
||||
// lines.add(line);
|
||||
}
|
||||
//for (String str : lines){
|
||||
// Log.e(TAG,str + " ");
|
||||
|
@ -606,7 +611,17 @@ public class PageFactory {
|
|||
} else {
|
||||
line += word;
|
||||
}
|
||||
// Log.e(TAG,"preLine is \n" + line);
|
||||
}
|
||||
|
||||
/* if ( mBookUtil.isChapterTitle(line)) {
|
||||
|
||||
mBookUtil.setPostition(mBookUtil.getPosition() - line.length()-2);
|
||||
break;
|
||||
}*/
|
||||
// lines.add(line);
|
||||
|
||||
// Log.e(TAG,"preLine is \n" + line);
|
||||
if (!line.isEmpty()){
|
||||
preLines.add(line);
|
||||
}
|
||||
|
@ -634,7 +649,7 @@ public class PageFactory {
|
|||
|
||||
if (num > 0){
|
||||
if ( mBookUtil.getPosition() > 0) {
|
||||
mBookUtil.setPostition(mBookUtil.getPosition() + num + 2);
|
||||
mBookUtil.setPostition(mBookUtil.getPosition() + num + 1);//mBookUtil.setPostition(mBookUtil.getPosition() + num + 2); // /r/n -> /n,只需要回退1个字符
|
||||
}else{
|
||||
mBookUtil.setPostition(mBookUtil.getPosition() + num );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue