before add qq ad
|
@ -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;
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;//最多加载的页数
|
||||
|
||||
}
|
||||
|
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 9.1 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 9.0 KiB After Width: | Height: | Size: 29 KiB |
|
@ -1,5 +1,5 @@
|
|||
<resources>
|
||||
<string name="app_name">味知阅读</string>
|
||||
<string name="app_name">网书助手</string>
|
||||
<string name="title_home">书架</string>
|
||||
<string name="title_dashboard">书城</string>
|
||||
<string name="title_notifications">排行榜</string>
|
||||
|
|