From 5825723362a8126e5e6ae980861562c2c82d2484 Mon Sep 17 00:00:00 2001 From: mwang <8205347@qq.com> Date: Wed, 19 Jun 2019 23:23:18 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=B9=A6=E6=9E=B6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zhuike/build.gradle | 29 ++++---- zhuike/src/main/AndroidManifest.xml | 2 +- zhuike/src/main/assets/litepal.xml | 2 +- .../com/novelbook/android/Activity_base.java | 7 ++ .../com/novelbook/android/BookActivity.java | 2 + .../android/Fragments/BasicFragment.java | 3 +- .../android/Fragments/CatalogFragment.java | 52 +++++++++++++- .../android/Fragments/Fragment_Shelf.java | 6 ++ .../com/novelbook/android/ReadActivity.java | 2 +- .../java/com/novelbook/android/db/Novel.java | 22 ++++-- .../com/novelbook/android/utils/BookUtil.java | 22 ++++-- .../novelbook/android/utils/ChangeSource.java | 1 + .../novelbook/android/utils/PageFactory.java | 61 +++++++++++----- .../fragment_shelf_botoomsheetdialog.xml | 70 +++++++++++++++---- zhuike/zhuike.iml | 1 - 15 files changed, 222 insertions(+), 60 deletions(-) diff --git a/zhuike/build.gradle b/zhuike/build.gradle index b580727..d763949 100644 --- a/zhuike/build.gradle +++ b/zhuike/build.gradle @@ -32,7 +32,7 @@ android { multiDexEnabled true //突破65535 manifestPlaceholders = [UMENG_CHANNEL_CALUE: "umeng"] //默认为uMeng - manifestPlaceholders = [MOBAPPID: "ca-app-pub-3940256099942544~3347511713"] + manifestPlaceholders = [MOBAPPID: "ca-app-pub-7589200066914535~9227821515"] flavorDimensions "default" //debug时注销 } buildTypes { @@ -62,7 +62,7 @@ android { proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' // versionCode 1 // versionName "v1.0" - /*applicationVariants.all { variant -> + /* applicationVariants.all { variant -> variant.outputs.all { output -> def outFile = output.outputFile if (outFile != null && outFile.name.endsWith(".apk")) { @@ -77,16 +77,23 @@ android { } } //渠道 - /* productFlavors { + /* productFlavors { // googleplay {} - google { + huawei { + applicationId "com.zhushou.yueshu" + versionName "v1.0" + buildConfigField "String", "MAIN_HOST", '"http://g.xiaoshuofenxiang.com/api/"' + buildConfigField "String", "API_HOST", '"{\\"master\\":[\\"http:\\\\/\\\\/g.xiaoshuofenxiang.com\\"],\\"page\\":[\\"http:\\\\/\\\\/p.xiaoshuofenxiang.com\\"],\\"report\\":[\\"http:\\\\/\\\\/r.xiaoshuofenxiang.com\\"],\\"search\\":[\\"http:\\\\/\\\\/s.xiaoshuofenxiang.com\\"],\\"novel\\":[\\"http:\\\\/\\\\/n.xiaoshuofenxiang.com\\"],\\"novelsbydot\\":[\\"http:\\\\/\\\\/nbd.xiaoshuofenxiang.com\\"],\\"user\\":[\\"http:\\\\/\\\\/u.xiaoshuofenxiang.com\\"]}"' + + } + google { applicationId "com.zhushou.yueshu" versionName "v1.0" buildConfigField "String", "MAIN_HOST", '"http://g.xiaoshuofenxiang.com/api/"' buildConfigField "String", "API_HOST", '"{\\"master\\":[\\"http:\\\\/\\\\/g.xiaoshuofenxiang.com\\"],\\"page\\":[\\"http:\\\\/\\\\/p.xiaoshuofenxiang.com\\"],\\"report\\":[\\"http:\\\\/\\\\/r.xiaoshuofenxiang.com\\"],\\"search\\":[\\"http:\\\\/\\\\/s.xiaoshuofenxiang.com\\"],\\"novel\\":[\\"http:\\\\/\\\\/n.xiaoshuofenxiang.com\\"],\\"novelsbydot\\":[\\"http:\\\\/\\\\/nbd.xiaoshuofenxiang.com\\"],\\"user\\":[\\"http:\\\\/\\\\/u.xiaoshuofenxiang.com\\"]}"' } ali { - applicationId "com.zhushou.wangshu" + applicationId "com.zhushou.yueshu" versionName "v1.0" buildConfigField "String", "MAIN_HOST", '"http://g.xiaoshuofenxiang.com/api/"' buildConfigField "String", "API_HOST", '"{\\"master\\":[\\"http:\\\\/\\\\/g.xiaoshuofenxiang.com\\"],\\"page\\":[\\"http:\\\\/\\\\/p.xiaoshuofenxiang.com\\"],\\"report\\":[\\"http:\\\\/\\\\/r.xiaoshuofenxiang.com\\"],\\"search\\":[\\"http:\\\\/\\\\/s.xiaoshuofenxiang.com\\"],\\"novel\\":[\\"http:\\\\/\\\\/n.xiaoshuofenxiang.com\\"],\\"novelsbydot\\":[\\"http:\\\\/\\\\/nbd.xiaoshuofenxiang.com\\"],\\"user\\":[\\"http:\\\\/\\\\/u.xiaoshuofenxiang.com\\"]}"' @@ -94,7 +101,7 @@ android { } qq { - applicationId "com.zhushou.wangshu" + applicationId "com.zhushou.yueshu" versionName "v1.0" buildConfigField "String", "MAIN_HOST", '"http://g.xiaoshuofenxiang.com/api/"' buildConfigField "String", "API_HOST", '"{\\"master\\":[\\"http:\\\\/\\\\/g.xiaoshuofenxiang.com\\"],\\"page\\":[\\"http:\\\\/\\\\/p.xiaoshuofenxiang.com\\"],\\"report\\":[\\"http:\\\\/\\\\/r.xiaoshuofenxiang.com\\"],\\"search\\":[\\"http:\\\\/\\\\/s.xiaoshuofenxiang.com\\"],\\"novel\\":[\\"http:\\\\/\\\\/n.xiaoshuofenxiang.com\\"],\\"novelsbydot\\":[\\"http:\\\\/\\\\/nbd.xiaoshuofenxiang.com\\"],\\"user\\":[\\"http:\\\\/\\\\/u.xiaoshuofenxiang.com\\"]}"' @@ -103,13 +110,6 @@ android { } xiaomi { - applicationId "com.zhushou.wangshu" - versionName "v1.0" - buildConfigField "String", "MAIN_HOST", '"http://g.xiaoshuofenxiang.com/api/"' - buildConfigField "String", "API_HOST", '"{\\"master\\":[\\"http:\\\\/\\\\/g.xiaoshuofenxiang.com\\"],\\"page\\":[\\"http:\\\\/\\\\/p.xiaoshuofenxiang.com\\"],\\"report\\":[\\"http:\\\\/\\\\/r.xiaoshuofenxiang.com\\"],\\"search\\":[\\"http:\\\\/\\\\/s.xiaoshuofenxiang.com\\"],\\"novel\\":[\\"http:\\\\/\\\\/n.xiaoshuofenxiang.com\\"],\\"novelsbydot\\":[\\"http:\\\\/\\\\/nbd.xiaoshuofenxiang.com\\"],\\"user\\":[\\"http:\\\\/\\\\/u.xiaoshuofenxiang.com\\"]}"' - - } - huawei { applicationId "com.zhushou.yueshu" versionName "v1.0" buildConfigField "String", "MAIN_HOST", '"http://g.xiaoshuofenxiang.com/api/"' @@ -117,8 +117,9 @@ android { } + kuan { - applicationId "com.zhushou.wangshu" + applicationId "com.zhushou.yueshu" versionName "v1.0" buildConfigField "String", "MAIN_HOST", '"http://g.xiaoshuofenxiang.com/api/"' buildConfigField "String", "API_HOST", '"{\\"master\\":[\\"http:\\\\/\\\\/g.xiaoshuofenxiang.com\\"],\\"page\\":[\\"http:\\\\/\\\\/p.xiaoshuofenxiang.com\\"],\\"report\\":[\\"http:\\\\/\\\\/r.xiaoshuofenxiang.com\\"],\\"search\\":[\\"http:\\\\/\\\\/s.xiaoshuofenxiang.com\\"],\\"novel\\":[\\"http:\\\\/\\\\/n.xiaoshuofenxiang.com\\"],\\"novelsbydot\\":[\\"http:\\\\/\\\\/nbd.xiaoshuofenxiang.com\\"],\\"user\\":[\\"http:\\\\/\\\\/u.xiaoshuofenxiang.com\\"]}"' diff --git a/zhuike/src/main/AndroidManifest.xml b/zhuike/src/main/AndroidManifest.xml index 66a28a3..e28742c 100644 --- a/zhuike/src/main/AndroidManifest.xml +++ b/zhuike/src/main/AndroidManifest.xml @@ -198,7 +198,7 @@ android:name="UMENG_APPKEY" android:value="5cd6238a570df375c3000cc9" /> - + - + diff --git a/zhuike/src/main/java/com/novelbook/android/Activity_base.java b/zhuike/src/main/java/com/novelbook/android/Activity_base.java index 0a10cb7..01fdff0 100644 --- a/zhuike/src/main/java/com/novelbook/android/Activity_base.java +++ b/zhuike/src/main/java/com/novelbook/android/Activity_base.java @@ -346,9 +346,16 @@ public abstract class Activity_base extends AppCompatActivity implements Native } if(NetUtil.isNetworkConnected()) mProgressDialog.show(); + Log.d(TAG, "prepare book showProgressDialog called" ); } public void hideProgress() { + Log.d(TAG, "prepare book hideProgress called" ); + /* try{ + throw new Exception("who dismissed"); + }catch (Exception e){ + Log.e(TAG, "prepare book hideProgress: ", e); + }*/ if (mProgressDialog == null) return; diff --git a/zhuike/src/main/java/com/novelbook/android/BookActivity.java b/zhuike/src/main/java/com/novelbook/android/BookActivity.java index b03d9c6..ea6b4b3 100644 --- a/zhuike/src/main/java/com/novelbook/android/BookActivity.java +++ b/zhuike/src/main/java/com/novelbook/android/BookActivity.java @@ -137,6 +137,7 @@ public class BookActivity extends Activity_base { TextView tvTonglei; @BindView(R.id.txtLatestUpdate) TextView tvLastUpdate; + @BindView(R.id.progress) TextView tvProgress; @BindView(R.id.smallCate) @@ -294,6 +295,7 @@ public class BookActivity extends Activity_base { // txtDesc2.setSuffixTrigger(false); this.txtLatestCate.setText(mNovel.getChapterName()); tvLastUpdate.setText(CommonUtil.getDateString( mNovel.getLastUpdateTime())); + loadImageView(mNovel.getCover(),imageView); try { gaosiHeadPic(); 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 7f0b45d..63ab946 100644 --- a/zhuike/src/main/java/com/novelbook/android/Fragments/BasicFragment.java +++ b/zhuike/src/main/java/com/novelbook/android/Fragments/BasicFragment.java @@ -185,6 +185,7 @@ public abstract class BasicFragment extends Fragment implements /* NativeADUnif Handler handler = new Handler() { @Override public void handleMessage(Message msg) { + Log.d(TAG, "prepare book handleMessage: msg" +msg.what); hideProgress(); int wt = msg.what; @@ -266,7 +267,7 @@ void initTabs(){ nv = gson.fromJson(result,Novel.class); if(id>0) { nv.update(id); - nv.checkAndUpdate(); + // nv.checkAndUpdate(); nv= LitePal.find(Novel.class,id); }else { nv.save(); diff --git a/zhuike/src/main/java/com/novelbook/android/Fragments/CatalogFragment.java b/zhuike/src/main/java/com/novelbook/android/Fragments/CatalogFragment.java index 15a4a9d..3762150 100644 --- a/zhuike/src/main/java/com/novelbook/android/Fragments/CatalogFragment.java +++ b/zhuike/src/main/java/com/novelbook/android/Fragments/CatalogFragment.java @@ -2,6 +2,8 @@ package com.novelbook.android.Fragments; import android.app.ProgressDialog; import android.os.Bundle; +import android.os.Handler; +import android.os.Message; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.widget.LinearLayoutManager; import android.text.TextUtils; @@ -178,7 +180,7 @@ public class CatalogFragment extends BasicFragment implements MarkActivity.Sortc } } } - + Log.d(TAG, String .format("prepare book: to open book cate to sleep ,pageFactory.getChapters().size() %s " , pageFactory.getChapters().size())); int maxSlept =NetUtil.isNetworkConnected()?250 :100; int slepttime = 0; while ( slepttime < maxSlept*50 && ( pageFactory.isReadingCatalogs() || pageFactory.getChapters().size() == 0)) { @@ -191,20 +193,35 @@ public class CatalogFragment extends BasicFragment implements MarkActivity.Sortc e.printStackTrace(); } } - Log.d(TAG, String .format("prepare book:to open book cate slept %s秒" , slepttime/1000)); + Log.d(TAG, String .format("prepare book:to open book cate slept %s" , slepttime)); /* if ( !pageFactory.isReadingCatalogs() && pageFactory.getChapters().size() == 0) { handler.sendEmptyMessage(2); }else{ handler.sendEmptyMessage(1); }*/ - handler.sendEmptyMessage(1); + handler.sendEmptyMessage(1); } }.start(); } + Handler handler = new Handler() { + @Override + public void handleMessage(Message msg) { + Log.d(TAG, "prepare book handleMessage: msg" + msg.what); + hideProgressSelf(); + if (msg.what == 1) { + try { + fillData(); + }catch (Exception e){ + Log.e(TAG, "handleMessage: filldata error ", e); + } + + } + } + }; @Override protected void initListener() { lv_catalogue.setOnItemClickListener(new AdapterView.OnItemClickListener() { @@ -221,6 +238,7 @@ public class CatalogFragment extends BasicFragment implements MarkActivity.Sortc novel.setLastReadChapt(cp.getIndex()); novel.setLastReadPos(1); + novel.setLastReadChaptName(cp.getChapterName()); novel.update(novel.getId()); ReadActivity.openBook(novel, getActivity()); @@ -298,4 +316,32 @@ public class CatalogFragment extends BasicFragment implements MarkActivity.Sortc super.onPause(); MobclickAgent.onPageEnd(TAG); } + private ProgressDialog mProgressDialog2; + public void showProgressDialog(boolean flag, String message) { + if (mProgressDialog2 == null) { + mProgressDialog2 = new ProgressDialog(getActivity()); + mProgressDialog2.setProgressStyle(ProgressDialog.STYLE_SPINNER); + mProgressDialog2.setCancelable(true); + mProgressDialog2.setCanceledOnTouchOutside(false); + mProgressDialog2.setMessage(message); + } + if(NetUtil.isNetworkConnected()) + mProgressDialog2.show(); + Log.d(TAG, "prepare book showProgressDialog2 called" ); + } + + public void hideProgressSelf() { + Log.d(TAG, "prepare book hideProgress2 called" ); + try{ + throw new Exception("who dismissed"); + }catch (Exception e){ + Log.e(TAG, "prepare book hideProgress2: ", e); + } + if (mProgressDialog2 == null) + return; + + if (mProgressDialog2.isShowing()) { + mProgressDialog2.dismiss(); + } + } } 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 863bb53..fab7b2d 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 @@ -374,6 +374,12 @@ public class Fragment_Shelf extends BasicFragment { 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()) ; + } else { tvLatestChapt.setText("本地导入"); tvAuthor.setText(""); diff --git a/zhuike/src/main/java/com/novelbook/android/ReadActivity.java b/zhuike/src/main/java/com/novelbook/android/ReadActivity.java index eee488e..6248b39 100644 --- a/zhuike/src/main/java/com/novelbook/android/ReadActivity.java +++ b/zhuike/src/main/java/com/novelbook/android/ReadActivity.java @@ -512,7 +512,7 @@ public class ReadActivity extends Activity_base implements AdInterface { setSeekBarProgress(progress); break; }*/ - hideProgress(); + // hideProgress(); } }; diff --git a/zhuike/src/main/java/com/novelbook/android/db/Novel.java b/zhuike/src/main/java/com/novelbook/android/db/Novel.java index 8dae022..9336382 100644 --- a/zhuike/src/main/java/com/novelbook/android/db/Novel.java +++ b/zhuike/src/main/java/com/novelbook/android/db/Novel.java @@ -45,7 +45,7 @@ public class Novel extends LitePalSupport implements Serializable{ private long readtime; //阅读时间 private int chaptCnt; //总章数 private long lastVisit;//最近浏览,如何设置默认时间? - + private String lastReadChaptName; public int getChaptCnt() { return chaptCnt; } @@ -309,7 +309,7 @@ public class Novel extends LitePalSupport implements Serializable{ @Override public int update(long id){ setValues(); - checkAndUpdate(); + // checkAndUpdate(); Log.d("checkshelf", String.format("checkshelf:novel %s going to update,isUpdated %s", getName() ,isUpdated)); /* try { throw new Exception("check update"); @@ -334,16 +334,21 @@ public void testUpdate(){ }*/ isUpdated = lastUpdateTime > nv.lastVisit || lastUpdateTime > nv.lastUpdateTime; Log.d("Novel", String.format("book %s server lastUpdateTime %s, local lastupdatetime %s, local lastvist %s" + - "is updated %s,diff1 %s,diff2 %s " + "is updated %s, lastUpdateTime - nv.lastVisit %s,lastUpdateTime - nv.lastUpdateTime %s " ,name ,lastUpdateTime,nv.lastUpdateTime,nv.lastVisit,isUpdated, lastUpdateTime - nv.lastVisit, lastUpdateTime - nv.lastUpdateTime ) ); - // isUpdated = isUpdated && !(!TextUtils.isEmpty(chapterName) && !TextUtils.isEmpty(nv.chapterName) && (chapterName.equals(nv.chapterName) || chapterName.equals(nv.lastReadChapt))); + // isUpdated = isUpdated && !(!TextUtils.isEmpty(chapterName) && !TextUtils.isEmpty(nv.chapterName) && (chapterName.equals(nv.lastReadChaptName) )); + // boolean isLastReadchaptUpdated = !TextUtils.isEmpty(chapterName) && !TextUtils.isEmpty(nv.lastReadChaptName) && !(chapterName.equals(nv.lastReadChaptName)); + boolean isLastReadchaptUpdated = TextUtils.isEmpty(nv.lastReadChaptName) || !(chapterName.equals(nv.lastReadChaptName)); + boolean isLastChaptUpdated = !TextUtils.isEmpty(chapterName) && !TextUtils.isEmpty(nv.chapterName) && !(chapterName.equals(nv.chapterName)); + Log.d("Novel", String.format( " isupdated %s, server lastUpdateTime ,server chaptername %s,chaptername %s,lastreadchapt %s" ,isLastReadchaptUpdated,chapterName,nv.chapterName,nv.lastReadChaptName ) ); - // Log.d("Novel", String.format( " isupdated %s, server lastUpdateTime ,server chaptername %s,chaptername %s,lastreadchapt %s" ,isUpdated,chapterName,nv.chapterName,nv.lastReadChapt ) ); + isUpdated = isLastChaptUpdated && isLastReadchaptUpdated ; + Log.d("Novel", String.format( " isupdated %s, server lastUpdateTime isLastReadchaptUpdated %s,isLastChaptUpdated %s" ,isUpdated,isLastReadchaptUpdated,isLastChaptUpdated ) ); if(!isUpdated){ setToDefault("isUpdated"); } @@ -360,4 +365,11 @@ public void testUpdate(){ return maxAge; // return 0;// maxAge; } + public String getLastReadChaptName() { + return lastReadChaptName; + } + + public void setLastReadChaptName(String lastReadChaptName) { + this.lastReadChaptName = lastReadChaptName; + } } 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 16f1b6f..b366aa4 100644 --- a/zhuike/src/main/java/com/novelbook/android/utils/BookUtil.java +++ b/zhuike/src/main/java/com/novelbook/android/utils/BookUtil.java @@ -71,6 +71,7 @@ public class BookUtil { public static final String cachedPath = storagePath + "/cache/"; public static final String chapterPath = storagePath + "/chapter/"; private static final String charachterType = "utf-8";//"UTF-16LE"; + private Context mContext; private ProgressDialog progressDialog; MuluStatus mMuluStatus; //目录是否下载完成 @@ -104,7 +105,7 @@ public class BookUtil { private final int MSG_FILLCONTENTDONE=1; private final int MSG_READCHAPTER_FAIL=2; private final int MSG_READCHAPTER_SUCCESS=3; - + private static final int MSG_READBOOK_FAIL = 4; private String m_strCharsetName; @@ -122,6 +123,11 @@ public class BookUtil { private Novel mNovel; private void clearBook() { + try{ + throw new Exception("chapters cleared"); + }catch (Exception e){ + Log.e(TAG, "prepare book: clearbook called", e); + } charPosition.clear(); this.muluRetryCount=0; this.downloadStatus = DownloadStatus.notStart; @@ -489,6 +495,7 @@ public class BookUtil { isChangeSource = true; mChapters.clear(); + Log.e(TAG, "prepare book: clearbook called ,changeSite()" ); getSiteRule(); } public void changeSource(String domain,int chapId,String chapTitle) { @@ -522,6 +529,7 @@ public class BookUtil { public boolean retryDownLoadContent(int chaptId) { if(chaptDownStatus.containsKey(chaptId)){ + Log.d(TAG, "prepare book retryDownLoadContent:chaptDownStatus.get(chaptId) " +chaptDownStatus.get(chaptId) ); if( chaptDownStatus.get(chaptId) == DownloadStatus.failure){ if(fileRetryCnt.containsKey(chaptId)){ if(fileRetryCnt.get(chaptId) < Constants.retryCnt){ @@ -538,8 +546,9 @@ public class BookUtil { return false; } }else{ + Log.d(TAG, "prepare book retryDownLoadContent:to start new download " ); chaptDownStatus.put(chaptId,DownloadStatus.downloading); - fileRetryCnt.put(chaptId,11 ); + fileRetryCnt.put(chaptId,1 ); } if(fileRetryCnt.get(chaptId) < Constants.retryCnt) { @@ -1137,6 +1146,7 @@ int muluRetryCount =0; int index = 0; bookLen = 0; mChapters.clear(); + Log.e(TAG, "prepare book: clearbook called ,cacheBook()" ); myArray.clear(); while (true){ char[] buf = new char[cachedSize]; @@ -1450,6 +1460,8 @@ int muluRetryCount =0; } */ + }else if(msg.what==MSG_READBOOK_FAIL ) { //change source + pagefactory.drawStatus(PageFactory.Status.FAIL); } } @@ -1600,9 +1612,9 @@ int muluRetryCount =0; Log.d(TAG, String.format(" prepare book %s, file.exists()? %s", file.getPath(), file.exists())); if (!file.exists()) { - String error = "下载内容失败"; + String error = ""; if( !NetUtil.isNetworkConnected()){ - error = "连不上网络"; + error = ""; } // loadChaptContent(index); @@ -1612,6 +1624,8 @@ int muluRetryCount =0; // return chaptChars( index); + + handler.sendEmptyMessage(MSG_READBOOK_FAIL); return error.toCharArray(); } if( Constants.PRE_LOAD_CHAPT) { diff --git a/zhuike/src/main/java/com/novelbook/android/utils/ChangeSource.java b/zhuike/src/main/java/com/novelbook/android/utils/ChangeSource.java index 863d6bd..db24814 100644 --- a/zhuike/src/main/java/com/novelbook/android/utils/ChangeSource.java +++ b/zhuike/src/main/java/com/novelbook/android/utils/ChangeSource.java @@ -3,4 +3,5 @@ package com.novelbook.android.utils; public interface ChangeSource { public void changeChapter(int chapNum); public void changeSource(String domainName,String domain,int chapId,String chapTitle); + public void drawStatus(PageFactory.Status status); } 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 0b11d49..8f01744 100644 --- a/zhuike/src/main/java/com/novelbook/android/utils/PageFactory.java +++ b/zhuike/src/main/java/com/novelbook/android/utils/PageFactory.java @@ -248,7 +248,7 @@ public class PageFactory implements ChangeSource{ drawStatus(); } else if (msg.what == MSG_HIDEPROGRESS) { - dismissProgressDialog(); + // dismissProgressDialog(); if(mAd!=null) { mAd.showRefresh(View.GONE); // mAd.hideProgressbar(); @@ -378,7 +378,7 @@ public class PageFactory implements ChangeSource{ public void run() { int slepttime =0; File file = new File(getChapterFileName(chid)); - while( !file.exists() && slepttime =Constants.retryCnt){ @@ -589,7 +602,7 @@ public class PageFactory implements ChangeSource{ public NovelSites getNovelSites() { return mBookUtil.getmNovelSites(); } - private ProgressDialog progressDialog; + /* private ProgressDialog progressDialog; private void showProgressDialog() { if ( null == progressDialog) { progressDialog =new ProgressDialog(mContext); @@ -607,9 +620,9 @@ public class PageFactory implements ChangeSource{ private void dismissProgressDialog() { if ( null != progressDialog) { - progressDialog.dismiss(); + // progressDialog.dismiss(); } - } + }*/ public void changeSource(String domainName,String domain,int chapId,String chapTitle) { hideSysUI(); fileRetryCnt.clear(); @@ -634,9 +647,15 @@ public class PageFactory implements ChangeSource{ } - /* public String getChapterName() { - return getChapters().get(currentChapter-1).getChapterName(); - }*/ + @Override + public void drawStatus(Status status) { + mStatus =status; + drawStatus(); + } + + /* public String getChapterName() { + return getChapters().get(currentChapter-1).getChapterName(); + }*/ public Chapter getChapter(){ return mBookUtil.getChapter(mBookUtil.getChapterNo()); } @@ -835,7 +854,7 @@ private void hideSysUI(){ private void drawStatus(Bitmap bitmap){ hideSysUI(); mAd.showRefresh(View.VISIBLE); - mAd.hideProgressbar(); + // mAd.hideProgressbar(); // mAd.showLoading(false); String status = ""; boolean showAd =false; @@ -1030,7 +1049,7 @@ private void hideSysUI(){ } // Log.d(TAG, String.format(" prepare book onDraw chapter _____________ %s ",currentChapter ) ); - + String chapterName =CommonUtil.subString(mBookUtil.getChapter(mBookUtil.getChapterNo()).getChapterName(),16); // CommonUtil.subString(getChapterName(),16); @@ -1045,6 +1064,9 @@ private void hideSysUI(){ if (currentChapter > 1) { getNovel().setLastReadChapt(currentChapter); + if(!TextUtils.isEmpty(chapterName)){ + getNovel().setLastReadChaptName(chapterName); + } } else { getNovel().setToDefault("lastReadChapt"); @@ -1258,7 +1280,7 @@ private void hideSysUI(){ }else*/ // if (getChapters().size() > 0) { - String chapterName =CommonUtil.subString(mBookUtil.getChapter(mBookUtil.getChapterNo()).getChapterName(),16); // CommonUtil.subString(getChapterName(),16); + int nChaterWidth = (int) mBatterryPaint.measureText(chapterName) + 1; c.drawText(chapterName, mWidth - marginWidth - nChaterWidth, statusMarginBottom + mBatterryFontSize, mBatterryPaint); @@ -1405,7 +1427,7 @@ private void hideSysUI(){ } currentChapter=mBookUtil.getChapterNo(); handler.sendEmptyMessage(MSG_NEXTPAGE) ; - }else if(mStatus !=Status.OPENING){ + }else if(mBookUtil.mMuluStatus == BookUtil.MuluStatus.failed || mStatus !=Status.OPENING){ handler.sendEmptyMessage(MSG_NEXTPAGE_FAIL) ; } @@ -2135,11 +2157,15 @@ private void hideSysUI(){ public void clear(){ // Log.d(TAG, String .format("prepare Book: clearing book info %s" , getNovle().getName())); - if(mBookUtil!=null) { - mBookUtil.clear(); + // if(mBookUtil!=null) { + // mBookUtil.clear(); // mBookUtil=null; - } - + // } + /* try{ + throw new Exception("factory cleared"); + }catch (Exception e){ + Log.e(TAG, "prepare book: clear() called", e); + }*/ fileRetryCnt.clear(); lastPageTime=0; if(chaptMap!=null){ @@ -2179,6 +2205,7 @@ private void hideSysUI(){ return m_islastPage || mStatus==Status.FAIL ||mStatus==Status.NETWORKFAILE + || mStatus==Status.SERVERERROR; } //是否是最后一页 diff --git a/zhuike/src/main/res/layout/fragment_shelf_botoomsheetdialog.xml b/zhuike/src/main/res/layout/fragment_shelf_botoomsheetdialog.xml index c133d28..65b6039 100644 --- a/zhuike/src/main/res/layout/fragment_shelf_botoomsheetdialog.xml +++ b/zhuike/src/main/res/layout/fragment_shelf_botoomsheetdialog.xml @@ -12,31 +12,30 @@ + android:orientation="vertical" + android:paddingStart="15dp" + > @@ -77,14 +76,60 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:lines="1" - android:text="" + android:text=" " /> + + + + + + + + diff --git a/zhuike/zhuike.iml b/zhuike/zhuike.iml index a959b37..aac38cb 100644 --- a/zhuike/zhuike.iml +++ b/zhuike/zhuike.iml @@ -105,7 +105,6 @@ -