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; break;
} }
char wordChar = (char) word; char wordChar = (char) word;
if ((wordChar + "").equals("\r") ){// if ((wordChar + "").equals("\r") && (((char)next(true)) + "").equals("\n")){ if ((wordChar + "").equals("\n") ){// if ((wordChar + "").equals("\r") && (((char)next(true)) + "").equals("\n")){
next(false); // next(false);
break; break;
} }
line += wordChar; line += wordChar;

View File

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