调整书架更新规则
This commit is contained in:
parent
516432b28c
commit
5825723362
|
@ -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")) {
|
||||
|
@ -79,6 +79,13 @@ android {
|
|||
//渠道
|
||||
/* productFlavors {
|
||||
// googleplay {}
|
||||
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"
|
||||
|
@ -86,7 +93,7 @@ android {
|
|||
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\\"]}"'
|
||||
|
|
|
@ -198,7 +198,7 @@
|
|||
android:name="UMENG_APPKEY"
|
||||
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="${UMENG_CHANNEL_VALUE}" />-->
|
||||
<!--<meta-data android:name="UMENG_CHANNEL" android:value="${UMENG_CHANNEL_VALUE}" />-->
|
||||
<!-- google ad-->
|
||||
<!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
|
||||
<meta-data
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<litepal>
|
||||
<dbname value="book" ></dbname>
|
||||
|
||||
<version value="16" ></version>
|
||||
<version value="17" ></version>
|
||||
|
||||
<list>
|
||||
<mapping class="com.novelbook.android.db.Chapter"></mapping>
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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,7 +193,7 @@ 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);
|
||||
|
@ -204,7 +206,22 @@ public class CatalogFragment extends BasicFragment implements MarkActivity.Sortc
|
|||
}.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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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("");
|
||||
|
|
|
@ -512,7 +512,7 @@ public class ReadActivity extends Activity_base implements AdInterface {
|
|||
setSeekBarProgress(progress);
|
||||
break;
|
||||
}*/
|
||||
hideProgress();
|
||||
// hideProgress();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 <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 {
|
||||
sleep(50);
|
||||
slepttime+=50;
|
||||
|
@ -386,7 +386,20 @@ public class PageFactory implements ChangeSource{
|
|||
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;
|
||||
if( mBookUtil.muluRetryCount>=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,6 +647,12 @@ public class PageFactory implements ChangeSource{
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawStatus(Status status) {
|
||||
mStatus =status;
|
||||
drawStatus();
|
||||
}
|
||||
|
||||
/* public String getChapterName() {
|
||||
return getChapters().get(currentChapter-1).getChapterName();
|
||||
}*/
|
||||
|
@ -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;
|
||||
}
|
||||
//是否是最后一页
|
||||
|
|
|
@ -12,31 +12,30 @@
|
|||
<RelativeLayout
|
||||
android:id="@+id/top_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="120dp"
|
||||
android:layout_height="160dp"
|
||||
android:elevation="1dp"
|
||||
tools:ignore="UnusedAttribute">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/llBookdetail"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="110dp"
|
||||
android:layout_height="150dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@color/white"
|
||||
android:clickable="true"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="105dp"
|
||||
android:paddingLeft="120dp">
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="15dp"
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="110dp"
|
||||
|
||||
android:layout_gravity="top"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/item_selector"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="15dp"
|
||||
android:paddingRight="10dp"
|
||||
android:paddingStart="105dp"
|
||||
android:paddingTop="5dp">
|
||||
|
||||
<TextView
|
||||
|
@ -67,7 +66,7 @@
|
|||
android:layout_marginTop="2dp"
|
||||
android:ellipsize="end"
|
||||
android:lines="1"
|
||||
android:text=""
|
||||
android:text=" "
|
||||
|
||||
/>
|
||||
|
||||
|
@ -77,14 +76,60 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:lines="1"
|
||||
android:text=""
|
||||
android:text=" "
|
||||
|
||||
/>
|
||||
|
||||
|
||||
</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>
|
||||
|
||||
<android.support.v7.widget.CardView
|
||||
|
@ -122,8 +167,9 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:gravity="bottom"
|
||||
android:background="@color/white"
|
||||
android:padding="40dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:paddingLeft="40dp"
|
||||
android:paddingBottom="25dp"
|
||||
android:paddingTop="25dp"
|
||||
>
|
||||
|
||||
|
||||
|
|
|
@ -105,7 +105,6 @@
|
|||
<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_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/merged_assets" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged_manifests" />
|
||||
|
|
Loading…
Reference in New Issue