调整书架更新规则

This commit is contained in:
mwang 2019-06-19 23:23:18 +08:00
parent 516432b28c
commit 5825723362
15 changed files with 222 additions and 60 deletions

View File

@ -32,7 +32,7 @@ android {
multiDexEnabled true //65535 multiDexEnabled true //65535
manifestPlaceholders = [UMENG_CHANNEL_CALUE: "umeng"] //uMeng manifestPlaceholders = [UMENG_CHANNEL_CALUE: "umeng"] //uMeng
manifestPlaceholders = [MOBAPPID: "ca-app-pub-3940256099942544~3347511713"] manifestPlaceholders = [MOBAPPID: "ca-app-pub-7589200066914535~9227821515"]
flavorDimensions "default" //debug时注销 flavorDimensions "default" //debug时注销
} }
buildTypes { buildTypes {
@ -62,7 +62,7 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
// versionCode 1 // versionCode 1
// versionName "v1.0" // versionName "v1.0"
/*applicationVariants.all { variant -> /* applicationVariants.all { variant ->
variant.outputs.all { output -> variant.outputs.all { output ->
def outFile = output.outputFile def outFile = output.outputFile
if (outFile != null && outFile.name.endsWith(".apk")) { if (outFile != null && outFile.name.endsWith(".apk")) {
@ -77,16 +77,23 @@ android {
} }
} }
// //
/* productFlavors { /* productFlavors {
// googleplay {} // 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" applicationId "com.zhushou.yueshu"
versionName "v1.0" versionName "v1.0"
buildConfigField "String", "MAIN_HOST", '"http://g.xiaoshuofenxiang.com/api/"' 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\\"]}"' 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 { ali {
applicationId "com.zhushou.wangshu" applicationId "com.zhushou.yueshu"
versionName "v1.0" versionName "v1.0"
buildConfigField "String", "MAIN_HOST", '"http://g.xiaoshuofenxiang.com/api/"' 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\\"]}"' 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 { qq {
applicationId "com.zhushou.wangshu" applicationId "com.zhushou.yueshu"
versionName "v1.0" versionName "v1.0"
buildConfigField "String", "MAIN_HOST", '"http://g.xiaoshuofenxiang.com/api/"' 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\\"]}"' 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 { 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" applicationId "com.zhushou.yueshu"
versionName "v1.0" versionName "v1.0"
buildConfigField "String", "MAIN_HOST", '"http://g.xiaoshuofenxiang.com/api/"' buildConfigField "String", "MAIN_HOST", '"http://g.xiaoshuofenxiang.com/api/"'
@ -117,8 +117,9 @@ android {
} }
kuan { kuan {
applicationId "com.zhushou.wangshu" applicationId "com.zhushou.yueshu"
versionName "v1.0" versionName "v1.0"
buildConfigField "String", "MAIN_HOST", '"http://g.xiaoshuofenxiang.com/api/"' 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\\"]}"' 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\\"]}"'

View File

@ -198,7 +198,7 @@
android:name="UMENG_APPKEY" android:name="UMENG_APPKEY"
android:value="5cd6238a570df375c3000cc9" /> <!-- <meta-data android:name="UMENG_CHANNEL" android:value="${UMENG_CHANNEL_VALUE}"/> --> android:value="5cd6238a570df375c3000cc9" /> <!-- <meta-data android:name="UMENG_CHANNEL" android:value="${UMENG_CHANNEL_VALUE}"/> -->
<meta-data android:name="UMENG_CHANNEL" android:value="debug" /> <meta-data android:name="UMENG_CHANNEL" android:value="debug" />
<!-- <meta-data android:name="UMENG_CHANNEL" android:value="${UMENG_CHANNEL_VALUE}" />--> <!--<meta-data android:name="UMENG_CHANNEL" android:value="${UMENG_CHANNEL_VALUE}" />-->
<!-- google ad--> <!-- google ad-->
<!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 --> <!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data <meta-data

View File

@ -2,7 +2,7 @@
<litepal> <litepal>
<dbname value="book" ></dbname> <dbname value="book" ></dbname>
<version value="16" ></version> <version value="17" ></version>
<list> <list>
<mapping class="com.novelbook.android.db.Chapter"></mapping> <mapping class="com.novelbook.android.db.Chapter"></mapping>

View File

@ -346,9 +346,16 @@ public abstract class Activity_base extends AppCompatActivity implements Native
} }
if(NetUtil.isNetworkConnected()) if(NetUtil.isNetworkConnected())
mProgressDialog.show(); mProgressDialog.show();
Log.d(TAG, "prepare book showProgressDialog called" );
} }
public void hideProgress() { 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) if (mProgressDialog == null)
return; return;

View File

@ -137,6 +137,7 @@ public class BookActivity extends Activity_base {
TextView tvTonglei; TextView tvTonglei;
@BindView(R.id.txtLatestUpdate) @BindView(R.id.txtLatestUpdate)
TextView tvLastUpdate; TextView tvLastUpdate;
@BindView(R.id.progress) @BindView(R.id.progress)
TextView tvProgress; TextView tvProgress;
@BindView(R.id.smallCate) @BindView(R.id.smallCate)
@ -294,6 +295,7 @@ public class BookActivity extends Activity_base {
// txtDesc2.setSuffixTrigger(false); // txtDesc2.setSuffixTrigger(false);
this.txtLatestCate.setText(mNovel.getChapterName()); this.txtLatestCate.setText(mNovel.getChapterName());
tvLastUpdate.setText(CommonUtil.getDateString( mNovel.getLastUpdateTime())); tvLastUpdate.setText(CommonUtil.getDateString( mNovel.getLastUpdateTime()));
loadImageView(mNovel.getCover(),imageView); loadImageView(mNovel.getCover(),imageView);
try { try {
gaosiHeadPic(); gaosiHeadPic();

View File

@ -185,6 +185,7 @@ public abstract class BasicFragment extends Fragment implements /* NativeADUnif
Handler handler = new Handler() { Handler handler = new Handler() {
@Override @Override
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
Log.d(TAG, "prepare book handleMessage: msg" +msg.what);
hideProgress(); hideProgress();
int wt = msg.what; int wt = msg.what;
@ -266,7 +267,7 @@ void initTabs(){
nv = gson.fromJson(result,Novel.class); nv = gson.fromJson(result,Novel.class);
if(id>0) { if(id>0) {
nv.update(id); nv.update(id);
nv.checkAndUpdate(); // nv.checkAndUpdate();
nv= LitePal.find(Novel.class,id); nv= LitePal.find(Novel.class,id);
}else { }else {
nv.save(); nv.save();

View File

@ -2,6 +2,8 @@ package com.novelbook.android.Fragments;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.widget.SwipeRefreshLayout; import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.text.TextUtils; 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 maxSlept =NetUtil.isNetworkConnected()?250 :100;
int slepttime = 0; int slepttime = 0;
while ( slepttime < maxSlept*50 && ( pageFactory.isReadingCatalogs() || pageFactory.getChapters().size() == 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(); 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) { /* if ( !pageFactory.isReadingCatalogs() && pageFactory.getChapters().size() == 0) {
handler.sendEmptyMessage(2); handler.sendEmptyMessage(2);
}else{ }else{
handler.sendEmptyMessage(1); handler.sendEmptyMessage(1);
}*/ }*/
handler.sendEmptyMessage(1); handler.sendEmptyMessage(1);
} }
}.start(); }.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 @Override
protected void initListener() { protected void initListener() {
lv_catalogue.setOnItemClickListener(new AdapterView.OnItemClickListener() { lv_catalogue.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@ -221,6 +238,7 @@ public class CatalogFragment extends BasicFragment implements MarkActivity.Sortc
novel.setLastReadChapt(cp.getIndex()); novel.setLastReadChapt(cp.getIndex());
novel.setLastReadPos(1); novel.setLastReadPos(1);
novel.setLastReadChaptName(cp.getChapterName());
novel.update(novel.getId()); novel.update(novel.getId());
ReadActivity.openBook(novel, getActivity()); ReadActivity.openBook(novel, getActivity());
@ -298,4 +316,32 @@ public class CatalogFragment extends BasicFragment implements MarkActivity.Sortc
super.onPause(); super.onPause();
MobclickAgent.onPageEnd(TAG); 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();
}
}
} }

