before add qq ad

This commit is contained in:
mwang 2019-06-11 13:19:38 +08:00
parent 4ff9cc763a
commit bd12f6f74f
13 changed files with 52 additions and 25 deletions

View File

@ -210,7 +210,7 @@ public class SplashActivity extends Activity implements WeakHandler.IHandler {
@Override @Override
public boolean onKeyUp(int keyCode, KeyEvent event) { public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) { if (keyCode == KeyEvent.KEYCODE_BACK|| keyCode == KeyEvent.KEYCODE_HOME) {
return true; return true;

View File

@ -116,7 +116,18 @@ public abstract class Activity_base extends AppCompatActivity {
setTitle(); setTitle();
initData(); initData();
initViews(); 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(){ 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) { public void onDownloadActive(long totalBytes, long currBytes, String fileName, String appName) {
if (mCreativeButton != null) { if (mCreativeButton != null) {
if (totalBytes <= 0L) { if (totalBytes <= 0L) {
mCreativeButton.setText("下载中 percent: 0"); mCreativeButton.setText("下载中 进度:0");
} else { } else {
mCreativeButton.setText("下载中 percent: " + (currBytes * 100 / totalBytes)); mCreativeButton.setText("下载中 进度:" + (currBytes * 100 / totalBytes));
} }
} }
} }
@ -780,7 +791,7 @@ public abstract class Activity_base extends AppCompatActivity {
@Override @Override
public void onDownloadPaused(long totalBytes, long currBytes, String fileName, String appName) { public void onDownloadPaused(long totalBytes, long currBytes, String fileName, String appName) {
if (mCreativeButton != null) { if (mCreativeButton != null) {
mCreativeButton.setText("下载暂停 percent: " + (currBytes * 100 / totalBytes)); mCreativeButton.setText("下载暂停 进度:" + (currBytes * 100 / totalBytes));
} }
} }

View File

@ -164,12 +164,12 @@ public class BookActivity extends Activity_base {
llAuthorMore. setVisibility(View.GONE); llAuthorMore. setVisibility(View.GONE);
tvAuthorMore.setText( ""); tvAuthorMore.setText( "");
initiDownloadReceiver(); initiDownloadReceiver();
if(Constants.SHOWAD){ /* if(Constants.SHOWAD){
loadNativeBannerAd(mBannerContainer,BuildConfig.AD_SLOT_TOUTIAO_BANNER_NATIVE_ID); loadNativeBannerAd(mBannerContainer,BuildConfig.AD_SLOT_TOUTIAO_BANNER_NATIVE_ID);
mBannerContainer.setVisibility(View.VISIBLE); mBannerContainer.setVisibility(View.VISIBLE);
}else{ }else{
mBannerContainer.setVisibility(View.GONE); mBannerContainer.setVisibility(View.GONE);
} }*/
} }
@Override @Override

View File

@ -89,7 +89,17 @@ public abstract class BasicFragment extends Fragment {
private static String TAG = BasicFragment.class.getSimpleName(); private static String TAG = BasicFragment.class.getSimpleName();
protected View rootView; protected View rootView;
protected int pageNo=1; 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 int getLayoutRes();
protected abstract void initData(); protected abstract void initData();
protected abstract void fillData(); protected abstract void fillData();
@ -142,7 +152,11 @@ public abstract class BasicFragment extends Fragment {
initData(); initData();
initViews(); initViews();
initSwipeRefreshLayout(); initSwipeRefreshLayout();
if (mBannerContainer!=null && !Constants.SHOWAD) {
if( mBannerContainer.getVisibility() !=View.GONE) {
mBannerContainer.setVisibility(View.GONE);
}
}
return view; return view;
// Inflate the layout for this fragment // Inflate the layout for this fragment
@ -460,7 +474,7 @@ void initTabs(){
return; 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) if( mBannerContainer.getVisibility() !=View.VISIBLE)
mBannerContainer.setVisibility(View.VISIBLE); mBannerContainer.setVisibility(View.VISIBLE);
} }

View File

@ -158,7 +158,7 @@ public class Fragment_booklist extends BasicFragment {
if(mMoreData.size()>0) { if(mMoreData.size()>0) {
pageNo++; 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.setPercent(pageNo/pageCount);
mAdapter.AddFooterItem(mMoreData); mAdapter.AddFooterItem(mMoreData);
mAdapter.changeMoreStatus(status); mAdapter.changeMoreStatus(status);
@ -231,8 +231,7 @@ public class Fragment_booklist extends BasicFragment {
// mFirstPage= gson.fromJson(result, FirstPage.class); // mFirstPage= gson.fromJson(result, FirstPage.class);
try { try {
JSONObject jsonObject = new JSONObject(result); JSONObject jsonObject = new JSONObject(result);
pageCount = jsonObject.getInt("pageCount"); setPageCount(jsonObject.getInt("pageCount")); ;
mMoreData = GsonUtil. parserJsonArray(jsonObject,Constants.BLOCK_TITLE_NOVELS); mMoreData = GsonUtil. parserJsonArray(jsonObject,Constants.BLOCK_TITLE_NOVELS);
if(mMoreData.size()>0){ if(mMoreData.size()>0){
loadListAd(mAdapter,1,mData.size()>0); loadListAd(mAdapter,1,mData.size()>0);
@ -266,9 +265,9 @@ public class Fragment_booklist extends BasicFragment {
try { try {
JSONObject jsonObject = new JSONObject(result); JSONObject jsonObject = new JSONObject(result);
String resultstr = jsonObject.getString("rank") ; 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); mMoreData = GsonUtil. parserJsonArray(resultstr,Constants.BLOCK_TITLE_NOVELS);
Log.d(TAG, "排行榜详细 onSuccess: pageCount " + pageCount); Log.d(TAG, "排行榜详细 onSuccess: pageCount " + getPageCount());
if(mMoreData.size()>0){ if(mMoreData.size()>0){
loadListAd(mAdapter,1,mData.size()>0); loadListAd(mAdapter,1,mData.size()>0);
} }
@ -337,12 +336,12 @@ public class Fragment_booklist extends BasicFragment {
@Override @Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) { public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState); super.onScrollStateChanged(recyclerView, newState);
Log.d(TAG, String.format("onScrollStateChanged , state %s ,lastVisibleitem %s ,getItemCount %s,pageno %s ,pageCount %s", 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,pageCount)); newState==RecyclerView.SCROLL_STATE_IDLE,lastVisibleItem,mAdapter.getItemCount(),pageNo,getPageCount()));
//判断RecyclerView的状态 是空闲时同时是最后一个可见的ITEM时才加载 //判断RecyclerView的状态 是空闲时同时是最后一个可见的ITEM时才加载
if(newState==RecyclerView.SCROLL_STATE_IDLE&&lastVisibleItem+1==mAdapter.getItemCount()){ if(newState==RecyclerView.SCROLL_STATE_IDLE&&lastVisibleItem+1==mAdapter.getItemCount()){
if(pageNo <= pageCount) { if(pageNo <= getPageCount()) {
//设置正在加载更多 //设置正在加载更多
mAdapter.changeMoreStatus(mAdapter.LOADING_MORE); mAdapter.changeMoreStatus(mAdapter.LOADING_MORE);
@ -374,7 +373,7 @@ public class Fragment_booklist extends BasicFragment {
super.run(); super.run();
mMoreData = Novel.getNovelsHistory(); mMoreData = Novel.getNovelsHistory();
pageCount=1; setPageCount(1);
handler.sendEmptyMessage(1); handler.sendEmptyMessage(1);
if(mMoreData!=null && mMoreData.size()>2) { if(mMoreData!=null && mMoreData.size()>2) {
loadListAd(mAdapter, 2, mData.size() > 0); loadListAd(mAdapter, 2, mData.size() > 0);

View File

@ -96,7 +96,7 @@ public static final String TAG = Fragment_paihang.class.getSimpleName();
if(mMoreData.size()>0) { if(mMoreData.size()>0) {
pageNo++; 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.setPercent(pageNo/pageCount);
mAdapter.AddFooterItem(mMoreData); mAdapter.AddFooterItem(mMoreData);
mAdapter.changeMoreStatus(status); mAdapter.changeMoreStatus(status);
@ -192,7 +192,7 @@ public static final String TAG = Fragment_paihang.class.getSimpleName();
// mFirstPage= gson.fromJson(result, FirstPage.class); // mFirstPage= gson.fromJson(result, FirstPage.class);
try { try {
JSONObject jsonObject = new JSONObject(result); JSONObject jsonObject = new JSONObject(result);
pageCount = jsonObject.getInt("pageCount"); setPageCount(jsonObject.getInt("pageCount"));
mMoreData = GsonUtil. parserJsonArray(jsonObject,Constants.BLOCK_TITLE_NOVELS); mMoreData = GsonUtil. parserJsonArray(jsonObject,Constants.BLOCK_TITLE_NOVELS);
if(mMoreData.size()>0){ if(mMoreData.size()>0){
@ -353,10 +353,10 @@ public static final String TAG = Fragment_paihang.class.getSimpleName();
//判断RecyclerView的状态 是空闲时同时是最后一个可见的ITEM时才加载 //判断RecyclerView的状态 是空闲时同时是最后一个可见的ITEM时才加载
Log.d(TAG, String.format("onScrollStateChanged , state %s ,lastVisibleitem %s ,getItemCount %s,pageno %s ,pageCount %s", 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(newState==RecyclerView.SCROLL_STATE_IDLE&&lastVisibleItem+1==mAdapter.getItemCount()){
if(pageNo <= pageCount) { if(pageNo <= getPageCount()) {
//设置正在加载更多 //设置正在加载更多
mAdapter.changeMoreStatus(mAdapter.LOADING_MORE); mAdapter.changeMoreStatus(mAdapter.LOADING_MORE);

View File

@ -47,5 +47,8 @@ public class Constants {
public static int version =0; public static int version =0;
public static int serverVersion =0; public static int serverVersion =0;
public static String updateUrl="http://xiaoshuofenxiang.com/version.xml";; 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;//最多加载的页数
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 29 KiB

View File

@ -1,5 +1,5 @@
<resources> <resources>
<string name="app_name">味知阅读</string> <string name="app_name">网书助手</string>
<string name="title_home">书架</string> <string name="title_home">书架</string>
<string name="title_dashboard">书城</string> <string name="title_dashboard">书城</string>
<string name="title_notifications">排行榜</string> <string name="title_notifications">排行榜</string>