update shelf rule

This commit is contained in:
mwang 2019-06-18 23:56:42 +08:00
parent 182135e945
commit eebe556071
14 changed files with 378 additions and 154 deletions

View File

@ -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")) {
@ -72,12 +72,12 @@ android {
}
}
}
}*/
signingConfig signingConfigs.releaseConfig
}
}
//
productFlavors {
/* productFlavors {
// googleplay {}
google {
applicationId "com.zhushou.yueshu"
@ -178,7 +178,7 @@ android {
flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: name]
}
}
}*/
android {
lintOptions {
abortOnError false
@ -247,5 +247,5 @@ dependencies {
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 'com.google.android.gms:play-services-ads:17.2.1'
implementation 'com.google.android.gms:play-services-ads:17.2.1'
}

View File

@ -282,4 +282,4 @@
-keep class com.ss.sys.ces.* {*;}
#GOOGLE MOBAD
-keep com.google.android.gms.ads.** { *; }
#-keep com.google.android.gms.ads.** { *; }

View File

@ -197,13 +197,13 @@
<meta-data
android:name="UMENG_APPKEY"
android:value="5cd6238a570df375c3000cc9" /> <!-- <meta-data android:name="UMENG_CHANNEL" android:value="${UMENG_CHANNEL_VALUE}"/> -->
<!--<meta-data android:name="UMENG_CHANNEL" android:value="debug" />-->
<meta-data android:name="UMENG_CHANNEL" android:value="${UMENG_CHANNEL_VALUE}" />
<meta-data android:name="UMENG_CHANNEL" android:value="debug" />
<!-- <meta-data android:name="UMENG_CHANNEL" android:value="${UMENG_CHANNEL_VALUE}" />-->
<!-- google ad-->
<!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
<!-- <meta-data
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="${MOBAPPID}"/>-->
android:value="${MOBAPPID}"/>
</application>
</manifest>

View File

@ -14,29 +14,34 @@ import android.os.Message;
import android.provider.Settings;
import android.support.annotation.MainThread;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.bytedance.sdk.openadsdk.AdSlot;
import com.bytedance.sdk.openadsdk.TTAdNative;
import com.bytedance.sdk.openadsdk.TTSplashAd;
import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.InterstitialAd;
import com.google.android.gms.ads.MobileAds;
import com.novelbook.android.AD.toutiao.TTAdManagerHolder;
import com.novelbook.android.AD.toutiao.WeakHandler;
import com.novelbook.android.BuildConfig;
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 org.litepal.util.Const;
import java.util.ArrayList;
import java.util.HashMap;
@ -54,10 +59,14 @@ import static com.novelbook.android.bean.AdSetting.getAppID;
*/
public class SplashActivity extends Activity implements WeakHandler.IHandler, SplashADListener {
private static final String TAG = SplashActivity.class.getSimpleName();
@Nullable
@BindView(R.id.splash_container)
ViewGroup mSplashContainer;
@Nullable
@BindView(R.id.textTile)
TextView tvTitle;
//--------tencent--->
private SplashAD splashAD;
@ -103,9 +112,10 @@ public class SplashActivity extends Activity implements WeakHandler.IHandler, Sp
//-toutiao---<---
//---admob--->
private InterstitialAd mInterstitialAd;
@BindView(R.id.textTile)
TextView tvTitle;
@SuppressWarnings("RedundantCast")
@Override
@ -125,13 +135,21 @@ public class SplashActivity extends Activity implements WeakHandler.IHandler, Sp
rid = R.layout.ad_toutiao_activity_splash;
splashSource=Constants.AD_TOUTIAO;
}
else{
goToMainActivity();return;
}
}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();
// goToMainActivity();
return;
}else if (Constants.AD_SETTING.getSplash2() .getSource() == Constants.AD_MOB) {
// goToMainActivity();
// return;
rid = R.layout.activity_blank;
splashSource=Constants.AD_MOB;
}
}
@ -152,6 +170,7 @@ public class SplashActivity extends Activity implements WeakHandler.IHandler, Sp
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
// | View.SYSTEM_UI_FLAG_IMMERSIVE
);
if(tvTitle!=null)
tvTitle.setText(R.string.app_name);
//加载开屏广告
if(splashSource == Constants.AD_TOUTIAO ) {
@ -171,6 +190,14 @@ public class SplashActivity extends Activity implements WeakHandler.IHandler, Sp
// 如果是Android6.0以下的机器默认在安装时获得了所有权限可以直接调用SDK
fetchSplashAD(this, mSplashContainer, skipView, getAppID(Constants.AD_TENCENT_QQ), getPosId(), this, 0);
}
}else if(splashSource == Constants.AD_MOB ){
getAdMob();
/* if (Build.VERSION.SDK_INT >= 23) {
checkAndRequestPermissionAdmob();
} else {
// 如果是Android6.0以下的机器默认在安装时获得了所有权限可以直接调用SDK
getAdMob();
}*/
}
}
/**
@ -352,10 +379,12 @@ public class SplashActivity extends Activity implements WeakHandler.IHandler, Sp
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);
if (!(checkSelfPermission(Manifest.permission.REQUEST_INSTALL_PACKAGES) == PackageManager.PERMISSION_GRANTED)) {
lackedPermission.add(Manifest.permission.REQUEST_INSTALL_PACKAGES);
}
/*if (!(checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED)) {
lackedPermission.add(Manifest.permission.ACCESS_FINE_LOCATION);
}*/
// 权限都已经有了那么直接调用SDK
if (lackedPermission.size() == 0) {
@ -496,4 +525,85 @@ public class SplashActivity extends Activity implements WeakHandler.IHandler, Sp
}
//----qq ad end <---
void getAdMob(){
MobileAds.initialize(this,"ca-app-pub-3940256099942544~3347511713");
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
// Code to be executed when an ad finishes loading.
Log.d(TAG, "onAdLoaded: ");
SplashAdManager.setSplashTime();
mInterstitialAd.show();
}
@Override
public void onAdFailedToLoad(int errorCode) {
// Code to be executed when an ad request fails.
Log.d(TAG, "onAdFailedToLoad: ");
goToMainActivity();
}
@Override
public void onAdOpened() {
// Code to be executed when the ad is displayed.
Log.d(TAG, "onAdOpened: ");
}
@Override
public void onAdClicked() {
// Code to be executed when the user clicks on an ad.
Log.d(TAG, "onAdClicked: ");
}
@Override
public void onAdLeftApplication() {
// Code to be executed when the user has left the app.
Log.d(TAG, "onAdLeftApplication: ");
}
@Override
public void onAdClosed() {
// Code to be executed when the interstitial ad is closed.
Log.d(TAG, "onAdClosed: ");
goToMainActivity();
}
});
mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
mInterstitialAd.loadAd(new AdRequest.Builder().build());
}
@TargetApi(Build.VERSION_CODES.M)
private void checkAndRequestPermissionAdmob() {
List<String> lackedPermission = new ArrayList<String>();
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.REQUEST_INSTALL_PACKAGES) == PackageManager.PERMISSION_GRANTED)) {
lackedPermission.add(Manifest.permission.REQUEST_INSTALL_PACKAGES);
}
/*if (!(checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED)) {
lackedPermission.add(Manifest.permission.ACCESS_FINE_LOCATION);
}*/
// 权限都已经有了那么直接调用SDK
if (lackedPermission.size() == 0) {
getAdMob();
} else {
// 请求所缺少的权限在onRequestPermissionsResult中再看是否获得权限如果获得权限就可以调用SDK否则不要调用SDK
String[] requestPermissions = new String[lackedPermission.size()];
lackedPermission.toArray(requestPermissions);
requestPermissions(requestPermissions, 1024);
}
}
}

