diff --git a/zhuike/build.gradle b/zhuike/build.gradle index 0c2240e..1095815 100644 --- a/zhuike/build.gradle +++ b/zhuike/build.gradle @@ -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")) { @@ -76,7 +76,7 @@ android { } } //渠道 - productFlavors { + productFlavors { // googleplay {} g { applicationId "com.zhushou.yueshu" @@ -86,12 +86,12 @@ android { } - google { + /* google { applicationId "com.zhushou.yueshu" versionName "v1.0" buildConfigField "String", "MAIN_HOST", '"http://g.xiaoshuofenxiang.com/api/"' buildConfigField "String", "API_HOST", '""' - } + }*/ //批量配置 productFlavors.all { flavor -> diff --git a/zhuike/src/main/java/com/novelbook/android/Activity_base.java b/zhuike/src/main/java/com/novelbook/android/Activity_base.java index 7c73ce9..cfe900f 100644 --- a/zhuike/src/main/java/com/novelbook/android/Activity_base.java +++ b/zhuike/src/main/java/com/novelbook/android/Activity_base.java @@ -452,7 +452,7 @@ public abstract class Activity_base extends AppCompatActivity implements Native } else { Log.d(TAG, String.format("checkAndRequestPermission: permision result requestCode %s,",requestCode )); // 如果用户没有授权,那么应该说明意图,引导用户去设置里面授权。 - Toast.makeText(this, "应用缺少必要的权限!请点击\"权限\",打开所需要的权限。", Toast.LENGTH_LONG).show(); + // Toast.makeText(this, "应用缺少必要的权限!请点击\"权限\",打开所需要的权限。", Toast.LENGTH_LONG).show(); // Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); // intent.setData(Uri.parse("package:" + getPackageName())); // startActivity(intent); 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 f61a01d..97876c5 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 @@ -188,7 +188,7 @@ public class Fragment_Shelf extends BasicFragment { novel2.checkAndUpdate(); } } - // loadNovelsOnShelf(); + loadNovelsOnShelf(); /* for(Novel nove : bookLists){ 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 9bbd78e..cc03b68 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 @@ -250,7 +250,7 @@ public class Fragment_booklist extends BasicFragment { }else if(!TextUtils.isEmpty(fn)){ //首页 更多 mAdapter.setShowTop(true); // showProgressDialog(true, "正在加载更多"); - BookSubscribe.getNovelPaihang(fn,Constants.SEX,new OnSuccessAndFaultSub(successAndFaultListener, getActivity())); + BookSubscribe.getNovelPaihang(fn,pageNo,Constants.SEX,new OnSuccessAndFaultSub(successAndFaultListener, getActivity())); } else if(!TextUtils.isEmpty((cate))) { //分类 diff --git a/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_jingxuan.java b/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_jingxuan.java index 318c50a..22c0e62 100644 --- a/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_jingxuan.java +++ b/zhuike/src/main/java/com/novelbook/android/Fragments/Fragment_jingxuan.java @@ -7,6 +7,7 @@ import android.os.Handler; import android.os.Message; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentPagerAdapter; +import android.support.v4.app.FragmentStatePagerAdapter; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.LinearLayoutManager; @@ -214,7 +215,7 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener if(mBlocks.size()>blockIndex) { ll1.setVisibility(View.VISIBLE); mHotNewData_l = mBlocks.get(blockIndex).getNs().subList(0,mBlocks.get(blockIndex).getOneself()); - mHotNewData_g = mBlocks.get(blockIndex).getNs().subList(mBlocks.get(blockIndex).getOneself(),mBlocks.get(blockIndex).getNs().size()-1); + mHotNewData_g = mBlocks.get(blockIndex).getNs().subList(mBlocks.get(blockIndex).getOneself(),mBlocks.get(blockIndex).getNs().size()); tvBlock1.setText(mBlocks.get(blockIndex).getName()); loadImageView(mBlocks.get(blockIndex).getIcon(),imageViewBlock1); if(TextUtils.isEmpty(mBlocks.get(blockIndex).getTitle())){ @@ -229,7 +230,7 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener if(mBlocks.size()>blockIndex) { ll2.setVisibility(View.VISIBLE); mHotLianZaiData_l = mBlocks.get(blockIndex).getNs().subList(0,mBlocks.get(blockIndex).getOneself()); - mHotLianZaiData_g = mBlocks.get(blockIndex).getNs().subList(mBlocks.get(blockIndex).getOneself(),mBlocks.get(blockIndex).getNs().size()-1); + mHotLianZaiData_g = mBlocks.get(blockIndex).getNs().subList(mBlocks.get(blockIndex).getOneself(),mBlocks.get(blockIndex).getNs().size()); tvBlock2.setText(mBlocks.get(blockIndex).getName()); loadImageView(mBlocks.get(blockIndex).getIcon(),imageViewBlock2); @@ -245,7 +246,7 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener if(mBlocks.size()> blockIndex ) { ll3.setVisibility(View.VISIBLE); mFinishedData_l= mBlocks.get(blockIndex).getNs().subList(0,mBlocks.get(blockIndex).getOneself()); - mFinishedData_g = mBlocks.get(blockIndex).getNs().subList(mBlocks.get(blockIndex).getOneself(),mBlocks.get(blockIndex).getNs().size()-1); + mFinishedData_g = mBlocks.get(blockIndex).getNs().subList(mBlocks.get(blockIndex).getOneself(),mBlocks.get(blockIndex).getNs().size()); tvBlock3.setText(mBlocks.get(blockIndex).getName()); loadImageView(mBlocks.get(blockIndex).getIcon(),imageViewBlock3); @@ -259,7 +260,7 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener if(mBlocks.size()> blockIndex ) { ll4.setVisibility(View.VISIBLE); mFinishedData_l= mBlocks.get(blockIndex).getNs().subList(0,mBlocks.get(blockIndex).getOneself()); - mFinishedData_g = mBlocks.get(blockIndex).getNs().subList(mBlocks.get(blockIndex).getOneself(),mBlocks.get(blockIndex).getNs().size()-1); + mFinishedData_g = mBlocks.get(blockIndex).getNs().subList(mBlocks.get(blockIndex).getOneself(),mBlocks.get(blockIndex).getNs().size()); tvBlock3.setText(mBlocks.get(blockIndex).getName()); loadImageView(mBlocks.get(blockIndex).getIcon(),imageViewBlock3); @@ -279,7 +280,7 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener @Override public void initViews() { - gridItemSpace = getResources().getDimensionPixelSize(R.dimen._10dp); + gridItemSpace = getResources().getDimensionPixelSize(R.dimen._10dp)/2; } @@ -393,8 +394,19 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener // mViewpagerTuijian =( MyViewPager) rootView.findViewById(R.id.viewpager_tuijian); // if (mFragments == null || mFragments.size() == 0) { // mTitle = new String[]{"精选", "榜单", "书单"}; + if(mBlocks==null ||mBlocks.size()<2){ + return; + } + if(mFragments==null) { mFragments = new ArrayList<>(); - NovelBlock block = mBlocks.get(1); + }else{ + mFragments.clear(); + } + + NovelBlock block = mBlocks.get(1); + if(block==null ){ + return; + } loadImageView(mBlocks.get(1).getIcon(),imageViewBlock0); tvBlock0.setText( mBlocks.get(1).getName()); List nvs = new ArrayList(); @@ -408,13 +420,16 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener nvs.add(novel); } } + if(nvs.size()>0){ + mFragments.add(Fragment_jingxuan_tuijian.newInstance(nvs)); + } 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(getChildFragmentManager()) { + FragmentStatePagerAdapter mAdapter = new FragmentStatePagerAdapter(getChildFragmentManager()) { @Override public Fragment getItem(int position) { return mFragments.get(position); @@ -432,6 +447,7 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener // } }; cyclell.removeAllViews(); + mViewpagerTuijian.removeAllViews(); mViewpagerTuijian.setAdapter(mAdapter); mViewpagerTuijian.clearOnPageChangeListeners(); // mViewpagerTuijian.setOnPageChangeListener(new CyclePageIndicator(getContext(), cyclell, mFragments.size())); @@ -464,6 +480,7 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener void initialBookList() { + int gridItemsLayout =R.layout.recycle_list_item_large; int spanCnt =getSpanCnt(); OnItemClickListener onItemClickListener = new OnItemClickListener() { @@ -496,7 +513,7 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener rvHotNewG.removeItemDecorationAt(0); } rvHotNewG.addItemDecoration(new SpaceItemDecoration( gridItemSpace)); - rvHotNewG.setAdapter(new BookListAdapter(activity, mHotNewData_g, R.layout.recycle_list_item, new OnItemClickListener() { + rvHotNewG.setAdapter(new BookListAdapter(activity, mHotNewData_g,gridItemsLayout, new OnItemClickListener() { @Override public void onItemClick(View view, int position) { @@ -549,7 +566,7 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener rvLianZaiG.removeItemDecorationAt(0); } rvLianZaiG.addItemDecoration(new SpaceItemDecoration( gridItemSpace)); - rvLianZaiG.setAdapter(new BookListAdapter(activity, mHotLianZaiData_g, R.layout.recycle_list_item, new OnItemClickListener() { + rvLianZaiG.setAdapter(new BookListAdapter(activity, mHotLianZaiData_g, gridItemsLayout, new OnItemClickListener() { @Override public void onItemClick(View view, int position) { @@ -603,7 +620,7 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener rvFinishG.removeItemDecorationAt(0); } rvFinishG.addItemDecoration(new SpaceItemDecoration( gridItemSpace)); - rvFinishG.setAdapter(new BookListAdapter(activity, mFinishedData_g, R.layout.recycle_list_item, new OnItemClickListener() { + rvFinishG.setAdapter(new BookListAdapter(activity, mFinishedData_g, gridItemsLayout, new OnItemClickListener() { @Override public void onItemClick(View view, int position) { @@ -632,7 +649,7 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener private int space; public SpaceItemDecoration(int space) { - this.space = space*3; + this.space = space*2; } @Override @@ -642,7 +659,7 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener // outRect.bottom = space; //由于每行都只有3个,所以第一个都是3的倍数,把左边距设为0 - if (parent.getChildLayoutPosition(view) %getSpanCnt()==0) { + /* if (parent.getChildLayoutPosition(view) %getSpanCnt()==0) { Log.d(TAG, "getItemOffsets: left " +parent.getChildLayoutPosition(view)); //outRect.set(0,0,0,0); outRect.right=space; @@ -657,7 +674,7 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener // outRect.right=space; // outRect.left=space; Log.d(TAG, "getItemOffsets: center " +parent.getChildLayoutPosition(view)); - } + }*/ // outRect.set(0,0,0,0); } @@ -665,6 +682,7 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener @Override public void onResume() { super.onResume(); + initTuijianPagers(); MobclickAgent.onPageStart(TAG); } @Override diff --git a/zhuike/src/main/java/com/novelbook/android/ReadActivity.java b/zhuike/src/main/java/com/novelbook/android/ReadActivity.java index 442e356..9cc954f 100644 --- a/zhuike/src/main/java/com/novelbook/android/ReadActivity.java +++ b/zhuike/src/main/java/com/novelbook/android/ReadActivity.java @@ -713,7 +713,7 @@ public class ReadActivity extends Activity_base implements AdInterface { } if(!pageFactory.canExitSilent()){ - if(book.isOnShelf() ||pageFactory.getChapters().size()>0){ + if(book.isOnShelf() ||pageFactory.getChapters().size()==0){ finish(); }else { // showNormalDialog(); 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 3f6843e..dcd7dff 100644 --- a/zhuike/src/main/java/com/novelbook/android/netapi/HttpApi.java +++ b/zhuike/src/main/java/com/novelbook/android/netapi/HttpApi.java @@ -67,7 +67,7 @@ public interface HttpApi { //小说排行 http://xiaoshuofenxiang.com/api/page/rank?fn=hot @GET("page/rank") - Observable getNovelPaihang(@Query("fn") String fn,@Query("sex") int Sex); + Observable getNovelPaihang(@Query("fn") String fn,@Query("pn") int pageNo,@Query("sex") int Sex); //相关小说 http://xiaoshuofenxiang.com/api/n/6/about @GET("n/{novelId}/about") 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 687b1cd..584d7d7 100644 --- a/zhuike/src/main/java/com/novelbook/android/netsubscribe/BookSubscribe.java +++ b/zhuike/src/main/java/com/novelbook/android/netsubscribe/BookSubscribe.java @@ -53,8 +53,8 @@ public class BookSubscribe { HttpMethods.getInstance().toSubscribe(observable, subscriber); } - public static void getNovelPaihang(String fn,int sex,DisposableObserver subscriber){ - Observable observable = HttpMethods.getInstance("/api/page/rank").getHttpApi().getNovelPaihang(fn,sex); + public static void getNovelPaihang(String fn,int pageNo,int sex,DisposableObserver subscriber){ + Observable observable = HttpMethods.getInstance("/api/page/rank").getHttpApi().getNovelPaihang(fn,pageNo,sex); HttpMethods.getInstance().toSubscribe(observable, subscriber); } 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 b1ce6ff..62433e5 100644 --- a/zhuike/src/main/java/com/novelbook/android/utils/BookUtil.java +++ b/zhuike/src/main/java/com/novelbook/android/utils/BookUtil.java @@ -125,11 +125,11 @@ public class BookUtil { private Novel mNovel; private void clearBook() { - try{ + /* 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; @@ -157,7 +157,7 @@ public class BookUtil { private SiteRule mSiteRule; private Map chaptCache = new HashMap(); - private Map chaptDownStatus = new HashMap(); + protected Map chaptDownStatus = new HashMap(); DownloadStatus downloadStatus = DownloadStatus.notStart; @@ -624,6 +624,8 @@ public class BookUtil { if(file.exists()){ file.delete(); } + fileRetryCnt.clear(); + chaptDownStatus.clear(); if(chaptCache.containsKey(chapterNo)){ chaptCache.remove(chapterNo); } diff --git a/zhuike/src/main/java/com/novelbook/android/utils/PageFactory.java b/zhuike/src/main/java/com/novelbook/android/utils/PageFactory.java index 933f9ca..27bb15a 100644 --- a/zhuike/src/main/java/com/novelbook/android/utils/PageFactory.java +++ b/zhuike/src/main/java/com/novelbook/android/utils/PageFactory.java @@ -686,6 +686,7 @@ public class PageFactory implements ChangeSource{ fileRetryCnt.clear(); mBookUtil.fileRetryCnt.clear(); + if( chaptMap.containsKey(getCurrentChapter())){ chaptMap.remove(getCurrentChapter()); } @@ -1052,7 +1053,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); - + Log.d(TAG, String.format(" prepare book reading chapter %s ",chapterName ) ); @@ -1063,12 +1064,14 @@ private void hideSysUI(){ public void run() { super.run(); if (getNovel().getLastReadChapt() != currentChapter || getNovel().getLastReadPos() != currentPage.getBegin()) { + + if(!TextUtils.isEmpty(chapterName)) { + getNovel().setLastReadChaptName(chapterName); + } + if (currentChapter > 1) { getNovel().setLastReadChapt(currentChapter); - if(!TextUtils.isEmpty(chapterName)){ - getNovel().setLastReadChaptName(chapterName); - } } else { getNovel().setToDefault("lastReadChapt"); @@ -2058,6 +2061,7 @@ private void hideSysUI(){ public void retryChapt(int chapNum){ fileRetryCnt.clear(); mBookUtil.fileRetryCnt.clear(); + mBookUtil.chaptDownStatus.clear(); changeChapter(chapNum); } public void openBookmark(int chapNum,long position){ diff --git a/zhuike/src/main/res/layout/recycle_list_item_horizon.xml b/zhuike/src/main/res/layout/recycle_list_item_horizon.xml index ace57a5..a238782 100644 --- a/zhuike/src/main/res/layout/recycle_list_item_horizon.xml +++ b/zhuike/src/main/res/layout/recycle_list_item_horizon.xml @@ -19,6 +19,7 @@ + + + + + + + + + + + + + diff --git a/zhuike/zhuike.iml b/zhuike/zhuike.iml index 1c0a608..298b0bd 100644 --- a/zhuike/zhuike.iml +++ b/zhuike/zhuike.iml @@ -140,7 +140,6 @@ - @@ -156,7 +155,6 @@ -