diff --git a/zhuike/.idea/workspace.xml b/zhuike/.idea/workspace.xml index cd60ada..db8edf4 100644 --- a/zhuike/.idea/workspace.xml +++ b/zhuike/.idea/workspace.xml @@ -6,8 +6,6 @@ - @@ -201,7 +199,6 @@ - @@ -237,8 +234,8 @@ - - + + @@ -397,8 +394,9 @@ + - + @@ -407,14 +405,14 @@ - + - + @@ -439,8 +437,8 @@ - - + + diff --git a/zhuike/build.gradle b/zhuike/build.gradle index 5c530de..c631b6f 100644 --- a/zhuike/build.gradle +++ b/zhuike/build.gradle @@ -38,7 +38,7 @@ android { debug { // 显示Log buildConfigField "boolean", "LOG_DEBUG", "true" - buildConfigField "String", "MAIN_HOST", '"http://g.xiaoshuofenxiang.com/api/"' + buildConfigField "String", "MAIN_HOST", '"http://dg.xiaoshuofenxiang.com/api/"' // buildConfigField "String", "API_HOST", '"{\\"master\\":[\\"http:\\\\/\\\\/dg.xiaoshuofenxiang.com\\"],\\"page\\":[\\"http:\\\\/\\\\/d.p.xiaoshuofenxiang.com\\"],\\"report\\":[\\"http:\\\\/\\\\//d.r.xiaoshuofenxiang.com\\"],\\"search\\":[\\"http:\\\\/\\\\//d.s.xiaoshuofenxiang.com\\"],\\"novel\\":[\\"http:\\\\/\\\\//d.n.xiaoshuofenxiang.com\\"],\\"novelsbydot\\":[\\"http:\\\\/\\\\//d.nbd.xiaoshuofenxiang.com\\"],\\"user\\":[\\"http:\\\\/\\\\//d.u.xiaoshuofenxiang.com\\"]}"' buildConfigField "String", "API_HOST", '""' diff --git a/zhuike/src/main/java.rar b/zhuike/src/main/java.rar deleted file mode 100644 index b64b56b..0000000 Binary files a/zhuike/src/main/java.rar and /dev/null differ 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 cf57b07..9c041a4 100644 --- a/zhuike/src/main/java/com/novelbook/android/utils/BookUtil.java +++ b/zhuike/src/main/java/com/novelbook/android/utils/BookUtil.java @@ -1517,12 +1517,14 @@ int muluRetryCount =0; getSiteRule(); } } - int slept = 0; - while (NetUtil.isNetworkConnected() && slept < 50 &&(mMuluStatus ==null || mMuluStatus == MuluStatus.isDownloading)) { + int maxSleep = Constants.MAX_SLEEP_4_CHAPT_DOWNLOAD; + int slepttime = 0; + + while (NetUtil.isNetworkConnected() && slepttime < maxSleep &&(mMuluStatus ==null || mMuluStatus == MuluStatus.isDownloading)) { try { Thread.sleep(50); - slept++; - Log.d(TAG, String.format("prepare book loadChapts----等待中 %s 目录, 目录数量 %s, slept %s, MuluStatus %s", mNovel.getName(), mChapters.size(), slept, mMuluStatus)); + slepttime+=50; + Log.d(TAG, String.format("prepare book loadChapts----等待中 %s 目录, 目录数量 %s, slept %s, MuluStatus %s", mNovel.getName(), mChapters.size(), slepttime, mMuluStatus)); } catch (InterruptedException e) { e.printStackTrace(); @@ -1530,7 +1532,7 @@ int muluRetryCount =0; } if (!NetUtil.isNetworkConnected() || muluRetryCount >= Constants.retryCnt && (mChapters == null || mChapters.size() == 0)) { - Log.d(TAG, String.format("prepare book loadChapts----超时。。。或出错了 %s 目录, 目录数量 %s, slept %s, MuluStatus %s,thread %s", mNovel.getName(), mChapters.size(), slept, mMuluStatus, Thread.currentThread().getName())); + Log.d(TAG, String.format("prepare book loadChapts----超时。。。或出错了 %s 目录, 目录数量 %s, slept %s, MuluStatus %s,thread %s", mNovel.getName(), mChapters.size(), slepttime, mMuluStatus, Thread.currentThread().getName())); String error = "网络不给力"; return error.toCharArray(); } @@ -1550,8 +1552,8 @@ int muluRetryCount =0; index, chaptDownStatus.get(Integer.valueOf(index)), Thread.currentThread().getName())); - int maxSleep = 10000; - int slepttime = 0; + + slepttime = 0; // while(!file.exists() && !getDownloadStatus()){//&& slepttime 100) url =url.substring(0,100); @@ -955,7 +956,7 @@ private void hideSysUI(){ if(Constants.SHOW_NOVEL_CHAPTER_URL) { c.drawText(url, targetRect.centerX(), baseline, waitPaint); } - String chaptName= mBookUtil.getChapter(currentChapter).getChapterName(); + String chaptName= mBookUtil.getChapter(getNovel().getLastReadChapt()).getChapterName(); if(!TextUtils.isEmpty(chaptName)) { if(chaptName.length()>100) chaptName =chaptName.substring(0,100); @@ -1377,7 +1378,7 @@ private void hideSysUI(){ @Override public void run() { int slepttime = 0; mBookUtil.muluRetryCount=0; - while (slepttime<80 && mBookUtil.getChapters().size()==0 && (mBookUtil.mMuluStatus == BookUtil.MuluStatus.isDownloading || mBookUtil.muluRetryCount < Constants.retryCnt)) { + while (slepttime<200 && mBookUtil.getChapters().size()==0 && (mBookUtil.mMuluStatus == BookUtil.MuluStatus.isDownloading || mBookUtil.muluRetryCount < Constants.retryCnt)) { try { sleep(50); slepttime++; @@ -1387,8 +1388,8 @@ private void hideSysUI(){ } } - Log.d(TAG, String.format("prepare book waiting for chapters slept %s, chapt size %s, MuluStatus %s, muluRetryCount %s " , - slepttime *50,mBookUtil.getChapters().size(),mBookUtil.mMuluStatus,mBookUtil.muluRetryCount)); + Log.d(TAG, String.format("prepare book waiting for chapters slept %s, chapt size %s, MuluStatus %s, muluRetryCount %s ,mStatus %s" , + slepttime *50,mBookUtil.getChapters().size(),mBookUtil.mMuluStatus,mBookUtil.muluRetryCount,mStatus)); if(mBookUtil.getChapters().size()>0){ if( mBookUtil.getChapterNo() == mBookUtil.getChapters().size()+1){ @@ -1396,7 +1397,7 @@ private void hideSysUI(){ } currentChapter=mBookUtil.getChapterNo(); handler.sendEmptyMessage(MSG_NEXTPAGE) ; - }else{ + }else if(mStatus !=Status.OPENING){ handler.sendEmptyMessage(MSG_NEXTPAGE_FAIL) ; } @@ -1412,8 +1413,8 @@ private void hideSysUI(){ drawStatus(); // currentPage(false); return; - } else { - + } else if(mBookUtil.getChapters().size()==0){ + return; } } // Log.d(TAG, "prepare book nextPage: to open next page: "); @@ -1518,7 +1519,7 @@ private void hideSysUI(){ bookName =book.getName();// FileUtils.getFileName(bookPath); // this.mCurrentChapter = chapter; mStatus = Status.OPENING; - drawStatus(); + if (bookTask != null && bookTask.getStatus() != AsyncTask.Status.FINISHED){ @@ -1528,6 +1529,8 @@ private void hideSysUI(){ bookTask = new BookTask(); Log.d(TAG, String.format("prepare book 1 to open chapter %s ,position %s,source %s",book.getLastReadChapt() ,book.getLastReadPos(),book.getDomain()+book.getDomainName() ) ); bookTask.execute((long)book.getLastReadChapt(),book .getLastReadPos()); + + drawStatus(); } private class BookTask extends AsyncTask{ diff --git a/zhuike/zhuike.iml b/zhuike/zhuike.iml index f1b0b94..1106ac4 100644 --- a/zhuike/zhuike.iml +++ b/zhuike/zhuike.iml @@ -103,6 +103,8 @@ + +