diff --git a/zhuike/build.gradle b/zhuike/build.gradle index fb878fc..4430e48 100644 --- a/zhuike/build.gradle +++ b/zhuike/build.gradle @@ -17,8 +17,8 @@ android { applicationId "com.novelbook.android" minSdkVersion 19 //target 19 Android 4.4 以下版本仅占比4.1% targetSdkVersion 28 - versionCode 5 - versionName "5.0" + versionCode 6 + versionName "6.0" // testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" @@ -40,13 +40,7 @@ android { buildConfigField "boolean", "LOG_DEBUG", "true" buildConfigField "String", "MAIN_HOST", '"http://xiaoshuofenxiang.com/api/"' buildConfigField "String", "API_HOST", '"{\\"master\\":[\\"http:\\\\/\\\\/g.xiaoshuofenxiang.com\\"],\\"page\\":[\\"http:\\\\/\\\\/p.xiaoshuofenxiang.com\\"],\\"report\\":[\\"http:\\\\/\\\\/r.xiaoshuofenxiang.com\\"],\\"search\\":[\\"http:\\\\/\\\\/s.xiaoshuofenxiang.com\\"],\\"novel\\":[\\"http:\\\\/\\\\/n.xiaoshuofenxiang.com\\"],\\"novelsbydot\\":[\\"http:\\\\/\\\\/nbd.xiaoshuofenxiang.com\\"],\\"user\\":[\\"http:\\\\/\\\\/u.xiaoshuofenxiang.com\\"]}"' -/* buildConfigField "String","AD_TOUTIAO_APP_ID",'"5019267"' - buildConfigField "String","AD_SLOT_TOUTIAO_FEEDAD_ID",'"919267464"' - buildConfigField "String","AD_SLOT_TOUTIAO_SPLASH_ID",'"819267134"' - buildConfigField "String","AD_SLOT_TOUTIAO_BANNER_ID",'"919267016"' - buildConfigField "String","AD_SLOT_TOUTIAO_BANNER_NATIVE_ID",'"919267816"' - buildConfigField "String","AD_SLOT_TOUTIAO_INTERACTION_ID",'"919267451"'*/ - // buildConfigField "String", "API_HOST", '""' + // buildConfigField "String", "CHANNEL",'"DEBUG"' versionNameSuffix "-debug" minifyEnabled false zipAlignEnabled false @@ -64,7 +58,7 @@ android { shrinkResources true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - /* applicationVariants.all { variant -> + /* applicationVariants.all { variant -> variant.outputs.all { output -> def outFile = output.outputFile if (outFile != null && outFile.name.endsWith(".apk")) { @@ -79,23 +73,25 @@ android { } } //渠道 - /*productFlavors { + /* productFlavors { // googleplay {} ali { - applicationId "com.novelbook.android" - versionName "v-qxs-1.0" - buildConfigField "String", "MAIN_HOST", '"http://chqxs.xiaoshuofenxiang.com/api/"' - buildConfigField "String", "API_HOST", '"{\\"master\\":[\\"http:\\\\/\\\\/qxs.xiaoshuofenxiang.com\\"],\\"page\\":[\\"http:\\\\/\\\\/p.xiaoshuofenxiang.com\\"],\\"report\\":[\\"http:\\\\/\\\\/r.xiaoshuofenxiang.com\\"],\\"search\\":[\\"http:\\\\/\\\\/s.xiaoshuofenxiang.com\\"],\\"novel\\":[\\"http:\\\\/\\\\/n.xiaoshuofenxiang.com\\"],\\"novelsbydot\\":[\\"http:\\\\/\\\\/nbd.xiaoshuofenxiang.com\\"],\\"user\\":[\\"http:\\\\/\\\\/u.xiaoshuofenxiang.com\\"]}"' + applicationId "com.zhushou.wangshu" + versionName "v1.0" + buildConfigField "String", "MAIN_HOST", '"http://xiaoshuofenxiang.com/api/"' + buildConfigField "String", "API_HOST", '"{\\"master\\":[\\"http:\\\\/\\\\/g.xiaoshuofenxiang.com\\"],\\"page\\":[\\"http:\\\\/\\\\/p.xiaoshuofenxiang.com\\"],\\"report\\":[\\"http:\\\\/\\\\/r.xiaoshuofenxiang.com\\"],\\"search\\":[\\"http:\\\\/\\\\/s.xiaoshuofenxiang.com\\"],\\"novel\\":[\\"http:\\\\/\\\\/n.xiaoshuofenxiang.com\\"],\\"novelsbydot\\":[\\"http:\\\\/\\\\/nbd.xiaoshuofenxiang.com\\"],\\"user\\":[\\"http:\\\\/\\\\/u.xiaoshuofenxiang.com\\"]}"' + - buildConfigField "String","AD_TOUTIAO_APP_ID",'"5019267"' - buildConfigField "String","AD_SLOT_TOUTIAO_FEEDAD_ID",'"919267464"' - buildConfigField "String","AD_SLOT_TOUTIAO_SPLASH_ID",'"819267134"' - buildConfigField "String","AD_SLOT_TOUTIAO_BANNER_ID",'"919267016"' - buildConfigField "String","AD_SLOT_TOUTIAO_BANNER_NATIVE_ID",'"919267816"' - buildConfigField "String","AD_SLOT_TOUTIAO_INTERACTION_ID",'"919267451"' } + qq { + applicationId "com.zhushou.wangshu" + versionName "v1.0" + buildConfigField "String", "MAIN_HOST", '"http://xiaoshuofenxiang.com/api/"' + buildConfigField "String", "API_HOST", '"{\\"master\\":[\\"http:\\\\/\\\\/g.xiaoshuofenxiang.com\\"],\\"page\\":[\\"http:\\\\/\\\\/p.xiaoshuofenxiang.com\\"],\\"report\\":[\\"http:\\\\/\\\\/r.xiaoshuofenxiang.com\\"],\\"search\\":[\\"http:\\\\/\\\\/s.xiaoshuofenxiang.com\\"],\\"novel\\":[\\"http:\\\\/\\\\/n.xiaoshuofenxiang.com\\"],\\"novelsbydot\\":[\\"http:\\\\/\\\\/nbd.xiaoshuofenxiang.com\\"],\\"user\\":[\\"http:\\\\/\\\\/u.xiaoshuofenxiang.com\\"]}"' + //buildConfigField "String", "API_HOST", '""' - *//* kuan { + } + *//*kuan { applicationId "com.novelbook.android" versionName "v-kuan-1.0" buildConfigField "String", "MAIN_HOST", '"http://xiaoshuofenxiang.com/api/"' @@ -111,14 +107,7 @@ android { //buildConfigField "String", "API_HOST", '""' buildConfigField "String", "CHANNEL",'"xiaomi"' } - qq { - applicationId "com.novelbook.android.qq" - versionName "v-qq-1.0" - buildConfigField "String", "MAIN_HOST", '"http://xiaoshuofenxiang.com/api/"' - buildConfigField "String", "API_HOST", '"{\\"master\\":[\\"http:\\\\/\\\\/g.xiaoshuofenxiang.com\\"],\\"page\\":[\\"http:\\\\/\\\\/p.xiaoshuofenxiang.com\\"],\\"report\\":[\\"http:\\\\/\\\\/r.xiaoshuofenxiang.com\\"],\\"search\\":[\\"http:\\\\/\\\\/s.xiaoshuofenxiang.com\\"],\\"novel\\":[\\"http:\\\\/\\\\/n.xiaoshuofenxiang.com\\"],\\"novelsbydot\\":[\\"http:\\\\/\\\\/nbd.xiaoshuofenxiang.com\\"],\\"user\\":[\\"http:\\\\/\\\\/u.xiaoshuofenxiang.com\\"]}"' - //buildConfigField "String", "API_HOST", '""' - } qxs { applicationId "com.novelbook.android.qxs" versionName "v-qxs-5.0" diff --git a/zhuike/src/main/java/com/novelbook/android/AD/SplashActivity.java b/zhuike/src/main/java/com/novelbook/android/AD/SplashActivity.java index 756925a..cb58051 100644 --- a/zhuike/src/main/java/com/novelbook/android/AD/SplashActivity.java +++ b/zhuike/src/main/java/com/novelbook/android/AD/SplashActivity.java @@ -111,16 +111,28 @@ public class SplashActivity extends Activity implements WeakHandler.IHandler, Sp @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - if(!Constants.AD_SETTING.isShowAdsense() ||!Constants.AD_SETTING.getSplash().isShow() ){ + boolean isGoToMain= getIntent().getBooleanExtra(EXTR_LUNCHER,true); + if(!Constants.AD_SETTING.isShowAdsense() ||isGoToMain && !Constants.AD_SETTING.getSplash().isShow() ){ goToMainActivity(); return; } - int rid =R.layout.ad_toutiao_activity_splash; - if(Constants.AD_SETTING.getSplash().getSource() == Constants.AD_TENCENT_QQ ){ - rid = R.layout.ad_qq_activity_splash; - }else if(Constants.AD_SETTING.getSplash().getSource() == Constants.AD_TOUTIAO ){ - rid = R.layout.ad_toutiao_activity_splash; + int splashSource=Constants.AD_TENCENT_QQ; + if(isGoToMain) { + if (Constants.AD_SETTING.getSplash().getSource() == Constants.AD_TENCENT_QQ) { + rid = R.layout.ad_qq_activity_splash; + } else if (Constants.AD_SETTING.getSplash().getSource() == Constants.AD_TOUTIAO) { + rid = R.layout.ad_toutiao_activity_splash; + splashSource=Constants.AD_TOUTIAO; + } + }else{ + if (Constants.AD_SETTING.getSplash2().getSource() == Constants.AD_TENCENT_QQ) { + rid = R.layout.ad_qq_activity_splash; + } else if (Constants.AD_SETTING.getSplash2().getSource() == Constants.AD_TOUTIAO) { + // rid = R.layout.ad_toutiao_activity_splash; + goToMainActivity(); + return; + } } setContentView(rid); @@ -142,7 +154,7 @@ public class SplashActivity extends Activity implements WeakHandler.IHandler, Sp ); tvTitle.setText(R.string.app_name); //加载开屏广告 - if(Constants.AD_SETTING.getSplash().getSource() == Constants.AD_TOUTIAO ) { + if(splashSource == Constants.AD_TOUTIAO ) { mHandler.sendEmptyMessageDelayed(MSG_GO_MAIN, AD_TIME_OUT); //step2:创建TTAdNative对象 try { @@ -152,7 +164,7 @@ public class SplashActivity extends Activity implements WeakHandler.IHandler, Sp return; } loadSplashAd(); - }else if(Constants.AD_SETTING.getSplash().getSource() == Constants.AD_TENCENT_QQ ){ + }else if(splashSource == Constants.AD_TENCENT_QQ ){ if (Build.VERSION.SDK_INT >= 23) { checkAndRequestPermission(); } else { diff --git a/zhuike/src/main/java/com/novelbook/android/AD/SplashAdManager.java b/zhuike/src/main/java/com/novelbook/android/AD/SplashAdManager.java index dd1693d..fc8f28e 100644 --- a/zhuike/src/main/java/com/novelbook/android/AD/SplashAdManager.java +++ b/zhuike/src/main/java/com/novelbook/android/AD/SplashAdManager.java @@ -135,7 +135,7 @@ public class SplashAdManager implements Application.ActivityLifecycleCallbacks, return false; } long in = new Date().getTime() -lastAd; - int interVal =60000;//Constants.AD_SETTING.getSplash2().getInterval4Display()*1000; + int interVal = Constants.AD_SETTING.getSplash2().getInterval4Display()*1000; Log.d("zzr", "canShowAd: interval is, " +in + ", canshow? "+ (in >interVal)); return in >interVal; } @@ -146,7 +146,8 @@ public class SplashAdManager implements Application.ActivityLifecycleCallbacks, public static void plusPage(Activity activity){ pages++; if(pages >Constants.AD_SETTING.getSplash2().getPageCount4Display()){ - showInterAd(activity); + clearPages(); + showSplashAd(activity); } } diff --git a/zhuike/src/main/java/com/novelbook/android/ActivitySetup.java b/zhuike/src/main/java/com/novelbook/android/ActivitySetup.java index ff8fd91..1e254cf 100644 --- a/zhuike/src/main/java/com/novelbook/android/ActivitySetup.java +++ b/zhuike/src/main/java/com/novelbook/android/ActivitySetup.java @@ -49,7 +49,7 @@ static final String TAG = ActivitySetup.class.getSimpleName(); public void run() { super.run(); mVersion =CommonUtil.getVersion(ActivitySetup.this); - mCacheSize =FileUtils.getCachedSize(); + mCacheSize =FileUtils.getFormatedCachedSize() ; handler.sendEmptyMessage(1); } }.start() ; @@ -66,12 +66,16 @@ static final String TAG = ActivitySetup.class.getSimpleName(); } + @Override public void fillData() { tvVersion.setText(mVersion); tvCache.setText(mCacheSize); + if(mCacheSize.equals("0.00B")){ + tvCache.setText(R.string.noCache); + } } @@ -85,6 +89,11 @@ static final String TAG = ActivitySetup.class.getSimpleName(); startActivity(intent); break; case R.id.llCache: + if(mCacheSize.equals("0.00B")){ + return; + } + + final AlertDialog.Builder normalDialog = new AlertDialog.Builder(ActivitySetup.this); @@ -98,8 +107,9 @@ static final String TAG = ActivitySetup.class.getSimpleName(); stopService(intent); FileUtils.clearCache(); LitePal.deleteAll(DownloadTask.class); - tvCache.setText(FileUtils.getCachedSize()); - + mCacheSize="0.00B"; + //tvCache.setText(FileUtils.getFormatedCachedSize()); + tvCache.setText(R.string.noCache); } }); normalDialog.setNegativeButton("取消", @@ -144,6 +154,7 @@ static final String TAG = ActivitySetup.class.getSimpleName(); }else if(Constants.serverVersion==-1){ handler.sendEmptyMessage(MSG_VERSION_LATEST); } + handler.sendEmptyMessage(1000); } 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 a079a7c..f3e8d2d 100644 --- a/zhuike/src/main/java/com/novelbook/android/Activity_base.java +++ b/zhuike/src/main/java/com/novelbook/android/Activity_base.java @@ -92,7 +92,7 @@ public abstract class Activity_base extends AppCompatActivity implements Native private static String TAG ="Activity_base"; private ProgressDialog mProgressDialog; - private MyApp application; + MyApp application; private Activity_base oContext; protected Gson gson = new Gson(); protected long mLastBannerTime =0; @@ -179,7 +179,7 @@ public abstract class Activity_base extends AppCompatActivity implements Native if(mBannerContainer==null){ return; } - if(Constants.AD_SETTING.isShowAdsense()){ + if(Constants.AD_SETTING.isShowAdsense() && Constants.AD_SETTING.getBigBanner().isShow() && NetUtil.isNetworkConnected()){ loadNativeBannerAd(); mBannerContainer.setVisibility(View.VISIBLE); }else{ diff --git a/zhuike/src/main/java/com/novelbook/android/Activity_cache.java b/zhuike/src/main/java/com/novelbook/android/Activity_cache.java index 5c6cc98..e7084d7 100644 --- a/zhuike/src/main/java/com/novelbook/android/Activity_cache.java +++ b/zhuike/src/main/java/com/novelbook/android/Activity_cache.java @@ -153,7 +153,7 @@ public class Activity_cache extends Activity_base { if( mData.size()>0){ tvMsg.setText(String.format("共有%s条下载记录",mData.size())); }else{ - tvMsg.setText("您还没有没有缓存过小说"); + tvMsg.setText(R.string.noRecord); } } @@ -247,7 +247,7 @@ public class Activity_cache extends Activity_base { private List mDatas = new ArrayList(); private OnItemClickLitener mOnItemClickLitener; private int listItemID; - private String norecord ="还没有下载记录"; + // private String norecord ="还没有下载记录"; public CacheAdapter(Context context, List mDatas, int listItemID, OnItemClickLitener clickLitener) { this.context = context; @@ -302,7 +302,7 @@ public class Activity_cache extends Activity_base { if (hd instanceof EmptyViewHolder) { EmptyViewHolder holder = ( EmptyViewHolder)hd; holder.tvEmpty.setVisibility(View.VISIBLE); - holder.tvEmpty.setText(norecord); + holder.tvEmpty.setText(R.string.noRecord); return; } MyViewHolder holder = ( MyViewHolder)hd; 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 2e4251a..81f37cc 100644 --- a/zhuike/src/main/java/com/novelbook/android/Fragments/BasicFragment.java +++ b/zhuike/src/main/java/com/novelbook/android/Fragments/BasicFragment.java @@ -65,11 +65,15 @@ import com.novelbook.android.utils.ImageUtil; import com.novelbook.android.utils.MyImageLoader; import com.novelbook.android.utils.OnItemClickListener; import com.novelbook.android.utils.PageFactory; +import com.qq.e.ads.nativ.ADSize; import com.qq.e.ads.nativ.NativeADUnifiedListener; import com.qq.e.ads.nativ.NativeExpressAD; +import com.qq.e.ads.nativ.NativeExpressADView; import com.qq.e.ads.nativ.NativeUnifiedAD; import com.qq.e.ads.nativ.NativeUnifiedADData; +import com.qq.e.comm.constants.AdPatternType; import com.qq.e.comm.util.AdError; +import com.qq.e.comm.util.GDTLogger; import com.umeng.analytics.MobclickAgent; import com.youth.banner.loader.ImageLoader; @@ -91,7 +95,7 @@ import static com.novelbook.android.utils.AdUtil.getAppID; /** * A simple {@link Fragment} subclass. */ -public abstract class BasicFragment extends Fragment implements NativeADUnifiedListener { +public abstract class BasicFragment extends Fragment implements /* NativeADUnifiedListener,*/NativeExpressAD.NativeExpressADListener { private static String TAG = BasicFragment.class.getSimpleName(); protected View rootView; @@ -459,13 +463,14 @@ void initTabs(){ error_try=0; } - //---------toutiao ad------ + //---------banner ad------ public void showBanner( FrameLayout bannerContainer , int adHeight ) { if(bannerContainer==null){ return; } // bannerContainer.setVisibility(View.GONE); - if (!Constants.AD_SETTING.isShowAdsense()) { + if (!Constants.AD_SETTING.isShowAdsense() || !Constants.AD_SETTING.getFixBanner().isShow() || !NetUtil.isNetworkConnected()) { + mBannerContainer.setVisibility(View.GONE); return; } @@ -475,7 +480,7 @@ void initTabs(){ } // qq ad ------------------------------begin - private NativeUnifiedAD mAdManager; + /* private NativeUnifiedAD mAdManager; private List mAds = new ArrayList<>(); public void loadListAd_qq(BookListAdapter adapter, int adCnt, boolean addFooter) { if(mAdManager==null) { @@ -488,11 +493,12 @@ void initTabs(){ qqAdapter =adapter; qqAddFooter=addFooter; Log.d(TAG, "loadListAd_qq: ad requested"); - } + }*/ + private boolean qqAddFooter; private BookListAdapter qqAdapter; - @Override +/* @Override public void onADLoaded(List ads) { Log.d(TAG, "loadListAd_qq: ad onADLoaded,qqAddFooter? "+qqAddFooter); // mIsLoading = false; @@ -506,7 +512,7 @@ void initTabs(){ }else{ qqAdapter.AddHeaderItem(ads); } - } + }*/ @Override public void onNoAD(AdError adError) { Log.d(TAG, "loadListAd_qq: ad onNoAD " ); @@ -516,6 +522,88 @@ void initTabs(){ adError.getErrorMsg())); } + private NativeExpressAD mADManager; + void loadListAd_qq(BookListAdapter adapter, int adCnt, boolean addFooter) { + ADSize adSize = new ADSize(ADSize.FULL_WIDTH, ADSize.AUTO_HEIGHT); // 消息流中用AUTO_HEIGHT + mADManager = new NativeExpressAD(activity, adSize, getAppID(Constants.AD_TENCENT_QQ), + Constants.AD_SETTING.getInformationFlow().getSlotId(Constants.AD_TENCENT_QQ), this); + mADManager.setMaxVideoDuration(5); + mADManager.loadAD(adCnt); + qqAdapter =adapter; + qqAddFooter=addFooter; + Log.d(TAG, "loadListAd_qq: ad requested"); + } + @Override + public void onADLoaded(List adList) { + Log.i(TAG, "onADLoaded: " + adList.size()); + /* mAdViewList = adList; + for (int i = 0; i < mAdViewList.size(); i++) { + int position = FIRST_AD_POSITION + ITEMS_PER_AD * i; + if (position < mNormalDataList.size()) { + NativeExpressADView view = mAdViewList.get(i); + GDTLogger.i("ad load[" + i + "]: " + getAdInfo(view)); + if (view.getBoundData().getAdPatternType() == AdPatternType.NATIVE_VIDEO) { + view.setMediaListener(mediaListener); + } + mAdViewPositionMap.put(view, position); // 把每个广告在列表中位置记录下来 + mAdapter.addADViewToPosition(position, mAdViewList.get(i)); + } + } + mAdapter.notifyDataSetChanged();*/ + if(qqAdapter==null){ + return; + } + + if(qqAddFooter) { + qqAdapter.AddFooterItem(adList); + }else{ + qqAdapter.AddHeaderItem(adList); + } + } + @Override + public void onRenderFail(NativeExpressADView adView) { + Log.i(TAG, "onRenderFail: " + adView.toString()); + } + + @Override + public void onRenderSuccess(NativeExpressADView adView) { + // Log.i(TAG, "onRenderSuccess: " + adView.toString() + ", adInfo: " + getAdInfo(adView)); + } + + @Override + public void onADExposure(NativeExpressADView adView) { + Log.i(TAG, "onADExposure: " + adView.toString()); + } + + @Override + public void onADClicked(NativeExpressADView adView) { + Log.i(TAG, "onADClicked: " + adView.toString()); + } + + @Override + public void onADClosed(NativeExpressADView adView) { + Log.i(TAG, "onADClosed: " + adView.toString()); + /* if (mAdapter != null) { + int removedPosition = mAdViewPositionMap.get(adView); + mAdapter.removeADView(removedPosition, adView); + }*/ + } + + @Override + public void onADLeftApplication(NativeExpressADView adView) { + Log.i(TAG, "onADLeftApplication: " + adView.toString()); + } + + @Override + public void onADOpenOverlay(NativeExpressADView adView) { + Log.i(TAG, "onADOpenOverlay: " + adView.toString()); + } + + @Override + public void onADCloseOverlay(NativeExpressADView adView) { + Log.i(TAG, "onADCloseOverlay"); + } + //qq ad end<------------- /** 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 5610581..40f9610 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 @@ -453,6 +453,7 @@ public class Fragment_Shelf extends BasicFragment { @OnClick({R.id.btnSelect, R.id.btnDelete}) void shelfZhengliSubmit(View view) { + if (view.getId() == R.id.btnSelect) { if (isSelectAll) { @@ -468,7 +469,29 @@ public class Fragment_Shelf extends BasicFragment { mChkAdapter.notifyDataSetChanged(); } else if (view.getId() == R.id.btnDelete) { + boolean isChecked = false; + for(boolean b :flag){ + if(b) { + isChecked = true; + break; + } + } + if(!isChecked){ + new AlertDialog.Builder(activity) + .setTitle(this.getString(R.string.app_name)) + .setMessage( "您还没有选择要移除的书籍") + .setNegativeButton("确定", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + return; + + } + }) + + .setCancelable(false).show(); + return; + } new AlertDialog.Builder(activity) .setTitle(this.getString(R.string.app_name)) .setMessage( "您将从书架移除选中的书籍,是否继续?") @@ -500,15 +523,16 @@ public class Fragment_Shelf extends BasicFragment { nv.update(nv.getId()); // nv.update(nv.getId()); //not work,,,If you set a default value to a field, the corresponding column won't be updated. } - bookLists = Novel.getNovelsOnShelf(); - flag = new boolean[bookLists.size()]; - zhengliShelf(); - initData(); + // flag = new boolean[bookLists.size()]; // bookLists.remove(i); } } - + btnSelectAll.setText("全选"); + bookLists = Novel.getNovelsOnShelf(); + flag = new boolean[bookLists.size()]; + zhengliShelf(); + initData(); } }) .setCancelable(false).show(); @@ -533,6 +557,27 @@ public class Fragment_Shelf extends BasicFragment { private void initZhengliDialog() { + if( flag==null || flag.length ==0 ){ + flag= new boolean[bookLists.size()]; + } + if( flag==null || flag.length ==0 ){ + new AlertDialog.Builder(activity) + .setTitle(this.getString(R.string.app_name)) + .setMessage( "您书架上还没有书籍可以整理") + .setNegativeButton("确定", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + return; + + + } + }) + + .setCancelable(false).show(); + return; + + } + zhengliShelf(); llShelfBottom.setVisibility(View.VISIBLE); Main2Activity main2Activity = (Main2Activity) activity; 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 9878fad..5d5b188 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 @@ -192,32 +192,7 @@ public class Fragment_booklist extends BasicFragment { } else { - mData = new ArrayList(); - mAdapter = new BookListAdapter(activity, mData, listItem, new OnItemClickListener() { - - @Override - public void onItemClick(View view, int position) { - if(mData.get(position) instanceof Novel) - showBookDetail((Novel)mData.get(position)); - // openBook(mData.get(position),mAdapter); - } - - @Override - public void onItemLongClick(View view, int position) { - // initDialog(position); - // mAdapter.removeData(position); - } - - @Override - public void onLinearOutClick(View view, int position, int llId) { - Toast.makeText(activity, "book " + position + " clicked", - Toast.LENGTH_SHORT).show(); - } - }); - mAdapter.setShowFootView(true); - mRecyclerView.setLayoutManager(new LinearLayoutManager(activity)); - mRecyclerView.setAdapter(mAdapter); - + initialDataAdapter(); } } /* if(mAdapter!=null){ @@ -311,6 +286,36 @@ public class Fragment_booklist extends BasicFragment { } + + private void initialDataAdapter() { + mData = new ArrayList(); + mAdapter = new BookListAdapter(activity, mData, listItem, new OnItemClickListener() { + + @Override + public void onItemClick(View view, int position) { + if(mData.get(position) instanceof Novel) + showBookDetail((Novel)mData.get(position)); + // openBook(mData.get(position),mAdapter); + } + + @Override + public void onItemLongClick(View view, int position) { + // initDialog(position); + // mAdapter.removeData(position); + } + + @Override + public void onLinearOutClick(View view, int position, int llId) { + Toast.makeText(activity, "book " + position + " clicked", + Toast.LENGTH_SHORT).show(); + } + }); + mAdapter.setShowFootView(true); + mRecyclerView.setLayoutManager(new LinearLayoutManager(activity)); + mRecyclerView.setAdapter(mAdapter); + + } + @Override public void initViews(){ //mRecyclerView @@ -367,6 +372,7 @@ public class Fragment_booklist extends BasicFragment { } void loadHistory(){ + initialDataAdapter(); new Thread() { @Override public void run() { @@ -374,9 +380,10 @@ public class Fragment_booklist extends BasicFragment { mMoreData = Novel.getNovelsHistory(); setPageCount(1); + // handler.sendEmptyMessage(1); - if(mMoreData!=null && mMoreData.size()>2) { - loadListAd(mAdapter, 2, mData.size() > 0); + if(mMoreData!=null && mMoreData.size()>5) { + loadListAd(mAdapter, 1, mData.size() > 0); } } }.start(); diff --git a/zhuike/src/main/java/com/novelbook/android/Main2Activity.java b/zhuike/src/main/java/com/novelbook/android/Main2Activity.java index 36cd3f2..73530e2 100644 --- a/zhuike/src/main/java/com/novelbook/android/Main2Activity.java +++ b/zhuike/src/main/java/com/novelbook/android/Main2Activity.java @@ -60,7 +60,7 @@ import static com.novelbook.android.FileActivity.EXTERNAL_STORAGE_REQ_CODE; public class Main2Activity extends Activity_base implements NavigationView.OnNavigationItemSelectedListener{//} , BasicFragment.OnFragmentInteractionListener { - public MyApp app ; + // public MyApp app ; public static final String TAG =Main2Activity.class.getSimpleName(); // @BindView(R.id.fab) @@ -89,17 +89,18 @@ public class Main2Activity extends Activity_base public static volatile Activity activityContext = null; @Override protected void onCreate(Bundle savedInstanceState) { + NetUtil.getHostPolicy(); super.onCreate(savedInstanceState); activityContext =this; //PageFactory.createPageFactory(this); - app =(MyApp) getApplicationContext(); + // requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); config =Config.getInstance(); // ButterKnife.bind(this); initialSexOption(); - // checkUpdate(true); + //checkUpdate(true); CommonUtil.getSearchTabTtitle(this); DisplayMetrics metric = new DisplayMetrics(); WindowManager wm = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE); @@ -445,7 +446,7 @@ private int bottomSelectedIndex; // return super.onKeyUp(keyCode, event); // return false; finish(); - app.exit(); + application.exit(); } } try{ diff --git a/zhuike/src/main/java/com/novelbook/android/MyApp.java b/zhuike/src/main/java/com/novelbook/android/MyApp.java index 7183a1f..b16160c 100644 --- a/zhuike/src/main/java/com/novelbook/android/MyApp.java +++ b/zhuike/src/main/java/com/novelbook/android/MyApp.java @@ -101,7 +101,14 @@ public class MyApp extends Application { if (!oList.contains(activity)) { oList.add(activity);//把当前Activity添加到集合中 } + currentAct=activity; } + private static Activity currentAct =null; + public static Activity getCurrentActivity(){ + return currentAct; + + } + /** diff --git a/zhuike/src/main/java/com/novelbook/android/ReadActivity.java b/zhuike/src/main/java/com/novelbook/android/ReadActivity.java index 27fac3b..1e4b17b 100644 --- a/zhuike/src/main/java/com/novelbook/android/ReadActivity.java +++ b/zhuike/src/main/java/com/novelbook/android/ReadActivity.java @@ -129,8 +129,8 @@ public class ReadActivity extends Activity_base implements AdInterface { @BindView(R.id.tvUrl) TextView tvUrl; -// @BindView(R.id.top_banner_container) -// FrameLayout mTopBannerContainer; + @BindView(R.id.top_banner_container) + FrameLayout mTopBannerContainer; @BindView(R.id.imgLoading) pl.droidsonroids.gif.GifImageView imgLoading; @@ -1084,6 +1084,10 @@ public class ReadActivity extends Activity_base implements AdInterface { return tmpFrame; } + @Override + void initNaviBanner() { + + } public void hideStatusAds(){ /* try{ @@ -1131,6 +1135,7 @@ public class ReadActivity extends Activity_base implements AdInterface { // mBannerContainer.removeAllViews(); // mBannerContainer.setBackgroundResource(R.color.transparent); hideAdSlot(mBannerContainer); + hideAdSlot(mNative_status_banner_container); if(height<=0){ return; } @@ -1138,7 +1143,7 @@ public class ReadActivity extends Activity_base implements AdInterface { if( adY >390*Constants.ONE_DP_SIZE){ return; } - + hideAdSlot(mTopBannerContainer); if(mBannerContainer.getChildCount()>0) { mBannerContainer.removeAllViews(); Log.d(TAG, "loadBannerAd: hideAdSlot()"); @@ -1163,21 +1168,26 @@ public class ReadActivity extends Activity_base implements AdInterface { // mTopBannerContainer.setVisibility(View.INVISIBLE);//翻页引起抖动 //mTopBannerContainer.removeAllViews(); // Log.d(TAG, String.format("loadBannerAd:showTopBanner width %s, height %s ,adY %s ",Constants.SCREEN_WIDTH_PIX-50,adHeight,adY)); - tmpFrame =mBannerContainer; + tmpFrame =mTopBannerContainer; // hideAdSlot(mBannerContainer); + + hideAdSlot(mBannerContainer); + hideAdSlot(mNative_status_banner_container); if(adHeight<=0){ + hideAdSlot(mTopBannerContainer); return; } + int topMargin = adY >200*Constants.ONE_DP_SIZE ? adY -15*Constants.ONE_DP_SIZE :adY -5*Constants.ONE_DP_SIZE; Log.d(TAG, String.format("loadBannerAd:showTopBanner width %s, height %s ,adY %s ",Constants.SCREEN_WIDTH_PIX-50,adHeight,adY)); - FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mBannerContainer.getLayoutParams(); - loadBanner(mBannerContainer, Constants.SCREEN_WIDTH_PIX-50,adHeight); + FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mTopBannerContainer.getLayoutParams(); + loadBanner(mTopBannerContainer, Constants.SCREEN_WIDTH_PIX-50,adHeight); // loadNativeBannerAd(mTopBannerContainer,BuildConfig.AD_SLOT_TOUTIAO_BANNER_NATIVE_ID, 304,200); params.setMargins(10*Constants.ONE_DP_SIZE, topMargin, 10*Constants.ONE_DP_SIZE, 0 ); params.width =-1; params.height = (int) getResources().getDimension(R.dimen.topBannerHeight); - mBannerContainer.setLayoutParams(params); - showAdSlot(mBannerContainer); + mTopBannerContainer.setLayoutParams(params); + showAdSlot(mTopBannerContainer); } diff --git a/zhuike/src/main/java/com/novelbook/android/adapter/BookListAdapter.java b/zhuike/src/main/java/com/novelbook/android/adapter/BookListAdapter.java index 75111f0..1038565 100644 --- a/zhuike/src/main/java/com/novelbook/android/adapter/BookListAdapter.java +++ b/zhuike/src/main/java/com/novelbook/android/adapter/BookListAdapter.java @@ -37,6 +37,7 @@ import com.novelbook.android.utils.CommonUtil; import com.novelbook.android.utils.ImageUtil; import com.novelbook.android.utils.MyImageLoader; import com.novelbook.android.utils.OnItemClickListener; +import com.qq.e.ads.nativ.NativeExpressADView; import java.util.ArrayList; import java.util.List; @@ -60,7 +61,7 @@ public class BookListAdapter extends RecyclerView.Adapter< RecyclerView.ViewHol private static final int ITEM_VIEW_TYPE_SMALL_PIC_AD = 6; private static final int ITEM_VIEW_TYPE_LARGE_PIC_AD = 7; private static final int ITEM_VIEW_TYPE_VIDEO = 8; - + private static final int ITEM_VIEW_TYPE_QQ_NATIVE_EXPRESS = 9; // private MyImageLoader loader = new MyImageLoader(); @@ -162,9 +163,12 @@ public class BookListAdapter extends RecyclerView.Adapter< RecyclerView.ViewHol return ITEM_VIEW_TYPE_VIDEO; } return ITEM_VIEW_TYPE_SMALL_PIC_AD; + }else if(mDatas.get(position) instanceof NativeExpressADView ){ + return ITEM_VIEW_TYPE_QQ_NATIVE_EXPRESS; } - }else if ( position == mDatas.size()) { + } + else if ( position == mDatas.size()) { //最后一个item设置为footerView if(!showFootView){ return NO_FOOTER; @@ -201,6 +205,10 @@ public class BookListAdapter extends RecyclerView.Adapter< RecyclerView.ViewHol return new GroupAdViewHolder(mInflater.inflate(R.layout.listitem_ad_group_pic, parent, false)); case ITEM_VIEW_TYPE_VIDEO: return new VideoAdViewHolder(mInflater.inflate(R.layout.listitem_ad_large_video, parent, false)); + case ITEM_VIEW_TYPE_QQ_NATIVE_EXPRESS: + + return new QQ_ExpressViewHolder(mInflater.inflate(R.layout.listitem_ad_qq_item_express, parent, false)); + default: return new MyViewHolder( mInflater.inflate(listItemID, parent, false)); } @@ -254,8 +262,27 @@ public class BookListAdapter extends RecyclerView.Adapter< RecyclerView.ViewHol EmptyViewHolder holder = (EmptyViewHolder)hd; holder.tvEmpty.setVisibility(View.VISIBLE); holder.tvEmpty.setText(norecord); - } + }else if (hd instanceof QQ_ExpressViewHolder) { + QQ_ExpressViewHolder holder = (QQ_ExpressViewHolder)hd; + // holder.title.setVisibility(View.VISIBLE); + final NativeExpressADView adView = (NativeExpressADView) mDatas.get(position); + // mAdViewPositionMap.put(adView, position); // 广告在列表中的位置是可以被更新的 + if (holder.container.getChildCount() > 0 + && holder.container.getChildAt(0) == adView) { + return; + } + if (holder.container.getChildCount() > 0) { + holder.container.removeAllViews(); + } + + if (adView.getParent() != null) { + ((ViewGroup) adView.getParent()).removeView(adView); + } + + holder.container.addView(adView); + adView.render(); // 调用render方法后sdk才会开始展示广告 + } else if (hd instanceof MyViewHolder && mDatas.get(position) instanceof Novel) { @@ -623,6 +650,19 @@ public class BookListAdapter extends RecyclerView.Adapter< RecyclerView.ViewHol super(itemView); } } + + class QQ_ExpressViewHolder extends RecyclerView.ViewHolder { + // public TextView title; + public ViewGroup container; + + public QQ_ExpressViewHolder(View view) { + super(view); + // title = (TextView) view.findViewById(R.id.title); + container = (ViewGroup) view.findViewById(R.id.express_ad_container); + } + } + + private void bindData(final AdViewHolder adViewHolder, TTFeedAd ad) { //可以被点击的view, 也可以把convertView放进来意味item可被点击 List clickViewList = new ArrayList<>(); diff --git a/zhuike/src/main/java/com/novelbook/android/bean/AdSetting.java b/zhuike/src/main/java/com/novelbook/android/bean/AdSetting.java index 1bc4df1..7d1e1f7 100644 --- a/zhuike/src/main/java/com/novelbook/android/bean/AdSetting.java +++ b/zhuike/src/main/java/com/novelbook/android/bean/AdSetting.java @@ -1,6 +1,9 @@ package com.novelbook.android.bean; +import com.novelbook.android.netutils.NetUtil; + public class AdSetting { + private boolean showAdsense; private String[] appIds={}; private slot splash = new slot(); private slot splash2 = new slot(); @@ -9,10 +12,10 @@ public class AdSetting { private slot chapterContentBanner = new slot(); private slot chapterEndBanner = new slot(); private slot pop = new slot(); - private boolean showAdsense; - + private slot fixBanner = new slot(); + private slot bigBanner = new slot(); public boolean isShowAdsense() { - return true;//showAdsense; + return showAdsense && NetUtil.isNetworkConnected(); } public void setShowAdsense(boolean showAdsense) { @@ -51,8 +54,15 @@ public class AdSetting { return pop; } + public slot getFixBanner() { + return fixBanner; + } -public class slot{ + public slot getBigBanner() { + return bigBanner; + } + + public class slot{ private boolean show; private int source; private int interval4Display; @@ -71,7 +81,7 @@ public class slot{ } public boolean isShow() { - return show; + return show && NetUtil.isNetworkConnected(); } public void setShow(boolean show) { @@ -79,8 +89,8 @@ public class slot{ } public int getSource() { - // return source; - return 1; + return source; + // return 1; } public void setSource(int source) { diff --git a/zhuike/src/main/java/com/novelbook/android/filechooser/DirectoryFragment.java b/zhuike/src/main/java/com/novelbook/android/filechooser/DirectoryFragment.java index c1c3ea6..7ffb77f 100644 --- a/zhuike/src/main/java/com/novelbook/android/filechooser/DirectoryFragment.java +++ b/zhuike/src/main/java/com/novelbook/android/filechooser/DirectoryFragment.java @@ -7,6 +7,7 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.graphics.drawable.Drawable; +import android.graphics.pdf.PdfDocument; import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; @@ -28,10 +29,12 @@ import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; +import com.novelbook.android.MyApp; import com.novelbook.android.R; import com.novelbook.android.ReadActivity; import com.novelbook.android.db.Novel; import com.novelbook.android.utils.FileUtils; +import com.novelbook.android.utils.PageFactory; import org.litepal.LitePal; @@ -644,12 +647,16 @@ public class DirectoryFragment extends Fragment implements View.OnClickListener for (Novel book : bookLists){ if (book.getNovelPath().equals(bookList.getNovelPath())){ isSave = true; + bookList =book; + break; } } if (!isSave){ bookList.save(); } + // PageFactory.getInstance(MyApp.applicationContext).prepareBook(bookList); + ReadActivity.openBook(bookList, getActivity()); } }).show(); diff --git a/zhuike/src/main/java/com/novelbook/android/filechooser/FileChooserActivity.java b/zhuike/src/main/java/com/novelbook/android/filechooser/FileChooserActivity.java index a70787a..e2c824a 100644 --- a/zhuike/src/main/java/com/novelbook/android/filechooser/FileChooserActivity.java +++ b/zhuike/src/main/java/com/novelbook/android/filechooser/FileChooserActivity.java @@ -107,7 +107,7 @@ public class FileChooserActivity extends AppCompatActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. - getMenuInflater().inflate(R.menu.file, menu); + // getMenuInflater().inflate(R.menu.file, menu); return true; } diff --git a/zhuike/src/main/java/com/novelbook/android/netutils/HttpMethods.java b/zhuike/src/main/java/com/novelbook/android/netutils/HttpMethods.java index c2e5ebc..273eddc 100644 --- a/zhuike/src/main/java/com/novelbook/android/netutils/HttpMethods.java +++ b/zhuike/src/main/java/com/novelbook/android/netutils/HttpMethods.java @@ -222,7 +222,7 @@ public class HttpMethods { }); - loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.HEADERS); + loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY); //设置 Debug Log 模式 okHttpBuilder.addInterceptor(loggingInterceptor); // okHttpBuilder.addInterceptor(new RetryInterceptor()); diff --git a/zhuike/src/main/java/com/novelbook/android/netutils/NetUtil.java b/zhuike/src/main/java/com/novelbook/android/netutils/NetUtil.java index cfdcbd0..817b622 100644 --- a/zhuike/src/main/java/com/novelbook/android/netutils/NetUtil.java +++ b/zhuike/src/main/java/com/novelbook/android/netutils/NetUtil.java @@ -1,6 +1,7 @@ package com.novelbook.android.netutils; import android.Manifest; +import android.app.Activity; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; @@ -12,6 +13,7 @@ import com.google.gson.Gson; import com.google.gson.JsonObject; import com.novelbook.android.AD.toutiao.TTAdManagerHolder; import com.novelbook.android.BookActivity; +import com.novelbook.android.BuildConfig; import com.novelbook.android.Main2Activity; import com.novelbook.android.MyApp; import com.novelbook.android.bean.AdSetting; @@ -317,10 +319,13 @@ public class NetUtil { String systemVersion = CommonUtil.getSystemVersion(); String deviceBrand = CommonUtil.getDeviceBrand(); String packagenm = CommonUtil.getPackageName(context); - userAgent = "Android/" + versionName + "/"+packagenm+"/" + deviceBrand + "/" + systemModel + "/" + systemVersion; + + String channel =CommonUtil.getChannel(context);// BuildConfig.CHANNEL; + userAgent = "Android/" +channel +"/"+ versionName + "/"+packagenm+"/" + deviceBrand + "/" + systemModel + "/" + systemVersion; return userAgent; } + public static void getHostPolicy(){ if(isRequestHosts){ return; @@ -432,7 +437,11 @@ public class NetUtil { } public static void checkUpdate(boolean isSilence){ - UpdateManager manager = new UpdateManager(Main2Activity.activityContext); + Activity currentActivity = MyApp.getCurrentActivity(); + if(currentActivity==null){ + return; + } + UpdateManager manager = new UpdateManager(currentActivity); if(isSilence) manager.checkUpdateSilence(); else 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 5f5db2f..35408e3 100644 --- a/zhuike/src/main/java/com/novelbook/android/netutils/RetryInterceptor.java +++ b/zhuike/src/main/java/com/novelbook/android/netutils/RetryInterceptor.java @@ -62,6 +62,11 @@ public class RetryInterceptor implements Interceptor { boolean isMainApi =path.equals("/api/g/"); if(oldUrl.indexOf("xiaoshuofenxiang.com") == -1 || !path.startsWith("/api/") || NetUtil.getHost(isMainApi)==null){ // rh = null; + if(oldUrl.indexOf("xiaoshuofenxiang.com")!=-1) { + Request.Builder requestBuilder = request.newBuilder(); + requestBuilder.removeHeader("User-Agent").addHeader("User-Agent", HttpMethods.LOCALUSERAGENT); + request =requestBuilder.build(); + } Response response = doRequest(chain, request); if(response!=null) @@ -137,7 +142,7 @@ public class RetryInterceptor implements Interceptor { response = doRequest(chain, newRequest); - Log.d(TAG, String.format("HttpMethods intercept: %s, response is null? %s",newRequest.url(), response == null)); + Log.d(TAG, String.format("HttpMethods intercept: %s, response is null? %s, ua %s",newRequest.url(), response == null,newRequest.header("User-Agent"))); /* int i=0; while((response==null || !response.isSuccessful() )&& i<5){ @@ -217,7 +222,7 @@ public class RetryInterceptor implements Interceptor { private Response doRequest(Chain chain, Request request) throws IOException { Response response = null; - + Log.d(TAG, String.format("HttpMethods ua: %s, ua %s",request.url(), request.header("User-Agent"))); try { response = chain.proceed(request); } catch (Exception e) { diff --git a/zhuike/src/main/java/com/novelbook/android/upgrade/UpdateManager.java b/zhuike/src/main/java/com/novelbook/android/upgrade/UpdateManager.java index 4a1ca5e..c39e944 100644 --- a/zhuike/src/main/java/com/novelbook/android/upgrade/UpdateManager.java +++ b/zhuike/src/main/java/com/novelbook/android/upgrade/UpdateManager.java @@ -331,8 +331,8 @@ public class UpdateManager { builder.setTitle(R.string.soft_update_title); } String upgradeDetails=mHashMap.get("details"); - String forceRefresh =isForceRefresh? "本地版本过低,请升级新版本\n":""; - builder.setMessage( forceRefresh +mContext.getPackageName() + "\n当前版本:"+getVersionCode(mContext) +"\n" + String forceRefresh =isForceRefresh? "本地版本过低,请升级新版本":""; + builder.setMessage( forceRefresh +/*mContext.getPackageName() +*/ "\n当前版本:"+getVersionCode(mContext) +"\n" +"最新版本:"+ serviceCode +"\n" + mContext.getString(R.string.soft_update_info) + upgradeDetails ); builder.setPositiveButton(R.string.soft_update_updatebtn, new OnClickListener() @@ -500,5 +500,6 @@ public class UpdateManager { mContext.startActivity(i); + exit(-1); } } 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 fe487e9..f6ded1a 100644 --- a/zhuike/src/main/java/com/novelbook/android/utils/BookUtil.java +++ b/zhuike/src/main/java/com/novelbook/android/utils/BookUtil.java @@ -168,9 +168,9 @@ public class BookUtil { mChapters = LitePal.where("novelId=?", mNovel.getId() + "").find(Chapter.class); - for (Chapter c : mChapters) { + /* for (Chapter c : mChapters) { Log.d(TAG, String.format("bookchapter :%s,fileName :%s, chapter Size %s", c.getChapterName(), c.getChapterPath(), c.getLength())); - } + }*/ chaptCache = new HashMap(); if (mChapters.isEmpty()) { //1. 首次打开 本地导入的书 diff --git a/zhuike/src/main/java/com/novelbook/android/utils/CommonUtil.java b/zhuike/src/main/java/com/novelbook/android/utils/CommonUtil.java index 2e8f6f9..bf8b471 100644 --- a/zhuike/src/main/java/com/novelbook/android/utils/CommonUtil.java +++ b/zhuike/src/main/java/com/novelbook/android/utils/CommonUtil.java @@ -505,7 +505,7 @@ public class CommonUtil { String date1 = format1.format(new Date(System.currentTimeMillis())); return date1;// 2012-10-03 23:41:31 } - private String getChannel(Context context) { + public static String getChannel(Context context) { try { PackageManager pm = context.getPackageManager(); ApplicationInfo appInfo = pm.getApplicationInfo(getPackageName(context), PackageManager.GET_META_DATA); diff --git a/zhuike/src/main/java/com/novelbook/android/utils/FileUtils.java b/zhuike/src/main/java/com/novelbook/android/utils/FileUtils.java index 2c0dcdc..dab2524 100644 --- a/zhuike/src/main/java/com/novelbook/android/utils/FileUtils.java +++ b/zhuike/src/main/java/com/novelbook/android/utils/FileUtils.java @@ -122,10 +122,14 @@ public class FileUtils { public static long getCacheSize(int noveId) { return Fileutil.getDirSize(getNovelDir(noveId)); } - public static String getCachedSize(){ + public static String getFormatedCachedSize(){ File f = new File(BookUtil.chapterPath); return Fileutil.formatFileSize(Fileutil.getDirSize(f)); } + public static long getCachedSize2(){ + File f = new File(BookUtil.chapterPath); + return Fileutil.getDirSize(f) ; + } public static void clearCache(){ File f = new File(BookUtil.chapterPath); Fileutil.deleteDir(f); diff --git a/zhuike/src/main/java/com/novelbook/android/utils/HistoryCache.java b/zhuike/src/main/java/com/novelbook/android/utils/HistoryCache.java index 446dec2..250c119 100644 --- a/zhuike/src/main/java/com/novelbook/android/utils/HistoryCache.java +++ b/zhuike/src/main/java/com/novelbook/android/utils/HistoryCache.java @@ -35,7 +35,7 @@ public class HistoryCache { Gson gson = new Gson(); List retList = (List)gson.fromJson(history, (new TypeToken>() { }).getType()); - if(retList.size()>9){ + if(retList!=null && retList.size()>9){ return retList.subList(0,9); } return retList; 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 aa449b9..ba538d7 100644 --- a/zhuike/src/main/java/com/novelbook/android/utils/PageFactory.java +++ b/zhuike/src/main/java/com/novelbook/android/utils/PageFactory.java @@ -500,10 +500,10 @@ public class PageFactory implements ChangeSource{ page.setFirstPage(pageNo==1); page.setPageNo(pageNo); - if(Constants.AD_SETTING.getChapterEndBanner().isShow() && length >=chars.length ){ + /* if(Constants.AD_SETTING.getChapterEndBanner().isShow() && length >=chars.length ){ if(page.getLines().size()< mLineCount/2) page.setBannerHeight(0); - } + }*/ chaptPages.add(page); // Log.d(TAG, String.format("prepare book build page %s ready for chapter %s,cost %s",pageNo, chaptId,new Date().getTime()-starttime1)); @@ -525,8 +525,8 @@ public class PageFactory implements ChangeSource{ // Constants.AD_CHAPT_TOP_BANNER_PER_PAGE_COUNT = 1; - int bannerPagecnt =-20;// Constants.AD_SETTING.getChapterBanner().getPageCount4Display(); - int nativeBannerPageCnt =20;// Constants.AD_SETTING.getChapterContentBanner().getPageCount4Display(); + int bannerPagecnt = Constants.AD_SETTING.getChapterBanner().getPageCount4Display(); + int nativeBannerPageCnt = Constants.AD_SETTING.getChapterContentBanner().getPageCount4Display(); if (Constants.AD_SETTING.getChapterContentBanner().isShow() && nativeBannerPageCnt > 0 && mNavtiveBannerPlusCnt >= nativeBannerPageCnt) { @@ -547,15 +547,19 @@ public class PageFactory implements ChangeSource{ Log.d(TAG, String.format("getNextChapterPage: pageNo %s, adLines %s,adLine %s, nativeBannerHeight %s", pageNo, adLines, adLine, trPage.getNativeBannerHeight())); } - } else if (Constants.AD_SETTING.getChapterBanner().isShow()) { + } + if(trPage.getNativeBannerHeight()==0) + if (Constants.AD_SETTING.getChapterBanner().isShow()) { if (bannerPagecnt <=0 || mSmallBannerPlusCnt < bannerPagecnt) { mSmallBannerPlusCnt++; trPage.setBannerHeight((int) mBannerTopHeight); } else { mSmallBannerMinusCnt--; - if (mSmallBannerMinusCnt <= 0) { + if (mSmallBannerMinusCnt < 0) { mSmallBannerMinusCnt = bannerPagecnt; + } + if (mSmallBannerMinusCnt == 0) { mSmallBannerPlusCnt = 0; } } @@ -921,11 +925,11 @@ private void hideSysUI(){ float adY =targetRect.top +250; if(showAd) - while(!showingStatusAd || new Date().getTime() - showStatusAdTime > 2000) { + while(!showingStatusAd /*|| new Date().getTime() - showStatusAdTime > 2000*/) { showingStatusAd =true; showStatusAdTime = new Date().getTime(); - showStatusAd((int) adHeight, (int) adY); - Log.d(TAG, "loadBannerAd: AD is requested, mStatus:" +mStatus); + // showStatusAd((int) adHeight, (int) adY); + // Log.d(TAG, "loadBannerAd: draw status, AD is requested, mStatus:" +mStatus); } if (mStatus==Status.OPENING ) { @@ -1086,7 +1090,9 @@ private void hideSysUI(){ mAdY=(int)marginHeight; mAdType =AdTpye.BANNER; - // mAd.showTopBanner(trPage.getTopBannerHeight(),(int)(marginHeight)); + if(trPage.getBannerHeight()==0) { + mAd.showNativeBannerInLines(0,0);//hide ad container + } // mAd.showNativeBannerInLines(0,0); // } @@ -1163,13 +1169,19 @@ private void hideSysUI(){ mAdY=(int) (mHeight - statusMarginBottom - trPage.getBannerHeight()); mAdHeight = trPage.getBannerHeight(); mAdType =AdTpye.BANNER; - }else { + }else if(trPage.getPageNo()>1 && trPage.isLastPage() && Constants.AD_SETTING.getChapterEndBanner().isShow()) { mAdY=(int)adY; mAdHeight = (int) adHeight; mAdType = AdTpye.CHAPTEREND; + } + + if(trPage.getBannerHeight()==0 || mAdType !=AdTpye.BANNER){ + mAd.showTopBanner(0, 0);//清除所有广告 + } + // showAd((int) adHeight, (int) adY); - Log.d(TAG, String.format("loadBannerAd: AD is requested, adtype %s, adHeight %s",mAdType,adHeight)); + Log.d(TAG, String.format("loadBannerAd: AD is requested, adtype %s, adHeight %s, ady %s",mAdType,adHeight,adY)); } // Log.d(TAG,String.format("ad + statusMarginBottom %s ",200+ statusMarginBottom)); // Log.d(TAG,String.format("adHeight %s, adY %s",adHeight,adY)); @@ -1259,26 +1271,31 @@ private void hideSysUI(){ } public void showAd(){ - if(mStatus == Status.LASTPAGE){ + if(mStatus == Status.LASTPAGE || mAd==null){ return; } - Log.d(TAG, String.format("loadBannerAd showAd: mAdType %s",mAdType)); + Log.d(TAG, String.format("loadBannerAd showAd: mAdType %s, pageNo %s",mAdType, currentPage.getPageNo())); if(mAdType ==AdTpye.BANNER){ mAd.showTopBanner(mAdHeight,mAdY); }else if(mAdType == AdTpye.NATIVEINLINES){ + // mAd.showNativeBannerInLines(0,0); mAd.showNativeBannerInLines(mAdHeight,mAdY); }else if(mAdType == AdTpye.CHAPTEREND){ + // mAd.showNativeBannerInLines(0,0); mAd.showNativeBannerInLines(mAdHeight,mAdY); + }else{ + mAd.showNativeBannerInLines(0,0); } } private void showStatusAd(int adHeight,int adY) { - boolean showAd = showingStatusAd || getCurrentPage()==null || getCurrentPage().getPageNo() > 1; - + boolean showAd = showingStatusAd /*|| getCurrentPage()==null || getCurrentPage().getPageNo() > 1*/; + //Log.d(TAG, String.format("loadBannerAd showStatusAd: mAdType %s",mAdType)); // boolean showAd =true; if (showAd && mAd != null) { - mAd.showStatusAd(adHeight, adY); + // mAd.showStatusAd(adHeight, adY); + } @@ -1526,6 +1543,7 @@ private void hideSysUI(){ // currentPage = getPageForBegin(begin); if (mBookPageWidget != null) { currentPage(true); + showAd(); } // Log.d(TAG, String.format("prepare book set PageFactory.mStatus %s .",PageFactory.Status.FINISH ) ); // PageFactory.mStatus = PageFactory.Status.FINISH; @@ -1969,6 +1987,9 @@ private void hideSysUI(){ currentPage = getPageForBegin(position); currentPage(true); hideSysUI(); + if(position>0){ + showAd(); + } } public void retryChapt(int chapNum){ @@ -1998,6 +2019,7 @@ private void hideSysUI(){ currentChaptPages = loadCurrentChapt(currentChapter ); currentPage = getPageForBegin(currentPage.getBegin()); currentPage(true); + showAd(); } //改变字体大小 @@ -2010,6 +2032,7 @@ private void hideSysUI(){ currentChaptPages = loadCurrentChapt(currentChapter ); currentPage = getPageForBegin(currentPage.getBegin()); currentPage(true); + showAd(); } //改变字体 diff --git a/zhuike/src/main/res/layout/content_book.xml b/zhuike/src/main/res/layout/content_book.xml index 1847e69..a86b5a7 100644 --- a/zhuike/src/main/res/layout/content_book.xml +++ b/zhuike/src/main/res/layout/content_book.xml @@ -207,12 +207,7 @@ - + + --> + android:visibility="visible" + + /> 20dp 280dp 1dp - 60dp + 55dp diff --git a/zhuike/src/main/res/values/strings.xml b/zhuike/src/main/res/values/strings.xml index ac192fa..af7def6 100644 --- a/zhuike/src/main/res/values/strings.xml +++ b/zhuike/src/main/res/values/strings.xml @@ -1,5 +1,5 @@ - 网书助手 + 网书助手(测试) 书架 书城 排行榜 @@ -114,7 +114,7 @@ 设置 如风小说阅读是专注于提供更舒适的阅读体验,主打本地阅读,操作方式简单易上手,目前支持txt格式。 - 没有数据 + 还没有记录 换源 00.00% 已缓存 @@ -143,48 +143,7 @@ [推广] gdtslogan 点击跳过 + 没有缓存 - - 小燕—女青、中英、普通话 - 小艾—女青、中英、普通话、支持情感 - 小宇—男青、中英、普通话 - 凯瑟琳—女青、英 - 亨利—男青、英 - 玛丽—女青、英 - 小研—女青、中英、普通话 - 小琪—女青、中英、普通话 - 小峰—男青、中英、普通话 - 小梅—女青、中英、粤语 - 小莉—女青、中英、台湾普通话 - 小蓉—女青、中、四川话 - 小芸—女青、中、东北话 - 小坤—男青、中、河南话 - 小强—男青、中、湖南话 - 小莹—女青、中、陕西话 - 小新—男童、中、普通话 - 楠楠—女童、中、普通话 - 老孙—男老、中、普通话 - - - xiaoyan - aisxa - xiaoyu - catherine - henry - vimary - vixy - xiaoqi - vixf - xiaomei - xiaolin - xiaorong - xiaoqian - xiaokun - xiaoqiang - vixying - xiaoxin - nannan - vils - diff --git a/zhuike/src/test/java/com/deiniu/zhuike/ExampleUnitTest.java b/zhuike/src/test/java/com/deiniu/zhuike/ExampleUnitTest.java deleted file mode 100644 index 4df10e8..0000000 --- a/zhuike/src/test/java/com/deiniu/zhuike/ExampleUnitTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.deiniu.zhuike; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * Example local unit test, which will execute on the development machine (host). - * - * @see Testing documentation - */ -public class ExampleUnitTest { - @Test - public void addition_isCorrect() { - assertEquals(4, 2 + 2); - } -} \ No newline at end of file diff --git a/zhuike/zhuike.iml b/zhuike/zhuike.iml index 9e6b3df..241f1b2 100644 --- a/zhuike/zhuike.iml +++ b/zhuike/zhuike.iml @@ -104,14 +104,19 @@ + + + + + @@ -121,6 +126,7 @@ +