diff --git a/zhuike/src/main/java/com/deiniu/zhuike/utils/PageFactory.java b/zhuike/src/main/java/com/deiniu/zhuike/utils/PageFactory.java index 1ead020..996db07 100644 --- a/zhuike/src/main/java/com/deiniu/zhuike/utils/PageFactory.java +++ b/zhuike/src/main/java/com/deiniu/zhuike/utils/PageFactory.java @@ -71,6 +71,8 @@ public class PageFactory { private float lineSpace; //段间距 private float paragraphSpace; + //段间距相对行间距的倍数 + private final float prate = 1.3f; //字高度 private float fontHeight; //字体 @@ -165,12 +167,12 @@ public class PageFactory { while(length 0) { float y = marginHeight; for (String strLine : m_lines) { // if(strLine.endsWith("\n")) { // if(strLine.charAt(strLine.length()-1) == ('\n' )) { - // Log.e("TAG", strLine); - // Log.e("TAG","最后字符 。。。" +strLine.charAt(strLine.length()-1) + ""); + // Log.d("TAG", strLine); + // Log.d("TAG","最后字符 。。。" +strLine.charAt(strLine.length()-1) + ""); if(( strLine.charAt(strLine.length()-1) + "" ).equals("\n")){ strLine =strLine.replace("\n",""); y += space; space =m_fontSize + paragraphSpace; - Log.e("TAG",String.format("开始新段落 %s, y plus is %s" ,strLine, m_fontSize + paragraphSpace)); + Log.d("TAG",String.format("开始新段落 %s, y plus is %s" ,strLine, m_fontSize + paragraphSpace)); }else{ y += space; space =m_fontSize + lineSpace; - Log.e("TAG",String.format("%s,y plus is %s" ,strLine, m_fontSize + lineSpace)); + Log.d("TAG",String.format("%s,y plus is %s" ,strLine, m_fontSize + lineSpace)); } c.drawText(strLine, measureMarginWidth, y, mPaint); // word.append(strLine); @@ -446,7 +449,7 @@ public class PageFactory { //向前翻页 public void prePage(){ if (currentPage.getBegin() <= 0) { - Log.e(TAG,"当前是本章第一页"); + Log.d(TAG,"当前是本章第一页"); m_isfirstPage =currentChapter ==1; if ( m_isfirstPage){ Toast.makeText(mContext, "当前是第一页", Toast.LENGTH_SHORT).show(); @@ -464,7 +467,7 @@ public class PageFactory { //向后翻页 public void nextPage(){ if (currentPage.getEnd() >= mBookUtil.getBookLen()) { - Log.e(TAG,"已经是本章最后一页了"); + Log.d(TAG,"已经是本章最后一页了"); m_islastPage =currentChapter == mBookUtil.getDirectoryList().size(); if ( m_islastPage){ @@ -481,7 +484,7 @@ public class PageFactory { currentPage = getNextPage(); // currentPage = currentChaptPages.get(currentPage.getPageNo()-1); onDraw(mBookPageWidget.getNextPage(),currentPage.getLines(),true); - Log.e("nextPage","nextPagenext"); + Log.d("nextPage","nextPagenext"); } //取消翻页 @@ -520,7 +523,7 @@ public class PageFactory { @Override protected void onPostExecute(Boolean result) { super.onPostExecute(result); - Log.e("onPostExecute",isCancelled() + ""); + Log.d("onPostExecute",isCancelled() + ""); if (isCancelled()){ return; } @@ -575,9 +578,9 @@ public class PageFactory { TRPage trPage = new TRPage(); trPage.setBegin(currentPage.getEnd() +1); - Log.e(TAG,"page postion next begin:" + (currentPage.getEnd() + 1) + ""); + Log.d(TAG,"page postion next begin:" + (currentPage.getEnd() + 1) + ""); trPage.setLines(getNextLines()); - Log.e(TAG,"page postion next end:" +mBookUtil.getPosition() + ""); + Log.d(TAG,"page postion next end:" +mBookUtil.getPosition() + ""); trPage.setEnd(mBookUtil.getPosition()); return trPage; */ @@ -598,9 +601,9 @@ public class PageFactory { TRPage trPage = new TRPage(); trPage.setEnd(mBookUtil.getPosition() -1); - Log.e(TAG,"page postion pre end:" + (mBookUtil.getPosition() - 1 )+ ""); + Log.d(TAG,"page postion pre end:" + (mBookUtil.getPosition() - 1 )+ ""); trPage.setLines(getPreLines()); - Log.e(TAG,"page postion pre begin:" +mBookUtil.getPosition() + ""); + Log.d(TAG,"page postion pre begin:" +mBookUtil.getPosition() + ""); trPage.setBegin(mBookUtil.getPosition() ); return trPage; */ @@ -657,7 +660,7 @@ public class PageFactory { // 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() )); + Log.d(TAG,String.format("title is %s\n,size is %s ,position is %s" ,line,line.length(),mBookUtil.getPosition() )); break; } lines.add(line+word); @@ -667,7 +670,7 @@ public class PageFactory { height += paragraphSpace - lineSpace; calculateLineCount(height); if (lines.size()>= mLineCount){ - Log.e(TAG,String.format("lines count limit a %s,lines size %s",mLineCount,lines.size())); + Log.d(TAG,String.format("lines count limit a %s,lines size %s",mLineCount,lines.size())); line =""; break; } @@ -679,7 +682,7 @@ public class PageFactory { width = widthChar; lines.add(line); /* if (lines.size() == mLineCount){ - Log.e(TAG,String.format("lines count limit b %s,lines size %s",mLineCount,lines.size())); + Log.d(TAG,String.format("lines count limit b %s,lines size %s",mLineCount,lines.size())); line =""; break; } @@ -691,7 +694,7 @@ public class PageFactory { } if (lines.size() == mLineCount){ - Log.e(TAG,String.format("lines count limit c %s,lines size %s",mLineCount,lines.size())); + Log.d(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() - 1); @@ -701,8 +704,8 @@ public class PageFactory { } /* 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)); + Log.d(TAG, String.format("lines count limit d %s,lines size %s", mLineCount, lines.size())); + Log.d(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); } @@ -719,7 +722,7 @@ public class PageFactory { // lines.add(line); } for (String str : lines){ - Log.e(TAG,str + " "); + Log.d(TAG,str + " "); } return lines; } @@ -743,7 +746,7 @@ public class PageFactory { } else { line += word; } -// Log.e(TAG,"preLine is \n" + line); +// Log.d(TAG,"preLine is \n" + line); } /* if ( mBookUtil.isChapterTitle(line)) { @@ -753,7 +756,7 @@ public class PageFactory { }*/ // lines.add(line); - // Log.e(TAG,"preLine is \n" + line); + // Log.d(TAG,"preLine is \n" + line); if (!line.isEmpty()){ preLines.add(line); } @@ -776,7 +779,7 @@ public class PageFactory { }else{ num = num + lines.get(i).length(); } - Log.e(TAG,lines.get(i) + " "); + Log.d(TAG,lines.get(i) + " "); } if (num > 0){