fixbugs
This commit is contained in:
parent
92a672b964
commit
58f9f26eca
|
@ -6,7 +6,7 @@ android {
|
|||
buildToolsVersion "28.0.3"
|
||||
defaultConfig {
|
||||
applicationId "com.novelbook.android"
|
||||
minSdkVersion 21 //target 19 Android 4.4 以下版本仅占比4.1%
|
||||
minSdkVersion 19 //target 19 Android 4.4 以下版本仅占比4.1%
|
||||
targetSdkVersion 28
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
|
|
@ -580,7 +580,7 @@ public class BookActivity extends Activity_base {
|
|||
}
|
||||
}, BookActivity.this));
|
||||
|
||||
BookSubscribe.getNovelsRelated(novelId, Constants.SEX, new OnSuccessAndFaultSub(new OnSuccessAndFaultListener() {
|
||||
BookSubscribe.getNovelsRelated(novelId, new OnSuccessAndFaultSub(new OnSuccessAndFaultListener() {
|
||||
@Override
|
||||
public void onSuccess(String result) {
|
||||
//成功
|
||||
|
@ -601,7 +601,7 @@ public class BookActivity extends Activity_base {
|
|||
}
|
||||
}, BookActivity.this));
|
||||
|
||||
BookSubscribe.getNovelsSameAuthor(novelId, Constants.SEX, new OnSuccessAndFaultSub(new OnSuccessAndFaultListener() {
|
||||
BookSubscribe.getNovelsSameAuthor(novelId, new OnSuccessAndFaultSub(new OnSuccessAndFaultListener() {
|
||||
@Override
|
||||
public void onSuccess(String result) {
|
||||
//成功
|
||||
|
|
|
@ -144,7 +144,12 @@ public abstract class BasicFragment extends Fragment {
|
|||
int wt = msg.what;
|
||||
|
||||
if (msg.what == 1) {
|
||||
fillData();
|
||||
try {
|
||||
fillData();
|
||||
}catch (Exception e){
|
||||
Log.e(TAG, "handleMessage: filldata error ", e);
|
||||
}
|
||||
|
||||
} else if (msg.what == 2) //
|
||||
{
|
||||
|
||||
|
@ -228,7 +233,8 @@ public abstract class BasicFragment extends Fragment {
|
|||
}
|
||||
}.start();*/
|
||||
|
||||
PageFactory.getInstance(activity.getApplicationContext()).prepareBook(nv ); //打开本地小说内容
|
||||
// PageFactory.getInstance(activity.getApplicationContext()).prepareBook(nv ); //打开本地小说内容
|
||||
PageFactory.getInstance(activity ).prepareBook(nv ); //打开本地小说内容
|
||||
|
||||
Log.d(TAG, String.format("prepare book %s 开始open book.",nv.getName()) );
|
||||
ReadActivity.openBook(nv ,activity);
|
||||
|
@ -239,7 +245,7 @@ public abstract class BasicFragment extends Fragment {
|
|||
public void onFault(String errorMsg) {
|
||||
//失败
|
||||
Toast.makeText(getActivity(),"Novel 请求失败:"+errorMsg,Toast.LENGTH_SHORT).show();
|
||||
PageFactory.getInstance(activity.getApplicationContext()).prepareBook(novel ); //打开本地小说内容
|
||||
PageFactory.getInstance(activity ).prepareBook(novel ); //打开本地小说内容
|
||||
ReadActivity.openBook(novel ,activity);
|
||||
handler.sendEmptyMessage(99);
|
||||
}
|
||||
|
@ -299,7 +305,7 @@ public abstract class BasicFragment extends Fragment {
|
|||
book.setLastReadPos(book1.getLastReadPos());
|
||||
book.setLastReadChapt(book1.getLastReadChapt());
|
||||
}
|
||||
Toast.makeText(activity, book.getName() + "加载", Toast.LENGTH_SHORT).show();
|
||||
// Toast.makeText(activity, book.getName() + "加载", Toast.LENGTH_SHORT).show();
|
||||
|
||||
if(!book.isLocalBook()){
|
||||
|
||||
|
|
|
@ -10,8 +10,10 @@ import android.widget.ListView;
|
|||
|
||||
import com.novelbook.android.MarkActivity;
|
||||
import com.novelbook.android.R;
|
||||
import com.novelbook.android.ReadActivity;
|
||||
import com.novelbook.android.adapter.MarkAdapter;
|
||||
import com.novelbook.android.db.BookMarks;
|
||||
import com.novelbook.android.db.Novel;
|
||||
import com.novelbook.android.utils.PageFactory;
|
||||
|
||||
import org.litepal.LitePal;
|
||||
|
@ -74,7 +76,22 @@ public class BookMarkFragment extends BasicFragment implements MarkActivity.Sor
|
|||
lv_bookmark.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
pageFactory.openBookmark(bookMarksList.get(position).getChapt(),bookMarksList.get(position).getBegin());
|
||||
|
||||
if( pageFactory.getmAd()==null){
|
||||
showProgressDialog(true,"正在加载");
|
||||
Novel nv = LitePal.find(Novel.class,novelId);
|
||||
nv.setLastReadChapt(bookMarksList.get(position).getChapt());
|
||||
nv.setLastReadPos(bookMarksList.get(position).getBegin());
|
||||
nv.update(novelId);
|
||||
|
||||
// pageFactory.prepareBook(nv ); //打开本地小说内容
|
||||
// Log.d(TAG, String.format("prepare book %s 开始open book.",nv.getName()) );
|
||||
ReadActivity.openBook(nv ,activity);
|
||||
handler.sendEmptyMessage(99);
|
||||
}else{
|
||||
pageFactory.openBookmark(bookMarksList.get(position).getChapt(),bookMarksList.get(position).getBegin());
|
||||
}
|
||||
|
||||
getActivity().finish();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -148,8 +148,10 @@ public class Fragment_bangdan extends BasicFragment {
|
|||
|
||||
void initialBookList() {
|
||||
mAdapter.setShowFootView(true);
|
||||
rvBandan.setLayoutManager(new LinearLayoutManager(activity));
|
||||
rvBandan.setAdapter(mAdapter);
|
||||
if(rvBandan!=null) { //TODO : why nll?
|
||||
rvBandan.setLayoutManager(new LinearLayoutManager(activity));
|
||||
rvBandan.setAdapter(mAdapter);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ public class Main2Activity extends Activity_base
|
|||
// ButterKnife.bind(this);
|
||||
|
||||
initialSexOption();
|
||||
checkUpdate(true);
|
||||
// checkUpdate(true);
|
||||
// getSearchTabTtitle();
|
||||
|
||||
}
|
||||
|
@ -327,8 +327,8 @@ public class Main2Activity extends Activity_base
|
|||
return false;
|
||||
}
|
||||
};
|
||||
@BindView(R.id.sexSelect)
|
||||
AppCompatSpinner spinner;
|
||||
//@BindView(R.id.sexSelect)
|
||||
//AppCompatSpinner spinner;
|
||||
@BindView(R.id.toolbarTitle)
|
||||
TextView txtTitle;
|
||||
private int bottomSelectedIndex;
|
||||
|
|
|
@ -763,7 +763,9 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
|
|||
// | View.SYSTEM_UI_FLAG_IMMERSIVE
|
||||
);
|
||||
|
||||
getWindow().setNavigationBarColor(getResources().getColor(R.color.read_dialog_bg));
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
getWindow().setNavigationBarColor(getResources().getColor(R.color.read_dialog_bg));
|
||||
}
|
||||
pageFactory.setBusy(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -69,10 +69,10 @@ public interface HttpApi {
|
|||
|
||||
//相关小说 http://xiaoshuofenxiang.com/api/n/6/about
|
||||
@GET("n/{novelId}/about")
|
||||
Observable<ResponseBody> getNovelsRelated(@Path("novelId") int novelId,@Query("sex") int Sex);
|
||||
Observable<ResponseBody> getNovelsRelated(@Path("novelId") int novelId);
|
||||
//同作者其它小说http://xiaoshuofenxiang.com/api/n/7/author
|
||||
@GET("n/{novelId}/author")
|
||||
Observable<ResponseBody> getNovelsSameAuthor(@Path("novelId") int novelId,@Query("sex") int Sex);
|
||||
Observable<ResponseBody> getNovelsSameAuthor(@Path("novelId") int novelId);
|
||||
//站点榜单http://xiaoshuofenxiang.com/api/page/siteranks?sex=1
|
||||
@GET("page/siteranks")
|
||||
Observable<ResponseBody> getSiteRanks(@Query("sex") int Sex);
|
||||
|
|
|
@ -52,13 +52,13 @@ public class BookSubscribe {
|
|||
HttpMethods.getInstance().toSubscribe(observable, subscriber);
|
||||
}
|
||||
|
||||
public static void getNovelsRelated(int novelId,int sex,DisposableObserver<ResponseBody> subscriber){
|
||||
Observable<ResponseBody> observable = HttpMethods.getInstance(String.format("/api/n/%s/about",novelId ) ).getHttpApi().getNovelsRelated(novelId,sex);
|
||||
public static void getNovelsRelated(int novelId,DisposableObserver<ResponseBody> subscriber){
|
||||
Observable<ResponseBody> observable = HttpMethods.getInstance(String.format("/api/n/%s/about",novelId ) ).getHttpApi().getNovelsRelated(novelId);
|
||||
HttpMethods.getInstance().toSubscribe(observable, subscriber);
|
||||
}
|
||||
|
||||
public static void getNovelsSameAuthor(int novelId,int sex,DisposableObserver<ResponseBody> subscriber){
|
||||
Observable<ResponseBody> observable = HttpMethods.getInstance(String.format("/api/n/%s/author",novelId ) ).getHttpApi().getNovelsSameAuthor(novelId,sex);
|
||||
public static void getNovelsSameAuthor(int novelId,DisposableObserver<ResponseBody> subscriber){
|
||||
Observable<ResponseBody> observable = HttpMethods.getInstance(String.format("/api/n/%s/author",novelId ) ).getHttpApi().getNovelsSameAuthor(novelId);
|
||||
HttpMethods.getInstance().toSubscribe(observable, subscriber);
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ public class HttpMethods {
|
|||
// SingletonHolder.INSTANCE.changeBaseUrl(NetUtil.getUrl(keyUrl));
|
||||
// RandomHost rh = new RandomHost( getHost() ,keyUrl);
|
||||
// okHttpBuilder.addInterceptor(new RetryInterceptor(rh));
|
||||
okHttpBuilder.addInterceptor(new RetryInterceptor());
|
||||
// okHttpBuilder.addInterceptor(new RetryInterceptor());
|
||||
okHttpBuilder.followRedirects(false);
|
||||
okHttpBuilder.retryOnConnectionFailure(false);
|
||||
retrofit = new Retrofit.Builder()
|
||||
|
@ -173,7 +173,7 @@ public class HttpMethods {
|
|||
Log.d(TAG, "getClient: to set cach control");
|
||||
// okHttpBuilder.cache(cache).addInterceptor(cacheInterceptor);
|
||||
okHttpBuilder.cache(cache)
|
||||
//.addNetworkInterceptor(REWRITE_RESPONSE_INTERCEPTOR)
|
||||
.addNetworkInterceptor(REWRITE_RESPONSE_INTERCEPTOR)
|
||||
.addInterceptor(REWRITE_RESPONSE_INTERCEPTOR_OFFLINE);
|
||||
|
||||
/**
|
||||
|
@ -219,7 +219,7 @@ public class HttpMethods {
|
|||
|
||||
|
||||
});
|
||||
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.HEADERS);
|
||||
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
//设置 Debug Log 模式
|
||||
okHttpBuilder.addInterceptor(loggingInterceptor);
|
||||
// okHttpBuilder.addInterceptor(new RetryInterceptor());
|
||||
|
@ -239,6 +239,11 @@ public class HttpMethods {
|
|||
//错误重连
|
||||
okHttpBuilder.retryOnConnectionFailure(true);
|
||||
|
||||
okHttpBuilder.addInterceptor(new RetryInterceptor());
|
||||
|
||||
okHttpBuilder.hostnameVerifier(SSLSocketClient.getHostnameVerifier());
|
||||
|
||||
|
||||
|
||||
|
||||
// Install the all-trusting trust manager
|
||||
|
|
|
@ -161,7 +161,7 @@ public class NetUtil {
|
|||
|
||||
public static String getUserAgent(){
|
||||
String[] uas = {
|
||||
// Opera
|
||||
/*// Opera
|
||||
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36 OPR/26.0.1656.60",
|
||||
"Opera/8.0 (Windows NT 5.1; U; en)",
|
||||
"Mozilla/5.0 (Windows NT 5.1; U; en; rv:1.8.1) Gecko/20061208 Firefox/2.0.0 Opera 9.50",
|
||||
|
@ -191,62 +191,67 @@ public class NetUtil {
|
|||
"Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.84 Safari/535.11 SE 2.X MetaSr 1.0",
|
||||
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; SV1; QQDownload 732; .NET4.0C; .NET4.0E; SE 2.X MetaSr 1.0)",
|
||||
// maxthon浏览器
|
||||
*/
|
||||
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Maxthon/4.4.3.4000 Chrome/30.0.1599.101 Safari/537.36",
|
||||
// UC浏览器
|
||||
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 UBrowser/4.0.3214.0 Safari/537.36",
|
||||
// IPhone
|
||||
"Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5",
|
||||
// IPod
|
||||
"Mozilla/5.0 (iPod; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5",
|
||||
// IPAD
|
||||
"Mozilla/5.0 (iPad; U; CPU OS 4_2_1 like Mac OS X; zh-cn) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5",
|
||||
"Mozilla/5.0 (iPad; U; CPU OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5",
|
||||
// Android
|
||||
"Mozilla/5.0 (Linux; U; Android 2.2.1; zh-cn; HTC_Wildfire_A3333 Build/FRG83D) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
|
||||
"Mozilla/5.0 (Linux; U; Android 2.3.7; en-us; Nexus One Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
|
||||
// QQ浏览器 Android版本
|
||||
"MQQBrowser/26 Mozilla/5.0 (Linux; U; Android 2.3.7; zh-cn; MB200 Build/GRJ22; CyanogenMod-7) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
|
||||
// Android Opera Mobile
|
||||
"Opera/9.80 (Android 2.3.4; Linux; Opera Mobi/build-1107180945; U; en-GB) Presto/2.8.149 Version/11.10",
|
||||
// Android Pad Moto Xoom
|
||||
"Mozilla/5.0 (Linux; U; Android 3.0; en-us; Xoom Build/HRI39) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13",
|
||||
// BlackBerry
|
||||
"Mozilla/5.0 (BlackBerry; U; BlackBerry 9800; en) AppleWebKit/534.1+ (KHTML, like Gecko) Version/6.0.0.337 Mobile Safari/534.1+",
|
||||
// WebOS HP Touchpad
|
||||
"Mozilla/5.0 (hp-tablet; Linux; hpwOS/3.0.0; U; en-US) AppleWebKit/534.6 (KHTML, like Gecko) wOSBrowser/233.70 Safari/534.6 TouchPad/1.0",
|
||||
// Nokia N97
|
||||
"Mozilla/5.0 (SymbianOS/9.4; Series60/5.0 NokiaN97-1/20.0.019; Profile/MIDP-2.1 Configuration/CLDC-1.1) AppleWebKit/525 (KHTML, like Gecko) BrowserNG/7.1.18124",
|
||||
// Windows Phone Mango
|
||||
"Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; HTC; Titan)",
|
||||
// UC浏览器
|
||||
"UCWEB7.0.2.37/28/999",
|
||||
"NOKIA5700/ UCWEB7.0.2.37/28/999",
|
||||
// UCOpenwave
|
||||
"Openwave/ UCWEB7.0.2.37/28/999",
|
||||
// UC Opera
|
||||
"Mozilla/4.0 (compatible; MSIE 6.0; ) Opera/UCWEB7.0.2.37/28/999",
|
||||
"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.2357.134 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2848.83 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36",
|
||||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 UBrowser/6.2.4094.1 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2864.75 Safari/537.36",
|
||||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2894.32 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.89 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 5.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2637.97 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2770.24 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0",
|
||||
"Mozilla/5.0 (Windows NT 6.3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2955.47 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2981.31 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 5.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2672.36 Safari/537.36",
|
||||
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; .NET CLR 3.5.21022; .NET CLR 1.0.3705; .NET CLR 1.1.4322)",
|
||||
"Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2912.2 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2956.56 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2812.77 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 5.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2650.71 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2624.94 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2690.7 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2842.56 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 6.3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2963.76 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2641.13 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2632.57 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2932.36 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2635.65 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2642.10 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2945.41 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2975.95 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2884.62 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2843.16 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 SE 2.X MetaSr 1.0",
|
||||
"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2938.72 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2660.98 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 6.3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2650.44 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2635.83 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2963.74 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 5.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2682.72 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 5.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2635.64 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 5.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2915.8 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 5.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2624.61 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2975.60 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2862.8 Safari/537.36"
|
||||
|
||||
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/22.0.1207.1 Safari/537.1",
|
||||
"Mozilla/5.0 (X11; CrOS i686 2268.111.0) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11",
|
||||
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.6 (KHTML, like Gecko) Chrome/20.0.1092.0 Safari/536.6",
|
||||
"Mozilla/5.0 (Windows NT 6.2) AppleWebKit/536.6 (KHTML, like Gecko) Chrome/20.0.1090.0 Safari/536.6",
|
||||
"Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/19.77.34.5 Safari/537.1",
|
||||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.9 Safari/536.5",
|
||||
"Mozilla/5.0 (Windows NT 6.0) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.36 Safari/536.5",
|
||||
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1063.0 Safari/536.3",
|
||||
"Mozilla/5.0 (Windows NT 5.1) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1063.0 Safari/536.3",
|
||||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_0) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1063.0 Safari/536.3",
|
||||
"Mozilla/5.0 (Windows NT 6.2) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1062.0 Safari/536.3",
|
||||
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1062.0 Safari/536.3",
|
||||
"Mozilla/5.0 (Windows NT 6.2) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1061.1 Safari/536.3",
|
||||
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1061.1 Safari/536.3",
|
||||
"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1061.1 Safari/536.3",
|
||||
"Mozilla/5.0 (Windows NT 6.2) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1061.0 Safari/536.3",
|
||||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.24 (KHTML, like Gecko) Chrome/19.0.1055.1 Safari/535.24",
|
||||
"Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/535.24 (KHTML, like Gecko) Chrome/19.0.1055.1 Safari/535.24"
|
||||
};
|
||||
|
||||
return uas[new Random().nextInt(uas.length-1)];
|
||||
return uas[new Random().nextInt(uas.length-1)];
|
||||
// return"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36";
|
||||
// return "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36";
|
||||
}
|
||||
|
||||
|
|
|
@ -20,39 +20,57 @@ public class RetryInterceptor implements Interceptor {
|
|||
public RetryInterceptor(){
|
||||
|
||||
}
|
||||
RandomHost rh = null;
|
||||
|
||||
public RetryInterceptor(RandomHost rh) {
|
||||
|
||||
/* public RetryInterceptor(RandomHost rh) {
|
||||
this.rh=rh;
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public Response intercept(Chain chain) throws IOException {
|
||||
Request request = chain.request();
|
||||
String oldUrl = request.url().toString();
|
||||
String prefix = REUtil.match("(?i)http[s]?://[^/]+", oldUrl);
|
||||
if (prefix == null) return doRequest(chain, request);
|
||||
String path = oldUrl.substring(prefix.length());
|
||||
/* if(oldUrl.indexOf("xiaoshuofenxiang.com") == -1 || !path.startsWith("/api/") || NetUtil.getHost()==null){
|
||||
rh = null;
|
||||
return doRequest(chain, request);
|
||||
}*/
|
||||
if (prefix == null){
|
||||
Response response = doRequest(chain, request);
|
||||
if(response!=null)
|
||||
{
|
||||
return response;
|
||||
}else
|
||||
{
|
||||
|
||||
throw new IOException();
|
||||
}
|
||||
}
|
||||
String path = oldUrl.substring(prefix.length());
|
||||
RandomHost rh = null;
|
||||
if(oldUrl.indexOf("xiaoshuofenxiang.com") == -1 || !path.startsWith("/api/") || NetUtil.getHost()==null){
|
||||
// rh = null;
|
||||
Response response = doRequest(chain, request);
|
||||
if(response!=null)
|
||||
{
|
||||
return response;
|
||||
}else
|
||||
{
|
||||
|
||||
throw new IOException();
|
||||
}
|
||||
}
|
||||
try {
|
||||
rh = new RandomHost(NetUtil.getHost(), path);
|
||||
Log.d(TAG, "HttpMethods intercept: api path is "+path);
|
||||
Log.d(TAG, "HttpMethods intercept: create new RandomHost--------------------------");
|
||||
|
||||
} catch (JSONException e) {
|
||||
Log.e(TAG, "intercept: ", e);
|
||||
|
||||
// TODO rh == null
|
||||
}
|
||||
|
||||
|
||||
Response response = null;
|
||||
while (true) {
|
||||
try {
|
||||
if(rh==null) {
|
||||
rh = new RandomHost(NetUtil.getHost(), path);
|
||||
Log.d(TAG, "HttpMethods intercept: api path is "+path);
|
||||
Log.d(TAG, "HttpMethods intercept: create new RandomHost--------------------------");
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
Log.e(TAG, "intercept: ", e);
|
||||
|
||||
// TODO rh == null
|
||||
}
|
||||
String newPrefix = rh.next();
|
||||
if ("".equals(newPrefix)) break;
|
||||
|
||||
|
@ -80,7 +98,7 @@ public class RetryInterceptor implements Interceptor {
|
|||
}
|
||||
|
||||
if (response != null && response.isSuccessful()) {
|
||||
rh = null;
|
||||
// rh = null;
|
||||
Log.d(TAG, String.format("HttpMethods intercept: set rh null,return response"));
|
||||
return response;
|
||||
}
|
||||
|
@ -127,28 +145,29 @@ public class RetryInterceptor implements Interceptor {
|
|||
return response;
|
||||
}
|
||||
|
||||
private Response doRequest(Chain chain, Request request) {
|
||||
private Response doRequest(Chain chain, Request request) throws IOException {
|
||||
Response response = null;
|
||||
try {
|
||||
response = chain.proceed(request);
|
||||
} catch (Exception e) {
|
||||
// Log.e(TAG, "doRequest: error 1 ",e );
|
||||
Log.e(TAG, "doRequest: error 1 ",e );
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
private String switchServer(String key) {
|
||||
/*private String switchServer(String key) {
|
||||
String newUrl = rh.next();
|
||||
|
||||
if(TextUtils.isEmpty(newUrl)){
|
||||
return newUrl;
|
||||
}
|
||||
|
||||
/* if(!newUrl.endsWith("/")){
|
||||
*//* if(!newUrl.endsWith("/")){
|
||||
newUrl+="/";
|
||||
}*/
|
||||
}*//*
|
||||
return newUrl +key;
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
package com.novelbook.android.netutils;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
import java.security.cert.X509Certificate;
|
||||
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
|
||||
public class SSLSocketClient {
|
||||
|
||||
//获取这个SSLSocketFactory
|
||||
public static SSLSocketFactory getSSLSocketFactory() {
|
||||
try {
|
||||
SSLContext sslContext = SSLContext.getInstance("SSL");
|
||||
sslContext.init(null, getTrustManager(), new SecureRandom());
|
||||
return sslContext.getSocketFactory();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
//获取TrustManager
|
||||
private static TrustManager[] getTrustManager() {
|
||||
TrustManager[] trustAllCerts = new TrustManager[]{
|
||||
new X509TrustManager() {
|
||||
@Override
|
||||
public void checkClientTrusted(X509Certificate[] chain, String authType) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(X509Certificate[] chain, String authType) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return new X509Certificate[]{};
|
||||
}
|
||||
}
|
||||
};
|
||||
return trustAllCerts;
|
||||
}
|
||||
|
||||
//获取HostnameVerifier
|
||||
public static HostnameVerifier getHostnameVerifier() {
|
||||
HostnameVerifier hostnameVerifier = new HostnameVerifier() {
|
||||
@Override
|
||||
public boolean verify(String s, SSLSession sslSession) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
return hostnameVerifier;
|
||||
}
|
||||
|
||||
}
|
|
@ -107,11 +107,11 @@ public class BookUtil {
|
|||
private String bookName;
|
||||
private String bookPath;
|
||||
|
||||
public void setBookLen(long bookLen) {
|
||||
this.bookLen = bookLen;
|
||||
public void setChapterLen(long chapterLen) {
|
||||
this.chapterLen = chapterLen;
|
||||
}
|
||||
|
||||
private long bookLen;
|
||||
private long chapterLen;
|
||||
private long position;
|
||||
private Novel mNovel;
|
||||
|
||||
|
@ -290,6 +290,9 @@ public class BookUtil {
|
|||
int siteRuleRetryCnt =0;
|
||||
public void getSiteRule() {
|
||||
mSiteRule = null;
|
||||
if(mSite==null){
|
||||
return;
|
||||
}
|
||||
BookSubscribe.getSiteRule(mSite.getDomain(),new OnSuccessAndFaultSub(new OnSuccessAndFaultListener() {
|
||||
@Override
|
||||
public void onSuccess(String result) {
|
||||
|
@ -750,7 +753,7 @@ int muluRetryCount =0;
|
|||
return;
|
||||
}
|
||||
String url = mSite.getMuluUrl();
|
||||
Request request = getTagRequest(url,mSite.getDomain(), mNovel.getMaxAge());
|
||||
Request request = getTagRequest(url,REUtil.getDomain(url), mNovel.getMaxAge());
|
||||
|
||||
mMuluStatus = MuluStatus.isDownloading;
|
||||
long startTime= new Date().getTime();
|
||||
|
@ -777,7 +780,8 @@ int muluRetryCount =0;
|
|||
// handler.sendEmptyMessage(3);
|
||||
|
||||
//TODO 如果是取消了访问,则返回
|
||||
if (e.toString().contains("closed") || e.getMessage().contains("Canceled")) {
|
||||
|
||||
if (e.toString()!=null && e.toString().contains("closed") || e.getMessage()!=null && e.getMessage().contains("Canceled")) {
|
||||
Log.d(TAG, String.format("prepare book loadChapts---- canceled %s 目录 from %s", mNovel.getName(), url));
|
||||
|
||||
|
||||
|
@ -787,7 +791,7 @@ int muluRetryCount =0;
|
|||
|
||||
if (muluRetryCount < Constants.muluRetryCnt) {
|
||||
try {
|
||||
long sleeptime =500;
|
||||
long sleeptime =100;
|
||||
if(mSiteRule!=null) {
|
||||
sleeptime = mSiteRule.getMiniInterval4AccessChapter();
|
||||
}
|
||||
|
@ -1255,8 +1259,8 @@ int muluRetryCount =0;
|
|||
return mChapters;
|
||||
}
|
||||
|
||||
public long getBookLen(){
|
||||
return bookLen;
|
||||
public long getChapterLen(){
|
||||
return chapterLen;
|
||||
}
|
||||
|
||||
protected String fileName(int index) {
|
||||
|
@ -1452,7 +1456,7 @@ int muluRetryCount =0;
|
|||
|
||||
if (mMuluStatus == null) {
|
||||
Log.e(TAG, String.format("prepare book loadChapts---- 还未有目录信息,出错了 %s 目录, 目录数量 %s, MuluStatus %s ,thread %s", mNovel.getName(), mChapters.size(), mMuluStatus, Thread.currentThread().getName()));
|
||||
// getTargetSites();
|
||||
getTargetSites();
|
||||
}
|
||||
if( mChapters.size() ==0) {
|
||||
if (mMuluStatus != MuluStatus.isDownloading){
|
||||
|
@ -1460,7 +1464,7 @@ int muluRetryCount =0;
|
|||
}
|
||||
}
|
||||
int slept = 0;
|
||||
while (NetUtil.isNetworkConnected() && slept < 100 && mMuluStatus == MuluStatus.isDownloading) {
|
||||
while (NetUtil.isNetworkConnected() && slept < 50 &&(mMuluStatus ==null || mMuluStatus == MuluStatus.isDownloading)) {
|
||||
try {
|
||||
Thread.sleep(50);
|
||||
slept++;
|
||||
|
@ -1478,19 +1482,21 @@ int muluRetryCount =0;
|
|||
}
|
||||
|
||||
Log.d(TAG, String.format("prepare book loadChaptContent----start %s", new Date().toString()));
|
||||
|
||||
Log.d(TAG, String.format("prepare book chaptDownStatus.containsKey %s ? %s", Integer.valueOf(index),chaptDownStatus.containsKey(Integer.valueOf(index))));
|
||||
|
||||
|
||||
if (!chaptDownStatus.containsKey(Integer.valueOf(index))) {
|
||||
chaptDownStatus.put(index, DownloadStatus.downloading);
|
||||
Log.d(TAG, String.format("prepare book put chaptDownStatus index %s,start to load chapcontent", index));
|
||||
loadChaptContent(index);
|
||||
}else{
|
||||
Log.d(TAG, String.format("prepare book chaptDownStatus for chapt %s status %s", Integer.valueOf(index),chaptDownStatus.get(Integer.valueOf(index))));
|
||||
}
|
||||
Log.d(TAG, String.format(" prepare book loadChaptContent %s for downloading, chaptDownStatus %s, thread %s ",
|
||||
index, chaptDownStatus.get(Integer.valueOf(index)), Thread.currentThread().getName()));
|
||||
|
||||
|
||||
int maxSleep = 4500;
|
||||
int maxSleep = 2500;
|
||||
int slepttime = 0;
|
||||
// while(!file.exists() && !getDownloadStatus()){//&& slepttime <maxSleep){
|
||||
// while( !getDownloadStatus() && slepttime <maxSleep){
|
||||
|
@ -1518,7 +1524,9 @@ int muluRetryCount =0;
|
|||
Log.d(TAG, String.format("prepare book loadChaptContent ,rertying to download chapt %s ", index));
|
||||
|
||||
loadChaptContent(index);
|
||||
Thread.sleep(mSiteRule.getMiniInterval4AccessChapter());
|
||||
if(mSiteRule!=null) {
|
||||
Thread.sleep(mSiteRule.getMiniInterval4AccessChapter());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1627,7 +1635,7 @@ private void loadChaptContent(final int chapterIndex) throws JSONException, Inte
|
|||
|
||||
}
|
||||
Chapter chapter = mChapters.get(index -1);
|
||||
String refUrl="";
|
||||
String refUrl=REUtil.getDomain(mSite.getMuluUrl());
|
||||
if(index>1){
|
||||
refUrl = mChapters.get(index -2).getChapterUrl();
|
||||
}
|
||||
|
@ -1649,10 +1657,10 @@ private void loadChaptContent(final int chapterIndex) throws JSONException, Inte
|
|||
HttpMethods.getOkClient().newCall(request).enqueue(new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
if(e.toString().contains("closed") ||e.getMessage().contains("Canceled"))
|
||||
/* if(e.toString().contains("closed") ||e.getMessage().contains("Canceled"))
|
||||
{
|
||||
// return;
|
||||
}
|
||||
}*/
|
||||
|
||||
// handler.sendEmptyMessage(123);
|
||||
// handler.sendEmptyMessage(1);
|
||||
|
@ -1661,7 +1669,7 @@ private void loadChaptContent(final int chapterIndex) throws JSONException, Inte
|
|||
chaptDownStatus.put(index,DownloadStatus.failure);
|
||||
// setDownloadFlag(true);
|
||||
Log.d( TAG,String.format("prepare book loadChaptContent %s fail, isDownloadChapt: %s",index,false));
|
||||
e.printStackTrace();
|
||||
// e.printStackTrace();
|
||||
// throw new RuntimeException("Error during writing " + fileChapterName( index));
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ public class Constants {
|
|||
public static List<String> lstNt=null;
|
||||
//public static List<Progress> lstProgress=null;
|
||||
public static String[] lstProgress={"连载中","已完本","新书"};
|
||||
public static int retryCnt =10;
|
||||
public static int retryCnt =3;
|
||||
public static int muluRetryCnt =3;
|
||||
// public static List<String> lstProgress=null;
|
||||
public static boolean showDialogOnUi =true;
|
||||
|
|
|
@ -180,6 +180,10 @@ public class PageFactory implements ChangeSource{
|
|||
private AdInterface mAd;
|
||||
private BookTask bookTask;
|
||||
|
||||
public AdInterface getmAd() {
|
||||
return mAd;
|
||||
}
|
||||
|
||||
public void setAd(AdInterface ad){
|
||||
mAd =ad;
|
||||
}
|
||||
|
@ -223,7 +227,7 @@ public class PageFactory implements ChangeSource{
|
|||
}
|
||||
if(chaptMap.containsKey(chaptId)){
|
||||
chaptPages =chaptMap.get(chaptId);
|
||||
mBookUtil.setBookLen( chaptPages.get(chaptPages.size()-1).getEnd());
|
||||
mBookUtil.setChapterLen( chaptPages.get(chaptPages.size()-1).getEnd());
|
||||
mBookUtil.setChapterNo(chaptId);
|
||||
Log.d(TAG, String.format("prepare book to load chapt %s, cost %s ",chaptId ,new Date().getTime() -starttime) );
|
||||
return chaptMap.get(chaptId);
|
||||
|
@ -331,7 +335,7 @@ public class PageFactory implements ChangeSource{
|
|||
|
||||
chaptPages =readChaptCache(chaptId);
|
||||
chaptMap.put(chaptId,chaptPages);
|
||||
mBookUtil.setBookLen( chaptPages.get(chaptPages.size()-1).getEnd());
|
||||
mBookUtil.setChapterLen( chaptPages.get(chaptPages.size()-1).getEnd());
|
||||
mBookUtil.setChapterNo(chaptId);
|
||||
|
||||
Log.d(TAG, String.format("prepare book to load chapt %s, cost %s ",chaptId ,new Date().getTime() -starttime) );
|
||||
|
@ -388,9 +392,9 @@ public class PageFactory implements ChangeSource{
|
|||
while(length <chars.length ) {
|
||||
pageNo++;
|
||||
TRPage page = getNextChapterPage(chaptId,length);
|
||||
// Log.d(TAG,"prepare book page.getBegin :" + page.getBegin()+ ",chapter length "+ mBookUtil.getBookLen());
|
||||
// Log.d(TAG,"prepare book page.getBegin :" + page.getBegin()+ ",chapter length "+ mBookUtil.getChapterLen());
|
||||
|
||||
// if(page.getBegin() == mBookUtil.getBookLen() ){ //最后一页空白的情况。。。
|
||||
// if(page.getBegin() == mBookUtil.getChapterLen() ){ //最后一页空白的情况。。。
|
||||
|
||||
// break;
|
||||
// }
|
||||
|
@ -778,7 +782,7 @@ public static boolean busy(){
|
|||
|
||||
//画进度及时间
|
||||
int dateWith = (int) (mBatterryPaint.measureText(date)+mBorderWidth);//时间宽度
|
||||
// float fPercent = (float) (currentPage.getBegin() * 1.0 / mBookUtil.getBookLen());//进度
|
||||
// float fPercent = (float) (currentPage.getBegin() * 1.0 / mBookUtil.getChapterLen());//进度
|
||||
float fPercent = (float) (currentPage.getPageNo() * 1.0 /currentChaptPages.size());//进度
|
||||
currentProgress = fPercent;
|
||||
if (mPageEvent != null){
|
||||
|
@ -898,10 +902,10 @@ public static boolean busy(){
|
|||
return;
|
||||
}
|
||||
|
||||
if (currentPage.getEnd() >= mBookUtil.getBookLen()) {
|
||||
if (currentPage.getEnd() >= mBookUtil.getChapterLen()) {
|
||||
Log.d(TAG,"已经是本章最后一页了");
|
||||
|
||||
m_islastPage =currentChapter == mBookUtil.getChapters().size();
|
||||
m_islastPage =currentChapter == mBookUtil.getChapters().size() ||mBookUtil.getChapters().size()==0;
|
||||
if ( m_islastPage){
|
||||
Toast.makeText(mContext, "已经是最后一页了", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
|
@ -1010,7 +1014,7 @@ if(book==null){
|
|||
}
|
||||
if (result) {
|
||||
Log.d(TAG, String.format("prepare book ready, to open chapter %s ",chapter ) );
|
||||
// m_mbBufLen = mBookUtil.getBookLen();
|
||||
// m_mbBufLen = mBookUtil.getChapterLen();
|
||||
mBookUtil.setChapterNo((int)chapter);
|
||||
Log.d(TAG, String.format("prepare book ready, to open chapter, loadCurrentChapt %s ",chapter ) );
|
||||
currentChaptPages = loadCurrentChapt((int)chapter);
|
||||
|
@ -1059,16 +1063,18 @@ if(book==null){
|
|||
public TRPage getNextPage(){
|
||||
|
||||
int nextPageNo =currentPage.getPageNo();
|
||||
Log.e(TAG,String.format("prepare book getNextPage() currentChapter %s, currentChaptPages .size() is %s,currentpage pageno is %s"
|
||||
,currentChapter, currentChaptPages.size() ,currentChapter, nextPageNo));
|
||||
if(nextPageNo >= currentChaptPages.size()){
|
||||
Log.e(TAG,String.format("prepare book getNextPage() currentChapter %s, chapters().size() %s,currentChaptPages .size() is %s,currentpage pageno is %s"
|
||||
,currentChapter, getChapters().size(), currentChaptPages.size() , nextPageNo));
|
||||
if(nextPageNo >= currentChaptPages.size() && getChapters().size()>currentChapter){
|
||||
preChaptPages =currentChaptPages;
|
||||
currentChapter++;
|
||||
mBookUtil.setChapterNo(currentChapter);
|
||||
currentChaptPages = loadCurrentChapt(currentChapter ) ;
|
||||
nextPageNo =0;
|
||||
}else {
|
||||
preReadChaptCache(currentChapter + 1);
|
||||
if(getChapters().size()>currentChapter) {
|
||||
preReadChaptCache(currentChapter + 1);
|
||||
}
|
||||
}
|
||||
return currentChaptPages.get(nextPageNo);
|
||||
}
|
||||
|
@ -1090,7 +1096,9 @@ if(book==null){
|
|||
currentChaptPages = loadCurrentChapt(currentChapter ) ;
|
||||
prePageNo = currentChaptPages.size();
|
||||
}else{
|
||||
preReadChaptCache(currentChapter-1);
|
||||
if(currentChapter-1>0) {
|
||||
preReadChaptCache(currentChapter - 1);
|
||||
}
|
||||
}
|
||||
|
||||
return currentChaptPages.get(prePageNo-1);
|
||||
|
@ -1351,7 +1359,7 @@ if(book==null){
|
|||
|
||||
//更新电量
|
||||
public void updateBattery(int mLevel){
|
||||
mAd.hideSystemUI();
|
||||
if(mAd!=null) mAd.hideSystemUI();
|
||||
if (currentPage != null && mBookPageWidget != null && !mBookPageWidget.isRunning()) {
|
||||
|
||||
Log.d(TAG, String.format("updateBattery: level old %s, new %s",level,mLevel));
|
||||
|
@ -1363,7 +1371,7 @@ if(book==null){
|
|||
}
|
||||
|
||||
public void updateTime(){
|
||||
mAd.hideSystemUI();
|
||||
if(mAd!=null) mAd.hideSystemUI();
|
||||
if (currentPage != null && mBookPageWidget != null && !mBookPageWidget.isRunning()) {
|
||||
String mDate = sdf.format(new java.util.Date());
|
||||
if (date != mDate) {
|
||||
|
@ -1375,7 +1383,7 @@ if(book==null){
|
|||
|
||||
//改变进度
|
||||
public void changeProgress(float progress){
|
||||
long begin = (long) (mBookUtil.getBookLen() * progress);
|
||||
long begin = (long) (mBookUtil.getChapterLen() * progress);
|
||||
currentPage = getPageForBegin(begin);
|
||||
currentPage(true);
|
||||
}
|
||||
|
@ -1526,7 +1534,7 @@ if(book==null){
|
|||
cancelPage = null;
|
||||
prePage = null;
|
||||
currentPage = null;
|
||||
|
||||
mAd=null;
|
||||
currentChaptPages =null;
|
||||
preChaptPages=null;
|
||||
nextChaptPages=null;
|
||||
|
@ -1602,8 +1610,8 @@ if(book==null){
|
|||
mBookUtil.getChapters().clear();
|
||||
mBookUtil.getSiteRule();
|
||||
}
|
||||
public long getBookLen(){
|
||||
return mBookUtil.getBookLen();
|
||||
public long getChapterLen(){
|
||||
return mBookUtil.getChapterLen();
|
||||
}
|
||||
|
||||
public TRPage getCurrentPage(){
|
||||
|
|
|
@ -11,6 +11,9 @@ import java.util.regex.Pattern;
|
|||
public class REUtil {
|
||||
private static final String[] EMPTY = new String[0];
|
||||
|
||||
public static String getDomain(String fullUrl){
|
||||
return REUtil.match("(?i)http[s]?://[^/]+", fullUrl);
|
||||
}
|
||||
public static String match(String pattern, String target) {
|
||||
return match(pattern, target, true);
|
||||
}
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- 实心 -->
|
||||
<solid android:color="@color/colorPrimary"/>
|
||||
<solid android:color="@color/colorPrimaryDark"/>
|
||||
<!-- 渐变 -->
|
||||
<!--<gradient-->
|
||||
<!--android:startColor="#ff8c00"-->
|
||||
<!--android:endColor="#FFFFFF"-->
|
||||
<!--android:angle="270" />-->
|
||||
<gradient
|
||||
android:startColor="@color/colorPrimary"
|
||||
android:endColor="@color/colorPrimaryDark"
|
||||
android:angle="270" />
|
||||
|
||||
<!-- 描边 -->
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:width="2dp"
|
||||
android:color="@color/white" />
|
||||
<!-- 圆角 -->
|
||||
<corners
|
||||
android:radius="6dp" />
|
||||
android:radius="8dp" />
|
||||
<padding
|
||||
android:left="15dp"
|
||||
android:top="5dp"
|
||||
android:right="15dp"
|
||||
android:bottom="5dp" />
|
||||
android:left="11dp"
|
||||
android:top="2dp"
|
||||
android:right="11dp"
|
||||
android:bottom="3dp" />
|
||||
</shape>
|
|
@ -34,13 +34,13 @@
|
|||
|
||||
android:gravity="center"
|
||||
android:text="我是标题"
|
||||
android:textSize="20sp"
|
||||
android:textSize="18sp"
|
||||
android:layout_weight="1"
|
||||
android:visibility="visible"
|
||||
android:textColor="@color/white"
|
||||
|
||||
/>
|
||||
<android.support.v7.widget.AppCompatSpinner
|
||||
<!-- <android.support.v7.widget.AppCompatSpinner
|
||||
android:id="@+id/sexSelect"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -52,7 +52,7 @@
|
|||
android:layout_gravity="left|center_vertical"
|
||||
android:layout_weight="0"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
/>-->
|
||||
<RadioGroup
|
||||
android:id="@+id/rgSex"
|
||||
|
||||
|
@ -69,6 +69,7 @@
|
|||
android:id="@+id/radioButtonGirl"
|
||||
android:text="女生"
|
||||
style="@style/radioButton"
|
||||
|
||||
/>
|
||||
</RadioGroup>
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
app:tl_indicator_width="45dp"
|
||||
app:tl_textSelectColor="@color/tabSelected"
|
||||
app:tl_textUnselectColor="@color/grey"
|
||||
app:tl_textsize="16sp"
|
||||
app:tl_textsize="14sp"
|
||||
app:tl_textBold="SELECT"
|
||||
app:tl_tab_space_equal ="true"
|
||||
app:tl_indicator_bounce_enable ="true"
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<!-- 书本宽边距 -->
|
||||
<dimen name="readingMarginWidth">15dp</dimen>
|
||||
<!-- 书本高边距 -->
|
||||
<dimen name="readingMarginHeight">30dp</dimen>
|
||||
<dimen name="readingMarginHeight">40dp</dimen>
|
||||
<!-- 状态栏离底部距离 -->
|
||||
<dimen name="reading_status_margin_bottom">3dp</dimen>
|
||||
<!-- 行间距 -->
|
||||
|
|
|
@ -104,6 +104,8 @@
|
|||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant_run_split_apk_resources" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javac" />
|
||||
<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/manifest-checker" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged-not-compiled-resources" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged_assets" />
|
||||
|
@ -188,6 +190,8 @@
|
|||
<orderEntry type="library" name="Gradle: __local_aars__:E.\reading\android\asProjects\zhuike\libs\Msc.jar:unspecified@jar" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.android.support:appcompat-v7:28.0.0@aar" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.squareup.okhttp3:okhttp:3.14.0@jar" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.android.support:multidex:1.0.2@aar" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support:multidex-instrumentation:1.0.2@aar" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.litepal.android:core:3.0.0@aar" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.reactivestreams:reactive-streams:1.0.2@jar" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.packetzoom:pz-okhttp3-interceptor:3.2.43@aar" level="project" />
|
||||
|
|
Loading…
Reference in New Issue