adjust ad
This commit is contained in:
parent
ad7ed7317d
commit
5f6205b41d
|
@ -34,7 +34,8 @@ static final String TAG = ActivitySetup.class.getSimpleName();
|
||||||
TextView tvVersion;
|
TextView tvVersion;
|
||||||
|
|
||||||
|
|
||||||
|
String mVersion ="";
|
||||||
|
String mCacheSize ="";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLayoutRes() {
|
public int getLayoutRes() {
|
||||||
|
@ -43,8 +44,15 @@ static final String TAG = ActivitySetup.class.getSimpleName();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initViews() {
|
protected void initViews() {
|
||||||
tvVersion.setText(CommonUtil.getVersion(this));
|
new Thread() {
|
||||||
tvCache.setText(FileUtils.getCachedSize());
|
@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
|
@Override
|
||||||
public void fillData() {
|
public void fillData() {
|
||||||
|
|
||||||
|
tvVersion.setText(mVersion);
|
||||||
|
tvCache.setText(mCacheSize);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,10 @@ import com.novelbook.android.adapter.BookListAdapter;
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
|
@ -500,19 +503,45 @@ public abstract class Activity_base extends AppCompatActivity {
|
||||||
|
|
||||||
loadNativeBannerAd(bannerContainer,codeId,690,388);
|
loadNativeBannerAd(bannerContainer,codeId,690,388);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 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) {
|
void loadNativeBannerAd(FrameLayout bannerContainer,String codeId,int width,int height) {
|
||||||
//step4:创建广告请求参数AdSlot,注意其中的setNativeAdtype方法,具体参数含义参考文档
|
//step4:创建广告请求参数AdSlot,注意其中的setNativeAdtype方法,具体参数含义参考文档
|
||||||
|
|
||||||
if (!Constants.SHOWAD || getTTAdNative() == null) {
|
if (!Constants.SHOWAD || getTTAdNative() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(bannerContainer==null) return;
|
|
||||||
|
|
||||||
|
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()
|
final AdSlot adSlot = new AdSlot.Builder()
|
||||||
.setCodeId(codeId)
|
.setCodeId(codeId)
|
||||||
.setSupportDeepLink(true)
|
.setSupportDeepLink(true)
|
||||||
.setImageAcceptedSize(width, height)
|
.setImageAcceptedSize(width, height)
|
||||||
.setNativeAdType(AdSlot.TYPE_BANNER) //请求原生广告时候,请务必调用该方法,设置参数为TYPE_BANNER或TYPE_INTERACTION_AD
|
.setNativeAdType(AdSlot.TYPE_BANNER) //请求原生广告时候,请务必调用该方法,设置参数为TYPE_BANNER或TYPE_INTERACTION_AD
|
||||||
.setAdCount(1)
|
.setAdCount(3)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
//step5:请求广告,对请求回调的广告作渲染处理
|
//step5:请求广告,对请求回调的广告作渲染处理
|
||||||
|
@ -521,11 +550,42 @@ public abstract class Activity_base extends AppCompatActivity {
|
||||||
public void onError(int code, String message) {
|
public void onError(int code, String message) {
|
||||||
// TToast.show(oContext, "load error : " + code + ", " + message);
|
// TToast.show(oContext, "load error : " + code + ", " + message);
|
||||||
Log.e(TAG, "loadBannerAd: " + code + ", " + message);
|
Log.e(TAG, "loadBannerAd: " + code + ", " + message);
|
||||||
|
bannerContainer.setBackgroundResource(R.color.transparent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNativeAdLoad(List<TTNativeAd> ads) {
|
public void onNativeAdLoad(List<TTNativeAd> ads) {
|
||||||
if (ads.get(0) == null||!mShowAd) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
View bannerView = LayoutInflater.from(oContext).inflate(R.layout.ad_toutiao_native_ad, bannerContainer, false);
|
View bannerView = LayoutInflater.from(oContext).inflate(R.layout.ad_toutiao_native_ad, bannerContainer, false);
|
||||||
|
@ -538,14 +598,61 @@ public abstract class Activity_base extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
bannerContainer.removeAllViews();
|
bannerContainer.removeAllViews();
|
||||||
bannerContainer.addView(bannerView);
|
bannerContainer.addView(bannerView);
|
||||||
// bannerContainer.setVisibility(View.VISIBLE);
|
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);
|
Log.d(TAG, "loadBannerAd: set banner VISIBLE,mShowAd " + mShowAd);
|
||||||
//绑定原生广告的数据
|
//绑定原生广告的数据
|
||||||
setAdData(bannerContainer,bannerView, ads.get(0));
|
setAdData(bannerContainer, bannerView, ads.get(0));*/
|
||||||
// mTTAdNative.loadNativeAd(adSlot,null);
|
// 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")
|
@SuppressWarnings("RedundantCast")
|
||||||
private void setAdData(FrameLayout bannerContainer,View nativeView, TTNativeAd nativeAd) {
|
private void setAdData(FrameLayout bannerContainer,View nativeView, TTNativeAd nativeAd) {
|
||||||
|
|
|
@ -141,7 +141,7 @@ public abstract class BasicFragment extends Fragment {
|
||||||
initData();
|
initData();
|
||||||
initViews();
|
initViews();
|
||||||
initSwipeRefreshLayout();
|
initSwipeRefreshLayout();
|
||||||
showBanner(mBannerContainer,260);
|
showBanner(mBannerContainer,(int) getResources().getDimension(R.dimen.topBannerHeight) );
|
||||||
return view;
|
return view;
|
||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
|
|
||||||
|
|
|
@ -46,10 +46,16 @@ public class MyApp extends Application {
|
||||||
initAD();
|
initAD();
|
||||||
}
|
}
|
||||||
private void initialConstants(){
|
private void initialConstants(){
|
||||||
Config confg= Config.createConfig(this);
|
Config config= Config.createConfig(this);
|
||||||
Constants.SEX = confg.getSexOption();
|
Constants.SEX = config.getSexOption();
|
||||||
Constants.SHOWAD =confg.isShowAd();
|
Constants.SHOWAD =config.isShowAd();
|
||||||
Constants.PRE_LOAD_CHAPT =confg.isPreLoadChapter();
|
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(){
|
private void initUmengApi(){
|
||||||
UMConfigure.init(applicationContext,UMConfigure.DEVICE_TYPE_PHONE,null);
|
UMConfigure.init(applicationContext,UMConfigure.DEVICE_TYPE_PHONE,null);
|
||||||
|
|
|
@ -14,8 +14,10 @@ import android.os.Build;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.constraint.solver.GoalRow;
|
||||||
import android.support.design.widget.AppBarLayout;
|
import android.support.design.widget.AppBarLayout;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
|
@ -124,17 +126,24 @@ public class ReadActivity extends Activity_base implements AdInterface {
|
||||||
@BindView(R.id.appbar)
|
@BindView(R.id.appbar)
|
||||||
AppBarLayout appbar;
|
AppBarLayout appbar;
|
||||||
|
|
||||||
|
@BindView(R.id.tvUrl)
|
||||||
|
TextView tvUrl;
|
||||||
|
|
||||||
@BindView(R.id.top_banner_container)
|
@BindView(R.id.top_banner_container)
|
||||||
FrameLayout mTopBannerContainer;
|
FrameLayout mTopBannerContainer;
|
||||||
|
|
||||||
@BindView(R.id.imgLoading)
|
@BindView(R.id.imgLoading)
|
||||||
pl.droidsonroids.gif.GifImageView imgLoading;
|
pl.droidsonroids.gif.GifImageView imgLoading;
|
||||||
|
@BindView(R.id.frmAD)
|
||||||
|
FrameLayout frmAD;
|
||||||
|
|
||||||
@BindView(R.id.native_banner_container )
|
@BindView(R.id.native_banner_container )
|
||||||
FrameLayout mNative_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 Config config;
|
||||||
private WindowManager.LayoutParams lp;
|
private WindowManager.LayoutParams lp;
|
||||||
private Novel book;
|
private Novel book;
|
||||||
|
@ -468,6 +477,20 @@ public class ReadActivity extends Activity_base implements AdInterface {
|
||||||
// Log.d(TAG, "canCancel: cancelPage canCancel ?" + pageFactory.canCancelPage());
|
// Log.d(TAG, "canCancel: cancelPage canCancel ?" + pageFactory.canCancelPage());
|
||||||
return true;//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;
|
return true;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
if(isShow){
|
||||||
|
hideReadSetting();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if(!pageFactory.canExitSilent()){
|
if(!pageFactory.canExitSilent()){
|
||||||
if(book.isOnShelf()){
|
if(book.isOnShelf()){
|
||||||
finish();
|
finish();
|
||||||
}else {
|
}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(){
|
public void showReadSetting(){
|
||||||
isShow = true;
|
isShow = true;
|
||||||
// rl_progress.setVisibility(View.GONE);
|
// 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){
|
if (isSpeaking){
|
||||||
Animation topAnim = AnimationUtils.loadAnimation(this, R.anim.dialog_top_enter);
|
|
||||||
rl_read_bottom.startAnimation(topAnim);
|
rl_read_bottom.startAnimation(topAnim);
|
||||||
rl_read_bottom.setVisibility(View.VISIBLE);
|
rl_read_bottom.setVisibility(View.VISIBLE);
|
||||||
}else {
|
}else {
|
||||||
showSystemUI();
|
showSystemUI();
|
||||||
|
|
||||||
Animation bottomAnim = AnimationUtils.loadAnimation(this, R.anim.dialog_enter);
|
// Animation bottomAnim = AnimationUtils.loadAnimation(this, R.anim.dialog_enter);
|
||||||
Animation topAnim = AnimationUtils.loadAnimation(this, R.anim.dialog_top_enter);
|
|
||||||
rl_bottom.startAnimation(topAnim);
|
rl_bottom.startAnimation(topAnim);
|
||||||
appbar.startAnimation(topAnim);
|
appbar.startAnimation(topAnim);
|
||||||
// ll_top.startAnimation(topAnim);// ll_top.setVisibility(View.VISIBLE);
|
// ll_top.startAnimation(topAnim);// ll_top.setVisibility(View.VISIBLE);
|
||||||
rl_bottom.setVisibility(View.VISIBLE);
|
rl_bottom.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
appbar.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));
|
getWindow().setNavigationBarColor(getResources().getColor(R.color.read_dialog_bg));
|
||||||
}
|
}
|
||||||
pageFactory.setBusy(false);
|
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
|
@Override
|
||||||
|
@ -918,13 +970,16 @@ public class ReadActivity extends Activity_base implements AdInterface {
|
||||||
rl_read_bottom.setVisibility(View.GONE);
|
rl_read_bottom.setVisibility(View.GONE);
|
||||||
// ll_top.setVisibility(View.GONE);
|
// ll_top.setVisibility(View.GONE);
|
||||||
appbar.setVisibility(View.GONE);
|
appbar.setVisibility(View.GONE);
|
||||||
|
tvUrl.setVisibility(View.GONE);
|
||||||
hideSystemUI();
|
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,
|
@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.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) {
|
public void onClick(View view) {
|
||||||
pageFactory.setPageWidget(bookpage);
|
pageFactory.setPageWidget(bookpage);
|
||||||
// if( pageFactory.isReady())
|
// if( pageFactory.isReady())
|
||||||
|
@ -985,6 +1040,15 @@ public class ReadActivity extends Activity_base implements AdInterface {
|
||||||
pageFactory.retryChapt(pageFactory.getCurrentChapter());
|
pageFactory.retryChapt(pageFactory.getCurrentChapter());
|
||||||
btnRefresh.setVisibility(View.GONE);
|
btnRefresh.setVisibility(View.GONE);
|
||||||
break;
|
break;
|
||||||
|
case R.id.btnShelf:
|
||||||
|
book.setOnShelf(true);
|
||||||
|
book.update(book.getId());
|
||||||
|
finish();
|
||||||
|
break;
|
||||||
|
case R.id.btnCancel:
|
||||||
|
finish();
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
// hideSystemUI();
|
// 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
|
@Override
|
||||||
public void showTopBanner( int adHeight,int adY) {
|
public void showTopBanner( int adHeight,int adY) {
|
||||||
hideSystemUI();
|
hideSystemUI();
|
||||||
mTopBannerContainer.setVisibility(View.GONE);
|
mTopBannerContainer.setVisibility(View.INVISIBLE);//翻页引起抖动
|
||||||
|
// mTopBannerContainer.removeAllViews();
|
||||||
if(adHeight<=0){
|
if(adHeight<=0){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Log.d(TAG, String.format("loadBannerAd:showTopBanner width %s, height %s ,adY %s ",Constants.SCREEN_WIDTH_PIX-50,adHeight,adY));
|
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();
|
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);
|
// 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;
|
params.width =-1;
|
||||||
mTopBannerContainer.setLayoutParams(params);
|
mTopBannerContainer.setLayoutParams(params);
|
||||||
mTopBannerContainer.setVisibility(View.VISIBLE);
|
mTopBannerContainer.setVisibility(View.VISIBLE);
|
||||||
|
@ -1031,40 +1124,51 @@ public class ReadActivity extends Activity_base implements AdInterface {
|
||||||
public void showAd(boolean showAd ,int adHeight,int adY) {
|
public void showAd(boolean showAd ,int adHeight,int adY) {
|
||||||
|
|
||||||
hideSystemUI(); mShowAd =showAd;
|
hideSystemUI(); mShowAd =showAd;
|
||||||
mBannerContainer.setVisibility(View.GONE);
|
// mBannerContainer.setVisibility(View.GONE);
|
||||||
mNative_banner_container.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){
|
if(!Constants.SHOWAD){
|
||||||
return;
|
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){
|
if(!showAd){
|
||||||
return;
|
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){
|
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));
|
// Log.d(TAG, String.format("loadBannerAd:width %s, height %s ,adY %s",Constants.SCREEN_WIDTH_PIX-50,adHeight,adY));
|
||||||
|
|
||||||
if(adHeight>500 && adY <500){
|
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);
|
loadNativeBannerAd(mNative_banner_container,BuildConfig.AD_SLOT_TOUTIAO_BANNER_NATIVE_ID);
|
||||||
params.setMargins(20, adY-30, 20, 150);
|
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.setLayoutParams(params);
|
||||||
mNative_banner_container.setVisibility(View.VISIBLE);
|
mNative_banner_container.setVisibility(View.VISIBLE);
|
||||||
|
showTopBanner(0,0);
|
||||||
}else
|
}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);
|
params.setMargins(20, adY-10, 20, 15);
|
||||||
mBannerContainer.setLayoutParams(params);
|
mBannerContainer.setLayoutParams(params);
|
||||||
mBannerContainer.setVisibility(View.VISIBLE);
|
mBannerContainer.setVisibility(View.VISIBLE);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -372,7 +372,8 @@ public class NetUtil {
|
||||||
|
|
||||||
Constants.AD_SPLASH_INVTERVAL =(long) 1000 * ads.getInt("splashInterval");
|
Constants.AD_SPLASH_INVTERVAL =(long) 1000 * ads.getInt("splashInterval");
|
||||||
Constants.AD_SPLASH_PAGES = ads.getInt("splashPageCount");
|
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 ));
|
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);
|
TTAdManagerHolder.init(MyApp.applicationContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Config config = Config.getInstance();
|
||||||
Constants.SHOWAD = ads.getBoolean("showAdsense");
|
Constants.SHOWAD = ads.getBoolean("showAdsense");
|
||||||
Constants.PRE_LOAD_CHAPT= false;//jsonObject.getBoolean("preLoadChapter");
|
Constants.PRE_LOAD_CHAPT= jsonObject.getBoolean("preLoadChapter");
|
||||||
Config.getInstance().setShowAd(Constants.SHOWAD);
|
config.setShowAd(Constants.SHOWAD);
|
||||||
Config.getInstance().setPreLoadChapter(Constants.PRE_LOAD_CHAPT);
|
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 "
|
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 ));
|
,Constants.AD_SPLASH_INVTERVAL,Constants.AD_SPLASH_PAGES, Constants.SHOWAD, Constants.PRE_LOAD_CHAPT ));
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ public interface AdInterface {
|
||||||
*/
|
*/
|
||||||
public void showAd(boolean showAd,int height,int adY);
|
public void showAd(boolean showAd,int height,int adY);
|
||||||
public void showTopBanner(int height,int adY);
|
public void showTopBanner(int height,int adY);
|
||||||
|
public void showNativeBannerInLines(int height,int adY);
|
||||||
public void hideSystemUI();
|
public void hideSystemUI();
|
||||||
public void showRefresh(int visible);
|
public void showRefresh(int visible);
|
||||||
public void showProgressbar(boolean dismissAble,String msg);
|
public void showProgressbar(boolean dismissAble,String msg);
|
||||||
|
@ -15,4 +16,5 @@ public interface AdInterface {
|
||||||
public void showLoading(boolean isShow);
|
public void showLoading(boolean isShow);
|
||||||
public void hideReadSetting();
|
public void hideReadSetting();
|
||||||
public void showReadSetting();
|
public void showReadSetting();
|
||||||
|
public void hideAds();
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,8 @@ public class Config {
|
||||||
public final static boolean SHOW_AD = false;
|
public final static boolean SHOW_AD = false;
|
||||||
public final static String SHOW_AD_KEY = "showAd";
|
public final static String SHOW_AD_KEY = "showAd";
|
||||||
private static final String PRE_LOAD_CHAPT_KEY ="preloadchapt" ;
|
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 Context mContext;
|
||||||
private static Config config;
|
private static Config config;
|
||||||
private SharedPreferences sp;
|
private SharedPreferences sp;
|
||||||
|
@ -224,4 +226,19 @@ public class Config {
|
||||||
public void setPreLoadChapter(boolean isPreloadChapt){
|
public void setPreLoadChapter(boolean isPreloadChapt){
|
||||||
sp.edit().putBoolean(PRE_LOAD_CHAPT_KEY,isPreloadChapt).commit();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.novelbook.android.utils;
|
package com.novelbook.android.utils;
|
||||||
|
|
||||||
|
|
||||||
|
import com.novelbook.android.R;
|
||||||
import com.novelbook.android.bean.ProgressType;
|
import com.novelbook.android.bean.ProgressType;
|
||||||
|
|
||||||
import java.util.List;
|
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_MAX =60*60*24*28; //28 天 ;
|
||||||
public static final int MAXAGE_MULU = 60*60*24*7*2; //2周;;
|
public static final int MAXAGE_MULU = 60*60*24*7*2; //2周;;
|
||||||
public static final String VERSION_ADDRESS ="version.xml";
|
public static final String VERSION_ADDRESS ="version.xml";
|
||||||
|
public static boolean AD_BACKGROUND_TRANSPARENT =true ;
|
||||||
public static boolean SHOWAD =false ;
|
public static boolean SHOWAD =false ;
|
||||||
public static boolean PRE_LOAD_CHAPT = false;
|
public static boolean PRE_LOAD_CHAPT = false;
|
||||||
public static long AD_SPLASH_INVTERVAL = 5*60*1000;//间隔5分钟
|
public static long AD_SPLASH_INVTERVAL = 5*60*1000;//间隔5分钟
|
||||||
public static int AD_SPLASH_PAGES = 15;
|
public static int AD_SPLASH_PAGES = 15;
|
||||||
public static int SCREEN_HEIGHT_PIX =1920 ;
|
public static int SCREEN_HEIGHT_PIX =1920 ;
|
||||||
public static int SCREEN_WIDTH_PIX = 1080;
|
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=0; //每几页show topbanner
|
||||||
public static int AD_CHAPT_TOP_BANNER_PER_PAGE_COUNT=1; //每几页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 LAST_G = 0;//主目录API上次访问时间
|
||||||
public static long MAXAGE_G = 3600;//主目录API上次访问时间
|
public static long MAXAGE_G = 3600;//主目录API上次访问时间
|
||||||
public static String[] HOT_KEYS_VALUE = {};
|
public static String[] HOT_KEYS_VALUE = {};
|
||||||
|
|
|
@ -48,6 +48,7 @@ import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
//import static com.baidu.tts.loopj.AsyncHttpClient.log;
|
//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_NEXTPAGE_FAIL=4;
|
||||||
private final int MSG_HID_AD=5;
|
private final int MSG_HID_AD=5;
|
||||||
private final int MSG_SHOW_LOADING=5;
|
private final int MSG_SHOW_LOADING=5;
|
||||||
|
private static int totalPageCnt =0;
|
||||||
public AdInterface getmAd() {
|
public AdInterface getmAd() {
|
||||||
return mAd;
|
return mAd;
|
||||||
}
|
}
|
||||||
|
@ -237,19 +239,17 @@ public class PageFactory implements ChangeSource{
|
||||||
// mAd.hideProgressbar();
|
// mAd.hideProgressbar();
|
||||||
|
|
||||||
mAd.showLoading(false);
|
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) {
|
}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(showingStatusAd) {
|
||||||
if (mAd != null) {
|
if (mAd != null) {
|
||||||
mAd.showAd(false, 0, 0);
|
mAd.hideAds();
|
||||||
Log.d(TAG, "loadBannerAd: set banner gone 1");
|
// 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) {
|
}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){
|
public TRPage getNextChapterPage(int chaptId,long position,int pageNo){
|
||||||
mBookUtil.setPostition(chaptId,position);
|
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();
|
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.setBegin(position +1);
|
||||||
trPage.setTopBannerHeight(topAdH);
|
|
||||||
// Log.d(TAG,"page postion next begin:" + (position + 1) + "");
|
// 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() + "");
|
// Log.d(TAG,"page postion next end:" +mBookUtil.getPosition() + "");
|
||||||
trPage.setEnd(mBookUtil.getPosition(chaptId));
|
trPage.setEnd(mBookUtil.getPosition(chaptId));
|
||||||
return trPage;
|
return trPage;
|
||||||
|
@ -741,7 +766,7 @@ private void hideSysUI(){
|
||||||
}
|
}
|
||||||
private void drawStatus(){
|
private void drawStatus(){
|
||||||
if(mBookPageWidget!=null) {
|
if(mBookPageWidget!=null) {
|
||||||
drawStatus(mBookPageWidget.getCurPage());
|
// drawStatus(mBookPageWidget.getCurPage());
|
||||||
drawStatus(mBookPageWidget.getNextPage());
|
drawStatus(mBookPageWidget.getNextPage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -872,8 +897,9 @@ private void hideSysUI(){
|
||||||
fontMetrics = waitPaint.getFontMetricsInt();
|
fontMetrics = waitPaint.getFontMetricsInt();
|
||||||
baseline = baseline +150;
|
baseline = baseline +150;
|
||||||
// 下面这行是实现水平居中,drawText对应改为传入targetRect.centerX()
|
// 下面这行是实现水平居中,drawText对应改为传入targetRect.centerX()
|
||||||
|
String site = getSite().getName() ==null ? "":getSite().getName();
|
||||||
waitPaint.setTextAlign(Paint.Align.CENTER);
|
waitPaint.setTextAlign(Paint.Align.CENTER);
|
||||||
c.drawText("转向第三方网站 " + getSite().getName() , targetRect.centerX(), baseline, waitPaint);
|
c.drawText("正加载第三方网站 " +site, targetRect.centerX(), baseline, waitPaint);
|
||||||
baseline+=40;
|
baseline+=40;
|
||||||
c.drawText(url , targetRect.centerX(), baseline, waitPaint);
|
c.drawText(url , targetRect.centerX(), baseline, waitPaint);
|
||||||
|
|
||||||
|
@ -904,17 +930,32 @@ private void hideSysUI(){
|
||||||
hideSysUI();
|
hideSysUI();
|
||||||
List<String> m_lines = trPage.getLines();
|
List<String> m_lines = trPage.getLines();
|
||||||
// mAd.showRefresh(View.GONE);
|
// mAd.showRefresh(View.GONE);
|
||||||
|
|
||||||
|
Log.d(TAG, String.format("onDraw: trPage pageno %s,showAd %s",trPage.getPageNo(),showAd));
|
||||||
|
|
||||||
|
|
||||||
if(m_lines.size()==0 ){
|
if(m_lines.size()==0 ){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
/* try {
|
||||||
|
throw new Exception("who's ad");
|
||||||
|
}catch (Exception e){
|
||||||
|
Log.e(TAG, "onDraw:showTopBanner ",e );
|
||||||
|
}*/
|
||||||
/* Log.d(TAG, "showloading: ondraw showAd: " +showAd );
|
/* Log.d(TAG, "showloading: ondraw showAd: " +showAd );
|
||||||
try{
|
try{
|
||||||
throw new Exception("showloading: ondraw mStatus: " +mStatus );
|
throw new Exception("showloading: ondraw mStatus: " +mStatus );
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
Log.e(TAG, "showloading: ", e);
|
Log.e(TAG, "showloading: ", e);
|
||||||
}*/
|
}*/
|
||||||
if(showAd && mAd!=null){
|
|
||||||
|
|
||||||
|
|
||||||
handler.sendEmptyMessage(MSG_HID_AD);
|
handler.sendEmptyMessage(MSG_HID_AD);
|
||||||
|
|
||||||
|
|
||||||
|
if(showAd && mAd!=null){
|
||||||
|
// handler.sendEmptyMessage(MSG_HID_AD);
|
||||||
handler.sendEmptyMessage(MSG_HIDEPROGRESS);
|
handler.sendEmptyMessage(MSG_HIDEPROGRESS);
|
||||||
}
|
}
|
||||||
mStatus =Status.FINISH;
|
mStatus =Status.FINISH;
|
||||||
|
@ -992,35 +1033,51 @@ private void hideSysUI(){
|
||||||
paragraphSpace = prate * lineSpace;
|
paragraphSpace = prate * lineSpace;
|
||||||
|
|
||||||
|
|
||||||
if(mAd!=null){
|
if(showAd && mAd!=null){
|
||||||
mAd.showTopBanner(trPage.getTopBannerHeight(),(int)(marginHeight + space));
|
mAd.showTopBanner(trPage.getTopBannerHeight(),(int)(marginHeight));
|
||||||
|
mAd.showNativeBannerInLines(0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (m_lines.size() > 0) {
|
if (m_lines.size() > 0) {
|
||||||
|
|
||||||
float y = marginHeight +trPage.getTopBannerHeight();
|
float y = marginHeight +(trPage.getTopBannerHeight() >0 ? trPage.getTopBannerHeight() :0);
|
||||||
String lastLine ="";
|
String lastLine ="";
|
||||||
|
int lineNo =0;
|
||||||
for (String strLine : m_lines) {
|
for (String strLine : m_lines) {
|
||||||
|
lineNo++;
|
||||||
// if(strLine.endsWith("\n")) {
|
// if(strLine.endsWith("\n")) {
|
||||||
// if(strLine.charAt(strLine.length()-1) == ('\n' )) {
|
// if(strLine.charAt(strLine.length()-1) == ('\n' )) {
|
||||||
// Log.d(TAG, strLine);
|
// Log.d(TAG, strLine);
|
||||||
// Log.d(TAG,"最后字符 。。。" +strLine.charAt(strLine.length()-1) + "");
|
// Log.d(TAG,"最后字符 。。。" +strLine.charAt(strLine.length()-1) + "");
|
||||||
lastLine =strLine;
|
lastLine =strLine;
|
||||||
|
|
||||||
|
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")) {
|
if (strLine.length() > 0 && (strLine.charAt(strLine.length() - 1) + "").equals("\n")) {
|
||||||
strLine = strLine.replace("\n", "");
|
strLine = strLine.replace("\n", "");
|
||||||
|
|
||||||
y += space;
|
y += space;
|
||||||
space = m_fontSize + paragraphSpace;
|
space = m_fontSize + paragraphSpace;
|
||||||
|
|
||||||
// Log.d( TAG ,String.format("prepare book 开始新段落 %s, y plus is %s" ,strLine, m_fontSize + paragraphSpace));
|
// Log.d( TAG ,String.format("prepare book 开始新段落 %s, y plus is %s" ,strLine, m_fontSize + paragraphSpace));
|
||||||
} else {
|
} else {
|
||||||
y += space;
|
y += space;
|
||||||
space = m_fontSize + lineSpace;
|
space = m_fontSize + lineSpace;
|
||||||
|
|
||||||
// Log.d(TAG,String.format("prepare book %s,y plus is %s" ,strLine, 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);
|
c.drawText(strLine, measureMarginWidth, y, mPaint);
|
||||||
|
|
||||||
// word.append(strLine);
|
// word.append(strLine);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log.d(TAG,String.format("getNavigationBarSize mHeight is %s ,last line height %s, power %s, %s",
|
// 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 adHeight = mHeight -y - space -marginHeight-statusMarginBottom;
|
||||||
float adY =y +space;
|
float adY =y +space;
|
||||||
if(showAd) {
|
if(showAd && trPage.getNativeBannerHeight()==0) {
|
||||||
showAd((int) adHeight, (int) adY);
|
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("ad + statusMarginBottom %s ",200+ statusMarginBottom));
|
||||||
// Log.d(TAG,String.format("adHeight %s, adY %s",adHeight,adY));
|
// Log.d(TAG,String.format("adHeight %s, adY %s",adHeight,adY));
|
||||||
|
@ -1269,12 +1326,15 @@ private void hideSysUI(){
|
||||||
currentChaptPages = loadCurrentChapt(cancelPage.getChapterNo());
|
currentChaptPages = loadCurrentChapt(cancelPage.getChapterNo());
|
||||||
currentPage = getPageForBegin(cancelPage.getBegin()) ;// currentChaptPages.get(0);
|
currentPage = getPageForBegin(cancelPage.getBegin()) ;// currentChaptPages.get(0);
|
||||||
// currentPage = getPageForBegin(begin);
|
// currentPage = getPageForBegin(begin);
|
||||||
|
/* if (mBookPageWidget != null) {
|
||||||
|
currentPage(true);
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
currentPage = cancelPage;
|
||||||
if (mBookPageWidget != null) {
|
if (mBookPageWidget != null) {
|
||||||
currentPage(true);
|
currentPage(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
currentPage = cancelPage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void prepareBook(Novel book){
|
public void prepareBook(Novel book){
|
||||||
|
|
||||||
|
@ -1499,7 +1559,7 @@ private void hideSysUI(){
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean showChapTitleOnTopWhenNextPage =false;
|
boolean showChapTitleOnTopWhenNextPage =false;
|
||||||
public List<String> getNextLines(int chaptId,int topAdHeight){
|
public List<String> getNextLines(int chaptId,TRPage trpage){
|
||||||
List<String> lines = new ArrayList<>();
|
List<String> lines = new ArrayList<>();
|
||||||
float width = 0;
|
float width = 0;
|
||||||
float height = 0;
|
float height = 0;
|
||||||
|
@ -1509,8 +1569,9 @@ private void hideSysUI(){
|
||||||
if(mBookUtil.getPosition(chaptId)==0) {
|
if(mBookUtil.getPosition(chaptId)==0) {
|
||||||
lines.add("\n");//lines.add("\n");
|
lines.add("\n");//lines.add("\n");
|
||||||
}
|
}
|
||||||
|
int adHeight = trpage.getNativeBannerHeight()+trpage.getTopBannerHeight();
|
||||||
calculateLineCount(topAdHeight);
|
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){
|
while (mBookUtil.next(true,chaptId) != -1){
|
||||||
char word = (char) mBookUtil.next(false,chaptId);
|
char word = (char) mBookUtil.next(false,chaptId);
|
||||||
// Log.d(TAG, String.format(" loadchapt getNextLines(), chaptId %s, word '%s'", chaptId,word ));
|
// Log.d(TAG, String.format(" loadchapt getNextLines(), chaptId %s, word '%s'", chaptId,word ));
|
||||||
|
@ -1530,7 +1591,7 @@ private void hideSysUI(){
|
||||||
line = "";
|
line = "";
|
||||||
width = 0;
|
width = 0;
|
||||||
height += paragraphSpace - lineSpace;
|
height += paragraphSpace - lineSpace;
|
||||||
calculateLineCount(topAdHeight+height);
|
calculateLineCount(adHeight+height);
|
||||||
if (lines.size()>= mLineCount +firstPageLine){
|
if (lines.size()>= mLineCount +firstPageLine){
|
||||||
// Log.d(TAG,String.format("lines count limit a %s,lines size %s",mLineCount,lines.size()));
|
// Log.d(TAG,String.format("lines count limit a %s,lines size %s",mLineCount,lines.size()));
|
||||||
line ="";
|
line ="";
|
||||||
|
@ -1941,6 +2002,7 @@ private void hideSysUI(){
|
||||||
currentChaptPages =null;
|
currentChaptPages =null;
|
||||||
preChaptPages=null;
|
preChaptPages=null;
|
||||||
nextChaptPages=null;
|
nextChaptPages=null;
|
||||||
|
totalPageCnt=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Status getStatus(){
|
public static Status getStatus(){
|
||||||
|
|
|
@ -13,6 +13,8 @@ public class TRPage {
|
||||||
private boolean isFirstPage;
|
private boolean isFirstPage;
|
||||||
private List<String> lines = new ArrayList<>();
|
private List<String> lines = new ArrayList<>();
|
||||||
private int topBannerHeight=0;
|
private int topBannerHeight=0;
|
||||||
|
private int nativeBannerStartLine=0;
|
||||||
|
private int nativeBannerHeight=0;
|
||||||
public TRPage( ){
|
public TRPage( ){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -52,10 +54,21 @@ public class TRPage {
|
||||||
isFirstPage = firstPage;
|
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() {
|
public int getPageNo() {
|
||||||
return pageNo;
|
return pageNo;
|
||||||
|
|
|
@ -415,6 +415,7 @@ public class BookPageWidget extends View {
|
||||||
Boolean prePage();
|
Boolean prePage();
|
||||||
Boolean nextPage();
|
Boolean nextPage();
|
||||||
void cancel();
|
void cancel();
|
||||||
|
void showAdAfterAni();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startAnimation(int delayMillis) {
|
private void startAnimation(int delayMillis) {
|
||||||
|
|
|
@ -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(){
|
public Bitmap getCurPage(){
|
||||||
return mCurPageBitmap;
|
return mCurPageBitmap;
|
||||||
}
|
}
|
||||||
|
@ -165,6 +192,7 @@ public class PageWidget extends View {
|
||||||
if(!PageFactory.busy())
|
if(!PageFactory.busy())
|
||||||
if (isMove){
|
if (isMove){
|
||||||
isMove = true;
|
isMove = true;
|
||||||
|
mTouchListener.hideAdBeforeIni() ;
|
||||||
if (moveX == 0 && moveY ==0) {
|
if (moveX == 0 && moveY ==0) {
|
||||||
//Log.e(TAG,"isMove");
|
//Log.e(TAG,"isMove");
|
||||||
//判断翻得是上一页还是下一页
|
//判断翻得是上一页还是下一页
|
||||||
|
@ -272,7 +300,9 @@ public class PageWidget extends View {
|
||||||
//Log.e(TAG, "isNext:" + isNext);
|
//Log.e(TAG, "isNext:" + isNext);
|
||||||
if (!noNext) {
|
if (!noNext) {
|
||||||
isRuning = true;
|
isRuning = true;
|
||||||
|
|
||||||
mAnimationProvider.startAnimation(mScroller);
|
mAnimationProvider.startAnimation(mScroller);
|
||||||
|
mTouchListener.showAdAfterIni();
|
||||||
this.postInvalidate();
|
this.postInvalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -318,6 +348,8 @@ public class PageWidget extends View {
|
||||||
Boolean nextPage();
|
Boolean nextPage();
|
||||||
void cancel();
|
void cancel();
|
||||||
Boolean canCancel();
|
Boolean canCancel();
|
||||||
|
void showAdAfterIni();
|
||||||
|
void hideAdBeforeIni();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,8 @@ public class CoverAnimation extends AnimationProvider {
|
||||||
int duration = (duation * Math.abs(dx)) / mScreenWidth;
|
int duration = (duation * Math.abs(dx)) / mScreenWidth;
|
||||||
Log.e("duration",duration + "");
|
Log.e("duration",duration + "");
|
||||||
scroller.startScroll((int) mTouch.x, 0, dx, 0, duration);
|
scroller.startScroll((int) mTouch.x, 0, dx, 0, duration);
|
||||||
|
|
||||||
|
Log.d("pageAnimation", "startAnimation: annimaiton is end");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,73 +3,104 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
<LinearLayout
|
||||||
<TextView
|
android:id="@+id/llTitle"
|
||||||
android:id="@+id/tv_native_ad_title"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="200dp"
|
|
||||||
android:layout_height="wrap_content"
|
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:singleLine="true"
|
||||||
|
android:text=" "
|
||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/iv_native_image"
|
android:id="@+id/iv_native_image"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/tv_native_ad_title"
|
android:layout_below="@id/llTitle"
|
||||||
android:layout_marginBottom="5dp"
|
android:src="@drawable/toutiao_splash_banner"
|
||||||
|
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_marginLeft="10dp"
|
||||||
android:layout_marginRight="10dp"
|
android:layout_marginRight="10dp"
|
||||||
android:scaleType="centerCrop" />
|
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
|
<LinearLayout
|
||||||
android:id="@+id/tv_source_desc_layout"
|
android:id="@+id/tv_source_desc_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center_vertical"
|
||||||
android:layout_below="@id/iv_native_image"
|
android:layout_below="@id/iv_native_image"
|
||||||
android:layout_toRightOf="@id/iv_native_icon"
|
android:background="@color/white"
|
||||||
android:layout_toEndOf="@id/iv_native_icon"
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
tools:ignore="UseCompoundDrawables">
|
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
|
<ImageView
|
||||||
android:id="@+id/img_native_dislike"
|
android:id="@+id/img_native_dislike"
|
||||||
android:layout_width="20dp"
|
android:layout_width="20dp"
|
||||||
android:layout_height="20dp"
|
android:layout_height="20dp"
|
||||||
android:background="@drawable/tt_dislike_icon" />
|
android:background="@drawable/tt_dislike_icon" />
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
|
<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
|
<Button
|
||||||
android:id="@+id/btn_native_creative"
|
android:id="@+id/btn_native_creative"
|
||||||
style="@style/buttonCates"
|
style="@style/buttonCates"
|
||||||
|
android:layout_weight="0"
|
||||||
android:layout_width="90dp"
|
android:layout_width="90dp"
|
||||||
android:layout_height="40dp"
|
android:layout_height="30dp"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_marginRight="14dp"
|
android:layout_marginRight="14dp"
|
||||||
android:layout_marginEnd="14dp"
|
android:layout_marginEnd="14dp"
|
||||||
android:layout_alignTop="@+id/tv_source_desc_layout"
|
|
||||||
android:textSize="10sp"
|
android:textSize="10sp"
|
||||||
/>
|
/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
|
@ -209,7 +209,7 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
style="@style/frmBannerContainer"
|
style="@style/frmBannerContainer"
|
||||||
android:layout_height="200dp"
|
android:layout_height="310dp"
|
||||||
android:id="@+id/banner_container"/>
|
android:id="@+id/banner_container"/>
|
||||||
<LinearLayout style="@style/llGraySplit" />
|
<LinearLayout style="@style/llGraySplit" />
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/banner_container"
|
android:id="@+id/banner_container"
|
||||||
|
android:layout_height="@dimen/topBannerHeight"
|
||||||
style="@style/frmBannerContainer" />
|
style="@style/frmBannerContainer" />
|
||||||
<android.support.v4.widget.SwipeRefreshLayout
|
<android.support.v4.widget.SwipeRefreshLayout
|
||||||
android:id="@+id/swipeLayout"
|
android:id="@+id/swipeLayout"
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/banner_container"
|
android:id="@+id/banner_container"
|
||||||
|
android:layout_height="@dimen/topBannerHeight"
|
||||||
style="@style/frmBannerContainer" />
|
style="@style/frmBannerContainer" />
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/banner_container"
|
android:id="@+id/banner_container"
|
||||||
|
android:layout_height="@dimen/topBannerHeight"
|
||||||
style="@style/frmBannerContainer"/>
|
style="@style/frmBannerContainer"/>
|
||||||
<!-- <include layout="@layout/fragment_jingxuan_cates" />-->
|
<!-- <include layout="@layout/fragment_jingxuan_cates" />-->
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
|
android:background="@color/read_dialog_bg"
|
||||||
android:theme="@style/AppTheme.AppBarOverlay"
|
android:theme="@style/AppTheme.AppBarOverlay"
|
||||||
|
|
||||||
android:visibility="gone">
|
android:visibility="gone">
|
||||||
|
@ -31,12 +31,26 @@
|
||||||
android:background="@color/read_dialog_bg"
|
android:background="@color/read_dialog_bg"
|
||||||
android:fitsSystemWindows="true"
|
android:fitsSystemWindows="true"
|
||||||
android:minHeight="?attr/actionBarSize"
|
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.design.widget.AppBarLayout>
|
||||||
<!-- <android.support.v7.widget.RecyclerView
|
<!-- <android.support.v7.widget.RecyclerView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"></android.support.v7.widget.RecyclerView>-->
|
android:layout_height="match_parent"></android.support.v7.widget.RecyclerView>-->
|
||||||
|
|
||||||
<com.novelbook.android.view.PageWidget
|
<com.novelbook.android.view.PageWidget
|
||||||
android:id="@+id/bookpage"
|
android:id="@+id/bookpage"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -75,24 +89,84 @@
|
||||||
|
|
||||||
</LinearLayout>-->
|
</LinearLayout>-->
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/frmAD"
|
||||||
|
android:visibility="invisible"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
style="@style/frmBannerContainer"
|
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:id="@+id/top_banner_container"
|
||||||
android:visibility="gone"
|
android:visibility="invisible"
|
||||||
/>
|
/>
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
style="@style/frmBannerContainer"
|
style="@style/frmBannerContainer"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/banner_container"
|
android:id="@+id/banner_container"
|
||||||
android:visibility="gone"
|
android:visibility="invisible"
|
||||||
/>
|
/>
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
style="@style/frmBannerContainer"
|
style="@style/frmBannerContainer"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
android:id="@+id/native_banner_container"
|
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>
|
</FrameLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<!-- 书本高边距 -->
|
<!-- 书本高边距 -->
|
||||||
<dimen name="readingMarginHeight">40dp</dimen>
|
<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>
|
<dimen name="reading_line_spacing">15dp</dimen>
|
||||||
<!-- 段间距 -->
|
<!-- 段间距 -->
|
||||||
|
@ -51,6 +51,9 @@
|
||||||
<dimen name="toolbarHeight">40dp</dimen>
|
<dimen name="toolbarHeight">40dp</dimen>
|
||||||
<dimen name="app_bar_height_250">240dp</dimen>
|
<dimen name="app_bar_height_250">240dp</dimen>
|
||||||
<dimen name="_20dp">20dp</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. -->
|
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||||
|
|
|
@ -138,6 +138,9 @@
|
||||||
<string name="cache_novel">全本缓存</string>
|
<string name="cache_novel">全本缓存</string>
|
||||||
<string name="title_navi">如意阅读</string>
|
<string name="title_navi">如意阅读</string>
|
||||||
<string name="title_ad">广告</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">
|
<string-array name="voicer_cloud_entries">
|
||||||
<item>小燕—女青、中英、普通话</item>
|
<item>小燕—女青、中英、普通话</item>
|
||||||
|
|
|
@ -451,10 +451,11 @@
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="frmBannerContainer">
|
<style name="frmBannerContainer">
|
||||||
<item name="android:layout_width">wrap_content</item>
|
<item name="android:layout_width">match_parent</item>
|
||||||
<item name="android:layout_height">50dp</item>
|
<item name="android:layout_height">@dimen/topBannerHeight</item>
|
||||||
<item name="android:layout_centerInParent">true</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>
|
<item name="android:visibility">gone</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue