From 7e820840febaaafea2402fda19a82caa4b375dd9 Mon Sep 17 00:00:00 2001 From: mwang <8205347@qq.com> Date: Sun, 14 Jul 2019 23:18:28 +0800 Subject: [PATCH] bug fix --- .../novelbook/android/Activity_Search.java | 4 +- .../android/Fragments/BasicFragment.java | 6 +-- .../android/Fragments/Fragment_Shelf.java | 34 +++++++++----- .../android/Fragments/Fragment_booklist.java | 25 +++++++++-- .../android/Fragments/Fragment_paihang.java | 25 +++++++++-- .../android/adapter/BookListAdapter.java | 28 +++++++++++- .../android/adapter/MyViewHolder.java | 4 +- .../com/novelbook/android/bean/AdSetting.java | 6 +-- .../java/com/novelbook/android/db/Novel.java | 24 +++++++--- .../com/novelbook/android/netapi/HttpApi.java | 2 +- .../android/netsubscribe/BookSubscribe.java | 4 +- .../com/novelbook/android/utils/BookUtil.java | 44 ++++++++++++++----- .../novelbook/android/utils/Constants.java | 2 + .../com/novelbook/android/utils/GsonUtil.java | 12 ++++- .../novelbook/android/utils/PageFactory.java | 42 +++++++++++++----- .../src/main/res/layout/activity_search.xml | 21 ++++++--- .../fragment_shelf_botoomsheetdialog.xml | 26 ++++++++++- .../res/layout/fragment_shelf_more_sheet.xml | 8 ++-- .../src/main/res/layout/recycle_list_item.xml | 21 +++++++-- .../res/layout/recycle_list_item_large.xml | 7 +-- zhuike/src/main/res/values/styles.xml | 11 +++-- zhuike/zhuike.iml | 2 + 22 files changed, 276 insertions(+), 82 deletions(-) diff --git a/zhuike/src/main/java/com/novelbook/android/Activity_Search.java b/zhuike/src/main/java/com/novelbook/android/Activity_Search.java index 9a806f6..a52306c 100644 --- a/zhuike/src/main/java/com/novelbook/android/Activity_Search.java +++ b/zhuike/src/main/java/com/novelbook/android/Activity_Search.java @@ -19,6 +19,8 @@ import com.novelbook.android.utils.Constants; import com.novelbook.android.utils.GsonUtil; import com.novelbook.android.utils.HistoryCache; +import org.litepal.util.Const; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -97,7 +99,7 @@ public class Activity_Search extends Activity_base { } }; - BookSubscribe.getHotKeyWords( new OnSuccessAndFaultSub(successAndFaultListener,this)); + BookSubscribe.getHotKeyWords(Constants.SEX, new OnSuccessAndFaultSub(successAndFaultListener,this)); } diff --git a/zhuike/src/main/java/com/novelbook/android/Fragments/BasicFragment.java b/zhuike/src/main/java/com/novelbook/android/Fragments/BasicFragment.java index e17027d..587d46d 100644 --- a/zhuike/src/main/java/com/novelbook/android/Fragments/BasicFragment.java +++ b/zhuike/src/main/java/com/novelbook/android/Fragments/BasicFragment.java @@ -120,7 +120,7 @@ public abstract class BasicFragment extends Fragment /*implements NativeADUnif int error_try=0; int error_try_max=5; - + protected List noveIds = new ArrayList(); public BasicFragment() { // Required empty public constructor } @@ -278,7 +278,7 @@ void initTabs(){ pageFactory.prepareBook(nv ); Log.d(TAG, String.format("prepare book %s 开始open book.",nv.getName()) ); ReadActivity.openBook(nv ,activity); - new Thread(){ + /* new Thread(){ @Override public void run() { super.run(); @@ -289,7 +289,7 @@ void initTabs(){ } handler.sendEmptyMessage(99); } - }.start(); + }.start();*/ } diff --git a/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_Shelf.java b/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_Shelf.java index e6359d1..4e4284d 100644 --- a/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_Shelf.java +++ b/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_Shelf.java @@ -452,26 +452,38 @@ public class Fragment_Shelf extends BasicFragment { TextView tvLatestChapt = (TextView) bottomSheetDialog.findViewById(R.id.txtLatestCate); TextView tvAuthor = (TextView) bottomSheetDialog.findViewById(R.id.tvAuthor); tvTitle.setText(bookLists.get(position).getName()); + ImageView imageView = (ImageView) bottomSheetDialog.findViewById(R.id.imageG1); + // TextView tvImportTitle = (TextView) bottomSheetDialog.findViewById(R.id.tvImportTitle); if (!bookLists.get(position).isLocalBook()) { - + tvLatestChapt.setText(bookLists.get(position).getChapterName()); tvAuthor.setText(bookLists.get(position).getAuthor()); TextView tvLatest = (TextView) bottomSheetDialog.findViewById(R.id.txtLatestUpdate); - - tvLatestChapt.setText(bookLists.get(position).getChapterName()); tvLatest.setText(CommonUtil.getDateString(bookLists.get(position).getLastUpdateTime())); - - TextView tvLastVisit = (TextView) bottomSheetDialog.findViewById(R.id.txtLatestVisit);; - tvLastVisit.setText( CommonUtil.getDateString( bookLists.get(position).getLastVisit())); - TextView tvLastReadChpapt = (TextView) bottomSheetDialog.findViewById(R.id.txtLatestReadChapter);; - tvLastReadChpapt.setText( bookLists.get(position).getLastReadChaptName()) ; - + TextView tvLastDomain = (TextView) bottomSheetDialog.findViewById(R.id.txtLastDomain); + tvLastDomain. setText( "[" + bookLists.get(position).getDomainName()+"]") ; + ImageUtil.loadImage(activity, bookLists.get(position).getCover(), imageView); + // tvImportTitle.setVisibility(View.GONE); + imageView.setVisibility(View.VISIBLE); } else { tvLatestChapt.setText("本地导入"); tvAuthor.setText(""); + // imageView.setImageResource(R.drawable.blankcover); + imageView.setVisibility(View.GONE); + // tvImportTitle.setText(bookLists.get(position).getName()); + // tvImportTitle.setVisibility(View.VISIBLE); } - ImageView imageView = (ImageView) bottomSheetDialog.findViewById(R.id.imageG1); - ImageUtil.loadImage(activity, bookLists.get(position).getCover(), imageView); + TextView tvLastVisit = (TextView) bottomSheetDialog.findViewById(R.id.txtLatestVisit);; + tvLastVisit.setText( CommonUtil.getDateString( bookLists.get(position).getLastVisit())); + TextView tvLastReadChpapt = (TextView) bottomSheetDialog.findViewById(R.id.txtLatestReadChapter); + String lastReadChapt = bookLists.get(position).getLastReadChaptName(); + lastReadChapt = TextUtils.isEmpty(lastReadChapt)? "":lastReadChapt; + lastReadChapt =lastReadChapt.replace("null","").trim(); + tvLastReadChpapt.setText( lastReadChapt) ; + + Log.d(TAG, "initDialog: " + lastReadChapt); + + LinearLayout lldetail = (LinearLayout) bottomSheetDialog.findViewById(R.id.llBookdetail); if (!bookLists.get(position).isLocalBook()) diff --git a/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_booklist.java b/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_booklist.java index f5132b9..3e80446 100644 --- a/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_booklist.java +++ b/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_booklist.java @@ -168,7 +168,7 @@ public class Fragment_booklist extends BasicFragment { // int pn = pageNo; if(pageNo==1) { - + noveIds = new ArrayList(); if (mData != null) { //下拉刷新 mData = new ArrayList(); mAdapter.setData(mData); @@ -191,7 +191,14 @@ public class Fragment_booklist extends BasicFragment { try { JSONObject jsonObject = new JSONObject(result); setPageCount(jsonObject.getInt("pageCount")); ; - mMoreData = GsonUtil. parserJsonArray(jsonObject,Constants.BLOCK_TITLE_NOVELS); + List list = GsonUtil. parserJsonArray(jsonObject,Constants.BLOCK_TITLE_NOVELS); + mMoreData =new ArrayList(); + for(Novel novel :list){ + if(!noveIds.contains(novel.getNovelId())){ + mMoreData.add(novel); + noveIds.add(novel.getNovelId()); + } + } if(mMoreData.size()>0){ loadListAd(mAdapter,1,mData.size()>0); } @@ -225,7 +232,19 @@ public class Fragment_booklist extends BasicFragment { JSONObject jsonObject = new JSONObject(result); String resultstr = jsonObject.getString("rank") ; setPageCount(jsonObject.getJSONObject("rank").getInt("pageCount")); ; - mMoreData = GsonUtil. parserJsonArray(resultstr,Constants.BLOCK_TITLE_NOVELS); + List list = GsonUtil. parserJsonArray(resultstr,Constants.BLOCK_TITLE_NOVELS); + mMoreData =new ArrayList(); + for(Novel novel :list){ + if(!noveIds.contains(novel.getNovelId())){ + mMoreData.add(novel); + noveIds.add(novel.getNovelId()); + } + } + + + + + Log.d(TAG, "排行榜详细 onSuccess: pageCount " + getPageCount()); if(mMoreData.size()>0){ loadListAd(mAdapter,1,mData.size()>0); diff --git a/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_paihang.java b/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_paihang.java index da02688..ef6ae53 100644 --- a/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_paihang.java +++ b/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_paihang.java @@ -134,6 +134,14 @@ public static final String TAG = Fragment_paihang.class.getSimpleName(); loadSearchData(); } private void loadSearchData(){ + + try{ + throw new Exception(); + }catch (Exception e){ + Log.e(TAG, "loadSearchData: ", e); + } + + int pn = pageNo; if(lstSex==null){ // getSearchTabTtitle(); @@ -145,7 +153,7 @@ public static final String TAG = Fragment_paihang.class.getSimpleName(); String sex = lstSex.get(tab1Pos); String cate = lstNt.get(tab2Pos); if(pageNo==1) { - + noveIds = new ArrayList(); if (mData != null) { //下拉刷新 mData = new ArrayList(); mAdapter.setData(mData); @@ -194,7 +202,18 @@ public static final String TAG = Fragment_paihang.class.getSimpleName(); JSONObject jsonObject = new JSONObject(result); setPageCount(jsonObject.getInt("pageCount")); - mMoreData = GsonUtil. parserJsonArray(jsonObject,Constants.BLOCK_TITLE_NOVELS); + + List list = GsonUtil. parserJsonArray(jsonObject,Constants.BLOCK_TITLE_NOVELS); + Log.d(TAG, "onSuccess: noveIds list size "+noveIds.size()); + + mMoreData =new ArrayList(); + for(Novel novel :list){ + if(!noveIds.contains(novel.getNovelId())){ + mMoreData.add(novel); + noveIds.add(novel.getNovelId()); + } + } + Log.d(TAG, "onSuccess: mMoreData list size "+mMoreData.size()); if(mMoreData.size()>0){ loadListAd(mAdapter,1,mData.size()>0); } @@ -335,7 +354,7 @@ public static final String TAG = Fragment_paihang.class.getSimpleName(); tvHint.setText(selectedKey); Log.d(TAG, String.format("tabChanged: to load data %s,pageno %s, tmp %s" , selectedKey,pageNo ,tmp)); - if( tmp nv.lastVisit; @@ -399,10 +401,18 @@ public void testUpdate(){ } public String getLastReadChaptName() { - return lastReadChaptName; + return filterBlankHtml(lastReadChaptName); } public void setLastReadChaptName(String lastReadChaptName) { this.lastReadChaptName = lastReadChaptName; } + + private String filterBlankHtml(String targets){ + String blank =" "; + if(!TextUtils.isEmpty(targets) && targets.contains(blank)){ + return targets.substring(targets.indexOf(blank)+blank.length()); + } + return targets; + } } diff --git a/zhuike/src/main/java/com/novelbook/android/netapi/HttpApi.java b/zhuike/src/main/java/com/novelbook/android/netapi/HttpApi.java index dcd7dff..a236f0e 100644 --- a/zhuike/src/main/java/com/novelbook/android/netapi/HttpApi.java +++ b/zhuike/src/main/java/com/novelbook/android/netapi/HttpApi.java @@ -91,7 +91,7 @@ public interface HttpApi { Observable getNovelsByIds(@Path("nvs")String nvs ); //返回指定id列表的小说列表 @GET("page/hot-keywords") - Observable getSearchHotKeys(); + Observable getSearchHotKeys(@Query("sex") int Sex); @GET("download/version.xml") Observable getVersion(); diff --git a/zhuike/src/main/java/com/novelbook/android/netsubscribe/BookSubscribe.java b/zhuike/src/main/java/com/novelbook/android/netsubscribe/BookSubscribe.java index 584d7d7..a03b347 100644 --- a/zhuike/src/main/java/com/novelbook/android/netsubscribe/BookSubscribe.java +++ b/zhuike/src/main/java/com/novelbook/android/netsubscribe/BookSubscribe.java @@ -85,8 +85,8 @@ public class BookSubscribe { Observable observable = HttpMethods.getInstance("/api/page/topdata").getHttpApi().getSearchTitles(sex); HttpMethods.getInstance().toSubscribe(observable, subscriber); } - public static void getHotKeyWords(DisposableObserver subscriber){ - Observable observable = HttpMethods.getInstance("/api/page/hot-keywords").getHttpApi().getSearchHotKeys(); + public static void getHotKeyWords(int sex,DisposableObserver subscriber){ + Observable observable = HttpMethods.getInstance("/api/page/hot-keywords").getHttpApi().getSearchHotKeys(sex); HttpMethods.getInstance().toSubscribe(observable, subscriber); } public static void getNovelsByIds(String ids,DisposableObserver subscriber){ diff --git a/zhuike/src/main/java/com/novelbook/android/utils/BookUtil.java b/zhuike/src/main/java/com/novelbook/android/utils/BookUtil.java index f785bc4..b03e6b6 100644 --- a/zhuike/src/main/java/com/novelbook/android/utils/BookUtil.java +++ b/zhuike/src/main/java/com/novelbook/android/utils/BookUtil.java @@ -108,7 +108,7 @@ public class BookUtil { private final int MSG_READCHAPTER_FAIL=2; private final int MSG_READCHAPTER_SUCCESS=3; private static final int MSG_READBOOK_FAIL = 4; - + private static final int MSG_READBOOK_EMPTY_CONTENT = 5; private String m_strCharsetName; private String bookName; @@ -130,6 +130,7 @@ public class BookUtil { }catch (Exception e){ Log.e(TAG, "prepare book: clearbook called", e); }*/ + chaptId=0; charPosition.clear(); this.muluRetryCount=0; this.downloadStatus = DownloadStatus.notStart; @@ -459,12 +460,18 @@ public class BookUtil { } + void reportMsg(String reportType,String url,String content,String headers,String httpStatus){ - String msg = String.format("{\"type\":%s, \"id\":%s ,\"name\":\"%s\",\"site\":\"%s\",\"url\":\"%s\",\"content\":\"%s\",\"requestHeader\":\"%s\",\"httpStatus\":\"%s\"}," , + /* String msg = String.format("{\"type\":%s, \"id\":%s ,\"name\":\"%s\",\"site\":\"%s\",\"url\":\"%s\",\"content\":\"%s\",\"requestHeader\":\"%s\",\"httpStatus\":\"%s\"}," , reportType ,mNovel.getId(),mNovel.getName(),mSite.getDomain(),url ,content,headers,httpStatus); - - msg = String.format("{\"type\":\"%s\", \"novelId\":%s ,\"site\":\"%s\",\"url\":\"%s\",\"httpStatus\":\"%s\",\"content\":\"%s\"}" , + */ + String key =mNovel.getNovelId()+url; + if(Constants.REPORT_HIS.contains(key)){ + return; + } + Constants.REPORT_HIS.add(key); + String msg = String.format("{\"type\":\"%s\", \"novelId\":%s ,\"site\":\"%s\",\"url\":\"%s\",\"httpStatus\":\"%s\",\"content\":\"%s\"}" , reportType ,mNovel.getNovelId(),mSite.getDomain(),url ,httpStatus,content); BookSubscribe.reportMsg(reportType ,msg); @@ -494,6 +501,14 @@ public class BookUtil { } public void setChapterNo(int chapterNo) { + + try{ + throw new Exception(); + }catch (Exception e){ + Log.e(TAG, "prepare book setChapterNo: who set chaptno "+ chapterNo,e ); + } + + this.chapterNo = chapterNo; /* if(chapterNo <= mChapters.size()) { @@ -507,7 +522,7 @@ public class BookUtil { public int getChapterNo() { if(chapterNo > mChapters.size()){ - // Log.d(TAG, String.format(" prepare book getChapterNo ,chapterNo %s, getChapters().size() %s ,mChangeChapId %s" ,chapterNo , mChapters.size(),mChangeChapId) ); + Log.d(TAG, String.format(" prepare book getChapterNo ,chapterNo %s, getChapters().size() %s ,mChangeChapId %s" ,chapterNo , mChapters.size(),mChangeChapId) ); if(mChangeChapId>0){ return mChangeChapId; } @@ -515,7 +530,7 @@ public class BookUtil { } chapterNo = chapterNo<=0 ?1 :chapterNo; - // Log.d(TAG, String.format(" prepare book getChapterNo ,chapterNo %s, getChapters().size() %s " ,chapterNo , mChapters.size()) ); + Log.d(TAG, String.format(" prepare book getChapterNo ,chapterNo %s, getChapters().size() %s " ,chapterNo , mChapters.size()) ); return chapterNo; } @@ -1408,6 +1423,7 @@ int muluRetryCount =0; return cachedPath + mNovel.getName() + index ; } public String fileChapterName(int chaptId ) { + checkAndCreateDir(chapterPath); if(mNovel!=null && !TextUtils.isEmpty(mNovel.getDomain())){ return getChapterPath() +mNovel.getDomain()+"/"+ chaptId ; @@ -1537,6 +1553,10 @@ int muluRetryCount =0; if(pagefactory!=null) pagefactory.drawStatus(PageFactory.Status.FAIL); } + else if(msg.what==MSG_READBOOK_EMPTY_CONTENT ) { //change source + if(pagefactory!=null) + pagefactory.drawStatus(PageFactory.Status.CONTENTPARESERROR); + } } @@ -1545,7 +1565,8 @@ int muluRetryCount =0; notStart, downloading, failure, - success + success, + emptyContent } public boolean isChapterContentExist(int index) { @@ -1637,7 +1658,7 @@ int muluRetryCount =0; Log.d(TAG, String.format("prepare book chaptDownStatus.containsKey %s ? %s", Integer.valueOf(index),chaptDownStatus.containsKey(Integer.valueOf(index)))); - if (!chaptDownStatus.containsKey(Integer.valueOf(index))) { + if (!chaptDownStatus.containsKey(Integer.valueOf(index)) || !file.exists() &&chaptDownStatus.get(Integer.valueOf(index))== DownloadStatus.success ) { chaptDownStatus.put(index, DownloadStatus.downloading); Log.d(TAG, String.format("prepare book put chaptDownStatus index %s,start to load chapcontent", index)); loadChaptContent(index); @@ -1659,8 +1680,8 @@ int muluRetryCount =0; Log.d(TAG, String.format(" prepare book loadChaptContent slept %s for downloading,isDownload %s ,thread %s ", slepttime, getDownloadStatus(), Thread.currentThread().getName())); }*/ while (!file.exists() && NetUtil.isNetworkConnected() && chaptDownStatus.get(Integer.valueOf(index)) == DownloadStatus.downloading && slepttime < maxSleep ) { - Thread.sleep(500); - slepttime += 500; + Thread.sleep(200); + slepttime += 200; Log.d(TAG, String.format(" prepare book loadChaptContent %s , slept %s for downloading, thread %s ",index, slepttime, Thread.currentThread().getName())); } Log.d(TAG, String.format("prepare book loadChaptContent slept %s for downloading ", slepttime)); @@ -1933,7 +1954,7 @@ private void loadChaptContent(final int chapterIndex) throws JSONException, Inte public void onFailure(Call call, IOException e) { if(e!=null && (e.toString().contains("closed") - ||e.getMessage().contains("Canceled"))) + ||e.getMessage()!=null && e.getMessage().contains("Canceled"))) { Log.d(TAG, "onFailure: prepare book cancled request ,return, " + request.url()); return; @@ -2005,6 +2026,7 @@ private void loadChaptContent(final int chapterIndex) throws JSONException, Inte String chapterContent = title+ "\n" + bodyStr; char[] buf = chapterContent.toCharArray(); File file = new File(fileChapterName(index)); + Log.d( TAG,"prepare book to create file " +fileChapterName(index)); file.createNewFile(); final OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(fileChapterName(index)), charachterType);//"UTF-16LE"); // UTF-16LE 比 utf-8 文件小 diff --git a/zhuike/src/main/java/com/novelbook/android/utils/Constants.java b/zhuike/src/main/java/com/novelbook/android/utils/Constants.java index 78a0315..7b8c1f2 100644 --- a/zhuike/src/main/java/com/novelbook/android/utils/Constants.java +++ b/zhuike/src/main/java/com/novelbook/android/utils/Constants.java @@ -5,6 +5,7 @@ import com.novelbook.android.R; import com.novelbook.android.bean.AdSetting; import com.novelbook.android.bean.ProgressType; +import java.util.ArrayList; import java.util.List; public class Constants { @@ -81,6 +82,7 @@ public class Constants { public static final String REPORT_REX_CHAPTER_CONTENT_ERROR ="EmptyText";//章节内容解析错误 public static final String REPORT_REX_MULU_ERROR ="NovelNotFound";//目录获取错误 ,或书不存在 + public static List REPORT_HIS = new ArrayList(); diff --git a/zhuike/src/main/java/com/novelbook/android/utils/GsonUtil.java b/zhuike/src/main/java/com/novelbook/android/utils/GsonUtil.java index 1f3d3ea..0d6f0ba 100644 --- a/zhuike/src/main/java/com/novelbook/android/utils/GsonUtil.java +++ b/zhuike/src/main/java/com/novelbook/android/utils/GsonUtil.java @@ -148,7 +148,10 @@ public class GsonUtil { while (it.hasNext()) { JsonElement e = (JsonElement) it.next(); //JsonElement转换为JavaBean对象 - list.add((NovelBlock) gson.fromJson(e, NovelBlock.class)); + NovelBlock nb = (NovelBlock) gson.fromJson(e, NovelBlock.class); + if(nb.getNs().size()>0) { + list.add(nb); + } } return list; } @@ -184,10 +187,17 @@ public class GsonUtil { //遍历JsonArray对象 Iterator it = jsonArray.iterator(); + // int lastNoveId =0; + List ids = new ArrayList(); while (it.hasNext()) { JsonElement e = (JsonElement) it.next(); //JsonElement转换为JavaBean对象 Novel nv = (Novel) gson.fromJson(e, Novel.class); + if(ids.contains(nv.getNovelId())){ + continue; + } + ids.add(nv.getNovelId()); + // lastNoveId =nv.getNovelId(); if(nv!=null) { list.add((Novel) gson.fromJson(e, Novel.class)); } diff --git a/zhuike/src/main/java/com/novelbook/android/utils/PageFactory.java b/zhuike/src/main/java/com/novelbook/android/utils/PageFactory.java index 17e6963..9d128e6 100644 --- a/zhuike/src/main/java/com/novelbook/android/utils/PageFactory.java +++ b/zhuike/src/main/java/com/novelbook/android/utils/PageFactory.java @@ -712,7 +712,8 @@ public class PageFactory implements ChangeSource{ SERVERERROR, CHANGESOURCE , LOCALFAIL, - LASTPAGE; + LASTPAGE, + CONTENTPARESERROR; } private void hideSysUI(){ if(mAd!=null){ @@ -870,17 +871,23 @@ private void hideSysUI(){ //handler.sendEmptyMessage(MSG_SHOW_LOADING); // showProgressDialog(); break; + case CONTENTPARESERROR: + status = "内容解析错误,请稍后再试"; + mAd.showRefresh(View.VISIBLE); + mAd.showReadSetting(); + mAd.showLoading(false); + break; case FAIL: status = "读取错误,请稍后重试"; mAd.showRefresh(View.VISIBLE); mAd.showReadSetting(); mAd.showLoading(false); - try { + /* try { throw new Exception("error on reading"); } catch (Exception e) { e.printStackTrace(); Log.d(TAG, "prepare book: why fail ",e); - } + }*/ break; case NETWORKFAILE: mAd.showLoading(false); @@ -1023,6 +1030,10 @@ private void hideSysUI(){ if(m_lines.size()==0 ){ return; } + + if(trPage.getChapterNo() >0 && trPage.getChapterNo() !=mBookUtil.getChapterNo()){ + mBookUtil.setChapterNo(trPage.getChapterNo()); + } /* try { throw new Exception("who's ad"); }catch (Exception e){ @@ -1410,8 +1421,11 @@ private void hideSysUI(){ if(mBookUtil.isBusy()){ return; } - - // Log.d(TAG, "prepare book nextPage:chaptid " +mBookUtil.getChapterNo()); + if(currentPage.getChapterNo()>0 && currentPage.getChapterNo() != currentChapter) { + currentChapter = currentPage.getChapterNo(); + Log.d(TAG, "getNextPage: prepare book correct current chapterno to " +currentChapter); + } + Log.d(TAG, "prepare book nextPage:chaptid " +mBookUtil.getChapterNo()); if (currentPage.getEnd() >= mBookUtil.getChapterLen()) { Log.d(TAG,"已经是本章最后一页了"); File file =new File( mBookUtil.fileChapterName(currentChapter+1)); @@ -1425,7 +1439,7 @@ private void hideSysUI(){ @Override public void run() { int slepttime = 0; mBookUtil.muluRetryCount=0; - while (slepttime<200 && mBookUtil.getChapters().size()==0 && (mBookUtil.mMuluStatus == BookUtil.MuluStatus.isDownloading || mBookUtil.muluRetryCount < Constants.retryCnt)) { + while (slepttime<300 && mBookUtil.getChapters().size()==0 && (mBookUtil.mMuluStatus == BookUtil.MuluStatus.isDownloading || mBookUtil.muluRetryCount < Constants.retryCnt)) { try { sleep(50); slepttime++; @@ -1445,8 +1459,11 @@ private void hideSysUI(){ currentChapter=mBookUtil.getChapterNo(); handler.sendEmptyMessage(MSG_NEXTPAGE) ; }else if(mBookUtil.mMuluStatus == BookUtil.MuluStatus.failed || mStatus !=Status.OPENING){ + mBookUtil.setChapterNo(mBookUtil.getChapterNo()-1); + currentChapter=mBookUtil.getChapterNo(); handler.sendEmptyMessage(MSG_NEXTPAGE_FAIL) ; } + mLoadingChaptNo=currentChapter; }}.start(); @@ -1664,8 +1681,12 @@ private void hideSysUI(){ public TRPage getNextPage(){ int nextPageNo =currentPage.getPageNo(); -// Log.e(TAG,String.format("prepare book getNextPage() currentChapter %s, chapters().size() %s,currentChaptPages .size() is %s,currentpage pageno is %s" -// ,currentChapter, getChapters().size(), currentChaptPages.size() , nextPageNo)); + Log.e(TAG,String.format("prepare book getNextPage() currentChapter %s, chapters().size() %s,currentChaptPages .size() is %s, currentpage pageno is %s ,currentpage chaptNo %s" + ,currentChapter, getChapters().size(), currentChaptPages.size() , nextPageNo,currentPage.getChapterNo())); + if(currentPage.getChapterNo()>0 && currentPage.getChapterNo() < currentChapter) { + currentChapter = currentPage.getChapterNo(); + Log.d(TAG, "getNextPage: prepare book correct current chapterno to " +currentChapter); + } if(nextPageNo==0){ drawStatus(); } @@ -1691,8 +1712,9 @@ private void hideSysUI(){ int prePageNo =currentPage.getPageNo()-1; - // Log.d(TAG,String.format("currentPageno %s,total pagno %s",currentPage.getPageNo(),currentChaptPages.size())); - + Log.d(TAG,String.format("prepare book currentPageno %s,total pagno %s",currentPage.getPageNo(),currentChaptPages.size())); + Log.e(TAG,String.format("prepare book getPrePage() currentChapter %s, chapters().size() %s,currentChaptPages .size() is %s,currentpage pageno is %s" + ,currentChapter, getChapters().size(), currentChaptPages.size() , prePageNo)); if(prePageNo <=0){ nextChaptPages =currentChaptPages; diff --git a/zhuike/src/main/res/layout/activity_search.xml b/zhuike/src/main/res/layout/activity_search.xml index 16a2ffb..b27d265 100644 --- a/zhuike/src/main/res/layout/activity_search.xml +++ b/zhuike/src/main/res/layout/activity_search.xml @@ -1,17 +1,25 @@ - + android:fitsSystemWindows="true" + android:clipToPadding="true" + > + + + + - - \ No newline at end of file + diff --git a/zhuike/src/main/res/layout/fragment_shelf_botoomsheetdialog.xml b/zhuike/src/main/res/layout/fragment_shelf_botoomsheetdialog.xml index 65b6039..603fbcf 100644 --- a/zhuike/src/main/res/layout/fragment_shelf_botoomsheetdialog.xml +++ b/zhuike/src/main/res/layout/fragment_shelf_botoomsheetdialog.xml @@ -96,7 +96,7 @@ android:layout_height="wrap_content" android:lines="1" android:text="上次读到" - android:paddingEnd="10dp" + android:paddingEnd="15dp" android:layout_gravity="center_vertical|center_horizontal" android:gravity="right" @@ -109,6 +109,15 @@ android:paddingLeft="5dp" > + + + + diff --git a/zhuike/src/main/res/layout/fragment_shelf_more_sheet.xml b/zhuike/src/main/res/layout/fragment_shelf_more_sheet.xml index adbd284..d825560 100644 --- a/zhuike/src/main/res/layout/fragment_shelf_more_sheet.xml +++ b/zhuike/src/main/res/layout/fragment_shelf_more_sheet.xml @@ -2,19 +2,19 @@