diff --git a/zhuike/build.gradle b/zhuike/build.gradle
index 414e1a9..83713ec 100644
--- a/zhuike/build.gradle
+++ b/zhuike/build.gradle
@@ -168,4 +168,8 @@ dependencies {
implementation 'com.github.ixiaow:multilayout:1.0.0'
implementation 'com.umeng.umsdk:analytics:8.0.2'
implementation 'com.umeng.umsdk:common:2.0.2'
+
+
+ implementation 'q.rorbin:VerticalTabLayout:1.2.5'
+ implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.16'
}
diff --git a/zhuike/src/main/AndroidManifest.xml b/zhuike/src/main/AndroidManifest.xml
index 4e43144..d5be0dd 100644
--- a/zhuike/src/main/AndroidManifest.xml
+++ b/zhuike/src/main/AndroidManifest.xml
@@ -49,6 +49,7 @@
mFragments;
ArrayList mList;
String[] mTitle;
- public static String TAG="com.novelbook.android.Activity_cate_books";
+
+ private int tabPos;
@Override
public int getLayoutRes() {
@@ -40,7 +54,7 @@ public class Activity_cate_books extends Activity_base {
@Override
protected void initViews() {
creatToolbar();
- initTabs();
+ initTabs2();
}
@@ -62,17 +76,37 @@ public class Activity_cate_books extends Activity_base {
//---------tabs-------------
void initTabs() {
-
- if (mFragments == null || mFragments.size() == 0) {
- mTitle = new String[]{"新书", "连载", "完本"};
- mFragments = new ArrayList();
-
- mFragments.add(Fragment_booklist.newInstance(cate, 1));
- mFragments.add(Fragment_booklist.newInstance(cate, 2));
- mFragments.add(Fragment_booklist.newInstance(cate, 3));
-
- Log.d(TAG, "initial fragments in tabs ");
+ List lstType = new ArrayList() ;//Arrays.asList(lstProgress);
+ for(ProgressType progressType : Constants.lstProgressType){
+ lstType.add(progressType.getName());
}
+ topic_layout.initTabNames(lstType) ;
+ topic_layout.setOnTabSelectListener(new MultiLayout.OnTabSelectListener() {
+ @Override
+ public void select(TextView textView, int i, int i1) {
+ Log.d(TAG, String.format("select: text %s,i %s i1 %s ",textView.getText(),i,i1));
+ tabPos = i1;
+ tabChanged();
+ }
+ });
+
+
+ }
+ void initTabs2() {
+
+
+ if (mFragments == null ) {
+
+ mFragments = new ArrayList();
+ }
+ mFragments.clear();
+
+ for(ProgressType progressType : Constants.lstProgressType) {
+ mFragments.add(Fragment_booklist.newInstance(cate, progressType.getId()));
+ }
+
+ Log.d(TAG, "initial fragments in tabs ");
+
Log.d(TAG, "set viewPager adapter ");
// FragmentPagerAdapter mAdapter = new FragmentPagerAdapter(activity.getSupportFragmentManager()) { 第一次进入没问题,再次进入ViewPager的fragment时里面内容就没了,数据丢失 https://blog.csdn.net/allan_bst/article/details/64920076
FragmentPagerAdapter mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
@@ -89,20 +123,71 @@ public class Activity_cate_books extends Activity_base {
//ViewPager与TabLayout绑定后,这里获取到PageTitle就是Tab的Text
@Override
public CharSequence getPageTitle(int position) {
- return mTitle[position];
+ return Constants.lstProgressType.get(position).getName();
}
};
mViewpager.setAdapter(mAdapter);
- mViewpager.setOffscreenPageLimit(3);
-
-
-
- tabLayout.setViewPager(mViewpager);
+ mViewpager.setOffscreenPageLimit( Constants.lstProgressType.size()+1);
+ tabLayout.setViewPager(mViewpager);
// tabLayout.setViewPager(mViewpager, mTitle, activity, mFragments);
mViewpager.setCurrentItem(0);
+
+
}
+ int tmp=0;
+ private void tabChanged() {
+
+ Log.d(TAG, String.format("tabChanged: to load data tmp %s" , tmp ));
+ tmp++;
+
+ if(lstSex==null) return;
+
+
+
+ if (mFragments == null ) {
+
+ mFragments = new ArrayList();
+ }
+ mFragments.clear();
+
+ mFragments.add(Fragment_booklist.newInstance(cate, Constants.lstProgressType.get(tabPos).getId()));
+
+
+ Log.d(TAG, "initial fragments in tabs ");
+
+ Log.d(TAG, "set viewPager adapter ");
+ // FragmentPagerAdapter mAdapter = new FragmentPagerAdapter(activity.getSupportFragmentManager()) { 第一次进入没问题,再次进入ViewPager的fragment时里面内容就没了,数据丢失 https://blog.csdn.net/allan_bst/article/details/64920076
+ FragmentPagerAdapter mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
+ @Override
+ public Fragment getItem(int position) {
+ return mFragments.get(position);
+ }
+
+ @Override
+ public int getCount() {
+ return mFragments.size();
+ }
+
+ //ViewPager与TabLayout绑定后,这里获取到PageTitle就是Tab的Text
+ @Override
+ public CharSequence getPageTitle(int position) {
+ return mTitle[position];
+ }
+ };
+ mViewpager.setAdapter(mAdapter);
+ mViewpager.setOffscreenPageLimit(2);
+
+
+
+ // tabLayout.setViewPager(mViewpager);
+ // tabLayout.setViewPager(mViewpager, mTitle, activity, mFragments);
+ mViewpager.setCurrentItem(0);
+
+ }
+
+
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
diff --git a/zhuike/src/main/java/com/novelbook/android/Activity_paihangbang.java b/zhuike/src/main/java/com/novelbook/android/Activity_paihangbang.java
index 4ba1212..3389b02 100644
--- a/zhuike/src/main/java/com/novelbook/android/Activity_paihangbang.java
+++ b/zhuike/src/main/java/com/novelbook/android/Activity_paihangbang.java
@@ -30,6 +30,7 @@ public static String TAG ="com.novelbook.android.paihangbang";
@BindView(R.id.tab_layout)
SlidingTabLayout tabLayout;
public static final String EXTR_FN="fn";
+ public static final String EXTR_CID="cid";
public static final String EXTR_TITLE="title";
public static final String EXTR_BANGDAN ="bangdan";
public static final String EXTR_SEARCH ="search";
@@ -47,7 +48,7 @@ public static String TAG ="com.novelbook.android.paihangbang";
initTabs();
}
-
+ int cid;
String bangdan,fn,keyword,histroy;
@Override
@@ -58,7 +59,7 @@ public static String TAG ="com.novelbook.android.paihangbang";
}
fn = getIntent().getStringExtra(EXTR_FN);
-
+ cid = getIntent().getIntExtra(EXTR_CID,-1);
bangdan = getIntent().getStringExtra(EXTR_BANGDAN);
String title = getIntent().getStringExtra(EXTR_TITLE);
@@ -95,6 +96,8 @@ public static String TAG ="com.novelbook.android.paihangbang";
}else if(!TextUtils.isEmpty(fn)){
mFragments.add(Fragment_booklist.newInstance(fn, bangdan)); //首页更多
+ }else if(cid>0){
+ mFragments.add(Fragment_booklist.newInstance(cid, bangdan)); //首页更多
}
diff --git a/zhuike/src/main/java/com/novelbook/android/BookActivity.java b/zhuike/src/main/java/com/novelbook/android/BookActivity.java
index 61fc06b..64503fc 100644
--- a/zhuike/src/main/java/com/novelbook/android/BookActivity.java
+++ b/zhuike/src/main/java/com/novelbook/android/BookActivity.java
@@ -268,7 +268,12 @@ public class BookActivity extends Activity_base {
this.txtLatestCate.setText(mNovel.getChapterName());
tvLastUpdate.setText(CommonUtil.getDateString( mNovel.getLastUpdateTime()));
loadImageView(mNovel.getCover(),imageView);
- gaosiHeadPic();
+ try {
+ gaosiHeadPic();
+ }catch (Exception e){
+ Log.e(TAG, "setBookDetailInfo: gosiheadpic error", e);
+ }
+
}
void gaosiHeadPic(){
//new BlurTransformation(BookActivity.this, 10)).into(mImageView);
diff --git a/zhuike/src/main/java/com/novelbook/android/Fragments/BasicFragment.java b/zhuike/src/main/java/com/novelbook/android/Fragments/BasicFragment.java
index 9367b07..6202e47 100644
--- a/zhuike/src/main/java/com/novelbook/android/Fragments/BasicFragment.java
+++ b/zhuike/src/main/java/com/novelbook/android/Fragments/BasicFragment.java
@@ -134,7 +134,7 @@ public abstract class BasicFragment extends Fragment {
}
- public abstract void setFTag();
+ public void setFTag(){};
Handler handler = new Handler() {
@Override
@@ -380,7 +380,7 @@ public abstract class BasicFragment extends Fragment {
Intent intent = new Intent(activity, Activity_paihangbang.class);
String title = TextUtils.isEmpty(nb.getTitle()) ? nb.getName() : nb.getTitle() ;
- intent.putExtra(Activity_paihangbang.EXTR_FN,nb.getFn() );
+ intent.putExtra(Activity_paihangbang.EXTR_CID,nb.getCid() );
intent.putExtra(Activity_paihangbang.EXTR_TITLE,title );
intent.putExtra(Activity_paihangbang.EXTR_BANGDAN,title );
startActivity(intent);
diff --git a/zhuike/src/main/java/com/novelbook/android/Fragments/CatalogFragment.java b/zhuike/src/main/java/com/novelbook/android/Fragments/CatalogFragment.java
index ebe4510..b9134f4 100644
--- a/zhuike/src/main/java/com/novelbook/android/Fragments/CatalogFragment.java
+++ b/zhuike/src/main/java/com/novelbook/android/Fragments/CatalogFragment.java
@@ -177,7 +177,7 @@ public class CatalogFragment extends BasicFragment implements MarkActivity.Sortc
}
}
- int maxSlept =NetUtil.isNetworkConnected()?50 :200;
+ int maxSlept =NetUtil.isNetworkConnected()?250 :100;
int slepttime = 0;
while ( slepttime < maxSlept && ( pageFactory.isReadingCatalogs() || pageFactory.getChapters().size() == 0)) {
try {
diff --git a/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_Shelf.java b/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_Shelf.java
index 06689cd..5b9bd28 100644
--- a/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_Shelf.java
+++ b/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_Shelf.java
@@ -80,6 +80,7 @@ public class Fragment_Shelf extends BasicFragment {
private List bookLists;
// private ShelfAdapter adapter;
private String noveIds ;
+ BottomSheetDialog bottomSheetDialog;
public Fragment_Shelf() {
// Required empty public constructor
}
@@ -330,7 +331,7 @@ void test(int maxAge){
private void initDialog(int position) {
- BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this.activity);
+ bottomSheetDialog = new BottomSheetDialog(this.activity);
bottomSheetDialog.setContentView(R.layout.fragment_shelf_botoomsheetdialog);
//给布局设置透明背景色
bottomSheetDialog.getDelegate().findViewById(android.support.design.R.id.design_bottom_sheet)
@@ -488,7 +489,9 @@ void test(int maxAge){
public void onResume() {
super.onResume();
getUpdatedData(); //TODO: 更新书的状态,是不有更新
-
+ if(bottomSheetDialog!=null){
+ bottomSheetDialog.hide();
+ }
}
diff --git a/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_bangdan.java b/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_bangdan.java
index 684fcaa..32845a8 100644
--- a/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_bangdan.java
+++ b/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_bangdan.java
@@ -31,8 +31,7 @@ public class Fragment_bangdan extends BasicFragment {
public static final String TAG=Fragment_bangdan.class.getSimpleName();
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
- private static final String ARG_PARAM1 = "param1";
- private static final String ARG_PARAM2 = "param2";
+ private static final String ARG_CID = "CID";
private BandanAdapterNew mAdapter;
private List mBlocks;
private List mMoreBlocks;
@@ -42,11 +41,11 @@ public class Fragment_bangdan extends BasicFragment {
// @BindView(R.id.topic_layout)
// MultiLayout topic_layout;
- public static Fragment_bangdan newInstance(String param1, String param2) {
+ private int cid;
+ public static Fragment_bangdan newInstance(int cid) {
Fragment_bangdan fragment = new Fragment_bangdan();
Bundle args = new Bundle();
- args.putString(ARG_PARAM1, param1);
- args.putString(ARG_PARAM2, param2);
+ args.putInt(ARG_CID, cid);
fragment.setArguments(args);
return fragment;
}
@@ -74,6 +73,11 @@ public class Fragment_bangdan extends BasicFragment {
@Override
public void initData() {
+
+ if (getArguments() != null) {
+ cid = getArguments().getInt(ARG_CID);
+ }
+
if(pageNo==1) {
if(mBlocks!=null){ //下拉刷新
@@ -116,7 +120,7 @@ public class Fragment_bangdan extends BasicFragment {
showProgressDialog(true, "正在加载");
mMoreBlocks =null;
- BookSubscribe.getSiteRanks( Constants.SEX,new OnSuccessAndFaultSub(new OnSuccessAndFaultListener() {
+ BookSubscribe.getPaihangBangByCate( Constants.SEX,cid,new OnSuccessAndFaultSub(new OnSuccessAndFaultListener() {
@Override
public void onSuccess(String result) {
diff --git a/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_bangdans.java b/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_bangdans.java
new file mode 100644
index 0000000..8f325b2
--- /dev/null
+++ b/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_bangdans.java
@@ -0,0 +1,185 @@
+package com.novelbook.android.Fragments;
+
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentStatePagerAdapter;
+import android.support.v4.view.ViewPager;
+import android.util.Log;
+import android.view.View;
+
+import com.flyco.tablayout.SlidingTabLayout;
+import com.novelbook.android.R;
+import com.novelbook.android.bean.BangdanCate;
+import com.novelbook.android.netsubscribe.BookSubscribe;
+import com.novelbook.android.netutils.OnSuccessAndFaultListener;
+import com.novelbook.android.netutils.OnSuccessAndFaultSub;
+import com.novelbook.android.utils.Constants;
+import com.novelbook.android.utils.GsonUtil;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import butterknife.BindView;
+import q.rorbin.verticaltablayout.VerticalTabLayout;
+
+
+public class Fragment_bangdans extends BasicFragment {
+
+ public static String TAG= Fragment_bangdans.class.getSimpleName();
+
+ @BindView(R.id.viewpager)
+ ViewPager mViewpager;
+ @BindView(R.id.tablayout)
+ VerticalTabLayout tabLayout;
+ private FragmentStatePagerAdapter mAdapter =null;
+ private ArrayList mFragments;
+ ArrayList mList;
+ String[] mTitle;
+
+ List mCateList;
+ protected void processArguments(){
+ if (getArguments() != null) {
+ Bundle bundle = getArguments() ;
+
+
+
+ }
+ }
+
+
+ public static Fragment_bangdans newInstance(String param1, String param2) {
+ Fragment_bangdans fragment = new Fragment_bangdans();
+ Bundle args = new Bundle();
+
+ fragment.setArguments(args);
+ return fragment;
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ if (getArguments() != null) {
+ // mParam1 = getArguments().getString(ARG_PARAM1);
+ // mParam2 = getArguments().getString(ARG_PARAM2);
+ }
+ }
+
+
+
+ @Override
+ protected int getLayoutRes() {
+ return R.layout.fragment_bangdans;
+ }
+
+ @Override
+ public void initData() {
+
+ showProgressDialog(false,"正在加载榜单列表");
+ getCateTabTtitle();
+
+ }
+ @Override
+ public void fillData() {
+
+ // initTabs();
+ };
+
+ public void onSexSwitch(){
+ if(mAdapter!=null) {
+ for(BasicFragment bf:mFragments){
+ bf.initData();
+ }
+ mAdapter.notifyDataSetChanged();
+
+ }
+ }
+
+ @Override
+ public void initViews(){
+ mFragments = new ArrayList<>();
+ mAdapter = new FragmentStatePagerAdapter(getChildFragmentManager()) {
+ @Override
+ public Fragment getItem(int position) {
+ return mFragments.get(position);
+ }
+
+ @Override
+ public int getCount() {
+ return mFragments.size();
+ }
+ //ViewPager与TabLayout绑定后,这里获取到PageTitle就是Tab的Text
+ @Override
+ public CharSequence getPageTitle(int position) {
+ return mCateList.get(position).getName();
+ }
+ };
+
+
+ // mViewpager.setAdapter(mAdapter);
+ // tabLayout.setupWithViewPager(mViewpager);
+ }
+
+ //---------tabs-------------
+
+ void initTabs() {
+ Log.d(TAG, "getCateTabTtitle: init tabs");
+ // if(mFragments ==null || mFragments.size() ==0)
+ {
+ // mTitle = new String[]{"精选", "榜单", "书单"};
+ mFragments.clear();
+
+ for(BangdanCate bangdanCate : mCateList) {
+ mFragments.add(Fragment_bangdan.newInstance(bangdanCate.getCid()));
+ }
+
+ // mFragments.add(new Fragment_shudan());
+ Log.d(TAG,"initial fragments in tabs ");
+ }
+ Log.d(TAG,"set viewPager adapter ");
+ // FragmentPagerAdapter mAdapter = new FragmentPagerAdapter(activity.getSupportFragmentManager()) { 第一次进入没问题,再次进入ViewPager的fragment时里面内容就没了,数据丢失 https://blog.csdn.net/allan_bst/article/details/64920076
+ mAdapter.notifyDataSetChanged();
+ // mViewpager.setOffscreenPageLimit(30);//预加载设置
+ if(mCateList!=null){
+ mViewpager.setOffscreenPageLimit(mCateList.size()+1);//预加载设置
+ }
+ mViewpager.setAdapter(mAdapter);
+ tabLayout.setupWithViewPager(mViewpager);
+ // tabLayout.setViewPager(mViewpager, mTitle, activity, mFragments);
+ // mViewpager.setCurrentItem(0);
+ }
+
+
+ void getCateTabTtitle(){
+
+ Log.d(TAG, "getCateTabTtitle: prepare cate tabs");
+
+ BookSubscribe.getPaihangBangCateList(Constants.SEX,new OnSuccessAndFaultSub(new OnSuccessAndFaultListener() {
+ @Override
+ public void onSuccess(String result) {
+ try {
+
+ mCateList = GsonUtil.parserBangdanCate(result,"subCategories");
+
+ initTabs();
+
+ } catch (Exception e) {
+ Log.e(TAG, "onSuccess: prepare book",e );
+ e.printStackTrace();
+ }
+ handler.sendEmptyMessage(0);
+
+ }
+
+ @Override
+ public void onFault(String errorMsg) {
+ //失败
+ Log.d(TAG, "error on get firstpage: " + errorMsg);
+ // getSearchTabTtitle();
+ handler.sendEmptyMessage(0);
+ }
+ },getActivity()));
+
+ }
+
+}
diff --git a/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_bookStore.java b/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_bookStore.java
index b733782..1d3532a 100644
--- a/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_bookStore.java
+++ b/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_bookStore.java
@@ -28,6 +28,7 @@ public class Fragment_bookStore extends BasicFragment {
SlidingTabLayout tabLayout;
private FragmentStatePagerAdapter mAdapter =null;
private ArrayList mFragments;
+ private ArrayList mFragments_cp;
ArrayList mList;
String[] mTitle;
@@ -75,9 +76,14 @@ public class Fragment_bookStore extends BasicFragment {
}
public void onSexSwitch(){
if(mAdapter!=null) {
- for(BasicFragment bf:mFragments){
+ for(BasicFragment bf: mFragments_cp){
bf.initData();
}
+ /* for(int i=0;i();
mFragments.add(new Fragment_jingxuan());
mFragments.add(FragmentCates.newInstance());
- mFragments.add(new Fragment_bangdan());
-
+ mFragments.add(new Fragment_bangdans());
+ mFragments_cp = new ArrayList<>();
+ mFragments_cp.addAll(mFragments);
// mFragments.add(new Fragment_shudan());
Log.d(TAG,"initial fragments in tabs ");
}
diff --git a/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_booklist.java b/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_booklist.java
index d364950..024d1dd 100644
--- a/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_booklist.java
+++ b/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_booklist.java
@@ -50,12 +50,13 @@ public class Fragment_booklist extends BasicFragment {
private static final String EXTR_FN ="fn" ;
private static final String EXTR_BANGDAN ="bangdan" ;
private static final String EXTR_HISTORY ="history" ;
+ private static final String EXTR_CID ="cid" ;
private BookListAdapter mAdapter;
// private BookListAdapter mAdapter;
private List mData;;
private List mMoreData;
private String cate;
- private int progress;
+ private int progress,cid;
private String keyWord ,fn,bangdan,history;
private int listItem =R.layout.recycle_list_item_horizon;
//private int pageNo=1;
@@ -75,6 +76,14 @@ public class Fragment_booklist extends BasicFragment {
public Fragment_booklist() {
// Required empty public constructor
}
+ public static Fragment_booklist newInstance(int cid,String bangdan) {
+ Fragment_booklist fragment = new Fragment_booklist();
+ Bundle args = new Bundle();
+ args.putInt(EXTR_CID,cid);
+ args.putString(EXTR_BANGDAN,bangdan);
+ fragment.setArguments(args);
+ return fragment;
+ }
public static Fragment_booklist newInstance(String fn,String bangdan) {
Fragment_booklist fragment = new Fragment_booklist();
Bundle args = new Bundle();
@@ -112,7 +121,7 @@ public class Fragment_booklist extends BasicFragment {
Bundle bundle = getArguments() ;
bangdan =bundle.getString(EXTR_BANGDAN);
fn= bundle.getString(EXTR_FN);
-
+ cid =bundle.getInt(EXTR_CID);
if(!TextUtils.isEmpty((fn))){
return;
}
@@ -230,10 +239,10 @@ public class Fragment_booklist extends BasicFragment {
Log.d(TAG,String.format("fn is %s",fn) );
- if(!TextUtils.isEmpty(bangdan) && !TextUtils.isEmpty(fn)){ //榜单
+ if(!TextUtils.isEmpty(bangdan) && (cid >0 || !TextUtils.isEmpty(fn))){ //榜单
// showProgressDialog(true, "正在加载榜单");
mAdapter.setShowTop(true);
- BookSubscribe.getSiteRankDetail(fn,pageNo,Constants.SEX,new OnSuccessAndFaultSub(new OnSuccessAndFaultListener() {
+ BookSubscribe.getPaihangBangList(Constants.SEX,pageNo,cid,new OnSuccessAndFaultSub(new OnSuccessAndFaultListener() {
@Override
public void onSuccess(String result) {
diff --git a/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_paihang.java b/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_paihang.java
index fe3fd1b..f8c25ff 100644
--- a/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_paihang.java
+++ b/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_paihang.java
@@ -9,16 +9,13 @@ import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
-import android.widget.LinearLayout;
import android.widget.TextView;
-import android.widget.Toast;
-import com.google.gson.Gson;
import com.ixiaow.multilayout.MultiLayout;
import com.novelbook.android.R;
-import com.novelbook.android.adapter.JudgeNestedScrollView;
-import com.novelbook.android.bean.Progress;
+
+import com.novelbook.android.bean.ProgressType;
import com.novelbook.android.db.Novel;
import com.novelbook.android.netapi.RandomHost;
import com.novelbook.android.netsubscribe.BookSubscribe;
@@ -31,10 +28,10 @@ import com.novelbook.android.utils.OnItemClickListener;
import com.novelbook.android.adapter.BookListAdapter;
import com.flyco.tablayout.CommonTabLayout;
import com.flyco.tablayout.listener.CustomTabEntity;
-import com.flyco.tablayout.listener.OnTabSelectListener;
import org.json.JSONArray;
import org.json.JSONObject;
+import org.litepal.util.Const;
import java.util.ArrayList;
import java.util.Arrays;
@@ -213,7 +210,7 @@ final String TAG = Fragment_paihang.class.getSimpleName();
}
};
showProgressDialog(false, "正在加载...");
- BookSubscribe.getCateNovelList(cate, pageNo, tab1Pos+1, tab3Pos+1, new OnSuccessAndFaultSub(successAndFaultListener, getActivity()));
+ BookSubscribe.getCateNovelList(cate, pageNo, Constants.SEX, Constants.lstProgressType.get(tab3Pos).getId(), new OnSuccessAndFaultSub(successAndFaultListener, getActivity()));
}
@@ -221,7 +218,7 @@ final String TAG = Fragment_paihang.class.getSimpleName();
public void initViews(){
appBarLayout.setVisibility(View.GONE);
if(lstNt==null) {
- getSearchTabTtitle();
+ // getSearchTabTtitle();
}
else {
initTabs();
@@ -263,7 +260,10 @@ final String TAG = Fragment_paihang.class.getSimpleName();
}*/
- List lstType = Arrays.asList(lstProgress);
+ List lstType = new ArrayList() ;//Arrays.asList(lstProgress);
+ for(ProgressType progressType : Constants.lstProgressType){
+ lstType.add(progressType.getName());
+ }
topic_layout.initTabNames(lstNt) ;
topic_layout1.initTabNames( lstSex) ;
topic_layout2.initTabNames(lstType) ;
@@ -322,8 +322,8 @@ final String TAG = Fragment_paihang.class.getSimpleName();
String sex = lstSex.get(tab1Pos);
String cate = lstNt.get(tab2Pos);
String selectedKey = lstSex.get(tab1Pos) +" " +
- cate +" " +
- lstProgress[tab3Pos] ;
+ cate +" " + Constants.lstProgressType.get(tab3Pos).getName();
+ // lstProgress[tab3Pos] ;
@@ -331,7 +331,7 @@ final String TAG = Fragment_paihang.class.getSimpleName();
tvHint.setText(selectedKey);
Log.d(TAG, String.format("tabChanged: to load data %s,pageno %s, tmp %s" , selectedKey,pageNo ,tmp));
- if( tmp<4) return;
+ if( tmp height;
- if (scrollY <= height) {
- // scale = (float) scrollY / height;
- // alpha = (int) (255 * scale);
- tvHint.setVisibility(View.GONE);
- // 随着滑动距离改变透明度
- // Log.e("al=","="+alpha);
- // re.setBackgroundColor(Color.argb(alpha, 255, 0, 0));
- mNestedScrollView.setNeedScroll(true);
- } else {
- tvHint.setVisibility(View.VISIBLE);
- // if (alpha < 255) {
- // Log.e("执行次数", "=" + (++count));
- // 防止频繁重复设置相同的值影响性能
- // alpha = 255;
- // re.setBackgroundColor(Color.argb(alpha, 255, 0, 0));
- // }
- mNestedScrollView.setNeedScroll(false);
- }
- *//* LinearLayoutManager layoutManager = (LinearLayoutManager) NestedScrollView.getLayoutManager();
- int lastVisibleItemPosition = 0;
- int totalItemCount = layoutManager.getItemCount();
-
- if(v.getChildAt(v.getChildCount() - 1) != null) {
- if (scrollY >= (v.getChildAt(v.getChildCount()-1).getMeasuredHeight() - v.getMeasuredHeight())
- && scrollY > oldScrollY) {
- if (layoutManager instanceof LinearLayoutManager) {
- lastVisibleItemPosition = ((LinearLayoutManager) layoutManager).findLastVisibleItemPosition();
- }
-
- if (totalItemCount < previousTotalItemCount) {
- this.currentPage = this.startingPageIndex;
- this.previousTotalItemCount = totalItemCount;
- if (totalItemCount == 0) {
- this.loading = true;
- }
- }
-
- if (loading && (totalItemCount > previousTotalItemCount)) {
- loading = false;
- previousTotalItemCount = totalItemCount;
- }
-
- if (!loading && (lastVisibleItemPosition + visibleThreshold) > totalItemCount) {
- currentPage++;
- onLoadMore();
- loading = true;
- }
- }
- }*//*
-
-
-
- }
-
- });
-
- }
-*/
@Override
public void onResume() {
super.onResume();
//mNestedScrollView.smoothScrollBy(1,1);
// tvHint.setVisibility(isShowHint? View.VISIBLE:View.GONE);
-
+ tmp=0;
}
@@ -496,38 +418,6 @@ final String TAG = Fragment_paihang.class.getSimpleName();
}
- void getSearchTabTtitle(){
- BookSubscribe.getSearchTitles(Constants.SEX,new OnSuccessAndFaultSub(new OnSuccessAndFaultListener() {
- @Override
- public void onSuccess(String result) {
-
- // mFirstPage= gson.fromJson(result, FirstPage.class);
- try {
-
- Constants.lstSex = GsonUtil.parserStringBlocks(result,"sex");
- Constants.lstNt =GsonUtil.parserStringBlocks(result,"nt");
- // Constants.lstProgress =GsonUtil.parserProgressBlocks(result,"progress");
- initTabs();
- loadSearchData();
- } catch (Exception e) {
- Log.e(TAG, "onSuccess: prepare book",e );
- e.printStackTrace();
- }
-
-
- }
-
- @Override
- public void onFault(String errorMsg) {
- //失败
- Log.d(TAG, "error on get firstpage: " + errorMsg);
- // getSearchTabTtitle();
- handler.sendEmptyMessage(0);
- }
- },getActivity()));
-
- }
-
}
diff --git a/zhuike/src/main/java/com/novelbook/android/Main2Activity.java b/zhuike/src/main/java/com/novelbook/android/Main2Activity.java
index 40a1a7f..5dfa6d5 100644
--- a/zhuike/src/main/java/com/novelbook/android/Main2Activity.java
+++ b/zhuike/src/main/java/com/novelbook/android/Main2Activity.java
@@ -86,7 +86,7 @@ public class Main2Activity extends Activity_base
initialSexOption();
checkUpdate(true);
- // getSearchTabTtitle();
+ getSearchTabTtitle();
}
@@ -551,6 +551,39 @@ private int bottomSelectedIndex;
}
//----get master domain
+void getSearchTabTtitle(){
+ BookSubscribe.getSearchTitles(Constants.SEX,new OnSuccessAndFaultSub(new OnSuccessAndFaultListener() {
+ @Override
+ public void onSuccess(String result) {
+
+ // mFirstPage= gson.fromJson(result, FirstPage.class);
+ try {
+
+ Constants.lstSex = GsonUtil.parserStringBlocks(result,"sex");
+ Constants.lstNt =GsonUtil.parserStringBlocks(result,"nt");
+ Constants.lstProgressType =GsonUtil.parserProgressType(result,"progress");
+
+ // initTabs();
+ // loadSearchData();
+ } catch (Exception e) {
+ Log.e(TAG, "onSuccess: prepare book",e );
+ e.printStackTrace();
+ }
+
+
+ }
+
+ @Override
+ public void onFault(String errorMsg) {
+ //失败
+ Log.d(TAG, "error on get firstpage: " + errorMsg);
+ // getSearchTabTtitle();
+ handler.sendEmptyMessage(0);
+ }
+ },this));
+
+}
+
}
diff --git a/zhuike/src/main/java/com/novelbook/android/MarkActivity.java b/zhuike/src/main/java/com/novelbook/android/MarkActivity.java
index 913f903..a1db955 100644
--- a/zhuike/src/main/java/com/novelbook/android/MarkActivity.java
+++ b/zhuike/src/main/java/com/novelbook/android/MarkActivity.java
@@ -11,6 +11,7 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageButton;
+import android.widget.ImageView;
import com.flyco.tablayout.SlidingTabLayout;
import com.novelbook.android.adapter.MyPagerAdapter;
diff --git a/zhuike/src/main/java/com/novelbook/android/ReadActivity.java b/zhuike/src/main/java/com/novelbook/android/ReadActivity.java
index be3443e..06cfb71 100644
--- a/zhuike/src/main/java/com/novelbook/android/ReadActivity.java
+++ b/zhuike/src/main/java/com/novelbook/android/ReadActivity.java
@@ -26,6 +26,7 @@ import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.FrameLayout;
+import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
@@ -111,6 +112,8 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
@BindView(R.id.llTopAd)
LinearLayout llTopAd;
+ @BindView(R.id.imgLoading)
+ pl.droidsonroids.gif.GifImageView imgLoading;
private Config config;
private WindowManager.LayoutParams lp;
@@ -178,6 +181,7 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
config = Config.getInstance();
pageFactory = PageFactory.getInstance(getApplicationContext());
+ pageFactory.clear();
pageFactory.setAd(this);
llTopAd.setVisibility(View.GONE);
@@ -589,7 +593,7 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
-
+ pageFactory.setPageWidget(bookpage);
if (id == R.id.action_add_bookmark){
if( pageFactory.isReady())
if (pageFactory.getCurrentPage() != null) {
@@ -804,6 +808,21 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
btnRefresh.setVisibility(visible);
}
+ @Override
+ public void showProgressbar(boolean dismissAble,String msg) {
+ showProgressDialog(dismissAble,msg);
+ }
+
+ @Override
+ public void hideProgressbar() {
+
+ }
+
+ @Override
+ public void showLoading(boolean isShow) {
+ imgLoading.setVisibility(isShow?View.VISIBLE:View.GONE);
+ }
+
private void showSystemUI() {
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
@@ -886,6 +905,7 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
R.id.tv_dayornight,R.id.tv_pagemode, R.id.tv_setting, R.id.bookpop_bottom, /*R.id.rl_bottom,*/R.id.tv_stop_read
,R.id.llTopAd,R.id.btnRefresh})
public void onClick(View view) {
+ pageFactory.setPageWidget(bookpage);
// if( pageFactory.isReady())
switch (view.getId()) {
// case R.id.btn_return:
diff --git a/zhuike/src/main/java/com/novelbook/android/bean/BangdanCate.java b/zhuike/src/main/java/com/novelbook/android/bean/BangdanCate.java
new file mode 100644
index 0000000..8d228e6
--- /dev/null
+++ b/zhuike/src/main/java/com/novelbook/android/bean/BangdanCate.java
@@ -0,0 +1,40 @@
+package com.novelbook.android.bean;
+
+public class BangdanCate {
+ private int cid;
+ private String fn;
+ private String name;
+ private String title;
+
+ public int getCid() {
+ return cid;
+ }
+
+ public void setCid(int cid) {
+ this.cid = cid;
+ }
+
+ public String getFn() {
+ return fn;
+ }
+
+ public void setFn(String fn) {
+ this.fn = fn;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+}
diff --git a/zhuike/src/main/java/com/novelbook/android/bean/NovelBlock.java b/zhuike/src/main/java/com/novelbook/android/bean/NovelBlock.java
index 0d819fc..b58cc8c 100644
--- a/zhuike/src/main/java/com/novelbook/android/bean/NovelBlock.java
+++ b/zhuike/src/main/java/com/novelbook/android/bean/NovelBlock.java
@@ -5,6 +5,7 @@ import com.novelbook.android.db.Novel;
import java.util.List;
public class NovelBlock{
+ private int cid;
private String fn;
private String title;
private int oneself;
@@ -14,6 +15,14 @@ public class NovelBlock{
private List pictures;
private List ns;
+ public int getCid() {
+ return cid;
+ }
+
+ public void setCid(int cid) {
+ this.cid = cid;
+ }
+
public String getFn() {
return fn;
}
diff --git a/zhuike/src/main/java/com/novelbook/android/bean/Progress.java b/zhuike/src/main/java/com/novelbook/android/bean/ProgressType.java
similarity index 92%
rename from zhuike/src/main/java/com/novelbook/android/bean/Progress.java
rename to zhuike/src/main/java/com/novelbook/android/bean/ProgressType.java
index 2328461..05fecbb 100644
--- a/zhuike/src/main/java/com/novelbook/android/bean/Progress.java
+++ b/zhuike/src/main/java/com/novelbook/android/bean/ProgressType.java
@@ -1,6 +1,6 @@
package com.novelbook.android.bean;
-public class Progress {
+public class ProgressType {
private int id;
private String name;
diff --git a/zhuike/src/main/java/com/novelbook/android/db/Novel.java b/zhuike/src/main/java/com/novelbook/android/db/Novel.java
index af88998..cd4d47b 100644
--- a/zhuike/src/main/java/com/novelbook/android/db/Novel.java
+++ b/zhuike/src/main/java/com/novelbook/android/db/Novel.java
@@ -272,7 +272,9 @@ public class Novel extends LitePalSupport implements Serializable{
}
public static List getNovelsOnShelf(){
- return LitePal.where("isOnShelf=?","1").order("isTop desc,isUpdated desc,lastVisit desc" ).find(Novel.class);
+ // return LitePal.where("isOnShelf=?","1").order("isTop desc,isUpdated desc,lastVisit desc,lastUpdateTime desc" ).find(Novel.class);
+ return LitePal.where("isOnShelf=?","1").order("isTop desc,lastUpdateTime desc" ).find(Novel.class);
+
}
public static List getLocalNovels(){
@@ -305,8 +307,12 @@ public class Novel extends LitePalSupport implements Serializable{
}
@Override
public int update(long id){
- setValues();
- return super.update(id);
+ setValues();try {
+ return super.update(id);
+ }catch (Exception e){
+ Log.e("NOVELDB", "update:error ", e);
+ }
+ return 0;
}
public void testUpdate(){
isUpdated=true;
diff --git a/zhuike/src/main/java/com/novelbook/android/dialog/SettingDialog.java b/zhuike/src/main/java/com/novelbook/android/dialog/SettingDialog.java
index ce59a05..2e5cd43 100644
--- a/zhuike/src/main/java/com/novelbook/android/dialog/SettingDialog.java
+++ b/zhuike/src/main/java/com/novelbook/android/dialog/SettingDialog.java
@@ -357,22 +357,23 @@ public class SettingDialog extends Dialog {
case R.id.iv_bg_default:
setBookBg(Config.BOOK_BG_DEFAULT);
selectBg(Config.BOOK_BG_DEFAULT);
+ config.setDayOrNight(false);
break;
case R.id.iv_bg_1:
setBookBg(Config.BOOK_BG_1);
- selectBg(Config.BOOK_BG_1);
+ selectBg(Config.BOOK_BG_1); config.setDayOrNight(false);
break;
case R.id.iv_bg_2:
setBookBg(Config.BOOK_BG_2);
- selectBg(Config.BOOK_BG_2);
+ selectBg(Config.BOOK_BG_2); config.setDayOrNight(false);
break;
case R.id.iv_bg_3:
setBookBg(Config.BOOK_BG_3);
- selectBg(Config.BOOK_BG_3);
+ selectBg(Config.BOOK_BG_3); config.setDayOrNight(false);
break;
case R.id.iv_bg_4:
setBookBg(Config.BOOK_BG_4);
- selectBg(Config.BOOK_BG_4);
+ selectBg(Config.BOOK_BG_4); config.setDayOrNight(false);
break;
case R.id.tv_lhadd:
addLineSpace();
diff --git a/zhuike/src/main/java/com/novelbook/android/netapi/HttpApi.java b/zhuike/src/main/java/com/novelbook/android/netapi/HttpApi.java
index 285824e..90b4bbe 100644
--- a/zhuike/src/main/java/com/novelbook/android/netapi/HttpApi.java
+++ b/zhuike/src/main/java/com/novelbook/android/netapi/HttpApi.java
@@ -74,11 +74,11 @@ public interface HttpApi {
@GET("n/{novelId}/author")
Observable getNovelsSameAuthor(@Path("novelId") int novelId);
//站点榜单http://xiaoshuofenxiang.com/api/page/siteranks?sex=1
- @GET("page/siteranks")
+/* @GET("page/siteranks")
Observable getSiteRanks(@Query("sex") int Sex);
//http://xiaoshuofenxiang.com/api/page/siterank?fn=qidian-yuanchuangfengyunbang&pn=3
@GET("page/siterank")
- Observable getSiteRankDetail(@Query("fn")String fn,@Query("pn")int pageNo,@Query("sex") int Sex);
+ Observable getSiteRankDetail(@Query("fn")String fn,@Query("pn")int pageNo,@Query("sex") int Sex);*/
@GET( "search/{keyword}/{pageno}")
Observable getSeachNolvelist(@Path("keyword")String keyWord,@Path("pageno")int pageNo,@Query("sex") int Sex);
// 搜索分类 http://xiaoshuofenxiang.com/api/page/topdata
@@ -94,5 +94,11 @@ public interface HttpApi {
@GET("download/version.xml")
Observable getVersion();
+ @GET("page/category")
+ Observable getPaihangBangCateList(@Query("sex") int Sex,@Query("type") String type);
+ @GET("page/siteranks")
+ Observable getPaihangBangByCate(@Query("sex") int Sex,@Query("cid") int cid);
+ @GET("page/siterank")
+ Observable getPaihangBangList(@Query("sex") int Sex,@Query("cid") int cid,@Query("pn")int pageNo);
}
diff --git a/zhuike/src/main/java/com/novelbook/android/netsubscribe/BookSubscribe.java b/zhuike/src/main/java/com/novelbook/android/netsubscribe/BookSubscribe.java
index 0999be5..2569267 100644
--- a/zhuike/src/main/java/com/novelbook/android/netsubscribe/BookSubscribe.java
+++ b/zhuike/src/main/java/com/novelbook/android/netsubscribe/BookSubscribe.java
@@ -62,14 +62,14 @@ public class BookSubscribe {
HttpMethods.getInstance().toSubscribe(observable, subscriber);
}
- public static void getSiteRanks( int sex,DisposableObserver subscriber){
+/* public static void getSiteRanks( int sex,DisposableObserver subscriber){
Observable observable = HttpMethods.getInstance("/api/page/siteranks").getHttpApi().getSiteRanks(sex);
HttpMethods.getInstance().toSubscribe(observable, subscriber);
}
public static void getSiteRankDetail( String fn,int pageNo,int sex,DisposableObserver subscriber){
- Observable observable = HttpMethods.getInstance("/api/page/siteranks").getHttpApi().getSiteRankDetail(fn,pageNo,sex);
+ Observable observable = HttpMethods.getInstance("/api/page/siterank").getHttpApi().getSiteRankDetail(fn,pageNo,sex);
HttpMethods.getInstance().toSubscribe(observable, subscriber);
- }
+ }*/
public static void getSearchNovelList( String keyWord,int pageNo,int sex,DisposableObserver subscriber){
Observable observable = HttpMethods.getInstance(String.format("/api/search/%s/%s",keyWord ,pageNo)).getHttpApi().getSeachNolvelist(keyWord,pageNo,sex);
@@ -92,5 +92,16 @@ public class BookSubscribe {
Observable observable = HttpMethods.getInstance("download/version.xml").getHttpApi().getVersion();
HttpMethods.getInstance().toSubscribe(observable, subscriber);
}
-
+ public static void getPaihangBangCateList(int sex,DisposableObserver subscriber){
+ Observable observable = HttpMethods.getInstance("page/category").getHttpApi().getPaihangBangCateList(sex,"rank");
+ HttpMethods.getInstance().toSubscribe(observable, subscriber);
+ }
+ public static void getPaihangBangByCate(int sex,int cid ,DisposableObserver subscriber){
+ Observable observable = HttpMethods.getInstance("page/siteranks").getHttpApi().getPaihangBangByCate(sex,cid);
+ HttpMethods.getInstance().toSubscribe(observable, subscriber);
+ }
+ public static void getPaihangBangList(int sex,int pageNo,int cid ,DisposableObserver subscriber){
+ Observable observable = HttpMethods.getInstance("page/siterank").getHttpApi().getPaihangBangList(sex,cid,pageNo);
+ HttpMethods.getInstance().toSubscribe(observable, subscriber);
+ }
}
diff --git a/zhuike/src/main/java/com/novelbook/android/netutils/RetryInterceptor.java b/zhuike/src/main/java/com/novelbook/android/netutils/RetryInterceptor.java
index 849808f..409b670 100644
--- a/zhuike/src/main/java/com/novelbook/android/netutils/RetryInterceptor.java
+++ b/zhuike/src/main/java/com/novelbook/android/netutils/RetryInterceptor.java
@@ -31,36 +31,58 @@ public class RetryInterceptor implements Interceptor {
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
String oldUrl = request.url().toString();
+ Log.d(TAG, "HttpMethods intercept: request url:"+oldUrl);
String prefix = REUtil.match("(?i)http[s]?://[^/]+", oldUrl);
+ Log.d(TAG, "HttpMethods intercept: prefix:"+prefix);
+
if (prefix == null){
Response response = doRequest(chain, request);
+
if(response!=null)
{
return response;
}else
{
-
- throw new IOException();
+ int i=0;
+ while(response==null && i<3){
+ request = chain.request();
+ i++;
+ }
+ if(response==null) {
+ throw new IOException();
+ }else {
+ return response;
+ }
}
}
String path = oldUrl.substring(prefix.length());
+ Log.d(TAG, "HttpMethods intercept: path:"+path);
RandomHost rh = null;
boolean isMainApi =path.equals("/api/g/");
if(oldUrl.indexOf("xiaoshuofenxiang.com") == -1 || !path.startsWith("/api/") || NetUtil.getHost(isMainApi)==null){
// rh = null;
+
Response response = doRequest(chain, request);
if(response!=null)
{
return response;
}else
{
+ int i=0;
+ while(response==null && i<3){
+ request = chain.request();
+ i++;
+ }
+ if(response==null) {
+ throw new IOException();
+ }else {
+ return response;
+ }
- throw new IOException();
}
}
try {
rh = new RandomHost(NetUtil.getHost(isMainApi), path);
- Log.d(TAG, "HttpMethods intercept: api path is "+path);
Log.d(TAG, "HttpMethods intercept: create new RandomHost--------------------------");
} catch (JSONException e) {
@@ -104,10 +126,17 @@ public class RetryInterceptor implements Interceptor {
if (response != null) { try {response.close();} catch (IllegalStateException e) {} }
+
response = doRequest(chain, newRequest);
Log.d(TAG, String.format("HttpMethods intercept: response is null? %s", response == null));
+ int i=0;
+ while(response==null && i<3){
+ request = chain.request();
+ i++;
+ }
+
if (response != null) {
Log.d(TAG, String.format("HttpMethods intercept: response .code? %s", response.code()));
}
@@ -173,10 +202,12 @@ public class RetryInterceptor implements Interceptor {
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, " + request.url(),e );
}
return response;
diff --git a/zhuike/src/main/java/com/novelbook/android/service/ServiceDownload.java b/zhuike/src/main/java/com/novelbook/android/service/ServiceDownload.java
index 6482436..a77a42e 100644
--- a/zhuike/src/main/java/com/novelbook/android/service/ServiceDownload.java
+++ b/zhuike/src/main/java/com/novelbook/android/service/ServiceDownload.java
@@ -134,11 +134,13 @@ public class ServiceDownload extends Service {
protected void onHandleIntent( Intent intent) {
Log.d(TAG,"ServiceDownload onHandleIntent...begin");
-
+ if(null==intent){
+ return;
+ }
String key ="taskId";
int taskId =0;
- if(intent.hasExtra(key)){
+ if ( intent.hasExtra(key)){
taskId= intent.getExtras().getInt(key);
DownloadTask dt = LitePal.find(DownloadTask.class,taskId);
diff --git a/zhuike/src/main/java/com/novelbook/android/utils/AdInterface.java b/zhuike/src/main/java/com/novelbook/android/utils/AdInterface.java
index 14caf4d..cdc9c5c 100644
--- a/zhuike/src/main/java/com/novelbook/android/utils/AdInterface.java
+++ b/zhuike/src/main/java/com/novelbook/android/utils/AdInterface.java
@@ -9,4 +9,8 @@ public interface AdInterface {
public void showAd(boolean showAd,int height,int adY);
public void hideSystemUI();
public void showRefresh(int visible);
+ public void showProgressbar(boolean dismissAble,String msg);
+ public void hideProgressbar();
+ public void showLoading(boolean isShow);
+
}
diff --git a/zhuike/src/main/java/com/novelbook/android/utils/BookUtil.java b/zhuike/src/main/java/com/novelbook/android/utils/BookUtil.java
index ae837de..a0749ef 100644
--- a/zhuike/src/main/java/com/novelbook/android/utils/BookUtil.java
+++ b/zhuike/src/main/java/com/novelbook/android/utils/BookUtil.java
@@ -553,7 +553,9 @@ public class BookUtil {
if(chaptCache.containsKey(chapterNo)){
chaptCache.remove(chapterNo);
}
- pagefactory.changeChapter(chapterNo);
+ if(pagefactory!=null) {
+ pagefactory.changeChapter(chapterNo);
+ }
}
@@ -647,9 +649,10 @@ public class BookUtil {
}
chId = chId <= mChapters.size() ? chId: mChapters.size();
Log.d(TAG, "changing Source: to open chapter with new site source " + chId + " : "+ mChangeTitle );
- pagefactory.changeChapter(chId);
+ if(pagefactory!=null)
+ pagefactory.changeChapter(chId);
// mChangeChapId=0;
- Toast.makeText(mContext,"换源成功",Toast.LENGTH_LONG).show();
+ // Toast.makeText(mContext,"换源成功",Toast.LENGTH_LONG).show();
}else{
Log.d(TAG, "changing Source: failed " );
}
@@ -1374,7 +1377,7 @@ int muluRetryCount =0;
// isDownloadChapt =true;
Log.d(TAG,String.format("handler msg, download %s",true) );
}else if(msg.what==99){
- // Toast.makeText(mContext,"网络拥堵,将帮您切换其它源",Toast.LENGTH_SHORT);
+ Toast.makeText(mContext,"网络拥堵,已帮您切换其它源",Toast.LENGTH_LONG).show();
// getSiteRule();
// pagefactory .changeChapter(getChapterNo());
diff --git a/zhuike/src/main/java/com/novelbook/android/utils/Constants.java b/zhuike/src/main/java/com/novelbook/android/utils/Constants.java
index d95e06d..f3a5d1c 100644
--- a/zhuike/src/main/java/com/novelbook/android/utils/Constants.java
+++ b/zhuike/src/main/java/com/novelbook/android/utils/Constants.java
@@ -1,6 +1,7 @@
package com.novelbook.android.utils;
-import com.novelbook.android.bean.Progress;
+
+import com.novelbook.android.bean.ProgressType;
import java.util.List;
@@ -22,6 +23,7 @@ public class Constants {
public static List lstNt=null;
//public static List