diff --git a/zhuike/src/main/java/com/novelbook/android/AD/toutiao/SplashActivity.java b/zhuike/src/main/java/com/novelbook/android/AD/toutiao/SplashActivity.java index d554b4f..7960121 100644 --- a/zhuike/src/main/java/com/novelbook/android/AD/toutiao/SplashActivity.java +++ b/zhuike/src/main/java/com/novelbook/android/AD/toutiao/SplashActivity.java @@ -210,7 +210,7 @@ public class SplashActivity extends Activity implements WeakHandler.IHandler { @Override public boolean onKeyUp(int keyCode, KeyEvent event) { - if (keyCode == KeyEvent.KEYCODE_BACK) { + if (keyCode == KeyEvent.KEYCODE_BACK|| keyCode == KeyEvent.KEYCODE_HOME) { return true; 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 204da89..42d3db2 100644 --- a/zhuike/src/main/java/com/novelbook/android/Activity_base.java +++ b/zhuike/src/main/java/com/novelbook/android/Activity_base.java @@ -116,7 +116,18 @@ public abstract class Activity_base extends AppCompatActivity { setTitle(); initData(); initViews(); - + initNaviBanner(); + } + void initNaviBanner(){ + if(mBannerContainer==null){ + return; + } + if(Constants.SHOWAD){ + loadNativeBannerAd(mBannerContainer,BuildConfig.AD_SLOT_TOUTIAO_BANNER_NATIVE_ID); + mBannerContainer.setVisibility(View.VISIBLE); + }else{ + mBannerContainer.setVisibility(View.GONE); + } } protected void setupToolbar(){ @@ -769,9 +780,9 @@ public abstract class Activity_base extends AppCompatActivity { public void onDownloadActive(long totalBytes, long currBytes, String fileName, String appName) { if (mCreativeButton != null) { if (totalBytes <= 0L) { - mCreativeButton.setText("下载中 percent: 0"); + mCreativeButton.setText("下载中 进度:0"); } else { - mCreativeButton.setText("下载中 percent: " + (currBytes * 100 / totalBytes)); + mCreativeButton.setText("下载中 进度:" + (currBytes * 100 / totalBytes)); } } } @@ -780,7 +791,7 @@ public abstract class Activity_base extends AppCompatActivity { @Override public void onDownloadPaused(long totalBytes, long currBytes, String fileName, String appName) { if (mCreativeButton != null) { - mCreativeButton.setText("下载暂停 percent: " + (currBytes * 100 / totalBytes)); + mCreativeButton.setText("下载暂停 进度:" + (currBytes * 100 / totalBytes)); } } diff --git a/zhuike/src/main/java/com/novelbook/android/BookActivity.java b/zhuike/src/main/java/com/novelbook/android/BookActivity.java index 7e8bbf0..2557bc2 100644 --- a/zhuike/src/main/java/com/novelbook/android/BookActivity.java +++ b/zhuike/src/main/java/com/novelbook/android/BookActivity.java @@ -164,12 +164,12 @@ public class BookActivity extends Activity_base { llAuthorMore. setVisibility(View.GONE); tvAuthorMore.setText( ""); initiDownloadReceiver(); - if(Constants.SHOWAD){ + /* if(Constants.SHOWAD){ loadNativeBannerAd(mBannerContainer,BuildConfig.AD_SLOT_TOUTIAO_BANNER_NATIVE_ID); mBannerContainer.setVisibility(View.VISIBLE); }else{ mBannerContainer.setVisibility(View.GONE); - } + }*/ } @Override 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 fd01ac7..232f22d 100644 --- a/zhuike/src/main/java/com/novelbook/android/Fragments/BasicFragment.java +++ b/zhuike/src/main/java/com/novelbook/android/Fragments/BasicFragment.java @@ -89,7 +89,17 @@ public abstract class BasicFragment extends Fragment { private static String TAG = BasicFragment.class.getSimpleName(); protected View rootView; protected int pageNo=1; - protected int pageCount; + private int pageCount; + + public int getPageCount() { + pageCount = pageCount >Constants.MAX_PAGE_CNT ? Constants.MAX_PAGE_CNT :pageCount; + return pageCount; + } + + public void setPageCount(int pageCount) { + this.pageCount = pageCount; + } + protected abstract int getLayoutRes(); protected abstract void initData(); protected abstract void fillData(); @@ -142,7 +152,11 @@ public abstract class BasicFragment extends Fragment { initData(); initViews(); initSwipeRefreshLayout(); - + if (mBannerContainer!=null && !Constants.SHOWAD) { + if( mBannerContainer.getVisibility() !=View.GONE) { + mBannerContainer.setVisibility(View.GONE); + } + } return view; // Inflate the layout for this fragment @@ -460,7 +474,7 @@ void initTabs(){ return; } - activity .loadBannerAd(bannerContainer, BuildConfig.AD_SLOT_TOUTIAO_BANNER_ID,(int)(adHeight*5.9), adHeight); + activity .loadBannerAd(bannerContainer, BuildConfig.AD_SLOT_TOUTIAO_BANNER_ID,(int)(adHeight*5.9), adHeight); if( mBannerContainer.getVisibility() !=View.VISIBLE) mBannerContainer.setVisibility(View.VISIBLE); } 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 8f77153..9878fad 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 @@ -158,7 +158,7 @@ public class Fragment_booklist extends BasicFragment { if(mMoreData.size()>0) { pageNo++; } - int status = pageCount >= pageNo ? BookListAdapter.PULLUP_LOAD_MORE : BookListAdapter.NO_LOAD_MORE; + int status =getPageCount()>= pageNo ? BookListAdapter.PULLUP_LOAD_MORE : BookListAdapter.NO_LOAD_MORE; // mAdapter.setPercent(pageNo/pageCount); mAdapter.AddFooterItem(mMoreData); mAdapter.changeMoreStatus(status); @@ -231,8 +231,7 @@ public class Fragment_booklist extends BasicFragment { // mFirstPage= gson.fromJson(result, FirstPage.class); try { JSONObject jsonObject = new JSONObject(result); - pageCount = jsonObject.getInt("pageCount"); - + setPageCount(jsonObject.getInt("pageCount")); ; mMoreData = GsonUtil. parserJsonArray(jsonObject,Constants.BLOCK_TITLE_NOVELS); if(mMoreData.size()>0){ loadListAd(mAdapter,1,mData.size()>0); @@ -266,9 +265,9 @@ public class Fragment_booklist extends BasicFragment { try { JSONObject jsonObject = new JSONObject(result); String resultstr = jsonObject.getString("rank") ; - pageCount = jsonObject.getJSONObject("rank").getInt("pageCount"); + setPageCount(jsonObject.getJSONObject("rank").getInt("pageCount")); ; mMoreData = GsonUtil. parserJsonArray(resultstr,Constants.BLOCK_TITLE_NOVELS); - Log.d(TAG, "排行榜详细 onSuccess: pageCount " + pageCount); + Log.d(TAG, "排行榜详细 onSuccess: pageCount " + getPageCount()); if(mMoreData.size()>0){ loadListAd(mAdapter,1,mData.size()>0); } @@ -337,12 +336,12 @@ public class Fragment_booklist extends BasicFragment { @Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); - Log.d(TAG, String.format("onScrollStateChanged , state %s ,lastVisibleitem %s ,getItemCount %s,pageno %s ,pageCount %s", - newState==RecyclerView.SCROLL_STATE_IDLE,lastVisibleItem,mAdapter.getItemCount(),pageNo,pageCount)); + Log.d(TAG, String.format("onScrollStateChanged , state %s ,lastVisibleitem %s ,getItemCount %s,pageno %s ,getPageCount() %s", + newState==RecyclerView.SCROLL_STATE_IDLE,lastVisibleItem,mAdapter.getItemCount(),pageNo,getPageCount())); //判断RecyclerView的状态 是空闲时,同时,是最后一个可见的ITEM时才加载 if(newState==RecyclerView.SCROLL_STATE_IDLE&&lastVisibleItem+1==mAdapter.getItemCount()){ - if(pageNo <= pageCount) { + if(pageNo <= getPageCount()) { //设置正在加载更多 mAdapter.changeMoreStatus(mAdapter.LOADING_MORE); @@ -374,7 +373,7 @@ public class Fragment_booklist extends BasicFragment { super.run(); mMoreData = Novel.getNovelsHistory(); - pageCount=1; + setPageCount(1); handler.sendEmptyMessage(1); if(mMoreData!=null && mMoreData.size()>2) { loadListAd(mAdapter, 2, mData.size() > 0); 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 5093665..da02688 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 @@ -96,7 +96,7 @@ public static final String TAG = Fragment_paihang.class.getSimpleName(); if(mMoreData.size()>0) { pageNo++; } - int status = pageCount >= pageNo ? BookListAdapter.LOADING_MORE : BookListAdapter.NO_LOAD_MORE; + int status = getPageCount() >= pageNo ? BookListAdapter.LOADING_MORE : BookListAdapter.NO_LOAD_MORE; // mAdapter.setPercent(pageNo/pageCount); mAdapter.AddFooterItem(mMoreData); mAdapter.changeMoreStatus(status); @@ -192,7 +192,7 @@ public static final String TAG = Fragment_paihang.class.getSimpleName(); // mFirstPage= gson.fromJson(result, FirstPage.class); try { JSONObject jsonObject = new JSONObject(result); - pageCount = jsonObject.getInt("pageCount"); + setPageCount(jsonObject.getInt("pageCount")); mMoreData = GsonUtil. parserJsonArray(jsonObject,Constants.BLOCK_TITLE_NOVELS); if(mMoreData.size()>0){ @@ -353,10 +353,10 @@ public static final String TAG = Fragment_paihang.class.getSimpleName(); //判断RecyclerView的状态 是空闲时,同时,是最后一个可见的ITEM时才加载 Log.d(TAG, String.format("onScrollStateChanged , state %s ,lastVisibleitem %s ,getItemCount %s,pageno %s ,pageCount %s", - newState==RecyclerView.SCROLL_STATE_IDLE,lastVisibleItem,mAdapter.getItemCount(),pageNo,pageCount)); + newState==RecyclerView.SCROLL_STATE_IDLE,lastVisibleItem,mAdapter.getItemCount(),pageNo,getPageCount())); if(newState==RecyclerView.SCROLL_STATE_IDLE&&lastVisibleItem+1==mAdapter.getItemCount()){ - if(pageNo <= pageCount) { + if(pageNo <= getPageCount()) { //设置正在加载更多 mAdapter.changeMoreStatus(mAdapter.LOADING_MORE); 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 53d6cf7..64b6910 100644 --- a/zhuike/src/main/java/com/novelbook/android/utils/Constants.java +++ b/zhuike/src/main/java/com/novelbook/android/utils/Constants.java @@ -47,5 +47,8 @@ public class Constants { public static int version =0; public static int serverVersion =0; public static String updateUrl="http://xiaoshuofenxiang.com/version.xml";; - public static final String BAD_CHAR =" "; + public static final String BAD_CHAR =" ";//not blank,don't edit + + public final static int MAX_PAGE_CNT =10;//最多加载的页数 + } diff --git a/zhuike/src/main/res/mipmap-hdpi/ic_launcher.png b/zhuike/src/main/res/mipmap-hdpi/ic_launcher.png index d8105f0..93d3302 100644 Binary files a/zhuike/src/main/res/mipmap-hdpi/ic_launcher.png and b/zhuike/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/zhuike/src/main/res/mipmap-mdpi/ic_launcher.png b/zhuike/src/main/res/mipmap-mdpi/ic_launcher.png index 3e3e9cf..17e4f5a 100644 Binary files a/zhuike/src/main/res/mipmap-mdpi/ic_launcher.png and b/zhuike/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/zhuike/src/main/res/mipmap-xhdpi/ic_launcher.png b/zhuike/src/main/res/mipmap-xhdpi/ic_launcher.png index a5c4a70..2e89761 100644 Binary files a/zhuike/src/main/res/mipmap-xhdpi/ic_launcher.png and b/zhuike/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/zhuike/src/main/res/mipmap-xxhdpi/ic_launcher.png b/zhuike/src/main/res/mipmap-xxhdpi/ic_launcher.png index dc06243..14e5849 100644 Binary files a/zhuike/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/zhuike/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/zhuike/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/zhuike/src/main/res/mipmap-xxxhdpi/ic_launcher.png index da2d46c..30b9921 100644 Binary files a/zhuike/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/zhuike/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/zhuike/src/main/res/values/strings.xml b/zhuike/src/main/res/values/strings.xml index 5b2e319..be77951 100644 --- a/zhuike/src/main/res/values/strings.xml +++ b/zhuike/src/main/res/values/strings.xml @@ -1,5 +1,5 @@ - 味知阅读 + 网书助手 书架 书城 排行榜