View File

@ -374,6 +374,12 @@ public class Fragment_Shelf extends BasicFragment {
tvLatestChapt.setText(bookLists.get(position).getChapterName()); tvLatestChapt.setText(bookLists.get(position).getChapterName());
tvLatest.setText(CommonUtil.getDateString(bookLists.get(position).getLastUpdateTime())); 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 { } else {
tvLatestChapt.setText("本地导入"); tvLatestChapt.setText("本地导入");
tvAuthor.setText(""); tvAuthor.setText("");

View File

@ -512,7 +512,7 @@ public class ReadActivity extends Activity_base implements AdInterface {
setSeekBarProgress(progress); setSeekBarProgress(progress);
break; break;
}*/ }*/
hideProgress(); // hideProgress();
} }
}; };

View File

@ -45,7 +45,7 @@ public class Novel extends LitePalSupport implements Serializable{
private long readtime; //阅读时间 private long readtime; //阅读时间
private int chaptCnt; //总章数 private int chaptCnt; //总章数
private long lastVisit;//最近浏览,如何设置默认时间 private long lastVisit;//最近浏览,如何设置默认时间
private String lastReadChaptName;
public int getChaptCnt() { public int getChaptCnt() {
return chaptCnt; return chaptCnt;
} }
@ -309,7 +309,7 @@ public class Novel extends LitePalSupport implements Serializable{
@Override @Override
public int update(long id){ public int update(long id){
setValues(); setValues();
checkAndUpdate(); // checkAndUpdate();
Log.d("checkshelf", String.format("checkshelf:novel %s going to update,isUpdated %s", getName() ,isUpdated)); Log.d("checkshelf", String.format("checkshelf:novel %s going to update,isUpdated %s", getName() ,isUpdated));
/* try { /* try {
throw new Exception("check update"); throw new Exception("check update");
@ -334,16 +334,21 @@ public void testUpdate(){
}*/ }*/
isUpdated = lastUpdateTime > nv.lastVisit || lastUpdateTime > nv.lastUpdateTime; isUpdated = lastUpdateTime > nv.lastVisit || lastUpdateTime > nv.lastUpdateTime;
Log.d("Novel", String.format("book %s server lastUpdateTime %s, local lastupdatetime %s, local lastvist %s" + 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, ,name ,lastUpdateTime,nv.lastUpdateTime,nv.lastVisit,isUpdated,
lastUpdateTime - nv.lastVisit, lastUpdateTime - nv.lastVisit,
lastUpdateTime - nv.lastUpdateTime 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){ if(!isUpdated){
setToDefault("isUpdated"); setToDefault("isUpdated");
} }
@ -360,4 +365,11 @@ public void testUpdate(){
return maxAge; // return 0;// maxAge; return maxAge; // return 0;// maxAge;
} }
public String getLastReadChaptName() {
return lastReadChaptName;
}
public void setLastReadChaptName(String lastReadChaptName) {
this.lastReadChaptName = lastReadChaptName;
}
} }

View File

@ -71,6 +71,7 @@ public class BookUtil {
public static final String cachedPath = storagePath + "/cache/"; public static final String cachedPath = storagePath + "/cache/";
public static final String chapterPath = storagePath + "/chapter/"; public static final String chapterPath = storagePath + "/chapter/";
private static final String charachterType = "utf-8";//"UTF-16LE"; private static final String charachterType = "utf-8";//"UTF-16LE";
private Context mContext; private Context mContext;
private ProgressDialog progressDialog; private ProgressDialog progressDialog;
MuluStatus mMuluStatus; //目录是否下载完成 MuluStatus mMuluStatus; //目录是否下载完成
@ -104,7 +105,7 @@ public class BookUtil {
private final int MSG_FILLCONTENTDONE=1; private final int MSG_FILLCONTENTDONE=1;
private final int MSG_READCHAPTER_FAIL=2; private final int MSG_READCHAPTER_FAIL=2;
private final int MSG_READCHAPTER_SUCCESS=3; private final int MSG_READCHAPTER_SUCCESS=3;
private static final int MSG_READBOOK_FAIL = 4;
private String m_strCharsetName; private String m_strCharsetName;
@ -122,6 +123,11 @@ public class BookUtil {
private Novel mNovel; private Novel mNovel;
private void clearBook() { private void clearBook() {
try{
throw new Exception("chapters cleared");
}catch (Exception e){
Log.e(TAG, "prepare book: clearbook called", e);
}
charPosition.clear(); charPosition.clear();
this.muluRetryCount=0; this.muluRetryCount=0;
this.downloadStatus = DownloadStatus.notStart; this.downloadStatus = DownloadStatus.notStart;
@ -489,6 +495,7 @@ public class BookUtil {
isChangeSource = true; isChangeSource = true;
mChapters.clear(); mChapters.clear();
Log.e(TAG, "prepare book: clearbook called ,changeSite()" );
getSiteRule(); getSiteRule();
} }
public void changeSource(String domain,int chapId,String chapTitle) { public void changeSource(String domain,int chapId,String chapTitle) {
@ -522,6 +529,7 @@ public class BookUtil {
public boolean retryDownLoadContent(int chaptId) { public boolean retryDownLoadContent(int chaptId) {
if(chaptDownStatus.containsKey(chaptId)){ if(chaptDownStatus.containsKey(chaptId)){
Log.d(TAG, "prepare book retryDownLoadContent:chaptDownStatus.get(chaptId) " +chaptDownStatus.get(chaptId) );
if( chaptDownStatus.get(chaptId) == DownloadStatus.failure){ if( chaptDownStatus.get(chaptId) == DownloadStatus.failure){
if(fileRetryCnt.containsKey(chaptId)){ if(fileRetryCnt.containsKey(chaptId)){
if(fileRetryCnt.get(chaptId) < Constants.retryCnt){ if(fileRetryCnt.get(chaptId) < Constants.retryCnt){
@ -538,8 +546,9 @@ public class BookUtil {
return false; return false;
} }
}else{ }else{
Log.d(TAG, "prepare book retryDownLoadContent:to start new download " );
chaptDownStatus.put(chaptId,DownloadStatus.downloading); chaptDownStatus.put(chaptId,DownloadStatus.downloading);
fileRetryCnt.put(chaptId,11 ); fileRetryCnt.put(chaptId,1 );
} }
if(fileRetryCnt.get(chaptId) < Constants.retryCnt) { if(fileRetryCnt.get(chaptId) < Constants.retryCnt) {
@ -1137,6 +1146,7 @@ int muluRetryCount =0;
int index = 0; int index = 0;
bookLen = 0; bookLen = 0;
mChapters.clear(); mChapters.clear();
Log.e(TAG, "prepare book: clearbook called ,cacheBook()" );
myArray.clear(); myArray.clear();
while (true){ while (true){
char[] buf = new char[cachedSize]; 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())); Log.d(TAG, String.format(" prepare book %s, file.exists()? %s", file.getPath(), file.exists()));
if (!file.exists()) { if (!file.exists()) {
String error = "下载内容失败"; String error = "";
if( !NetUtil.isNetworkConnected()){ if( !NetUtil.isNetworkConnected()){
error = "连不上网络"; error = "";
} }
// loadChaptContent(index); // loadChaptContent(index);
@ -1612,6 +1624,8 @@ int muluRetryCount =0;
// return chaptChars( index); // return chaptChars( index);
handler.sendEmptyMessage(MSG_READBOOK_FAIL);
return error.toCharArray(); return error.toCharArray();
} }
if( Constants.PRE_LOAD_CHAPT) { if( Constants.PRE_LOAD_CHAPT) {

View File

@ -3,4 +3,5 @@ package com.novelbook.android.utils;
public interface ChangeSource { public interface ChangeSource {
public void changeChapter(int chapNum); public void changeChapter(int chapNum);
public void changeSource(String domainName,String domain,int chapId,String chapTitle); public void changeSource(String domainName,String domain,int chapId,String chapTitle);
public void drawStatus(PageFactory.Status status);
} }

View File

@ -248,7 +248,7 @@ public class PageFactory implements ChangeSource{
drawStatus(); drawStatus();
} else if (msg.what == MSG_HIDEPROGRESS) { } else if (msg.what == MSG_HIDEPROGRESS) {
dismissProgressDialog(); // dismissProgressDialog();
if(mAd!=null) { if(mAd!=null) {
mAd.showRefresh(View.GONE); mAd.showRefresh(View.GONE);
// mAd.hideProgressbar(); // mAd.hideProgressbar();
@ -378,7 +378,7 @@ public class PageFactory implements ChangeSource{
public void run() { public void run() {
int slepttime =0; int slepttime =0;
File file = new File(getChapterFileName(chid)); File file = new File(getChapterFileName(chid));
while( !file.exists() && slepttime <maxSleep && mBookUtil.muluRetryCount<Constants.retryCnt ||showingStatusAd &&(new Date().getTime() - showStatusAdTime <2200) ){ while( slepttime <maxSleep && getChapters().size()==0 && mBookUtil.muluRetryCount<Constants.retryCnt ||showingStatusAd &&(new Date().getTime() - showStatusAdTime <2200) ){
try { try {
sleep(50); sleep(50);
slepttime+=50; slepttime+=50;
@ -386,7 +386,20 @@ public class PageFactory implements ChangeSource{
e.printStackTrace(); e.printStackTrace();
} }
} }
Log.d(TAG, String.format("prepare book to download chapter %s ,slepted %s ,thread.name %s",chid,slepttime*50 ,Thread.currentThread().getName() ) ); Log.d(TAG, String.format("prepare book to download chapter %s ,slepted %s ,getChapters().size() %s," +
" mBookUtil.muluRetryCount %s,thread.name %s",chid,slepttime , getChapters().size(),mBookUtil.muluRetryCount,Thread.currentThread().getName() ) );
slepttime=0;
while( !file.exists() && slepttime <maxSleep && ( !mBookUtil.fileRetryCnt.containsKey(chid) || mBookUtil.fileRetryCnt.get(chid)< Constants.retryCnt)
||showingStatusAd &&(new Date().getTime() - showStatusAdTime <2200) ){
try {
sleep(50);
slepttime+=50;
} catch (InterruptedException e) {
e.printStackTrace();
}
}
Log.d(TAG, String.format("prepare book to download chapter %s ,slepted %s , mBookUtil.fileRetryCnt.get(chid) %s,thread.name %s"
,chid,slepttime, mBookUtil.fileRetryCnt.get(chid),Thread.currentThread().getName() ) );
mStatus = Status.FINISH; mStatus = Status.FINISH;
if( mBookUtil.muluRetryCount>=Constants.retryCnt){ if( mBookUtil.muluRetryCount>=Constants.retryCnt){
@ -589,7 +602,7 @@ public class PageFactory implements ChangeSource{
public NovelSites getNovelSites() { public NovelSites getNovelSites() {
return mBookUtil.getmNovelSites(); return mBookUtil.getmNovelSites();
} }
private ProgressDialog progressDialog; /* private ProgressDialog progressDialog;
private void showProgressDialog() { private void showProgressDialog() {
if ( null == progressDialog) { if ( null == progressDialog) {
progressDialog =new ProgressDialog(mContext); progressDialog =new ProgressDialog(mContext);
@ -607,9 +620,9 @@ public class PageFactory implements ChangeSource{
private void dismissProgressDialog() { private void dismissProgressDialog() {
if ( null != progressDialog) { if ( null != progressDialog) {
progressDialog.dismiss(); // progressDialog.dismiss();
} }
} }*/
public void changeSource(String domainName,String domain,int chapId,String chapTitle) { public void changeSource(String domainName,String domain,int chapId,String chapTitle) {
hideSysUI(); hideSysUI();
fileRetryCnt.clear(); fileRetryCnt.clear();
@ -634,9 +647,15 @@ public class PageFactory implements ChangeSource{
} }
/* public String getChapterName() { @Override
return getChapters().get(currentChapter-1).getChapterName(); public void drawStatus(Status status) {
}*/ mStatus =status;
drawStatus();
}
/* public String getChapterName() {
return getChapters().get(currentChapter-1).getChapterName();
}*/
public Chapter getChapter(){ public Chapter getChapter(){
return mBookUtil.getChapter(mBookUtil.getChapterNo()); return mBookUtil.getChapter(mBookUtil.getChapterNo());
} }
@ -835,7 +854,7 @@ private void hideSysUI(){
private void drawStatus(Bitmap bitmap){ private void drawStatus(Bitmap bitmap){
hideSysUI(); hideSysUI();
mAd.showRefresh(View.VISIBLE); mAd.showRefresh(View.VISIBLE);
mAd.hideProgressbar(); // mAd.hideProgressbar();
// mAd.showLoading(false); // mAd.showLoading(false);
String status = ""; String status = "";
boolean showAd =false; boolean showAd =false;
@ -1030,7 +1049,7 @@ private void hideSysUI(){
} }
// Log.d(TAG, String.format(" prepare book onDraw chapter _____________ %s ",currentChapter ) ); // 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) { if (currentChapter > 1) {
getNovel().setLastReadChapt(currentChapter); getNovel().setLastReadChapt(currentChapter);
if(!TextUtils.isEmpty(chapterName)){
getNovel().setLastReadChaptName(chapterName);
}
} else { } else {
getNovel().setToDefault("lastReadChapt"); getNovel().setToDefault("lastReadChapt");
@ -1258,7 +1280,7 @@ private void hideSysUI(){
}else*/ }else*/
// if (getChapters().size() > 0) // 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; int nChaterWidth = (int) mBatterryPaint.measureText(chapterName) + 1;
c.drawText(chapterName, mWidth - marginWidth - nChaterWidth, statusMarginBottom + mBatterryFontSize, mBatterryPaint); c.drawText(chapterName, mWidth - marginWidth - nChaterWidth, statusMarginBottom + mBatterryFontSize, mBatterryPaint);
@ -1405,7 +1427,7 @@ private void hideSysUI(){
} }
currentChapter=mBookUtil.getChapterNo(); currentChapter=mBookUtil.getChapterNo();
handler.sendEmptyMessage(MSG_NEXTPAGE) ; handler.sendEmptyMessage(MSG_NEXTPAGE) ;
}else if(mStatus !=Status.OPENING){ }else if(mBookUtil.mMuluStatus == BookUtil.MuluStatus.failed || mStatus !=Status.OPENING){
handler.sendEmptyMessage(MSG_NEXTPAGE_FAIL) ; handler.sendEmptyMessage(MSG_NEXTPAGE_FAIL) ;
} }
@ -2135,11 +2157,15 @@ private void hideSysUI(){
public void clear(){ public void clear(){
// Log.d(TAG, String .format("prepare Book: clearing book info %s" , getNovle().getName())); // Log.d(TAG, String .format("prepare Book: clearing book info %s" , getNovle().getName()));
if(mBookUtil!=null) { // if(mBookUtil!=null) {
mBookUtil.clear(); // mBookUtil.clear();
// mBookUtil=null; // mBookUtil=null;
} // }
/* try{
throw new Exception("factory cleared");
}catch (Exception e){
Log.e(TAG, "prepare book: clear() called", e);
}*/
fileRetryCnt.clear(); fileRetryCnt.clear();
lastPageTime=0; lastPageTime=0;
if(chaptMap!=null){ if(chaptMap!=null){
@ -2179,6 +2205,7 @@ private void hideSysUI(){
return m_islastPage return m_islastPage
|| mStatus==Status.FAIL || mStatus==Status.FAIL
||mStatus==Status.NETWORKFAILE ||mStatus==Status.NETWORKFAILE
|| mStatus==Status.SERVERERROR; || mStatus==Status.SERVERERROR;
} }
//是否是最后一页 //是否是最后一页

View File

@ -12,31 +12,30 @@
<RelativeLayout <RelativeLayout
android:id="@+id/top_layout" android:id="@+id/top_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="120dp" android:layout_height="160dp"
android:elevation="1dp" android:elevation="1dp"
tools:ignore="UnusedAttribute"> tools:ignore="UnusedAttribute">
<LinearLayout <LinearLayout
android:id="@+id/llBookdetail" android:id="@+id/llBookdetail"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="110dp" android:layout_height="150dp"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:background="@color/white" android:background="@color/white"
android:clickable="true" android:clickable="true"
android:orientation="horizontal" android:orientation="vertical"
android:paddingStart="105dp" android:paddingStart="15dp"
android:paddingLeft="120dp"> >
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="110dp"
android:layout_gravity="top" android:layout_gravity="top"
android:layout_weight="1" android:layout_weight="1"
android:background="@drawable/item_selector" android:background="@drawable/item_selector"
android:orientation="vertical" android:orientation="vertical"
android:paddingStart="15dp" android:paddingStart="105dp"
android:paddingRight="10dp"
android:paddingTop="5dp"> android:paddingTop="5dp">
<TextView <TextView
@ -67,7 +66,7 @@
android:layout_marginTop="2dp" android:layout_marginTop="2dp"
android:ellipsize="end" android:ellipsize="end"
android:lines="1" android:lines="1"
android:text="" android:text=" "
/> />
@ -77,14 +76,60 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:lines="1" android:lines="1"
android:text="" android:text=" "
/> />
</LinearLayout> </LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
style="@style/TextViewDesc.small"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:lines="1"
android:text="上次读到"
android:paddingEnd="10dp"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="right"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="5dp"
>
<TextView
android:id="@+id/txtLatestReadChapter"
style="@style/TextViewDesc.small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="1"
android:text="aaaaaaaaaa "
/>
<TextView
android:id="@+id/txtLatestVisit"
style="@style/TextViewDesc.small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="1"
android:text="aaaaaaaaaaaa "
/>
</LinearLayout>
</LinearLayout>
</LinearLayout> </LinearLayout>
<android.support.v7.widget.CardView <android.support.v7.widget.CardView
@ -122,8 +167,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="bottom" android:gravity="bottom"
android:background="@color/white" android:background="@color/white"
android:padding="40dp" android:paddingLeft="40dp"
android:paddingBottom="5dp" android:paddingBottom="25dp"
android:paddingTop="25dp"
> >

View File

@ -105,7 +105,6 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/legacy_multidex_aapt_derived_proguard_rules" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/legacy_multidex_aapt_derived_proguard_rules" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/legacy_multidex_main_dex_list" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/legacy_multidex_main_dex_list" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint_jar" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifest-checker" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifest-checker" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged_assets" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged_assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged_manifests" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged_manifests" />