View File

@ -8,9 +8,16 @@ import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.InterstitialAd;
import com.google.android.gms.ads.MobileAds;
import com.novelbook.android.Main2Activity;
import com.novelbook.android.MyApp;
import com.novelbook.android.bean.AdSetting;
import com.novelbook.android.utils.Constants;
import java.util.Date;
@ -19,12 +26,13 @@ import static com.novelbook.android.utils.Constants.AD_TENCENT_QQ;
import static com.novelbook.android.utils.Constants.AD_TOUTIAO;
public class SplashAdManager implements Application.ActivityLifecycleCallbacks, ComponentCallbacks2 {
final static String TAG= SplashAdManager.class.getSimpleName();
private boolean mIsBackground;
private static long lastAd =0;
//private static long interVal = 5000;//Constants.AD_SPLASH_INVTERVAL;
private static int pages =0;
private static InterstitialAd mInterstitialAd ;
/******
* 使用方式在Application中直接构造即可
* @param application
@ -49,6 +57,10 @@ public class SplashAdManager implements Application.ActivityLifecycleCallbacks,
@Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
if(Constants.AD_SETTING.getSplash2() .getSource() == Constants.AD_MOB) {
getAdMob(activity);
}
Log.d(TAG, "onActivityCreated:mInterstitialAd initialized ");
if(activity instanceof Main2Activity){
//showAd(activity);
@ -117,16 +129,29 @@ public class SplashAdManager implements Application.ActivityLifecycleCallbacks,
static void showSplashAd(Activity activity){
if(canShowAd()) {
lastAd = new Date().getTime();
if(Constants.AD_SETTING.getSplash2() .getSource() == Constants.AD_MOB){
Log.d(TAG, "showSplashAd:mInterstitialAd.isLoaded() " +mInterstitialAd.isLoaded());
if(mInterstitialAd!=null && mInterstitialAd.isLoaded()) {
SplashAdManager.setSplashTime();
activity.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
);
mInterstitialAd.show();
mInterstitialAd.loadAd(new AdRequest.Builder().build());
}
return;
}
Intent intent = new Intent(activity, SplashActivity.class);
intent.putExtra(SplashActivity.EXTR_LUNCHER, false);
/* if(Constants.AD_SPLASH_SOURCE ==AD_TENCENT_QQ) {
intent = new Intent(activity, com.novelbook.android.AD.qq.SplashActivity.class);
}else if(Constants.AD_SPLASH_SOURCE ==AD_TOUTIAO){
intent = new Intent(activity, SplashActivity.class);
intent.putExtra(SplashActivity.EXTR_LUNCHER, false);
}*/
activity.startActivity(intent);
}
}
@ -145,10 +170,66 @@ public class SplashAdManager implements Application.ActivityLifecycleCallbacks,
}
public static void plusPage(Activity activity){
pages++;
if(pages >Constants.AD_SETTING.getSplash2().getPageCount4Display()){
int pcnt =Constants.AD_SETTING.getSplash2().getPageCount4Display();;
if(pages > pcnt){
clearPages();
showSplashAd(activity);
}
}
void getAdMob(Activity activity){
mInterstitialAd = new InterstitialAd(activity);
Log.d(TAG, "getAdMob: mIntersititiaAd is null ?" + (mInterstitialAd==null));
if(mInterstitialAd!=null)
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
// Code to be executed when an ad finishes loading.
Log.d(TAG, "onAdLoaded: ");
}
@Override
public void onAdFailedToLoad(int errorCode) {
// Code to be executed when an ad request fails.
Log.d(TAG, "onAdFailedToLoad: ");
}
@Override
public void onAdOpened() {
// Code to be executed when the ad is displayed.
Log.d(TAG, "onAdOpened: ");
}
@Override
public void onAdClicked() {
// Code to be executed when the user clicks on an ad.
Log.d(TAG, "onAdClicked: ");
}
@Override
public void onAdLeftApplication() {
// Code to be executed when the user has left the app.
Log.d(TAG, "onAdLeftApplication: ");
}
@Override
public void onAdClosed() {
// Code to be executed when the interstitial ad is closed.
Log.d(TAG, "onAdClosed: ");
}
});
mInterstitialAd.setAdUnitId( Constants.AD_SETTING.getSplash2().getSlotId(Constants.AD_MOB));
mInterstitialAd.loadAd(new AdRequest.Builder().build());
}
}

