working on txt import

This commit is contained in:
mwang 2019-03-05 18:45:13 +08:00
parent ba0dfc5ba6
commit 0249ac4119
2 changed files with 14 additions and 11 deletions

View File

@ -105,8 +105,8 @@ public class BookUtil {
break;
}
char wordChar = (char) word;
if ((wordChar + "").equals("\r") ){// if ((wordChar + "").equals("\r") && (((char)next(true)) + "").equals("\n")){
next(false);
if ((wordChar + "").equals("\n") ){// if ((wordChar + "").equals("\r") && (((char)next(true)) + "").equals("\n")){
// next(false);
break;
}
line += wordChar;

View File

@ -502,11 +502,11 @@ public class PageFactory {
mBookUtil.setPostition(currentPage.getEnd());
TRPage trPage = new TRPage();
trPage.setBegin(currentPage.getEnd() -1);
trPage.setBegin(currentPage.getEnd() +1);
Log.e(TAG,"page postion next begin:" + (currentPage.getEnd() + 1) + "");
trPage.setLines(getNextLines());
Log.e(TAG,"page postion next end:" +mBookUtil.getPosition() + "");
trPage.setEnd(mBookUtil.getPosition()-1);
trPage.setEnd(mBookUtil.getPosition());
return trPage;
}
@ -514,11 +514,11 @@ public class PageFactory {
mBookUtil.setPostition(currentPage.getBegin());
TRPage trPage = new TRPage();
trPage.setEnd(mBookUtil.getPosition() - 1);
trPage.setEnd(mBookUtil.getPosition() -1);
Log.e(TAG,"page postion pre end:" + (mBookUtil.getPosition() - 1 )+ "");
trPage.setLines(getPreLines());
Log.e(TAG,"page postion pre begin:" +mBookUtil.getPosition() + "");
trPage.setBegin(mBookUtil.getPosition());
trPage.setBegin(mBookUtil.getPosition() );
return trPage;
}
@ -542,7 +542,7 @@ public class PageFactory {
char word = (char) mBookUtil.next(false);
//判断是否换行
if ((word + "" ).equals("\n") ){// if ((word + "" ).equals("\r") && (((char) mBookUtil.next(true)) + "").equals("\n")){
mBookUtil.next(false);
// mBookUtil.next(false);
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() ));
@ -564,11 +564,12 @@ public class PageFactory {
if (width > mVisibleWidth) {
width = widthChar;
lines.add(line);
if (lines.size() == mLineCount){
/* if (lines.size() == mLineCount){
Log.e(TAG,String.format("lines count limit b %s,lines size %s",mLineCount,lines.size()));
line ="";
break;
}
*/
line = word + "";
} else {
line += word;
@ -578,18 +579,20 @@ public class PageFactory {
if (lines.size() == mLineCount){
Log.e(TAG,String.format("lines count limit c %s,lines size %s",mLineCount,lines.size()));
if (!line.isEmpty()){
mBookUtil.setPostition(mBookUtil.getPosition() - line.length()-2);// mBookUtil.setPostition(mBookUtil.getPosition() - 1);
// mBookUtil.setPostition(mBookUtil.getPosition() - line.length()-2);// mBookUtil.setPostition(mBookUtil.getPosition() - 1);
mBookUtil.setPostition(mBookUtil.getPosition() - 1);
}
break;
}
}
/*
if (lines.size() == mLineCount) {
Log.e(TAG, String.format("lines count limit d %s,lines size %s", mLineCount, lines.size()));
Log.e(TAG, String.format("lines count limit d %s,line is \n %s", mLineCount, line));
if (!line.isEmpty()) {
mBookUtil.setPostition(mBookUtil.getPosition() - line.length() - 2);// mBookUtil.setPostition(mBookUtil.getPosition() - 1);
}
}
}*/
if (!line.isEmpty() && lines.size() < mLineCount){
@ -597,7 +600,7 @@ public class PageFactory {
lines.add(line);
}else
{
mBookUtil.setPostition(mBookUtil.getPosition() - line.length()-2);
// mBookUtil.setPostition(mBookUtil.getPosition() - line.length()-2);
}
// lines.add(line);
}