adjust ad

This commit is contained in:
mwang 2019-06-06 23:46:47 +08:00
parent ad7ed7317d
commit 5f6205b41d
23 changed files with 651 additions and 173 deletions

View File

@ -34,7 +34,8 @@ static final String TAG = ActivitySetup.class.getSimpleName();
TextView tvVersion;
String mVersion ="";
String mCacheSize ="";
@Override
public int getLayoutRes() {
@ -43,8 +44,15 @@ static final String TAG = ActivitySetup.class.getSimpleName();
@Override
protected void initViews() {
tvVersion.setText(CommonUtil.getVersion(this));
tvCache.setText(FileUtils.getCachedSize());
new Thread() {
@Override
public void run() {
super.run();
mVersion =CommonUtil.getVersion(ActivitySetup.this);
mCacheSize =FileUtils.getCachedSize();
handler.sendEmptyMessage(1);
}
}.start() ;
}
@ -61,7 +69,8 @@ static final String TAG = ActivitySetup.class.getSimpleName();
@Override
public void fillData() {
tvVersion.setText(mVersion);
tvCache.setText(mCacheSize);

View File

@ -53,7 +53,10 @@ import com.novelbook.android.adapter.BookListAdapter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import butterknife.BindView;
import butterknife.ButterKnife;
@ -500,52 +503,156 @@ public abstract class Activity_base extends AppCompatActivity {
loadNativeBannerAd(bannerContainer,codeId,690,388);
}
void loadNativeBannerAd(FrameLayout bannerContainer,String codeId,int width,int height) {
//step4:创建广告请求参数AdSlot,注意其中的setNativeAdtype方法具体参数含义参考文档
if(!Constants.SHOWAD || getTTAdNative()==null ){
// List<TTNativeAd> toutiaoNati_Banner_AdCache = new ArrayList<TTNativeAd>();
Map<String, List<TTNativeAd> > toutiaoNati_Banner_AdCache = new ConcurrentHashMap<String, List<TTNativeAd>>();
void loadNativeBannerAd(FrameLayout bannerContainer,String codeId,int width,int height) {
//step4:创建广告请求参数AdSlot,注意其中的setNativeAdtype方法具体参数含义参考文档
if (!Constants.SHOWAD || getTTAdNative() == null) {
return;
}
if(bannerContainer==null) return;
final AdSlot adSlot = new AdSlot.Builder()
.setCodeId(codeId)
.setSupportDeepLink(true)
.setImageAcceptedSize(width, height)
.setNativeAdType(AdSlot.TYPE_BANNER) //请求原生广告时候请务必调用该方法设置参数为TYPE_BANNER或TYPE_INTERACTION_AD
.setAdCount(1)
.build();
//step5:请求广告对请求回调的广告作渲染处理
final String key =width+"_"+height;
List<TTNativeAd> adCache =null;
if( toutiaoNati_Banner_AdCache.containsKey(key)){
adCache = toutiaoNati_Banner_AdCache.get(key);
}
final boolean isfillAd = adCache!=null &&adCache.size()>1;
// final boolean isfillAd =!toutiaoNati_Banner_AdCache.containsKey(key);
if(adCache!=null && isfillAd){
Log.d(TAG, "loadNativeBannerAd: set ad from cache, cache Size " + adCache.size());
setNativeBanner(bannerContainer, key);
if(adCache.size()>0){
return;
}
}
final AdSlot adSlot = new AdSlot.Builder()
.setCodeId(codeId)
.setSupportDeepLink(true)
.setImageAcceptedSize(width, height)
.setNativeAdType(AdSlot.TYPE_BANNER) //请求原生广告时候请务必调用该方法设置参数为TYPE_BANNER或TYPE_INTERACTION_AD
.setAdCount(3)
.build();
//step5:请求广告对请求回调的广告作渲染处理
getTTAdNative().loadNativeAd(adSlot, new TTAdNative.NativeAdListener() {
@Override
public void onError(int code, String message) {
// TToast.show(oContext, "load error : " + code + ", " + message);
Log.e(TAG, "loadBannerAd: " + code + ", " + message);
}
@Override
public void onError(int code, String message) {
// TToast.show(oContext, "load error : " + code + ", " + message);
Log.e(TAG, "loadBannerAd: " + code + ", " + message);
bannerContainer.setBackgroundResource(R.color.transparent);
}
@Override
public void onNativeAdLoad(List<TTNativeAd> ads) {
if (ads.get(0) == null||!mShowAd) {
return;
}
View bannerView = LayoutInflater.from(oContext).inflate(R.layout.ad_toutiao_native_ad , bannerContainer, false);
if (bannerView == null) {
return;
}
if (mCreativeButton != null) {
//防止内存泄漏
mCreativeButton = null;
}
bannerContainer.removeAllViews();
bannerContainer.addView(bannerView);
// bannerContainer.setVisibility(View.VISIBLE);
Log.d(TAG, "loadBannerAd: set banner VISIBLE,mShowAd " +mShowAd);
//绑定原生广告的数据
setAdData(bannerContainer,bannerView, ads.get(0));
// mTTAdNative.loadNativeAd(adSlot,null);
}
});
}
@Override
public void onNativeAdLoad(List<TTNativeAd> ads) {
bannerContainer.setBackgroundResource(R.color.transparent);
List<TTNativeAd> tmp = new ArrayList<TTNativeAd>();
for (TTNativeAd ad : ads) {
if (ad != null) {
tmp.add(ad);
}
}
if (!toutiaoNati_Banner_AdCache.containsKey(key)) {
toutiaoNati_Banner_AdCache.put(key, tmp);
} else {
toutiaoNati_Banner_AdCache.get(key).addAll(tmp);
}
boolean isfillAd1 =toutiaoNati_Banner_AdCache.get(key).size()>1;
Log.d(TAG, String.format("loadNativeBannerAd: ads count %s ,not null count %s,key %s,will fill ad %s", ads.size(), tmp.size(), key, isfillAd1));
if (isfillAd1) {
setNativeBanner(bannerContainer, key);
}else{
loadNativeBannerAd(bannerContainer, codeId, width, height);
Log.d(TAG, String.format("loadNativeBannerAd: load again ... containsKey(key) ? %s,ads size %s",toutiaoNati_Banner_AdCache.containsKey(key),
toutiaoNati_Banner_AdCache.containsKey(key)?toutiaoNati_Banner_AdCache.get(key).size() :0
));
}
/* if (!toutiaoNati_Banner_AdCache.containsKey(key)){
loadNativeBannerAd(bannerContainer, codeId, width, height);
Log.d(TAG, String.format("loadNativeBannerAd: load again ... containsKey(key) ? %s,ads size %s",toutiaoNati_Banner_AdCache.containsKey(key),
toutiaoNati_Banner_AdCache.containsKey(key)?toutiaoNati_Banner_AdCache.get(key).size() :0
));
}*/
/* if (ads.get(0) == null || !mShowAd) {
return;
}
View bannerView = LayoutInflater.from(oContext).inflate(R.layout.ad_toutiao_native_ad, bannerContainer, false);
if (bannerView == null) {
return;
}
if (mCreativeButton != null) {
//防止内存泄漏
mCreativeButton = null;
}
bannerContainer.removeAllViews();
bannerContainer.addView(bannerView);
bannerContainer.setVisibility(View.VISIBLE);
if (!Constants.AD_BACKGROUND_TRANSPARENT)
bannerContainer.setBackgroundResource(R.color.mintcream); // @color/mintcream
Log.d(TAG, "loadBannerAd: set banner VISIBLE,mShowAd " + mShowAd);
//绑定原生广告的数据
setAdData(bannerContainer, bannerView, ads.get(0));*/
// mTTAdNative.loadNativeAd(adSlot,null);
}
});
}
void setNativeBanner(FrameLayout bannerContainer,String key ){
if(!toutiaoNati_Banner_AdCache.containsKey(key)){
return;
}
List<TTNativeAd> adCache = toutiaoNati_Banner_AdCache.get(key);
TTNativeAd nativeAd =null ;
int i=0;
for (TTNativeAd ad :adCache){
if(ad!=null){
nativeAd =ad;
break;
}
i++;
}
if (nativeAd == null || !mShowAd) {
return;
}
adCache.remove(i);
if(adCache.size()>0) {
toutiaoNati_Banner_AdCache.put(key, adCache);
}else{
toutiaoNati_Banner_AdCache.remove(key);
}
View bannerView = LayoutInflater.from(oContext).inflate(R.layout.ad_toutiao_native_ad, bannerContainer, false);
if (bannerView == null) {
return;
}
if (mCreativeButton != null) {
//防止内存泄漏
mCreativeButton = null;
}
bannerContainer.removeAllViews();
bannerContainer.addView(bannerView);
//bannerContainer.setVisibility(View.VISIBLE);
if (!Constants.AD_BACKGROUND_TRANSPARENT)
bannerContainer.setBackgroundResource(R.color.mintcream); // @color/mintcream
Log.d(TAG, "loadBannerAd: set banner VISIBLE,mShowAd " + mShowAd);
//绑定原生广告的数据
setAdData(bannerContainer, bannerView, nativeAd);
// mTTAdNative.loadNativeAd(adSlot,null);
}
@SuppressWarnings("RedundantCast")
private void setAdData(FrameLayout bannerContainer,View nativeView, TTNativeAd nativeAd) {

View File

@ -141,7 +141,7 @@ public abstract class BasicFragment extends Fragment {
initData();
initViews();
initSwipeRefreshLayout();
showBanner(mBannerContainer,260);
showBanner(mBannerContainer,(int) getResources().getDimension(R.dimen.topBannerHeight) );
return view;
// Inflate the layout for this fragment

View File

@ -46,10 +46,16 @@ public class MyApp extends Application {
initAD();
}
private void initialConstants(){
Config confg= Config.createConfig(this);
Constants.SEX = confg.getSexOption();
Constants.SHOWAD =confg.isShowAd();
Constants.PRE_LOAD_CHAPT =confg.isPreLoadChapter();
Config config= Config.createConfig(this);
Constants.SEX = config.getSexOption();
Constants.SHOWAD =config.isShowAd();
Constants.PRE_LOAD_CHAPT =config.isPreLoadChapter();
Constants.AD_CHAPT_TOP_BANNER_PER_PAGE_COUNT = config.getAdTopBannerRate();
Constants.AD_CHAPT_NATIVE_BANNER_PER_PAGE_COUNT= config.getAdNativeBannerInLinesRate() ;
Constants.ONE_DP_SIZE = (int)applicationContext.getResources().getDimension(R.dimen.one_dp);
}
private void initUmengApi(){
UMConfigure.init(applicationContext,UMConfigure.DEVICE_TYPE_PHONE,null);

View File

@ -14,8 +14,10 @@ import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable;
import android.support.constraint.solver.GoalRow;
import android.support.design.widget.AppBarLayout;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.util.Log;
import android.view.Display;
import android.view.KeyEvent;
@ -124,17 +126,24 @@ public class ReadActivity extends Activity_base implements AdInterface {
@BindView(R.id.appbar)
AppBarLayout appbar;
@BindView(R.id.tvUrl)
TextView tvUrl;
@BindView(R.id.top_banner_container)
FrameLayout mTopBannerContainer;
@BindView(R.id.imgLoading)
pl.droidsonroids.gif.GifImageView imgLoading;
@BindView(R.id.frmAD)
FrameLayout frmAD;
@BindView(R.id.native_banner_container )
FrameLayout mNative_banner_container;
@BindView(R.id.native_banner_container_in_lines )
FrameLayout mNative_banner_container_in_lines;
@BindView(R.id.llShelfBottom)
LinearLayout llShelf;
private Config config;
private WindowManager.LayoutParams lp;
private Novel book;
@ -468,6 +477,20 @@ public class ReadActivity extends Activity_base implements AdInterface {
// Log.d(TAG, "canCancel: cancelPage canCancel ?" + pageFactory.canCancelPage());
return true;//pageFactory.canCancelPage();
}
@Override
public void showAdAfterIni() {
if(frmAD.getVisibility()== View.INVISIBLE)
// frmAD.setVisibility(View.VISIBLE);
Log.d(TAG, "pageAnimation showAdAfterIni: ");
}
@Override
public void hideAdBeforeIni() {
if(frmAD.getVisibility()== View.VISIBLE)
// frmAD.setVisibility(View.INVISIBLE);
Log.d(TAG, "pageAnimation hideAdBeforeIni: ");
}
});
}
@ -567,12 +590,20 @@ public class ReadActivity extends Activity_base implements AdInterface {
return true;
}*/
if(isShow){
hideReadSetting();
return true;
}
if(!pageFactory.canExitSilent()){
if(book.isOnShelf()){
finish();
}else {
showNormalDialog();
// showNormalDialog();
Animation bottomAnim = AnimationUtils.loadAnimation(this, R.anim.dialog_enter);
llShelf.startAnimation(bottomAnim);
llShelf.setVisibility(View.VISIBLE);
return true;
}
}
@ -822,22 +853,37 @@ public class ReadActivity extends Activity_base implements AdInterface {
public void showReadSetting(){
isShow = true;
// rl_progress.setVisibility(View.GONE);
Animation topAnim = AnimationUtils.loadAnimation(this, R.anim.dialog_top_enter);
Animation botoomAnim = AnimationUtils.loadAnimation(this, R.anim.dialog_exit);
if (llShelf.getVisibility() == View.VISIBLE) {
llShelf.startAnimation(botoomAnim);
llShelf.setVisibility(View.GONE);
}
if (isSpeaking){
Animation topAnim = AnimationUtils.loadAnimation(this, R.anim.dialog_top_enter);
rl_read_bottom.startAnimation(topAnim);
rl_read_bottom.setVisibility(View.VISIBLE);
}else {
showSystemUI();
Animation bottomAnim = AnimationUtils.loadAnimation(this, R.anim.dialog_enter);
Animation topAnim = AnimationUtils.loadAnimation(this, R.anim.dialog_top_enter);
// Animation bottomAnim = AnimationUtils.loadAnimation(this, R.anim.dialog_enter);
rl_bottom.startAnimation(topAnim);
appbar.startAnimation(topAnim);
// ll_top.startAnimation(topAnim);// ll_top.setVisibility(View.VISIBLE);
rl_bottom.setVisibility(View.VISIBLE);
appbar.setVisibility(View.VISIBLE);
tvUrl.setVisibility(View.VISIBLE);
tvUrl.setText("abcd+" + pageFactory.getChapter().getChapterUrl());
if(pageFactory.getChapter()!=null && !TextUtils.isEmpty(pageFactory.getChapter().getChapterUrl())) {
tvUrl.setVisibility(View.VISIBLE);
tvUrl.setText(pageFactory.getChapter().getChapterUrl());
}
}
}
/**
@ -861,6 +907,12 @@ public class ReadActivity extends Activity_base implements AdInterface {
getWindow().setNavigationBarColor(getResources().getColor(R.color.read_dialog_bg));
}
pageFactory.setBusy(false);
if (llShelf.getVisibility() == View.VISIBLE) {
Animation topAnim = AnimationUtils.loadAnimation(this, R.anim.dialog_exit);
llShelf.startAnimation(topAnim);
llShelf.setVisibility(View.GONE);
}
}
@Override
@ -918,13 +970,16 @@ public class ReadActivity extends Activity_base implements AdInterface {
rl_read_bottom.setVisibility(View.GONE);
// ll_top.setVisibility(View.GONE);
appbar.setVisibility(View.GONE);
tvUrl.setVisibility(View.GONE);
hideSystemUI();
// Animation bottomAnim = AnimationUtils.loadAnimation(this, R.anim.dialog_enter);
}
@OnClick({R.id.tv_progress, R.id.rl_progress, R.id.tv_pre, R.id.sb_progress, R.id.tv_next, R.id.tv_directory,
R.id.tv_dayornight,R.id.tv_pagemode, R.id.tv_setting, R.id.bookpop_bottom, /*R.id.rl_bottom,*/R.id.tv_stop_read
,R.id.btnRefresh})
,R.id.btnRefresh,R.id.btnCancel,R.id.btnShelf})
public void onClick(View view) {
pageFactory.setPageWidget(bookpage);
// if( pageFactory.isReady())
@ -985,6 +1040,15 @@ public class ReadActivity extends Activity_base implements AdInterface {
pageFactory.retryChapt(pageFactory.getCurrentChapter());
btnRefresh.setVisibility(View.GONE);
break;
case R.id.btnShelf:
book.setOnShelf(true);
book.update(book.getId());
finish();
break;
case R.id.btnCancel:
finish();
break;
}
// hideSystemUI();
}
@ -1007,18 +1071,47 @@ public class ReadActivity extends Activity_base implements AdInterface {
}
*/
public void hideAds(){
/* if(mNative_banner_container.getVisibility() ==View.VISIBLE) {
mNative_banner_container.setVisibility(View.GONE);
}*/
}
public void showNativeBannerInLines(int height,int adY){
hideSystemUI();
if(mNative_banner_container.getVisibility() ==View.VISIBLE) {
mNative_banner_container.setVisibility(View.INVISIBLE);
}
mNative_banner_container_in_lines .setVisibility(View.INVISIBLE);
// mNative_banner_container_in_lines.removeAllViews();
// mNative_banner_container_in_lines.removeAllViews();
mNative_banner_container_in_lines.setBackgroundResource(R.color.transparent);
if(height<=0){
return;
}
Log.d(TAG, String.format("loadBannerAd:showNativeBannerInLines width %s, height %s ,adY %s ",Constants.SCREEN_WIDTH_PIX-50,height,adY));
loadNativeBannerAd(mNative_banner_container_in_lines,BuildConfig.AD_SLOT_TOUTIAO_BANNER_NATIVE_ID);
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mNative_banner_container_in_lines.getLayoutParams();
params.setMargins(10*Constants.ONE_DP_SIZE, adY+5*Constants.ONE_DP_SIZE, 10*Constants.ONE_DP_SIZE, 0*Constants.ONE_DP_SIZE);
params.width =-1;
mNative_banner_container_in_lines.setLayoutParams(params);
mNative_banner_container_in_lines.setVisibility(View.VISIBLE);
}
@Override
public void showTopBanner( int adHeight,int adY) {
hideSystemUI();
mTopBannerContainer.setVisibility(View.GONE);
mTopBannerContainer.setVisibility(View.INVISIBLE);//翻页引起抖动
// mTopBannerContainer.removeAllViews();
if(adHeight<=0){
return;
}
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) mTopBannerContainer.getLayoutParams();
loadBannerAd(mTopBannerContainer,BuildConfig.AD_SLOT_TOUTIAO_BANNER_ID, 690,adHeight);
loadBannerAd(mTopBannerContainer,BuildConfig.AD_SLOT_TOUTIAO_BANNER_ID, Constants.SCREEN_WIDTH_PIX-50,adHeight);
// loadNativeBannerAd(mTopBannerContainer,BuildConfig.AD_SLOT_TOUTIAO_BANNER_NATIVE_ID, 304,200);
params.setMargins(20, adY-10, 20, 10);
params.setMargins(10*Constants.ONE_DP_SIZE, adY -5*Constants.ONE_DP_SIZE, 10*Constants.ONE_DP_SIZE, 0);
params.width =-1;
mTopBannerContainer.setLayoutParams(params);
mTopBannerContainer.setVisibility(View.VISIBLE);
@ -1031,41 +1124,52 @@ public class ReadActivity extends Activity_base implements AdInterface {
public void showAd(boolean showAd ,int adHeight,int adY) {
hideSystemUI(); mShowAd =showAd;
mBannerContainer.setVisibility(View.GONE);
mNative_banner_container.setVisibility(View.GONE);
// mBannerContainer.setVisibility(View.GONE);
mNative_banner_container.setVisibility(View.INVISIBLE);
if(mTopBannerContainer.getVisibility() ==View.VISIBLE) {
mTopBannerContainer.setVisibility(View.INVISIBLE);
}
if(mNative_banner_container_in_lines.getVisibility() ==View.VISIBLE) {
mNative_banner_container_in_lines.setVisibility(View.INVISIBLE);
}
if(!Constants.SHOWAD){
return;
}
Log.d(TAG, String.format("loadBannerAd:width %s, height %s ,adY %s,showAd %s",Constants.SCREEN_WIDTH_PIX-50,adHeight,adY, showAd));
if(!showAd){
return;
}
// Log.d(TAG, String.format("loadBannerAd:width %s, height %s ,adY %s,showAd %s",Constants.SCREEN_WIDTH_PIX-50,adHeight/Constants.ONE_DP_SIZE,adY/Constants.ONE_DP_SIZE, showAd));
if(adHeight >contentAdHight){
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mBannerContainer.getLayoutParams();
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mNative_banner_container.getLayoutParams();
// Log.d(TAG, String.format("loadBannerAd:width %s, height %s ,adY %s",Constants.SCREEN_WIDTH_PIX-50,adHeight,adY));
if(adHeight>500 && adY <500){
loadNativeBannerAd(mNative_banner_container,BuildConfig.AD_SLOT_TOUTIAO_BANNER_NATIVE_ID);
params.setMargins(20, adY-30, 20, 150);
mNative_banner_container.setLayoutParams(params);
mNative_banner_container.setVisibility(View.VISIBLE);
if(adHeight>150*Constants.ONE_DP_SIZE && adY <400*Constants.ONE_DP_SIZE){
Log.d(TAG, String.format("loadBannerAd:width %s, height %s ,adY %s,showAd %s",Constants.SCREEN_WIDTH_PIX-50,adHeight/Constants.ONE_DP_SIZE,adY/Constants.ONE_DP_SIZE, showAd));
mNative_banner_container.removeAllViews();
mNative_banner_container.setBackgroundResource(R.color.transparent);
loadNativeBannerAd(mNative_banner_container,BuildConfig.AD_SLOT_TOUTIAO_BANNER_NATIVE_ID);
params.setMargins(10*Constants.ONE_DP_SIZE, adY-20*Constants.ONE_DP_SIZE, 10*Constants.ONE_DP_SIZE, 50*Constants.ONE_DP_SIZE);
mNative_banner_container.setLayoutParams(params);
mNative_banner_container.setVisibility(View.VISIBLE);
showTopBanner(0,0);
}else
{
loadBannerAd(mBannerContainer,BuildConfig.AD_SLOT_TOUTIAO_BANNER_ID, Constants.SCREEN_WIDTH_PIX-50,adHeight);
/* loadBannerAd(mBannerContainer,BuildConfig.AD_SLOT_TOUTIAO_BANNER_ID, Constants.SCREEN_WIDTH_PIX-50,adHeight);
params.setMargins(20, adY-10, 20, 15);
mBannerContainer.setLayoutParams(params);
mBannerContainer.setVisibility(View.VISIBLE);
}
mBannerContainer.setVisibility(View.VISIBLE);*/
}

View File

@ -372,7 +372,8 @@ public class NetUtil {
Constants.AD_SPLASH_INVTERVAL =(long) 1000 * ads.getInt("splashInterval");
Constants.AD_SPLASH_PAGES = ads.getInt("splashPageCount");
Constants.AD_CHAPT_TOP_BANNER_PER_PAGE_COUNT = ads.getInt("times4ChapterTopBanner");
Constants.AD_CHAPT_NATIVE_BANNER_PER_PAGE_COUNT = ads.getInt("times4ChapterContentBanner"); //TODO: put it in server
Log.d(TAG, String.format("initHostConstants: Constants.AD_SPLASH_INVTERVAL %s,AD_SPLASH_PAGES %s",Constants.AD_SPLASH_INVTERVAL,Constants.AD_SPLASH_PAGES ));
@ -393,10 +394,13 @@ public class NetUtil {
TTAdManagerHolder.init(MyApp.applicationContext);
}
}
Config config = Config.getInstance();
Constants.SHOWAD = ads.getBoolean("showAdsense");
Constants.PRE_LOAD_CHAPT= false;//jsonObject.getBoolean("preLoadChapter");
Config.getInstance().setShowAd(Constants.SHOWAD);
Config.getInstance().setPreLoadChapter(Constants.PRE_LOAD_CHAPT);
Constants.PRE_LOAD_CHAPT= jsonObject.getBoolean("preLoadChapter");
config.setShowAd(Constants.SHOWAD);
config.setPreLoadChapter(Constants.PRE_LOAD_CHAPT);
config.setAdTopBannerRate( Constants.AD_CHAPT_TOP_BANNER_PER_PAGE_COUNT);
config.setAdNativeBannerInLinesRate(Constants.AD_CHAPT_NATIVE_BANNER_PER_PAGE_COUNT);
Log.d(TAG, String.format("initHostConstants: Constants.AD_SPLASH_INVTERVAL %s,AD_SPLASH_PAGES %s, Constants.SHOWAD %s,Constants.AD_PRE_LOAD_CHAPT %s "
,Constants.AD_SPLASH_INVTERVAL,Constants.AD_SPLASH_PAGES, Constants.SHOWAD, Constants.PRE_LOAD_CHAPT ));

View File

@ -8,6 +8,7 @@ public interface AdInterface {
*/
public void showAd(boolean showAd,int height,int adY);
public void showTopBanner(int height,int adY);
public void showNativeBannerInLines(int height,int adY);
public void hideSystemUI();
public void showRefresh(int visible);
public void showProgressbar(boolean dismissAble,String msg);
@ -15,4 +16,5 @@ public interface AdInterface {
public void showLoading(boolean isShow);
public void hideReadSetting();
public void showReadSetting();
public void hideAds();
}

View File

@ -43,6 +43,8 @@ public class Config {
public final static boolean SHOW_AD = false;
public final static String SHOW_AD_KEY = "showAd";
private static final String PRE_LOAD_CHAPT_KEY ="preloadchapt" ;
private static final String AD_TOP_BANNER_SEEDS_KEY ="topbannerseeds" ;
private static final String AD_NATVIE_BANNER_IN_LINES_SEEDS_KEY ="nativebannerinlinesseeds" ;
private Context mContext;
private static Config config;
private SharedPreferences sp;
@ -224,4 +226,19 @@ public class Config {
public void setPreLoadChapter(boolean isPreloadChapt){
sp.edit().putBoolean(PRE_LOAD_CHAPT_KEY,isPreloadChapt).commit();
}
public int getAdTopBannerRate(){
return sp.getInt(AD_TOP_BANNER_SEEDS_KEY,0);
}
public void setAdTopBannerRate(int pageCnt){
sp.edit().putInt(AD_TOP_BANNER_SEEDS_KEY,pageCnt).commit();
}
public int getAdNativeBannerInLinesRate(){
return sp.getInt(AD_NATVIE_BANNER_IN_LINES_SEEDS_KEY,0);
}
public void setAdNativeBannerInLinesRate(int pageCnt){
sp.edit().putInt(AD_NATVIE_BANNER_IN_LINES_SEEDS_KEY,pageCnt).commit();
}
}

View File

@ -1,6 +1,7 @@
package com.novelbook.android.utils;
import com.novelbook.android.R;
import com.novelbook.android.bean.ProgressType;
import java.util.List;
@ -13,14 +14,17 @@ public class Constants {
public static final int MAXAGE_MAX =60*60*24*28; //28 ;
public static final int MAXAGE_MULU = 60*60*24*7*2; //2周;;
public static final String VERSION_ADDRESS ="version.xml";
public static boolean AD_BACKGROUND_TRANSPARENT =true ;
public static boolean SHOWAD =false ;
public static boolean PRE_LOAD_CHAPT = false;
public static long AD_SPLASH_INVTERVAL = 5*60*1000;//间隔5分钟
public static int AD_SPLASH_PAGES = 15;
public static int SCREEN_HEIGHT_PIX =1920 ;
public static int SCREEN_WIDTH_PIX = 1080;
public static int AD_CHAPT_TOP_BANNER_HEIGHT=200;
public static int AD_CHAPT_TOP_BANNER_PER_PAGE_COUNT=1; //每几页show topbanner
public static int AD_CHAPT_TOP_BANNER_PER_PAGE_COUNT=0; //每几页show topbanner
public static int AD_CHAPT_NATIVE_BANNER_PER_PAGE_COUNT=0; //每几页show nativebanner
public static int ONE_DP_SIZE =1;
public static long LAST_G = 0;//主目录API上次访问时间
public static long MAXAGE_G = 3600;//主目录API上次访问时间
public static String[] HOT_KEYS_VALUE = {};

View File

@ -48,6 +48,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;
//import static com.baidu.tts.loopj.AsyncHttpClient.log;
@ -188,6 +189,7 @@ public class PageFactory implements ChangeSource{
private final int MSG_NEXTPAGE_FAIL=4;
private final int MSG_HID_AD=5;
private final int MSG_SHOW_LOADING=5;
private static int totalPageCnt =0;
public AdInterface getmAd() {
return mAd;
}
@ -237,19 +239,17 @@ public class PageFactory implements ChangeSource{
// mAd.hideProgressbar();
mAd.showLoading(false);
Log.d(TAG, "showloading: case MSG_HIDEPROGRESS: false" );
// Log.d(TAG, "showloading: case MSG_HIDEPROGRESS: false" );
}
}else if (msg.what == MSG_HID_AD) {
/* Log.d(TAG, "loadBannerAd: set banner gone 0, showingStatusAd " +showingStatusAd);
// Log.d(TAG, "loadBannerAd: set banner gone 0, showingStatusAd " +showingStatusAd);
if(showingStatusAd) {
if (mAd != null) {
mAd.showAd(false, 0, 0);
Log.d(TAG, "loadBannerAd: set banner gone 1");
mAd.hideAds();
// Log.d(TAG, "loadBannerAd: set banner gone 1");
}
showingStatusAd = false;
Log.d(TAG, "loadBannerAd: set banner gone 2");
}*/
}
}else if (msg.what == MSG_SHOW_LOADING) {
@ -492,15 +492,40 @@ public class PageFactory implements ChangeSource{
public TRPage getNextChapterPage(int chaptId,long position,int pageNo){
mBookUtil.setPostition(chaptId,position);
int topAdH =0;
if(Constants.SHOWAD && pageNo >1 && pageNo%Constants.AD_CHAPT_TOP_BANNER_PER_PAGE_COUNT==0){
topAdH =Constants.AD_CHAPT_TOP_BANNER_HEIGHT;
}
TRPage trPage = new TRPage();
totalPageCnt++;
float bannerH =0;
if(Constants.SHOWAD && pageNo >1) {
if (Constants.AD_CHAPT_TOP_BANNER_PER_PAGE_COUNT >0 && totalPageCnt % Constants.AD_CHAPT_TOP_BANNER_PER_PAGE_COUNT == 0) {
bannerH = mContext.getResources().getDimension(R.dimen.topBannerHeight) +0*Constants.ONE_DP_SIZE;
trPage.setTopBannerHeight((int)bannerH);
}
Constants.AD_CHAPT_NATIVE_BANNER_PER_PAGE_COUNT=4;
if (Constants.AD_CHAPT_NATIVE_BANNER_PER_PAGE_COUNT >0 && totalPageCnt % Constants.AD_CHAPT_NATIVE_BANNER_PER_PAGE_COUNT == 0) {
bannerH = mContext.getResources().getDimension(R.dimen.nativeBannerHeight) +4*Constants.ONE_DP_SIZE;
calculateLineCount();
int adLines = (int) ( bannerH / ((m_fontSize + lineSpace)));
int adLine = new Random().nextInt( mLineCount -adLines -1);
adLine =adLine <mLineCount ? adLine :mLineCount-2;
if(adLine>0) {
trPage.setNativeBannerStartLine(adLine);
//trPage.setNativeBannerHeight(Constants.AD_CHAPT_NATIVE_BANNER_HEIGHT);
trPage.setNativeBannerHeight((int)bannerH);
}
Log.d(TAG, String.format("getNextChapterPage: pageNo %s, topBannerHeight %s, adLines %s,adLine %s, nativeBannerHeight %s",
pageNo,trPage.getTopBannerHeight(),adLines,adLine,trPage.getNativeBannerHeight()));
}
}
trPage.setPageNo(pageNo);
trPage.setBegin(position +1);
trPage.setTopBannerHeight(topAdH);
// Log.d(TAG,"page postion next begin:" + (position + 1) + "");
trPage.setLines(getNextLines(chaptId,topAdH));
trPage.setLines(getNextLines(chaptId,trPage));
if(trPage.getNativeBannerStartLine() >0 && trPage.getNativeBannerStartLine() >= trPage.getLines().size()){
trPage.setNativeBannerStartLine(trPage.getLines().size()-1);
}
// Log.d(TAG,"page postion next end:" +mBookUtil.getPosition() + "");
trPage.setEnd(mBookUtil.getPosition(chaptId));
return trPage;
@ -741,8 +766,8 @@ private void hideSysUI(){
}
private void drawStatus(){
if(mBookPageWidget!=null) {
drawStatus(mBookPageWidget.getCurPage());
drawStatus(mBookPageWidget.getNextPage());
// drawStatus(mBookPageWidget.getCurPage());
drawStatus(mBookPageWidget.getNextPage());
}
}
private String loadingTxt ="";
@ -872,8 +897,9 @@ private void hideSysUI(){
fontMetrics = waitPaint.getFontMetricsInt();
baseline = baseline +150;
// 下面这行是实现水平居中drawText对应改为传入targetRect.centerX()
String site = getSite().getName() ==null ? "":getSite().getName();
waitPaint.setTextAlign(Paint.Align.CENTER);
c.drawText("转向第三方网站 " + getSite().getName() , targetRect.centerX(), baseline, waitPaint);
c.drawText("正加载第三方网站 " +site, targetRect.centerX(), baseline, waitPaint);
baseline+=40;
c.drawText(url , targetRect.centerX(), baseline, waitPaint);
@ -904,17 +930,32 @@ private void hideSysUI(){
hideSysUI();
List<String> m_lines = trPage.getLines();
// mAd.showRefresh(View.GONE);
Log.d(TAG, String.format("onDraw: trPage pageno %s,showAd %s",trPage.getPageNo(),showAd));
if(m_lines.size()==0 ){
return;
}
/* try {
throw new Exception("who's ad");
}catch (Exception e){
Log.e(TAG, "onDraw:showTopBanner ",e );
}*/
/* Log.d(TAG, "showloading: ondraw showAd: " +showAd );
try{
throw new Exception("showloading: ondraw mStatus: " +mStatus );
}catch (Exception e){
Log.e(TAG, "showloading: ", e);
}*/
handler.sendEmptyMessage(MSG_HID_AD);
if(showAd && mAd!=null){
handler.sendEmptyMessage(MSG_HID_AD);
// handler.sendEmptyMessage(MSG_HID_AD);
handler.sendEmptyMessage(MSG_HIDEPROGRESS);
}
mStatus =Status.FINISH;
@ -992,35 +1033,51 @@ private void hideSysUI(){
paragraphSpace = prate * lineSpace;
if(mAd!=null){
mAd.showTopBanner(trPage.getTopBannerHeight(),(int)(marginHeight + space));
if(showAd && mAd!=null){
mAd.showTopBanner(trPage.getTopBannerHeight(),(int)(marginHeight));
mAd.showNativeBannerInLines(0,0);
}
if (m_lines.size() > 0) {
float y = marginHeight +trPage.getTopBannerHeight();
float y = marginHeight +(trPage.getTopBannerHeight() >0 ? trPage.getTopBannerHeight() :0);
String lastLine ="";
int lineNo =0;
for (String strLine : m_lines) {
lineNo++;
// if(strLine.endsWith("\n")) {
// if(strLine.charAt(strLine.length()-1) == ('\n' )) {
// Log.d(TAG, strLine);
// Log.d(TAG,"最后字符 。。。" +strLine.charAt(strLine.length()-1) + "");
lastLine =strLine;
if(strLine.length()>0 && ( strLine.charAt(strLine.length()-1) + "" ).equals("\n")){
strLine =strLine.replace("\n","");
y += space;
space =m_fontSize + paragraphSpace;
// Log.d( TAG ,String.format("prepare book 开始新段落 %s, y plus is %s" ,strLine, m_fontSize + paragraphSpace));
}else{
y += space;
space =m_fontSize + lineSpace;
// Log.d(TAG,String.format("prepare book %s,y plus is %s" ,strLine, m_fontSize + lineSpace));
if(lineNo==trPage.getNativeBannerStartLine()){
if(showAd && mAd!=null){
mAd.showNativeBannerInLines(trPage.getNativeBannerHeight(),(int)y);
}
y+=trPage.getNativeBannerHeight() +m_fontSize;
Log.d(TAG, String.format("onDraw showNativeBannerInLines : lineno %s,strline %s ",lineNo,strLine));
}else {
if (strLine.length() > 0 && (strLine.charAt(strLine.length() - 1) + "").equals("\n")) {
strLine = strLine.replace("\n", "");
y += space;
space = m_fontSize + paragraphSpace;
// Log.d( TAG ,String.format("prepare book 开始新段落 %s, y plus is %s" ,strLine, m_fontSize + paragraphSpace));
} else {
y += space;
space = m_fontSize + lineSpace;
// Log.d(TAG,String.format("prepare book %s,y plus is %s" ,strLine, m_fontSize + lineSpace));
}
}
c.drawText(strLine, measureMarginWidth, y, mPaint);
// word.append(strLine);
}
// Log.d(TAG,String.format("getNavigationBarSize mHeight is %s ,last line height %s, power %s, %s",
@ -1028,9 +1085,9 @@ private void hideSysUI(){
float adHeight = mHeight -y - space -marginHeight-statusMarginBottom;
float adY =y +space;
if(showAd) {
if(showAd && trPage.getNativeBannerHeight()==0) {
showAd((int) adHeight, (int) adY);
Log.d(TAG, "loadBannerAd: AD is requested");
Log.d(TAG, "loadBannerAd: AD is requested, adHeight "+adHeight);
}
// Log.d(TAG,String.format("ad + statusMarginBottom %s ",200+ statusMarginBottom));
// Log.d(TAG,String.format("adHeight %s, adY %s",adHeight,adY));
@ -1269,11 +1326,14 @@ private void hideSysUI(){
currentChaptPages = loadCurrentChapt(cancelPage.getChapterNo());
currentPage = getPageForBegin(cancelPage.getBegin()) ;// currentChaptPages.get(0);
// currentPage = getPageForBegin(begin);
if (mBookPageWidget != null) {
/* if (mBookPageWidget != null) {
currentPage(true);
}
}*/
}
currentPage = cancelPage;
if (mBookPageWidget != null) {
currentPage(true);
}
}
public void prepareBook(Novel book){
@ -1499,7 +1559,7 @@ private void hideSysUI(){
}
boolean showChapTitleOnTopWhenNextPage =false;
public List<String> getNextLines(int chaptId,int topAdHeight){
public List<String> getNextLines(int chaptId,TRPage trpage){
List<String> lines = new ArrayList<>();
float width = 0;
float height = 0;
@ -1509,8 +1569,9 @@ private void hideSysUI(){
if(mBookUtil.getPosition(chaptId)==0) {
lines.add("\n");//lines.add("\n");
}
calculateLineCount(topAdHeight);
int adHeight = trpage.getNativeBannerHeight()+trpage.getTopBannerHeight();
calculateLineCount(adHeight );
Log.d(TAG, String.format("getNextChapterPage getNextLines: pageNo %s, adHeight %s, totalLines %s",trpage.getPageNo(),adHeight,mLineCount));
while (mBookUtil.next(true,chaptId) != -1){
char word = (char) mBookUtil.next(false,chaptId);
// Log.d(TAG, String.format(" loadchapt getNextLines() chaptId %s, word '%s'", chaptId,word ));
@ -1530,7 +1591,7 @@ private void hideSysUI(){
line = "";
width = 0;
height += paragraphSpace - lineSpace;
calculateLineCount(topAdHeight+height);
calculateLineCount(adHeight+height);
if (lines.size()>= mLineCount +firstPageLine){
// Log.d(TAG,String.format("lines count limit a %s,lines size %s",mLineCount,lines.size()));
line ="";
@ -1941,6 +2002,7 @@ private void hideSysUI(){
currentChaptPages =null;
preChaptPages=null;
nextChaptPages=null;
totalPageCnt=0;
}
public static Status getStatus(){

View File

@ -13,6 +13,8 @@ public class TRPage {
private boolean isFirstPage;
private List<String> lines = new ArrayList<>();
private int topBannerHeight=0;
private int nativeBannerStartLine=0;
private int nativeBannerHeight=0;
public TRPage( ){
}
@ -52,10 +54,21 @@ public class TRPage {
isFirstPage = firstPage;
}
public int getNativeBannerStartLine() {
return nativeBannerStartLine;
}
public void setNativeBannerStartLine(int nativeBannerStartLine) {
this.nativeBannerStartLine = nativeBannerStartLine;
}
public int getNativeBannerHeight() {
return nativeBannerHeight;
}
public void setNativeBannerHeight(int nativeBannerHeight) {
this.nativeBannerHeight = nativeBannerHeight;
}
public int getPageNo() {
return pageNo;

View File

@ -415,6 +415,7 @@ public class BookPageWidget extends View {
Boolean prePage();
Boolean nextPage();
void cancel();
void showAdAfterAni();
}
private void startAnimation(int delayMillis) {

View File

@ -102,6 +102,33 @@ public class PageWidget extends View {
}
}
/* public void setPageMode2(int pageMode){
switch (pageMode){
case PAGE_MODE_SIMULATION:
mAnimationProvider = new SimulationAnimation(mCurPageBitmap,mNextPageBitmap,mScreenWidth,mScreenHeight);
break;
case PAGE_MODE_COVER:
mAnimationProvider = new CoverAnimation(mCurPageBitmap,mNextPageBitmap,mScreenWidth,mScreenHeight);
break;
case PAGE_MODE_SLIDE:
mAnimationProvider = new SlideAnimation(mCurPageBitmap,mNextPageBitmap,mScreenWidth,mScreenHeight);
break;
case PAGE_MODE_NONE:
mAnimationProvider = new NoneAnimation(mCurPageBitmap,mNextPageBitmap,mScreenWidth,mScreenHeight);
break;
default:
mAnimationProvider = new SimulationAnimation(mCurPageBitmap,mNextPageBitmap,mScreenWidth,mScreenHeight);
}
}
private Bitmap getCurPageBitmap(){
return Bitmap.createBitmap(mScreenWidth, mScreenHeight, Bitmap.Config.RGB_565);
}
private Bitmap getNextPageBitmap(){
return mNextPageBitmap;
}*/
public Bitmap getCurPage(){
return mCurPageBitmap;
}
@ -165,6 +192,7 @@ public class PageWidget extends View {
if(!PageFactory.busy())
if (isMove){
isMove = true;
mTouchListener.hideAdBeforeIni() ;
if (moveX == 0 && moveY ==0) {
//Log.e(TAG,"isMove");
//判断翻得是上一页还是下一页
@ -272,7 +300,9 @@ public class PageWidget extends View {
//Log.e(TAG, "isNext:" + isNext);
if (!noNext) {
isRuning = true;
mAnimationProvider.startAnimation(mScroller);
mTouchListener.showAdAfterIni();
this.postInvalidate();
}
}
@ -318,6 +348,8 @@ public class PageWidget extends View {
Boolean nextPage();
void cancel();
Boolean canCancel();
void showAdAfterIni();
void hideAdBeforeIni();
}
}

View File

@ -89,6 +89,8 @@ public class CoverAnimation extends AnimationProvider {
int duration = (duation * Math.abs(dx)) / mScreenWidth;
Log.e("duration",duration + "");
scroller.startScroll((int) mTouch.x, 0, dx, 0, duration);
Log.d("pageAnimation", "startAnimation: annimaiton is end");
}
}

View File

@ -3,73 +3,104 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tv_native_ad_title"
android:layout_width="200dp"
<LinearLayout
android:id="@+id/llTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:orientation="horizontal"
android:gravity="center_vertical"
android:background="@color/white"
>
<ImageView
android:id="@+id/iv_native_icon"
android:layout_weight="0"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_marginRight="2dp"
android:layout_marginLeft="2dp"
/>
<TextView
android:id="@+id/tv_native_ad_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:ellipsize="end"
android:singleLine="true"
android:text=" "
android:textSize="14sp" />
</LinearLayout>
<ImageView
android:id="@+id/iv_native_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tv_native_ad_title"
android:layout_marginBottom="5dp"
android:layout_below="@id/llTitle"
android:src="@drawable/toutiao_splash_banner"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:scaleType="centerCrop" />
<ImageView
android:id="@+id/iv_native_icon"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_below="@id/iv_native_image"
android:layout_marginLeft="3dp"
android:layout_marginStart="3dp" />
<LinearLayout
android:id="@+id/tv_source_desc_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:orientation="horizontal"
android:gravity="center_vertical"
android:layout_below="@id/iv_native_image"
android:layout_toRightOf="@id/iv_native_icon"
android:layout_toEndOf="@id/iv_native_icon"
android:background="@color/white"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
tools:ignore="UseCompoundDrawables">
<TextView
android:id="@+id/tv_native_ad_desc"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:layout_marginTop="15dp"
android:ellipsize="end"
android:singleLine="true"
android:textSize="14sp" />
<ImageView
android:id="@+id/img_native_dislike"
android:layout_width="20dp"
android:layout_height="20dp"
android:background="@drawable/tt_dislike_icon" />
<TextView
android:layout_weight="0"
android:layout_marginLeft="2dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textSize="12sp"
android:text="@string/ad_title"
/>
<TextView
android:id="@+id/tv_native_ad_title"
android:layout_weight="1"
android:layout_marginLeft="5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textSize="14sp"
android:text=" "
/>
<Button
android:id="@+id/btn_native_creative"
style="@style/buttonCates"
android:layout_weight="0"
android:layout_width="90dp"
android:layout_height="30dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginRight="14dp"
android:layout_marginEnd="14dp"
android:textSize="10sp"
/>
</LinearLayout>
<Button
android:id="@+id/btn_native_creative"
style="@style/buttonCates"
android:layout_width="90dp"
android:layout_height="40dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginRight="14dp"
android:layout_marginEnd="14dp"
android:layout_alignTop="@+id/tv_source_desc_layout"
android:textSize="10sp"
/>
</RelativeLayout>

View File

@ -209,7 +209,7 @@
</LinearLayout>
<FrameLayout
style="@style/frmBannerContainer"
android:layout_height="200dp"
android:layout_height="310dp"
android:id="@+id/banner_container"/>
<LinearLayout style="@style/llGraySplit" />

View File

@ -7,6 +7,7 @@
<FrameLayout
android:id="@+id/banner_container"
android:layout_height="@dimen/topBannerHeight"
style="@style/frmBannerContainer" />
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeLayout"

View File

@ -9,6 +9,7 @@
<FrameLayout
android:id="@+id/banner_container"
android:layout_height="@dimen/topBannerHeight"
style="@style/frmBannerContainer" />

View File

@ -33,6 +33,7 @@
<FrameLayout
android:id="@+id/banner_container"
android:layout_height="@dimen/topBannerHeight"
style="@style/frmBannerContainer"/>
<!-- <include layout="@layout/fragment_jingxuan_cates" />-->

View File

@ -19,7 +19,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="@color/read_dialog_bg"
android:theme="@style/AppTheme.AppBarOverlay"
android:visibility="gone">
@ -31,12 +31,26 @@
android:background="@color/read_dialog_bg"
android:fitsSystemWindows="true"
android:minHeight="?attr/actionBarSize"
app:popupTheme="@style/AppTheme.PopupOverlay" />
app:popupTheme="@style/AppTheme.PopupOverlay" >
</android.support.v7.widget.Toolbar>
<TextView
android:id="@+id/tvUrl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:text="http://abc.om..fd"
android:layout_gravity="bottom"
android:background="@color/read_dialog_bg"
android:textColor="@color/whitesmoke"
android:gravity="bottom"
android:textSize="11sp"
android:ellipsize="end"
android:lines="1"/>
</android.support.design.widget.AppBarLayout>
<!-- <android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"></android.support.v7.widget.RecyclerView>-->
<com.novelbook.android.view.PageWidget
android:id="@+id/bookpage"
android:layout_width="match_parent"
@ -75,24 +89,84 @@
</LinearLayout>-->
<FrameLayout
android:id="@+id/frmAD"
android:visibility="invisible"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
style="@style/frmBannerContainer"
android:layout_height="wrap_content"
android:layout_height="@dimen/nativeBannerHeight"
android:id="@+id/native_banner_container_in_lines"/>
<FrameLayout
style="@style/frmBannerContainer"
android:layout_height="@dimen/topBannerHeight"
android:id="@+id/top_banner_container"
android:visibility="gone"
android:visibility="invisible"
/>
<FrameLayout
style="@style/frmBannerContainer"
android:layout_height="wrap_content"
android:id="@+id/banner_container"
android:visibility="gone"
android:visibility="invisible"
/>
<FrameLayout
style="@style/frmBannerContainer"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/native_banner_container"
android:visibility="gone"
android:visibility="invisible"
/>
</FrameLayout>
<LinearLayout
android:id="@+id/llShelfBottom"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_weight="0"
android:background="@color/white"
android:gravity="center_vertical"
android:layout_gravity="bottom"
android:orientation="vertical"
android:visibility="gone"
android:paddingBottom="0dp"
>
<TextView
style="@style/TextViewTitle"
android:layout_width="match_parent"
android:layout_height="40dp"
android:gravity="center_vertical"
android:text="@string/note"
android:textAlignment="center"
/>
<LinearLayout style="@style/llGraySplit.2dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="60dp"
android:text="@string/put_to_shelf"
android:gravity="center_vertical"
android:textAlignment="center"
/>
<LinearLayout style="@style/llGraySplit.2dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/btnCancel"
style="@style/buttonCates"
android:text="取消"
android:textColor="@color/colorAccent" />
<Button
android:id="@+id/btnShelf"
style="@style/buttonCates"
android:text="加入书架"
android:textColor="@color/colorAccent" />
</LinearLayout>
</LinearLayout>
</FrameLayout>

View File

@ -16,7 +16,7 @@
<!-- 书本高边距 -->
<dimen name="readingMarginHeight">40dp</dimen>
<!-- 状态栏离底部距离 -->
<dimen name="reading_status_margin_bottom">3dp</dimen>
<dimen name="reading_status_margin_bottom">10dp</dimen>
<!-- 行间距 -->
<dimen name="reading_line_spacing">15dp</dimen>
<!-- 段间距 -->
@ -51,6 +51,9 @@
<dimen name="toolbarHeight">40dp</dimen>
<dimen name="app_bar_height_250">240dp</dimen>
<dimen name="_20dp">20dp</dimen>
<dimen name="nativeBannerHeight">280dp</dimen>
<dimen name="one_dp">1dp</dimen>
<dimen name="topBannerHeight">60dp</dimen>
<!-- Default screen margins, per the Android Design guidelines. -->

View File

@ -138,6 +138,9 @@
<string name="cache_novel">全本缓存</string>
<string name="title_navi">如意阅读</string>
<string name="title_ad">广告</string>
<string name="note">提示</string>
<string name="put_to_shelf">喜欢就加入书架吧</string>
<string name="ad_title">[推广]</string>
<string-array name="voicer_cloud_entries">
<item>小燕—女青、中英、普通话</item>

View File

@ -451,10 +451,11 @@
</style>
<style name="frmBannerContainer">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">50dp</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">@dimen/topBannerHeight</item>
<item name="android:layout_centerInParent">true</item>
<item name="android:background">@color/mintcream</item>
<!--<item name="android:background">@color/mintcream</item>-->
<item name="android:background">@color/transparent</item>
<item name="android:visibility">gone</item>
</style>