View File

@ -42,10 +42,10 @@ import com.bytedance.sdk.openadsdk.TTImage;
import com.bytedance.sdk.openadsdk.TTInteractionAd;
import com.bytedance.sdk.openadsdk.TTNativeAd;
import com.google.android.gms.ads.AdListener;
/*import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.MobileAds;*/
import com.google.android.gms.ads.MobileAds;
import com.google.gson.Gson;
import com.novelbook.android.AD.toutiao.TTAdManagerHolder;
@ -423,6 +423,8 @@ public abstract class Activity_base extends AppCompatActivity implements Native
loadNativeBanner_qq(-1, 388);
}else if(Constants.AD_SETTING.getChapterContentBanner().getSource() == AD_TOUTIAO) {
loadNativeBanner_toutiao(mBannerContainer ,690,388);
}else if(Constants.AD_SETTING.getChapterContentBanner().getSource() == AD_MOB) {
loadBanner_Mob(mBannerContainer, 699,388);
}
}
@ -446,7 +448,7 @@ public abstract class Activity_base extends AppCompatActivity implements Native
loadBanner_toutiao(mBannerContainer, width,height);
}else if(Constants.AD_SETTING.getChapterBanner().getSource()== AD_MOB){
//loadBanner_Mob(mBannerContainer, width,height);
loadBanner_Mob(mBannerContainer, width,height);
}
}
@ -454,7 +456,7 @@ public abstract class Activity_base extends AppCompatActivity implements Native
void initializeAd(){
if(Constants.AD_SETTING.isShowAdsense()) {
initAD_TouTiao();
initialMobileAd();
// initialMobileAd();
}
}
@ -1332,21 +1334,21 @@ public abstract class Activity_base extends AppCompatActivity implements Native
//------------------------AD Google MobileAds---------------
// MobileAds.initialize(this, "YOUR_ADMOB_APP_ID");
/* boolean isMobleAdInitialize =false;
AdView mAdView;
boolean isMobleAdInitialize =false;
//AdView mAdView;
void initialMobileAd(){
// Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713
String appID = AdSetting.getAppID(Constants.AD_MOB);
appID ="ca-app-pub-3940256099942544~3347511713";
appID =AdSetting.getAppID(Constants.AD_MOB);
MobileAds.initialize(this, appID);
isMobleAdInitialize =true;
Log.d(TAG, "onAdLoaded: initialMobileAd ");
}
AdView getAdView(){
if(mAdView ==null){
mAdView = new AdView(this);
mAdView.setAdSize(AdSize.BANNER);
String codeId = "ca-app-pub-3940256099942544/6300978111";//Constants.AD_SETTING.getChapterBanner().getSlotId(Constants.AD_MOB) ;
// if(mAdView ==null){
AdView mAdView = new AdView(this);
String codeId = Constants.AD_SETTING.getChapterBanner().getSlotId(Constants.AD_MOB);//Constants.AD_SETTING.getChapterBanner().getSlotId(Constants.AD_MOB) ;
mAdView.setAdUnitId(codeId);
mAdView.setAdListener(new AdListener() {
@Override
@ -1359,7 +1361,7 @@ public abstract class Activity_base extends AppCompatActivity implements Native
@Override
public void onAdFailedToLoad(int errorCode) {
// Code to be executed when an ad request fails.
Log.d(TAG, "onAdLoaded: Code to be executed when an ad request fails.");
Log.d(TAG, "onAdLoaded: Code to be executed when an ad request fails." +errorCode);
}
@Override
@ -1388,7 +1390,7 @@ public abstract class Activity_base extends AppCompatActivity implements Native
Log.d(TAG, "onAdLoaded: Code to be executed when the user is about to return to the app after tapping on an ad.");
}
});
}
// }
return mAdView;
}
private void loadBanner_Mob(FrameLayout bannerContainer, int width, int height) {
@ -1397,16 +1399,20 @@ public abstract class Activity_base extends AppCompatActivity implements Native
if(!isMobleAdInitialize){
initialMobileAd();
}
Log.d(TAG, "onAdLoaded: 2 loadBanner_Mob ");
Log.d(TAG, "onAdLoaded: 2 loadBanner_Mob height:" +height);
AdSize adsize = new AdSize(width,height);
AdView adView = getAdView();
if(height<250){
adView.setAdSize(AdSize.BANNER);
}else {
adView.setAdSize(AdSize.MEDIUM_RECTANGLE);
}
AdRequest adRequest = new AdRequest.Builder().build();
getAdView().loadAd(adRequest);
adView.loadAd(adRequest);
bannerContainer.removeAllViews();
bannerContainer.addView( getAdView());
}*/
bannerContainer.addView( adView);
}
@Override
protected void onResume() {

View File

@ -9,6 +9,7 @@ import android.util.Log;
import com.bytedance.sdk.openadsdk.TTAdConfig;
import com.bytedance.sdk.openadsdk.TTAdConstant;
import com.bytedance.sdk.openadsdk.TTAdSdk;
import com.google.android.gms.ads.MobileAds;
import com.google.gson.Gson;
import com.novelbook.android.AD.toutiao.TTAdManagerHolder;
import com.novelbook.android.bean.AdSetting;
@ -67,10 +68,17 @@ public class MyApp extends Application {
}
private void initAD(){
initAD_ChuanShanJia();
initAD_AdMob();
}
private void initAD_ChuanShanJia(){
TTAdManagerHolder.init(applicationContext);
}
private void initAD_AdMob(){
if(AdSetting.getAppID(Constants.AD_MOB).length()>0){
MobileAds.initialize(MyApp.applicationContext, AdSetting.getAppID(Constants.AD_MOB));
}
}
public boolean exit() {

View File

@ -545,8 +545,10 @@ public class ReadActivity extends Activity_base implements AdInterface {
}*/
hideReadSetting();
if( pageFactory.isReady()) {
pageFactory.updateTime();
pageFactory.showAd();
}
}

View File

@ -16,6 +16,7 @@ public class AdSetting {
private slot fixBanner = new slot();
private slot bigBanner = new slot();
public boolean isShowAdsense() {
// return true;
return showAdsense && NetUtil.isNetworkConnected();
}
@ -90,6 +91,7 @@ public class AdSetting {
}
public boolean isShow() {
// return true;
return show && NetUtil.isNetworkConnected();
}
@ -99,7 +101,7 @@ public class AdSetting {
public int getSource() {
return source;
// return 1;
// return 3 ;
}
public void setSource(int source) {

View File

@ -111,6 +111,7 @@ public class Novel extends LitePalSupport implements Serializable{
}
public String getChapterName() {
return chapterName;
}
@ -331,12 +332,17 @@ public void testUpdate(){
/* if(lastUpdateTime > nv.lastVisit && lastUpdateTime > nv.lastUpdateTime){
isUpdated =true;
}*/
isUpdated =lastUpdateTime > nv.lastVisit || lastUpdateTime > nv.lastUpdateTime;
isUpdated = lastUpdateTime > nv.lastVisit && lastUpdateTime > nv.lastUpdateTime;
Log.d("Novel", String.format("book %s server lastUpdateTime %s, local lastupdatetime %s, local lastvist %s" +
"is updated %s,diff1 %s,diff2 %s"
"is updated %s,diff1 %s,diff2 %s "
,name ,lastUpdateTime,nv.lastUpdateTime,nv.lastVisit,isUpdated,
lastUpdateTime - nv.lastVisit,
lastUpdateTime - nv.lastUpdateTime) );
lastUpdateTime - nv.lastUpdateTime
) );
isUpdated = isUpdated && !(!TextUtils.isEmpty(chapterName) && !TextUtils.isEmpty(nv.chapterName) && (chapterName.equals(nv.chapterName) || chapterName.equals(nv.lastReadChapt)));
Log.d("Novel", String.format( " isupdated %s, server lastUpdateTime ,server chaptername %s,chaptername %s,lastreadchapt %s" ,isUpdated,chapterName,nv.chapterName,nv.lastReadChapt ) );
if(!isUpdated){
setToDefault("isUpdated");

View File

@ -121,8 +121,23 @@ public class BookUtil {
private Novel mNovel;
private void clearBook() {
charPosition.clear();
this.muluRetryCount=0;
this.downloadStatus = DownloadStatus.notStart;
chaptDownStatus.clear();
chaptCache.clear();
fileRetryCnt.clear();
siteRuleRetryCnt=0;
isChangeSource=false;
mChapters.clear();
myArray.clear();
}
public void setNovel(Novel novel) {
clearBook();
this.mNovel = novel;
}
public Novel getNovel( ) {
return mNovel ;
@ -299,6 +314,9 @@ public class BookUtil {
int siteRuleRetryCnt =0;
public void getSiteRule() {
getSiteRule(false);
}
public void getSiteRule(boolean isForceRefresh) {
mSiteRule = null;
if(mSite==null){
return;
@ -334,10 +352,11 @@ public class BookUtil {
Log.d(TAG, String.format("目录正则表达式下载完成,开始读取章节信息") );
int maxAge = isForceRefresh? 0:mNovel.getMaxAge() ;
if(mSiteRule.getChapterUrlRegexOnMulu().length>0) {
mMuluStatus = MuluStatus.isDownloading;
long startTime= new Date().getTime();
Log.d(TAG,String.format("prepare book loadChapts----start download %s,maxAge %s, 目录 from %s", mNovel.getName() ,mNovel.getMaxAge() ,mSite.getMuluUrl() ));
Log.d(TAG,String.format("prepare book loadChapts----start download %s,maxAge %s, 目录 from %s", mNovel.getName() ,maxAge ,mSite.getMuluUrl() ));
new Thread(){
@Override
public void run() {
@ -348,7 +367,7 @@ public class BookUtil {
try {
JSONObject siteJson = new JSONObject(result);
mChapters = NovelParseUtil.getChapters(mSite.getMuluUrl(), siteJson,mSite.getDomain(),mNovel.getMaxAge(),mSiteRule);
mChapters = NovelParseUtil.getChapters(mSite.getMuluUrl(), siteJson,mSite.getDomain(),maxAge,mSiteRule);
/* if (mChapters != null){
for (Chapter chapter:mChapters) {
@ -489,17 +508,7 @@ public class BookUtil {
}
private void clearBook() {
charPosition.clear();
this.muluRetryCount=0;
this.downloadStatus = DownloadStatus.notStart;
chaptDownStatus.clear();
chaptCache.clear();
fileRetryCnt.clear();
siteRuleRetryCnt=0;
isChangeSource=false;
}
public Site getSite() {
return mSite !=null? mSite :new Site();
@ -787,13 +796,17 @@ public class BookUtil {
int muluRetryCount =0;
void readChaptersAsync( ) {
void readChaptersAsync(){
readChaptersAsync(false);
}
void readChaptersAsync(boolean isForceRefresh ) {
if(mSite==null ||mSiteRule ==null){
Log.d(TAG,String.format("prepare book loadChapts failed---- %s ,mSite is null? %s ,mSiteRule ==null ? %s", mNovel.getName() ,mSite==null,mSiteRule ==null ));
return;
}
String url = mSite.getMuluUrl();
Request request = getTagRequest(url,REUtil.getDomain(url), mNovel.getMaxAge());
int maxAge= isForceRefresh ?0 : mNovel.getMaxAge();
Request request = getTagRequest(url,REUtil.getDomain(url),maxAge);
mMuluStatus = MuluStatus.isDownloading;
long startTime= new Date().getTime();

View File

@ -30,6 +30,7 @@ import android.widget.Toast;
import com.novelbook.android.MyApp;
import com.novelbook.android.R;
import com.novelbook.android.bean.AdSetting;
import com.novelbook.android.bean.NovelSites;
import com.novelbook.android.bean.Site;
import com.novelbook.android.db.Chapter;
@ -626,7 +627,7 @@ public class PageFactory implements ChangeSource{
if(!TextUtils.isEmpty(domainName)) {
statusChangeSource = "前往 " + domainName.substring(0,domainName.length()>5?5:domainName.length()) + "...";
}
// drawChangeSourceStatus();
drawStatus();
mBookUtil.pagefactory=this;
mBookUtil.changeSource(domain, chapId, chapTitle);
@ -713,7 +714,7 @@ private void hideSysUI(){
}
private PageFactory(Context context) {
// mBookUtil = new BookUtil();
mBookUtil = new BookUtil();
mContext = context.getApplicationContext();
config = Config.getInstance();
//获取屏幕宽高
@ -822,6 +823,11 @@ private void hideSysUI(){
drawStatus(mBookPageWidget.getNextPage());
}
}
public boolean isChangingSource(){
return mStatus == Status.CHANGESOURCE;
}
private String loadingTxt ="";
private String statusChangeSource ="正在换源...";
private boolean showingStatusAd =false;
@ -832,7 +838,7 @@ private void hideSysUI(){
mAd.hideProgressbar();
// mAd.showLoading(false);
String status = "";
boolean showAd =true;
boolean showAd =false;
switch (mStatus){
case OPENING:
status = "正在拼命加载" + loadingTxt;
@ -909,6 +915,7 @@ private void hideSysUI(){
// 下面这行是实现水平居中drawText对应改为传入targetRect.centerX()
waitPaint.setTextAlign(Paint.Align.CENTER);
c.drawText(status, targetRect.centerX(), baseline, waitPaint);
Log.d(TAG, "changing Source showloading: drawing status :" +status );
// c.drawText("正在打开书本...", mHeight / 2, 0, waitPaint);
/* TextPaint tp = new TextPaint();
tp.setColor(getTextColor());
@ -988,7 +995,7 @@ private void hideSysUI(){
// mAd.showRefresh(View.GONE);
Log.d(TAG, String.format("onDraw: trPage pageno %s,showAd %s",trPage.getPageNo(),showAd));
// Log.d(TAG, "changing Source onDraw showloading: drawing status :" );
if(m_lines.size()==0 ){
return;
@ -996,7 +1003,7 @@ private void hideSysUI(){
/* try {
throw new Exception("who's ad");
}catch (Exception e){
Log.e(TAG, "onDraw:showTopBanner ",e );
Log.e(TAG, "onDraw:changing Source ",e );
}*/
/* Log.d(TAG, "showloading: ondraw showAd: " +showAd );
try{
@ -1280,7 +1287,7 @@ private void hideSysUI(){
public void showAd(){
Log.d(TAG, String.format("loadBannerAd showAd: mAdType %s ",mAdType ));
if(mStatus == Status.LASTPAGE || mAd==null ||currentPage==null){
if(mStatus == Status.LASTPAGE || mAd==null ||currentPage==null || !Constants.AD_SETTING.isShowAdsense()){
return;
}
Log.d(TAG, String.format("loadBannerAd showAd: mAdType %s, pageNo %s",mAdType, currentPage.getPageNo()));
@ -2127,8 +2134,11 @@ private void hideSysUI(){
public void clear(){
// Log.d(TAG, String .format("prepare Book: clearing book info %s" , getNovle().getName()));
if(mBookUtil!=null) {
mBookUtil.clear();
mBookUtil=null;
// mBookUtil=null;
}
fileRetryCnt.clear();
lastPageTime=0;
if(chaptMap!=null){
@ -2143,7 +2153,7 @@ private void hideSysUI(){
cancelPage = null;
prePage = null;
currentPage = null;
mAd=null;
// mAd=null;
currentChaptPages =null;
preChaptPages=null;
nextChaptPages=null;
@ -2220,7 +2230,7 @@ private void hideSysUI(){
public void refreshCate(){
mBookUtil.getChapters().clear();
mBookUtil.getSiteRule();
mBookUtil.getSiteRule(true);
}
public long getChapterLen(){
return mBookUtil.getChapterLen();

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Activity_paihangbang"
android:fitsSystemWindows="true"
android:clipToPadding="true"
android:background="@color/black"
>
<!-- 即toolbar悬浮在statusbar之后 https://blog.csdn.net/zafir6453/article/details/51344241-->
</android.support.design.widget.CoordinatorLayout >

View File

@ -8,80 +8,38 @@
</facet>
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="aliDebug" />
<option name="ASSEMBLE_TASK_NAME" value="assembleAliDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileAliDebugSources" />
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<afterSyncTasks>
<task>generateAliDebugSources</task>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res;file://$MODULE_DIR$/src/ali/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/build/intermediates/javac/aliDebug/compileAliDebugJavaWithJavac/classes" />
<output-test url="file://$MODULE_DIR$/build/intermediates/javac/aliDebugUnitTest/compileAliDebugUnitTestJavaWithJavac/classes" />
<output url="file://$MODULE_DIR$/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes" />
<output-test url="file://$MODULE_DIR$/build/intermediates/javac/debugUnitTest/compileDebugUnitTestJavaWithJavac/classes" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/ali/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/aliDebug/compileAliDebugAidl/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/ali/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/aliDebug/compileAliDebugRenderscript/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/ali/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/ali/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/aliDebug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/aliDebug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/aliDebug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/aliDebug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/aliDebug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/aliDebug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/aliDebug/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/ali/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/aliDebugAndroidTest/compileAliDebugAndroidTestAidl/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/ali/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/aliDebugAndroidTest/compileAliDebugAndroidTestRenderscript/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/ali/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/ali/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAliDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAliDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAliDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAliDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAliDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAliDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAliDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/test/ali/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testAliDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testAliDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testAliDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testAliDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testAliDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testAliDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testAliDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/ali/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/ali/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/ali/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/ali/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/ali/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/ali/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/ali/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAli/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAli/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAli/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAli/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAli/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAli/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAli/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testAli/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testAli/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testAli/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testAli/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testAli/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testAli/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testAli/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debug/compileDebugAidl/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debug/compileDebugRenderscript/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debugAndroidTest/compileDebugAndroidTestAidl/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debugAndroidTest/compileDebugAndroidTestRenderscript/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
@ -129,33 +87,42 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotation_processor_list" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/apk_list" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/build-info" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundle_manifest" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check_manifest_result" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/compatible_screen_manifest" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-runtime-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-verifier" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-apk" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant_app_manifest" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant_run_app_info_output_file" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant_run_main_apk_resources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant_run_merged_manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant_run_split_apk_resources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javac" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/legacy_multidex_aapt_derived_proguard_rules" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/legacy_multidex_main_dex_list" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged-not-compiled-resources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint_jar" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifest-checker" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged_assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged_manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/metadata_feature_manifest" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/prebuild" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/processed_res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard-files" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard-rules" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/resources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shader_assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/signing_config" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/split-apk" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/reports" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 28 Platform" jdkType="Android SDK" />