From a871acb16477a20fff630b6984c08de82a0e8d3d Mon Sep 17 00:00:00 2001 From: mwang <8205347@qq.com> Date: Mon, 24 Jun 2019 22:34:53 +0800 Subject: [PATCH] update tencent ad --- zhuike/build.gradle | 118 ++----- zhuike/src/main/AndroidManifest.xml | 8 +- .../novelbook/android/AD/SplashActivity.java | 26 +- .../novelbook/android/AD/SplashAdManager.java | 19 +- .../android/AD/qq/SplashActivity.java | 292 ------------------ .../novelbook/android/ActivityAnounce.java | 2 + .../com/novelbook/android/Activity_base.java | 95 +++++- .../android/Fragments/BasicFragment.java | 4 +- .../android/Fragments/Fragment_Shelf.java | 17 +- .../com/novelbook/android/bean/AdSetting.java | 18 +- .../com/novelbook/android/utils/BookUtil.java | 41 ++- .../novelbook/android/utils/PageFactory.java | 2 +- 12 files changed, 215 insertions(+), 427 deletions(-) delete mode 100644 zhuike/src/main/java/com/novelbook/android/AD/qq/SplashActivity.java diff --git a/zhuike/build.gradle b/zhuike/build.gradle index d763949..d24a615 100644 --- a/zhuike/build.gradle +++ b/zhuike/build.gradle @@ -14,7 +14,7 @@ android { buildToolsVersion "28.0.3" defaultConfig { // applicationId "com.qq.e.union.demo" - applicationId "com.novelbook.android" + applicationId "com.zhushou.yueshu" minSdkVersion 19 //target 19 Android 4.4 以下版本仅占比4.1% targetSdkVersion 28 versionCode 6 @@ -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")) { @@ -77,103 +77,45 @@ android { } } //渠道 - /* productFlavors { +/* productFlavors { // googleplay {} - huawei { + yingyonghui { + applicationId "com.zhushou.yueshu" + versionName "v1.0" + buildConfigField "String", "MAIN_HOST", '"http://g.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\\"]}"' + + } + yiwan { applicationId "com.zhushou.yueshu" versionName "v1.0" buildConfigField "String", "MAIN_HOST", '"http://g.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\\"]}"' } - google { - applicationId "com.zhushou.yueshu" - versionName "v1.0" - buildConfigField "String", "MAIN_HOST", '"http://g.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\\"]}"' - } - ali { - applicationId "com.zhushou.yueshu" - versionName "v1.0" - buildConfigField "String", "MAIN_HOST", '"http://g.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\\"]}"' + haote { + applicationId "com.zhushou.yueshu" + versionName "v1.0" + buildConfigField "String", "MAIN_HOST", '"http://g.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\\"]}"' + } - } - qq { - applicationId "com.zhushou.yueshu" - versionName "v1.0" - buildConfigField "String", "MAIN_HOST", '"http://g.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", '""' + anzhi { + applicationId "com.zhushou.yueshu" + versionName "v1.0" + buildConfigField "String", "MAIN_HOST", '"http://g.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\\"]}"' - } + } - xiaomi { - applicationId "com.zhushou.yueshu" - versionName "v1.0" - buildConfigField "String", "MAIN_HOST", '"http://g.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\\"]}"' + google { + applicationId "com.zhushou.yueshu" + versionName "v1.0" + buildConfigField "String", "MAIN_HOST", '"http://g.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\\"]}"' + } - } - - - kuan { - applicationId "com.zhushou.yueshu" - versionName "v1.0" - buildConfigField "String", "MAIN_HOST", '"http://g.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\\"]}"' - - } - m360 { - applicationId "com.zhushou.yueshu" - versionName "v1.0" - buildConfigField "String", "MAIN_HOST", '"http://g.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\\"]}"' - - } - baidu { - applicationId "com.zhushou.yueshu" - versionName "v1.0" - buildConfigField "String", "MAIN_HOST", '"http://g.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\\"]}"' - - } - m91 { - applicationId "com.zhushou.yueshu" - versionName "v1.0" - buildConfigField "String", "MAIN_HOST", '"http://g.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\\"]}"' - - } - anzhi { - applicationId "com.zhushou.yueshu" - versionName "v1.0" - buildConfigField "String", "MAIN_HOST", '"http://g.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\\"]}"' - - } - wzzw { - applicationId "com.novelbook.android.wzzw" - versionName "v-wzzw-5.0" - buildConfigField "String", "MAIN_HOST", '"http://chwzzw.xiaoshuofenxiang.com/api/"' - buildConfigField "String", "API_HOST", '"{\\"master\\":[\\"http:\\\\/\\\\/wzzw.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", '""' - } - bo { - applicationId "com.novelbook.android.bo" - versionName "v-bo-5.0" - buildConfigField "String", "MAIN_HOST", '"http://chbo.xiaoshuofenxiang.com/api/"' - buildConfigField "String", "API_HOST", '"{\\"master\\":[\\"http:\\\\/\\\\/bo.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", '""' - } - g { - applicationId "com.novelbook.android.g" - versionName "v-g-5.0" - buildConfigField "String", "MAIN_HOST", '"http://chg.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", '""' - } //批量配置 productFlavors.all { flavor -> flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: name] @@ -247,6 +189,6 @@ dependencies { implementation 'q.rorbin:VerticalTabLayout:1.2.5' implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.16' implementation(name: 'open_ad_sdk', ext: 'aar') - implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.6' + // implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.6' implementation 'com.google.android.gms:play-services-ads:17.2.1' } diff --git a/zhuike/src/main/AndroidManifest.xml b/zhuike/src/main/AndroidManifest.xml index b082e70..500fd74 100644 --- a/zhuike/src/main/AndroidManifest.xml +++ b/zhuike/src/main/AndroidManifest.xml @@ -115,14 +115,12 @@ android:exported="false" /> - - - - + --> - + interVal)); return in >interVal; } @@ -173,8 +180,10 @@ public class SplashAdManager implements Application.ActivityLifecycleCallbacks, int pcnt =Constants.AD_SETTING.getSplash2().getPageCount4Display();; if(pages > pcnt){ + Log.d(TAG, String.format("canShowAd: plusPage pages %s, maxpage %s ", pages,pcnt)); clearPages(); - showSplashAd(activity); + + showSplash2Ad(activity); } } diff --git a/zhuike/src/main/java/com/novelbook/android/AD/qq/SplashActivity.java b/zhuike/src/main/java/com/novelbook/android/AD/qq/SplashActivity.java deleted file mode 100644 index 1dacd8c..0000000 --- a/zhuike/src/main/java/com/novelbook/android/AD/qq/SplashActivity.java +++ /dev/null @@ -1,292 +0,0 @@ -package com.novelbook.android.AD.qq; - -import android.Manifest; -import android.annotation.TargetApi; -import android.app.Activity; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.net.Uri; -import android.os.Build; -import android.os.Bundle; -import android.os.Handler; -import android.os.Looper; -import android.provider.Settings; -import android.text.TextUtils; -import android.util.Log; -import android.view.KeyEvent; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; -import android.widget.Toast; - -import com.novelbook.android.Main2Activity; -import com.novelbook.android.R; -import com.novelbook.android.utils.Constants; -import com.qq.e.ads.splash.SplashAD; -import com.qq.e.ads.splash.SplashADListener; -import com.qq.e.comm.util.AdError; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static com.novelbook.android.bean.AdSetting.getAppID; - -/** - * 这是demo工程的入口Activity,在这里会首次调用广点通的SDK。 - * - * 在调用SDK之前,如果您的App的targetSDKVersion >= 23,那么一定要把"READ_PHONE_STATE"、"WRITE_EXTERNAL_STORAGE"、"ACCESS_FINE_LOCATION"这几个权限申请到,否则SDK将不会工作。 - */ -public class SplashActivity extends Activity implements SplashADListener { - - private SplashAD splashAD; - private ViewGroup container; - private TextView skipView; - //private ImageView splashHolder; - private TextView splashHolder; - private TextView tvTitle; - private static final String SKIP_TEXT = "点击跳过 %d"; - - public boolean canJump = false; - - - /** - * 为防止无广告时造成视觉上类似于"闪退"的情况,设定无广告时页面跳转根据需要延迟一定时间,demo - * 给出的延时逻辑是从拉取广告开始算开屏最少持续多久,仅供参考,开发者可自定义延时逻辑,如果开发者采用demo - * 中给出的延时逻辑,也建议开发者考虑自定义minSplashTimeWhenNoAD的值(单位ms) - **/ - private int minSplashTimeWhenNoAD = 2000; - /** - * 记录拉取广告的时间 - */ - private long fetchSplashADTime = 0; - private Handler handler = new Handler(Looper.getMainLooper()); - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.ad_qq_activity_splash ); - container = (ViewGroup) this.findViewById(R.id.splash_container); - skipView = (TextView) findViewById(R.id.skip_view); - tvTitle = (TextView) findViewById(R.id.textTile); - splashHolder = (TextView) findViewById(R.id.splash_holder); - - tvTitle.setText(R.string.app_name); - getWindow().getDecorView().setSystemUiVisibility( - View.SYSTEM_UI_FLAG_LAYOUT_STABLE - | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN - | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar - | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar - | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY - // | View.SYSTEM_UI_FLAG_IMMERSIVE - ); - - /* boolean needLogo = getIntent().getBooleanExtra("need_logo", true); - needStartDemoList = getIntent().getBooleanExtra("need_start_demo_list", true); - if (!needLogo) { - findViewById(R.id.app_logo).setVisibility(View.GONE); - }*/ - // 如果targetSDKVersion >= 23,就要申请好权限。如果您的App没有适配到Android6.0(即targetSDKVersion < 23),那么只需要在这里直接调用fetchSplashAD接口。 - if (Build.VERSION.SDK_INT >= 23) { - checkAndRequestPermission(); - } else { - // 如果是Android6.0以下的机器,默认在安装时获得了所有权限,可以直接调用SDK - fetchSplashAD(this, container, skipView, getAppID(Constants.AD_TENCENT_QQ), getPosId(), this, 0); - } - } - - private String getPosId() { - return Constants.AD_SETTING.getSplash().getSlotId(Constants.AD_TENCENT_QQ); - } - - /** - * - * ----------非常重要---------- - * - * Android6.0以上的权限适配简单示例: - * - * 如果targetSDKVersion >= 23,那么必须要申请到所需要的权限,再调用广点通SDK,否则广点通SDK不会工作。 - * - * Demo代码里是一个基本的权限申请示例,请开发者根据自己的场景合理地编写这部分代码来实现权限申请。 - * 注意:下面的`checkSelfPermission`和`requestPermissions`方法都是在Android6.0的SDK中增加的API,如果您的App还没有适配到Android6.0以上,则不需要调用这些方法,直接调用广点通SDK即可。 - */ - @TargetApi(Build.VERSION_CODES.M) - private void checkAndRequestPermission() { - List lackedPermission = new ArrayList(); - if (!(checkSelfPermission(Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED)) { - lackedPermission.add(Manifest.permission.READ_PHONE_STATE); - } - - if (!(checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED)) { - lackedPermission.add(Manifest.permission.WRITE_EXTERNAL_STORAGE); - } - - if (!(checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED)) { - lackedPermission.add(Manifest.permission.ACCESS_FINE_LOCATION); - } - - // 权限都已经有了,那么直接调用SDK - if (lackedPermission.size() == 0) { - fetchSplashAD(this, container, skipView, getAppID(Constants.AD_TENCENT_QQ), getPosId(), this, 0); - } else { - // 请求所缺少的权限,在onRequestPermissionsResult中再看是否获得权限,如果获得权限就可以调用SDK,否则不要调用SDK。 - String[] requestPermissions = new String[lackedPermission.size()]; - lackedPermission.toArray(requestPermissions); - requestPermissions(requestPermissions, 1024); - } - } - - private boolean hasAllPermissionsGranted(int[] grantResults) { - for (int grantResult : grantResults) { - if (grantResult == PackageManager.PERMISSION_DENIED) { - return false; - } - } - return true; - } - - @Override - public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { - super.onRequestPermissionsResult(requestCode, permissions, grantResults); - if (requestCode == 1024 && hasAllPermissionsGranted(grantResults)) { - fetchSplashAD(this, container, skipView, getAppID(Constants.AD_TENCENT_QQ), getPosId(), this, 0); - } else { - // 如果用户没有授权,那么应该说明意图,引导用户去设置里面授权。 - Toast.makeText(this, "应用缺少必要的权限!请点击\"权限\",打开所需要的权限。", Toast.LENGTH_LONG).show(); - Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); - intent.setData(Uri.parse("package:" + getPackageName())); - startActivity(intent); - finish(); - } - } - - /** - * 拉取开屏广告,开屏广告的构造方法有3种,详细说明请参考开发者文档。 - * - * @param activity 展示广告的activity - * @param adContainer 展示广告的大容器 - * @param skipContainer 自定义的跳过按钮:传入该view给SDK后,SDK会自动给它绑定点击跳过事件。SkipView的样式可以由开发者自由定制,其尺寸限制请参考activity_splash.xml或者接入文档中的说明。 - * @param appId 应用ID - * @param posId 广告位ID - * @param adListener 广告状态监听器 - * @param fetchDelay 拉取广告的超时时长:取值范围[3000, 5000],设为0表示使用广点通SDK默认的超时时长。 - */ - private void fetchSplashAD(Activity activity, ViewGroup adContainer, View skipContainer, - String appId, String posId, SplashADListener adListener, int fetchDelay) { - fetchSplashADTime = System.currentTimeMillis(); - Map tags = new HashMap<>(); - tags.put("tag_s1", "value_s1"); - tags.put("tag_s2", "value_s2"); - - splashAD = new SplashAD(activity, adContainer, skipContainer, appId, posId, adListener, - fetchDelay, tags); - // 如果不需要传tag,使用如下构造函数 - // splashAD = new SplashAD(activity, adContainer, skipContainer, appId, posId, adListener, fetchDelay); - } - - @Override - public void onADPresent() { - Log.i("AD_DEMO", "SplashADPresent"); - splashHolder.setVisibility(View.INVISIBLE); // 广告展示后一定要把预设的开屏图片隐藏起来 - } - - @Override - public void onADClicked() { - Log.i("AD_DEMO", "SplashADClicked clickUrl: " - + (splashAD.getExt() != null ? splashAD.getExt().get("clickUrl") : "")); - } - - /** - * 倒计时回调,返回广告还将被展示的剩余时间。 - * 通过这个接口,开发者可以自行决定是否显示倒计时提示,或者还剩几秒的时候显示倒计时 - * - * @param millisUntilFinished 剩余毫秒数 - */ - @Override - public void onADTick(long millisUntilFinished) { - Log.i("AD_DEMO", "SplashADTick " + millisUntilFinished + "ms"); - skipView.setText(String.format(SKIP_TEXT, Math.round(millisUntilFinished / 1000f))); - } - - @Override - public void onADExposure() { - Log.i("AD_DEMO", "SplashADExposure"); - } - - @Override - public void onADDismissed() { - Log.i("AD_DEMO", "SplashADDismissed"); - next(); - } - - @Override - public void onNoAD(AdError error) { - Log.i( - "AD_DEMO", - String.format("LoadSplashADFail, eCode=%d, errorMsg=%s", error.getErrorCode(), - error.getErrorMsg())); - /** - * 为防止无广告时造成视觉上类似于"闪退"的情况,设定无广告时页面跳转根据需要延迟一定时间,demo - * 给出的延时逻辑是从拉取广告开始算开屏最少持续多久,仅供参考,开发者可自定义延时逻辑,如果开发者采用demo - * 中给出的延时逻辑,也建议开发者考虑自定义minSplashTimeWhenNoAD的值 - **/ - long alreadyDelayMills = System.currentTimeMillis() - fetchSplashADTime;//从拉广告开始到onNoAD已经消耗了多少时间 - long shouldDelayMills = alreadyDelayMills > minSplashTimeWhenNoAD ? 0 : minSplashTimeWhenNoAD - - alreadyDelayMills;//为防止加载广告失败后立刻跳离开屏可能造成的视觉上类似于"闪退"的情况,根据设置的minSplashTimeWhenNoAD - // 计算出还需要延时多久 - handler.postDelayed(new Runnable() { - @Override - public void run() { - - SplashActivity.this.finish(); - } - }, shouldDelayMills); - } - - /** - * 设置一个变量来控制当前开屏页面是否可以跳转,当开屏广告为普链类广告时,点击会打开一个广告落地页,此时开发者还不能打开自己的App主页。当从广告落地页返回以后, - * 才可以跳转到开发者自己的App主页;当开屏广告是App类广告时只会下载App。 - */ - private void next() { - if (canJump) { - - this.finish(); - } else { - canJump = true; - } - } - - @Override - protected void onPause() { - super.onPause(); - canJump = false; - } - - @Override - protected void onResume() { - super.onResume(); - if (canJump) { - next(); - } - canJump = true; - } - - @Override - protected void onDestroy() { - super.onDestroy(); - handler.removeCallbacksAndMessages(null); - } - - /** 开屏页一定要禁止用户对返回按钮的控制,否则将可能导致用户手动退出了App而广告无法正常曝光和计费 */ - @Override - public boolean onKeyDown(int keyCode, KeyEvent event) { - if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME) { - return true; - } - return super.onKeyDown(keyCode, event); - } - -} diff --git a/zhuike/src/main/java/com/novelbook/android/ActivityAnounce.java b/zhuike/src/main/java/com/novelbook/android/ActivityAnounce.java index 65c8d0a..0e39b31 100644 --- a/zhuike/src/main/java/com/novelbook/android/ActivityAnounce.java +++ b/zhuike/src/main/java/com/novelbook/android/ActivityAnounce.java @@ -42,4 +42,6 @@ public class ActivityAnounce extends Activity_base { public void fillData() { } + + } 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 496f40a..38bc151 100644 --- a/zhuike/src/main/java/com/novelbook/android/Activity_base.java +++ b/zhuike/src/main/java/com/novelbook/android/Activity_base.java @@ -7,6 +7,7 @@ import android.app.ProgressDialog; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; +import android.graphics.Point; import android.os.Build; import android.os.Bundle; import android.os.Handler; @@ -22,6 +23,8 @@ import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.Button; +import android.widget.CheckBox; +import android.widget.EditText; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.TextView; @@ -73,6 +76,8 @@ import java.util.concurrent.ConcurrentHashMap; import com.qq.e.ads.banner.AbstractBannerADListener; import com.qq.e.ads.banner.BannerView; +import com.qq.e.ads.banner2.UnifiedBannerADListener; +import com.qq.e.ads.banner2.UnifiedBannerView; import com.qq.e.ads.cfg.VideoOption; import com.qq.e.ads.nativ.ADSize; import com.qq.e.ads.nativ.NativeADUnifiedListener; @@ -95,7 +100,7 @@ import static com.novelbook.android.utils.Constants.AD_MOB; import static com.novelbook.android.utils.Constants.AD_TENCENT_QQ; import static com.novelbook.android.utils.Constants.AD_TOUTIAO; -public abstract class Activity_base extends AppCompatActivity implements NativeExpressAD.NativeExpressADListener { +public abstract class Activity_base extends AppCompatActivity implements NativeExpressAD.NativeExpressADListener,UnifiedBannerADListener { private static final int MSG_AD_LOAD =10 ; private static String TAG ="Activity_base"; @@ -453,7 +458,7 @@ public abstract class Activity_base extends AppCompatActivity implements Native Log.d(TAG, String.format("loadBanner:mLastBannerTime %s ,timepassed %s",mLastBannerTime,(new Date().getTime() - mLastBannerTime)/1000)); return; } - + mLastBannerTime =new Date().getTime(); Log.d(TAG, "loadBanner:mLastBannerTime start new banner request,mBannerContainer.getChildCount(): "+mBannerContainer.getChildCount()); if(Constants.AD_SETTING.getChapterBanner().getSource()== AD_TENCENT_QQ) { getBanner_qq(); @@ -1086,7 +1091,7 @@ public abstract class Activity_base extends AppCompatActivity implements Native - BannerView bv; + /* BannerView bv; private void getBanner_qq() { if(this.bv != null){ @@ -1098,8 +1103,8 @@ public abstract class Activity_base extends AppCompatActivity implements Native } this.bv = new BannerView(this, com.qq.e.ads.banner.ADSize.BANNER, - AdSetting.getAppID(Constants.AD_TENCENT_QQ), - Constants.AD_SETTING.getChapterBanner().getSlotId(Constants.AD_TENCENT_QQ)); + "1109247602" *//* AdSetting.getAppID(Constants.AD_TENCENT_QQ)*//*, + "9000263914551986" *//* Constants.AD_SETTING.getChapterBanner().getSlotId(Constants.AD_TENCENT_QQ)*//*); // 注意:如果开发者的banner不是始终展示在屏幕中的话,请关闭自动刷新,否则将导致曝光率过低。 // 并且应该自行处理:当banner广告区域出现在屏幕后,再手动loadAD。 // bv.setRefresh(0); @@ -1107,24 +1112,85 @@ public abstract class Activity_base extends AppCompatActivity implements Native @Override public void onNoAD(AdError error) { - Log.i( - "AD_DEMO", - String.format("Banner onNoAD,eCode = %d, eMsg = %s", error.getErrorCode(), + Log.d( + TAG, + String.format("loadListAd,eCode = %d, eMsg = %s", error.getErrorCode(), error.getErrorMsg())); } @Override public void onADReceiv() { - Log.i("AD_DEMO", "ONBannerReceive"); + Log.d(TAG, "loadListAd ONBannerReceive"); } }); mBannerContainer.addView(bv); this.bv.loadAD(); mLastBannerTime =new Date().getTime(); + }*/ + UnifiedBannerView bv; + //banner2.0 + private void getBanner_qq() { + if(this.bv != null){ + mBannerContainer.removeView(bv); + bv.destroy(); + } + String posId =Constants.AD_SETTING.getChapterBanner().getSlotId(Constants.AD_TENCENT_QQ);//"9000263914551986"; + + Map tags = new HashMap<>(); + tags.put("tag_b1", "value_b1"); + tags.put("tag_b2", "value_b2"); + this.bv = new UnifiedBannerView(this, AdSetting.getAppID(Constants.AD_TENCENT_QQ) , posId, this, tags); + this.bv.setRefresh(0); + // 不需要传递tags使用下面构造函数 + // this.bv = new UnifiedBannerView(this, Constants.APPID, posId, this); + mBannerContainer.addView(bv, getUnifiedBannerLayoutParams()); + bv.loadAD(); + mLastBannerTime =new Date().getTime(); + // return this.bv; + } + @Override + public void onADReceive() { + Log.d(TAG, "loadListAd UnifiedBannerView ONBannerReceive"); + } + @Override + public void onADExposure() { + Log.d(TAG, "loadListAd UnifiedBannerView onADExposure"); + } + @Override + public void onADClosed() { + Log.d(TAG, "loadListAd UnifiedBannerView onADClosed"); + } + + @Override + public void onADClicked() { + Log.d(TAG, "loadListAd UnifiedBannerView onADClicked"); + } + + @Override + public void onADLeftApplication() { + Log.d(TAG, "loadListAd UnifiedBannerView onADLeftApplication"); + } + + @Override + public void onADOpenOverlay() { + Log.d(TAG, "loadListAd UnifiedBannerView onADOpenOverlay"); + } + + @Override + public void onADCloseOverlay() { + Log.d(TAG, "loadListAd onADCloseOverlay"); + } + private FrameLayout.LayoutParams getUnifiedBannerLayoutParams() { + Point screenSize = new Point(); + getWindowManager().getDefaultDisplay().getSize(screenSize); + return new FrameLayout.LayoutParams(screenSize.x, Math.round(screenSize.x / 6.4F)); + } + + //原生上图下文1280x720 8020766944969033 private void loadNativeBanner_qq(int adWidth,int adHeight) { try { @@ -1139,8 +1205,8 @@ public abstract class Activity_base extends AppCompatActivity implements Native nativeExpressAD = new NativeExpressAD(this, getMyADSize(adWidth, adHeight), - AdSetting.getAppID(Constants.AD_TENCENT_QQ), - Constants.AD_SETTING.getChapterContentBanner().getSlotId(Constants.AD_TENCENT_QQ), this); // 这里的Context必须为Activity + AdSetting.getAppID(Constants.AD_TENCENT_QQ) , + /*原生上图下文1280x720*/ Constants.AD_SETTING.getChapterContentBanner().getSlotId(Constants.AD_TENCENT_QQ) , this); // 这里的Context必须为Activity /* nativeExpressAD.setVideoOption(new VideoOption.Builder() .setAutoPlayPolicy(VideoOption.AutoPlayPolicy.WIFI) // 设置什么网络环境下可以自动播放视频 .setAutoPlayMuted(true) // 设置自动播放视频时,是否静音 @@ -1441,5 +1507,12 @@ public abstract class Activity_base extends AppCompatActivity implements Native hideProgress(); // MobclickAgent.onPause(this); } + @Override + protected void onDestroy() { + super.onDestroy(); + if (bv != null) { + bv.destroy(); + } + } } 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 63ab946..904acd2 100644 --- a/zhuike/src/main/java/com/novelbook/android/Fragments/BasicFragment.java +++ b/zhuike/src/main/java/com/novelbook/android/Fragments/BasicFragment.java @@ -527,8 +527,8 @@ void initTabs(){ 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 = 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; 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 e81a69f..6260175 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 @@ -31,8 +31,10 @@ import com.novelbook.android.BuildConfig; import com.novelbook.android.Main2Activity; import com.novelbook.android.R; import com.novelbook.android.db.Chapter; +import com.novelbook.android.db.DownloadTask; import com.novelbook.android.db.Novel; +import com.novelbook.android.db.SiteRule; import com.novelbook.android.filechooser.FileChooserActivity; import com.novelbook.android.netsubscribe.BookSubscribe; import com.novelbook.android.netutils.HttpMethods; @@ -56,6 +58,7 @@ import org.litepal.LitePal; import java.io.File; import java.io.IOException; import java.util.ArrayList; +import java.util.Date; import java.util.List; import butterknife.BindView; @@ -102,11 +105,23 @@ public class Fragment_Shelf extends BasicFragment { } private void loadNovelsOnShelf() { + + Log.d(TAG, String.format("db count info: chapters %s,novels %s,downtask %s,siterule %s,maxsize %s", + LitePal.count(Chapter.class), LitePal.count(Novel.class),LitePal.count(DownloadTask.class),LitePal.count(SiteRule.class) + ,Fileutil.formatFileSize( LitePal.getDatabase().getMaximumSize()) + )); + + try{ + throw new Exception("show trace"); + }catch (Exception e){ + Log.e(TAG, "loadNovelsOnShelf: ",e); + } + bookLists = Novel.getNovelsOnShelf(); noveIds = ""; int i=0; for (Novel novel : bookLists) { - if (novel.isFinished() || novel.isLocalBook() || novel.isUpdated()) { + if (novel.isFinished() || novel.isLocalBook() || (novel.isUpdated() && (new Date().getTime() - novel.getLastVisit() > 1*3600*1000 ))) { continue; } if(i>Constants.MAX_SHELF_CNT){ 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 61106b6..da3d777 100644 --- a/zhuike/src/main/java/com/novelbook/android/bean/AdSetting.java +++ b/zhuike/src/main/java/com/novelbook/android/bean/AdSetting.java @@ -5,7 +5,7 @@ import com.novelbook.android.utils.Constants; public class AdSetting { private boolean showAdsense; - private String[] appIds={}; + private String[] appIds={ }; private slot splash = new slot(); private slot splash2 = new slot(); private slot informationFlow = new slot(); @@ -16,8 +16,8 @@ public class AdSetting { private slot fixBanner = new slot(); private slot bigBanner = new slot(); public boolean isShowAdsense() { - return true; - // return showAdsense && NetUtil.isNetworkConnected(); + // return true; + return showAdsense && NetUtil.isNetworkConnected(); } public void setShowAdsense(boolean showAdsense) { @@ -82,8 +82,8 @@ public class AdSetting { private int displayPosition; public int getDisplayPosition() { - //return 1; - return displayPosition; + // return 2; + return displayPosition; } public void setDisplayPosition(int displayPosition) { @@ -91,8 +91,8 @@ public class AdSetting { } public boolean isShow() { - return true; - // return show && NetUtil.isNetworkConnected(); + // return true; + return show && NetUtil.isNetworkConnected(); } public void setShow(boolean show) { @@ -100,8 +100,8 @@ public class AdSetting { } 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/utils/BookUtil.java b/zhuike/src/main/java/com/novelbook/android/utils/BookUtil.java index 583dcea..2088507 100644 --- a/zhuike/src/main/java/com/novelbook/android/utils/BookUtil.java +++ b/zhuike/src/main/java/com/novelbook/android/utils/BookUtil.java @@ -375,11 +375,21 @@ public class BookUtil { mChapters = NovelParseUtil.getChapters(mSite.getMuluUrl(), siteJson,mSite.getDomain(),maxAge,mSiteRule); - /* if (mChapters != null){ + if (mChapters != null){ + /* int i=0; for (Chapter chapter:mChapters) { - Log.i(TAG, String.format("prepare book to get chaps readChaptersAsync %s-->%s",chapter.getChapterUrl(), chapter.getChapterName())); - } - }*/ + i++; + // Log.i(TAG, String.format("prepare book to get chaps readChaptersAsync %s-->%s",chapter.getChapterUrl(), chapter.getChapterName())); + if(chapter.getChapterName().equals(mNovel.getChapterName())){ + if(i0;i--) { + if(mChapters.get(i).getChapterName().equals(mNovel.getChapterName())){ + if(i mNovel.getChaptCnt()){ + mNovel.setChaptCnt(mChapters.size()); + mNovel.update(mNovel.getId()); + } + } + public void setChapterNo(int chapterNo) { this.chapterNo = chapterNo; /* @@ -973,11 +1001,8 @@ int muluRetryCount =0; mChapters = NovelParseUtil.getChapters(mSite.getDomain(),url, content, siteJson); Log.d(TAG,String.format("mulu on Site %s download status %s",mSite.getDomain(),mMuluStatus)); - if( mChapters.size()> mNovel.getChaptCnt()){ - mNovel.setChaptCnt(mChapters.size()); - mNovel.update(mNovel.getId()); - } + checkLastUpdatedChapter(); } catch (JSONException e) { // } catch (JSONException | IOException e) { Log.e(TAG,String.format("prepare book, mulu on Site %s download status %s",mSite.getDomain(),mMuluStatus),e); 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 85ee658..933f9ca 100644 --- a/zhuike/src/main/java/com/novelbook/android/utils/PageFactory.java +++ b/zhuike/src/main/java/com/novelbook/android/utils/PageFactory.java @@ -542,7 +542,7 @@ public class PageFactory implements ChangeSource{ int bannerPagecnt = Constants.AD_SETTING.getChapterBanner().getPageCount4Display(); - int nativeBannerPageCnt =4;// Constants.AD_SETTING.getChapterContentBanner().getPageCount4Display(); + int nativeBannerPageCnt = Constants.AD_SETTING.getChapterContentBanner().getPageCount4Display(); if (Constants.AD_SETTING.getChapterContentBanner().isShow() && nativeBannerPageCnt > 0 && mNavtiveBannerPlusCnt >= nativeBannerPageCnt) {