ad 翻页效果

This commit is contained in:
mwang 2019-06-21 23:19:57 +08:00
parent 5825723362
commit 95546f9b90
21 changed files with 299 additions and 64 deletions

View File

@ -6,7 +6,7 @@
<uses-permission android:name="android.permission.INTERNET" /> <!-- <uses-permission android:name="android.permission.VIBRATE" /> -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<!--<uses-permission android:name="android.permission.READ_PHONE_STATE" />-->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<!-- chanshanjia-->

View File

@ -144,6 +144,7 @@ public class SplashActivity extends Activity implements WeakHandler.IHandler, Sp
} else if (Constants.AD_SETTING.getSplash2().getSource() == Constants.AD_TOUTIAO) {
// rid = R.layout.ad_toutiao_activity_splash;
// goToMainActivity();
finish();//头条不可作为返回全屏广告
return;
}else if (Constants.AD_SETTING.getSplash2() .getSource() == Constants.AD_MOB) {
// goToMainActivity();

View File

@ -61,11 +61,11 @@ public class SplashAdManager implements Application.ActivityLifecycleCallbacks,
getAdMob(activity);
}
Log.d(TAG, "onActivityCreated:mInterstitialAd initialized ");
if(activity instanceof Main2Activity){
/* if(activity instanceof Main2Activity){
//showAd(activity);
Log.d("zzr", " 启动应用");
}
}*/
}
@Override
@ -80,7 +80,7 @@ public class SplashAdManager implements Application.ActivityLifecycleCallbacks,
showSplashAd(activity);
Log.d("zzr", "从广告页回到前台");
Log.d(TAG, "从广告页回到前台");
}
}
@ -160,8 +160,8 @@ public class SplashAdManager implements Application.ActivityLifecycleCallbacks,
return false;
}
long in = new Date().getTime() -lastAd;
int interVal = Constants.AD_SETTING.getSplash2().getInterval4Display()*1000;
Log.d("zzr", "canShowAd: interval is, " +in + ", canshow? "+ (in >interVal));
int interVal = Constants.AD_SETTING.getSplash2().getInterval4Display()*10;
Log.d(TAG, "canShowAd: interval is, " +in + ", canshow? "+ (in >interVal));
return in >interVal;
}
public static void setSplashTime(){ lastAd = new Date().getTime(); }

View File

@ -97,6 +97,7 @@ import static com.novelbook.android.utils.Constants.AD_TOUTIAO;
public abstract class Activity_base extends AppCompatActivity implements NativeExpressAD.NativeExpressADListener {
private static final int MSG_AD_LOAD =10 ;
private static String TAG ="Activity_base";
private ProgressDialog mProgressDialog;
MyApp application;
@ -304,6 +305,9 @@ public abstract class Activity_base extends AppCompatActivity implements Native
}else if (msg.what == MSG_VERSION_FAILE) {
Toast.makeText(Activity_base.this, "版本检查失败", Toast.LENGTH_LONG).show();
}else if (msg.what == MSG_AD_LOAD) {
attachAd();
}
hideProgress();
@ -311,7 +315,9 @@ public abstract class Activity_base extends AppCompatActivity implements Native
}
};
protected void attachAd(){
}
class MyViewHolder extends RecyclerView.ViewHolder {
@ -790,6 +796,9 @@ public abstract class Activity_base extends AppCompatActivity implements Native
// Log.d(TAG, "loadBannerAd: set banner VISIBLE,mShowAd " + mShowAd);
//绑定原生广告的数据
setAdData(bannerContainer, bannerView, nativeAd);
handler.sendEmptyMessageDelayed( MSG_AD_LOAD,500);
// mTTAdNative.loadNativeAd(adSlot,null);
}

View File

@ -25,6 +25,7 @@ import com.novelbook.android.db.Chapter;
import com.novelbook.android.db.DownloadTask;
import com.novelbook.android.db.Novel;
import com.novelbook.android.netutils.NetUtil;
import com.novelbook.android.utils.Constants;
import com.novelbook.android.utils.PageFactory;
import com.umeng.analytics.MobclickAgent;
@ -101,6 +102,7 @@ public class CatalogFragment extends BasicFragment implements MarkActivity.Sortc
}else btnRefresh.setVisibility(View.GONE);
}
@OnClick(R.id.btnRefresh)
@ -343,5 +345,6 @@ public class CatalogFragment extends BasicFragment implements MarkActivity.Sortc
if (mProgressDialog2.isShowing()) {
mProgressDialog2.dismiss();
}
mSwipeRefresh.setRefreshing(false);
}
}

View File

@ -104,11 +104,16 @@ public class Fragment_Shelf extends BasicFragment {
private void loadNovelsOnShelf() {
bookLists = Novel.getNovelsOnShelf();
noveIds = "";
int i=0;
for (Novel novel : bookLists) {
if (novel.isFinished() || novel.isLocalBook() || novel.isUpdated()) {
continue;
}
if(i>Constants.MAX_SHELF_CNT){
break;
}
noveIds += novel.getNovelId() + ",";
i++;
}
}
@ -152,7 +157,7 @@ public class Fragment_Shelf extends BasicFragment {
*/
private void getUpdatedData() {
loadNovelsOnShelf();
List<Integer> novelIds;
OnSuccessAndFaultListener successAndFaultListener = new OnSuccessAndFaultListener() {
@Override
@ -167,7 +172,7 @@ public class Fragment_Shelf extends BasicFragment {
novel2.checkAndUpdate();
}
}
loadNovelsOnShelf();
// loadNovelsOnShelf();
/* for(Novel nove : bookLists){

View File

@ -12,11 +12,13 @@ import android.view.MenuItem;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import com.flyco.tablayout.SlidingTabLayout;
import com.novelbook.android.adapter.MyPagerAdapter;
import com.novelbook.android.db.Chapter;
import com.novelbook.android.utils.Config;
import com.novelbook.android.utils.Constants;
import com.novelbook.android.utils.PageFactory;
import java.util.ArrayList;
@ -44,7 +46,8 @@ public class MarkActivity extends Activity_base {
ImageButton ibSort;
@BindView(R.id.btnRefresh)
ImageButton btnRefresh;*/
@BindView(R.id.tvSource)
TextView tvSource;
private PageFactory pageFactory;
/* private Config config;
@ -100,7 +103,7 @@ public class MarkActivity extends Activity_base {
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle(pageFactory.getBookName());
}
tvSource.setText(String.format("以下目录及内容来自%s%s",pageFactory.getSite().getName(), Constants.SHOW_NOVEL_CHAPTER_URL ? pageFactory.getSite().getMuluUrl():""));
pager.setAdapter(new MyPagerAdapter(getSupportFragmentManager(),pageFactory.getNovle().getId()));
tabLayout.setViewPager(pager);

View File

@ -8,9 +8,13 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.SQLException;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Point;
import android.graphics.Typeface;
import android.os.Build;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable;
@ -68,6 +72,9 @@ import com.umeng.analytics.MobclickAgent;
import org.litepal.LitePal;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
@ -135,12 +142,16 @@ public class ReadActivity extends Activity_base implements AdInterface {
@BindView(R.id.imgLoading)
pl.droidsonroids.gif.GifImageView imgLoading;
@BindView(R.id.frmAD)
FrameLayout frmAD;
LinearLayout frmAD;
@BindView(R.id.native_banner_container )
FrameLayout mNative_status_banner_container;
@BindView(R.id.banner_container )
FrameLayout mBannerContainer;
@BindView(R.id.frmContainer )
FrameLayout frmContainer;
@BindView(R.id.llShelfBottom)
LinearLayout llShelf;
private Config config;
@ -436,8 +447,13 @@ public class ReadActivity extends Activity_base implements AdInterface {
if (isShow || isSpeaking){
// return false;
}
// bookpage.setetCurPage(loadBitmapFromView(frmContainer));
// bookpage.setFrmContainer(frmContainer);
Bitmap bitmap =loadBitmapFromView(frmContainer);
hideAd();
pageFactory.prePage();
bookpage.setetCurPage( bitmap);
SplashAdManager.plusPage(ReadActivity.this);
if (pageFactory.isfirstPage() || !pageFactory.isReady()) {
return false;
@ -457,9 +473,15 @@ public class ReadActivity extends Activity_base implements AdInterface {
if (isShow || isSpeaking){
// return false;
}
//
// bookpage.setFrmContainer(frmContainer);
Bitmap bitmap =loadBitmapFromView(frmContainer);
hideAd();
pageFactory.nextPage();
bookpage.setetCurPage(bitmap);
SplashAdManager.plusPage(ReadActivity.this);
Log.d(TAG, "onTouchEvent:set current bitmap set new bitmap");
if (pageFactory.islastPage() || !pageFactory.isReady()) {
return false;
}
@ -489,19 +511,104 @@ public class ReadActivity extends Activity_base implements AdInterface {
@Override
public void hideAdBeforeIni() {
// if(frmAD.getVisibility()== View.VISIBLE)
// frmAD.setVisibility(View.INVISIBLE);
/* if(mBannerContainer.getVisibility()== View.VISIBLE)
mBannerContainer.setVisibility(View.GONE);*/
// hideAd();
}
});
}
void hideAd () {
/* if(frmAD.getVisibility()== View.VISIBLE)
frmAD.setVisibility(View.INVISIBLE);*/
// if(mTopBannerContainer.getVisibility()== View.VISIBLE)
// mTopBannerContainer.setVisibility(View.INVISIBLE);
if(mBannerContainer.getVisibility()== View.VISIBLE)
mBannerContainer.setVisibility(View.GONE);
// mBannerContainer.removeAllViews();
// Log.d(TAG, "pageAnimation hideAdBeforeIni: ");
}
});
public Bitmap getBitmapWithAd(){
return loadBitmapFromView(frmContainer);
}
@Override
protected void attachAd(){
/* if(bookpage.isRunning()){
return;
}
Bitmap bitmap =loadBitmapFromView(frmContainer);
savePicture(bitmap);
pageFactory.getPageWidget(). setetCurPage(bitmap);
pageFactory.getPageWidget().setPageMode(config.getPageMode());
Log.d(TAG, "attachAd: ad attached");*/
}
private Bitmap loadBitmapFromView(View v) {
int w=v.getWidth();int h=v.getHeight();Bitmap bmp=Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
Canvas c=new Canvas(bmp);
c.drawColor(Color.WHITE);/** 如果不设置canvas画布为白色则生成透明 */
v.layout(0,0,w,h);
v.draw(c);
// savePicture(bmp,new Date().getTime()+".jpg");
return bmp;
}
public void savePicture(Bitmap bm) {
String fileName =new Date().getTime()+".jpg";
if (bm == null) {
Toast.makeText(this, "savePicture null !", Toast.LENGTH_SHORT).show();
Log.d("SSSSSSSSSSS", "savePicture: savePicture null ");
return;
}
String PATH_LOGCAT = Environment.getExternalStorageDirectory()
.getAbsolutePath() + File.separator + "anovelbmp";
File foder = new File(PATH_LOGCAT);
if (!foder.exists()) {
foder.mkdirs();
}
File myCaptureFile = new File(foder, fileName);
try {
if (!myCaptureFile.exists()) {
myCaptureFile.createNewFile();
}
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(myCaptureFile));
bm.compress(Bitmap.CompressFormat.JPEG, 90, bos);
bos.flush();
bos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public static Bitmap convertViewToBitmap(View view){
view.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
view.buildDrawingCache();
Bitmap bitmap = view.getDrawingCache();
return bitmap;
}
public Bitmap screenShot(View view) {
Log.d(TAG, "screenShot: .....");
view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
Bitmap bmp = view.getDrawingCache();
Bitmap ret = Bitmap.createBitmap(bmp, 0, 0, Constants.SCREEN_WIDTH_PIX, Constants.SCREEN_HEIGHT_PIX);
view.destroyDrawingCache();
return ret;
}
private Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
@ -1101,10 +1208,10 @@ public class ReadActivity extends Activity_base implements AdInterface {
}catch (Exception e){
Log.e(TAG, "loadBannerAd: ", e);
}*/
if(mNative_status_banner_container.getVisibility() ==View.VISIBLE) {
/* if(mNative_status_banner_container.getVisibility() ==View.VISIBLE) {
Log.d(TAG, "loadBannerAd: hideStatusAds()");
mNative_status_banner_container.setVisibility(View.GONE);
}
}*/
// mBannerContainer.removeAllViews();
// mBannerContainer.setBackgroundResource(R.color.transparent);
}
@ -1144,7 +1251,7 @@ public class ReadActivity extends Activity_base implements AdInterface {
Log.d(TAG, String.format("loadBannerAd:showNativeBannerInLines height %s, adY %s ",height, adY/Constants.ONE_DP_SIZE ));
hideAdSlot(mBannerContainer);
hideAdSlot(mNative_status_banner_container);
// hideAdSlot(mNative_status_banner_container);
if(height<=0){
return;
}
@ -1157,15 +1264,20 @@ public class ReadActivity extends Activity_base implements AdInterface {
if(mBannerContainer.getChildCount()>0) {
mBannerContainer.removeAllViews();
}
tmpFrame = new FrameLayout(this);
tmpFrame =mBannerContainer;
mLastBannerTime=0;
Log.d(TAG, String.format("loadBannerAd:showNativeBannerInLines to get ad, width %s, height %s ,adY %s ",Constants.SCREEN_WIDTH_PIX-50,height,adY));
loadNativeBannerAd(mBannerContainer);
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mBannerContainer.getLayoutParams();
loadNativeBannerAd(tmpFrame);
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams)tmpFrame.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;
params.height = (int) getResources().getDimension(R.dimen.nativeBannerHeight);
mBannerContainer.setLayoutParams(params);
tmpFrame.setLayoutParams(params);
tmpFrame.setVisibility(View.VISIBLE);
showAdSlot(mBannerContainer);
@ -1181,7 +1293,7 @@ public class ReadActivity extends Activity_base implements AdInterface {
// hideAdSlot(mBannerContainer);
Log.d(TAG, String.format("loadBannerAd:showTopBanner width %s, height %s ,adY %s ",Constants.SCREEN_WIDTH_PIX-50,adHeight,adY));
//hideAdSlot(mBannerContainer);
hideAdSlot(mNative_status_banner_container);
// hideAdSlot(mNative_status_banner_container);
if(adHeight<=0){
hideAdSlot(mTopBannerContainer);
return;
@ -1189,7 +1301,8 @@ public class ReadActivity extends Activity_base implements AdInterface {
int topMargin = adY >200*Constants.ONE_DP_SIZE ? adY -15*Constants.ONE_DP_SIZE :adY -5*Constants.ONE_DP_SIZE;
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mTopBannerContainer.getLayoutParams();
// FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mTopBannerContainer.getLayoutParams();
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mTopBannerContainer.getLayoutParams();
loadBanner(mTopBannerContainer, Constants.SCREEN_WIDTH_PIX-50,adHeight);
// loadNativeBannerAd(mTopBannerContainer,BuildConfig.AD_SLOT_TOUTIAO_BANNER_NATIVE_ID, 304,200);
params.setMargins(10*Constants.ONE_DP_SIZE, topMargin, 10*Constants.ONE_DP_SIZE, 0 );
@ -1230,7 +1343,7 @@ public class ReadActivity extends Activity_base implements AdInterface {
hideAdSlot(mBannerContainer);
// hideAdSlot(mTopBannerContainer);
tmpFrame =mNative_status_banner_container;
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mNative_status_banner_container.getLayoutParams();
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mNative_status_banner_container.getLayoutParams();
hideAdSlot(mNative_status_banner_container);
// mBannerContainer.removeAllViews();

View File

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

View File

@ -4,6 +4,7 @@ package com.novelbook.android.db;
import android.text.TextUtils;
import android.util.Log;
import com.novelbook.android.utils.CommonUtil;
import com.novelbook.android.utils.Constants;
import org.litepal.LitePal;
@ -310,7 +311,7 @@ public class Novel extends LitePalSupport implements Serializable{
public int update(long id){
setValues();
// checkAndUpdate();
Log.d("checkshelf", String.format("checkshelf:novel %s going to update,isUpdated %s", getName() ,isUpdated));
Log.d("checkshelf", String.format("checkshelf:novel %s going to update,isUpdated %s,lastvist %s", getName() ,isUpdated, CommonUtil.getDateString(lastVisit )));
/* try {
throw new Exception("check update");
}catch (Exception e){
@ -342,11 +343,11 @@ public void testUpdate(){
) );
// isUpdated = isUpdated && !(!TextUtils.isEmpty(chapterName) && !TextUtils.isEmpty(nv.chapterName) && (chapterName.equals(nv.lastReadChaptName) ));
// boolean isLastReadchaptUpdated = !TextUtils.isEmpty(chapterName) && !TextUtils.isEmpty(nv.lastReadChaptName) && !(chapterName.equals(nv.lastReadChaptName));
boolean isLastReadchaptUpdated = TextUtils.isEmpty(nv.lastReadChaptName) || !(chapterName.equals(nv.lastReadChaptName));
boolean isLastReadchaptUpdated = TextUtils.isEmpty(nv.lastReadChaptName) || !(chapterName.equals(nv.lastReadChaptName)); //没看过最新章节
boolean isLastChaptUpdated = !TextUtils.isEmpty(chapterName) && !TextUtils.isEmpty(nv.chapterName) && !(chapterName.equals(nv.chapterName));
Log.d("Novel", String.format( " isupdated %s, server lastUpdateTime ,server chaptername %s,chaptername %s,lastreadchapt %s" ,isLastReadchaptUpdated,chapterName,nv.chapterName,nv.lastReadChaptName ) );
Log.d("Novel", String.format( " server lastUpdateTime ,server chaptername %s,chaptername %s,lastreadchapt %s" , chapterName,nv.chapterName,nv.lastReadChaptName ) );
isUpdated = isLastChaptUpdated && isLastReadchaptUpdated ;
isUpdated = isUpdated && isLastReadchaptUpdated || isLastChaptUpdated ;
Log.d("Novel", String.format( " isupdated %s, server lastUpdateTime isLastReadchaptUpdated %s,isLastChaptUpdated %s" ,isUpdated,isLastReadchaptUpdated,isLastChaptUpdated ) );
if(!isUpdated){

View File

@ -1,5 +1,7 @@
package com.novelbook.android.utils;
import android.graphics.Bitmap;
public interface AdInterface {
/**
* 显示activity 上的广告
@ -17,4 +19,5 @@ public interface AdInterface {
public void hideReadSetting();
public void showReadSetting();
public void hideStatusAds();
public Bitmap getBitmapWithAd();
}

View File

@ -1461,6 +1461,7 @@ int muluRetryCount =0;
}
*/
}else if(msg.what==MSG_READBOOK_FAIL ) { //change source
if(pagefactory!=null)
pagefactory.drawStatus(PageFactory.Status.FAIL);
}
}

View File

@ -73,6 +73,7 @@ public class Constants {
public final static int MAX_PAGE_CNT =10;//最多加载的页数
public final static int MAX_SLEEP_4_CHAPT_DOWNLOAD =10000;//最多等待时间10s
public final static int MAX_SHELF_CNT =100;
}

View File

@ -195,6 +195,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 int mLoadingChaptNo;
public AdInterface getmAd() {
return mAd;
@ -541,7 +542,7 @@ public class PageFactory implements ChangeSource{
int bannerPagecnt = Constants.AD_SETTING.getChapterBanner().getPageCount4Display();
int nativeBannerPageCnt = Constants.AD_SETTING.getChapterContentBanner().getPageCount4Display();
int nativeBannerPageCnt =4;// Constants.AD_SETTING.getChapterContentBanner().getPageCount4Display();
if (Constants.AD_SETTING.getChapterContentBanner().isShow() &&
nativeBannerPageCnt > 0 &&
mNavtiveBannerPlusCnt >= nativeBannerPageCnt) {
@ -960,7 +961,8 @@ private void hideSysUI(){
}
Log.d(TAG, "drawStatus: mStatus is " +mStatus);
if (mStatus==Status.OPENING ) {
String url = mBookUtil.getChapter(getNovel().getLastReadChapt()).getChapterUrl();
mLoadingChaptNo =mLoadingChaptNo >0?mLoadingChaptNo: getNovel().getLastReadChapt();
String url = mBookUtil.getChapter(mLoadingChaptNo).getChapterUrl();
Log.d(TAG, "drawStatus: url is " +url);
if(!TextUtils.isEmpty(url)) {
if(url.length()>100)
@ -983,7 +985,7 @@ private void hideSysUI(){
if(Constants.SHOW_NOVEL_CHAPTER_URL) {
c.drawText(url, targetRect.centerX(), baseline, waitPaint);
}
String chaptName= mBookUtil.getChapter(getNovel().getLastReadChapt()).getChapterName();
String chaptName= mBookUtil.getChapter(mLoadingChaptNo).getChapterName();
if(!TextUtils.isEmpty(chaptName)) {
if(chaptName.length()>100)
chaptName =chaptName.substring(0,100);
@ -1285,8 +1287,7 @@ private void hideSysUI(){
c.drawText(chapterName, mWidth - marginWidth - nChaterWidth, statusMarginBottom + mBatterryFontSize, mBatterryPaint);
}
if(mBookPageWidget!=null)
mBookPageWidget.postInvalidate();
if(currentPage!=null && currentPage.getPageNo()==1){
String sn = getNovel().getDomainName();
@ -1306,6 +1307,17 @@ private void hideSysUI(){
c.drawText( Constants.announcement, marginWidth, statusMarginBottom + mBatterryFontSize+anny, mBatterryPaint);
}
if(mBookPageWidget!=null) {
mBookPageWidget.postInvalidate();
/* if(mAd!=null)
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
mBookPageWidget.setetCurPage(mAd.getBitmapWithAd());
mBookPageWidget.setPageMode(config.getPageMode());
}
}, 1000);*/
}
}
public void showAd(){
@ -1365,7 +1377,7 @@ private void hideSysUI(){
return;
}
if(mStatus ==Status.LASTPAGE) {
onDraw(mBookPageWidget.getCurPage(),currentPage ,true,false);
// onDraw(mBookPageWidget.getCurPage(),currentPage ,true,false);
if(mBookPageWidget==null){
return;
}
@ -1377,6 +1389,7 @@ private void hideSysUI(){
}
Log.d(TAG, " prePage() onDraw: mBookPageWidget.getNextPage() ");
currentPage = getPrePage();
onDraw(mBookPageWidget.getNextPage(),currentPage ,true,true);
}
@ -1403,6 +1416,7 @@ private void hideSysUI(){
if(mBookUtil.getChapters().size()==0 &&NetUtil.isNetworkConnected()){
mBookUtil.setChapterNo(currentChapter+1);
mStatus = Status.OPENING;
drawStatus();
new Thread() {
@Override
@ -1435,6 +1449,7 @@ private void hideSysUI(){
return;
}
mLoadingChaptNo =currentChapter+1;
m_islastPage =currentChapter == mBookUtil.getChapters().size();// ||mBookUtil.getChapters().size()==0;
if ( m_islastPage){
@ -1453,9 +1468,11 @@ private void hideSysUI(){
return;
}
Log.d(TAG, "nextPage() onDraw: mBookPageWidget.getCurPage() ");
onDraw(mBookPageWidget.getCurPage(),currentPage ,true,false);
// onDraw(mBookPageWidget.getCurPage(),currentPage ,true,false);
Log.d(TAG, "nextpage:set current bitmap ..ondraw");
prePage = currentPage;
currentPage = getNextPage();
mLoadingChaptNo=0;
// currentPage = currentChaptPages.get(currentPage.getPageNo()-1);
if(mBookPageWidget==null){
return;
@ -1676,6 +1693,7 @@ private void hideSysUI(){
if(prePageNo <=0){
nextChaptPages =currentChaptPages;
currentChapter--;
mLoadingChaptNo =currentChapter;
if(currentChapter ==0) {
return new TRPage("没有内容了");
}
@ -1687,7 +1705,7 @@ private void hideSysUI(){
preReadChaptCache(currentChapter - 1);
}
}
mLoadingChaptNo =0;
return currentChaptPages.get(prePageNo-1);
}

View File

@ -1,8 +1,12 @@
package com.novelbook.android.view;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Environment;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
@ -11,7 +15,9 @@ import android.view.View;
import android.view.ViewConfiguration;
import android.view.WindowManager;
import android.view.animation.LinearInterpolator;
import android.widget.FrameLayout;
import android.widget.Scroller;
import android.widget.Toast;
import com.novelbook.android.utils.CommonUtil;
import com.novelbook.android.utils.PageFactory;
@ -21,6 +27,12 @@ import com.novelbook.android.view.animation.NoneAnimation;
import com.novelbook.android.view.animation.SimulationAnimation;
import com.novelbook.android.view.animation.SlideAnimation;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Date;
import static com.novelbook.android.utils.Config.*;
@ -55,6 +67,16 @@ public class PageWidget extends View {
private int mBgColor = 0xFFCEC29C;
private TouchListener mTouchListener;
public void setActivity(Activity activity) {
this.activity = activity;
}
public void setFrmContainer(FrameLayout frmContainer) {
this.frmContainer = frmContainer;
}
private FrameLayout frmContainer;
private Activity activity;
public PageWidget(Context context) {
this(context,null);
}
@ -82,8 +104,9 @@ public class PageWidget extends View {
mCurPageBitmap = Bitmap.createBitmap(mScreenWidth, mScreenHeight, Bitmap.Config.RGB_565); //android:LargeHeap=true use in manifest application
mNextPageBitmap = Bitmap.createBitmap(mScreenWidth, mScreenHeight, Bitmap.Config.RGB_565);
}
int mPageMode =0;
public void setPageMode(int pageMode){
mPageMode=pageMode;
switch (pageMode){
case PAGE_MODE_SIMULATION:
mAnimationProvider = new SimulationAnimation(mCurPageBitmap,mNextPageBitmap,mScreenWidth,mScreenHeight);
@ -132,6 +155,14 @@ public class PageWidget extends View {
public Bitmap getCurPage(){
return mCurPageBitmap;
}
public void setetCurPage(Bitmap bitmap){
// mCurPageBitmap =bitmap;
mAnimationProvider.setetCurPage(bitmap);
}
public void setetNextPage(Bitmap bitmap){
// mCurPageBitmap =bitmap;
mAnimationProvider.setetNextPage(bitmap);
}
public Bitmap getNextPage(){
return mNextPageBitmap;
@ -145,7 +176,7 @@ public class PageWidget extends View {
protected void onDraw(Canvas canvas) {
// canvas.drawColor(0xFFAAAAAA);
canvas.drawColor(mBgColor);
// //Log.e("onDraw","isNext:" + isNext + " isRuning:" + isRuning);
Log.e("pagewidget onDraw","isMoveing isNext:" + isNext + " isRuning:" + isRuning);
if (isRuning) {
mAnimationProvider.drawMove(canvas);
} else {
@ -165,7 +196,7 @@ public class PageWidget extends View {
int x = (int)event.getX();
int y = (int)event.getY();
Log.d(TAG, String.format("onTouchEvent: x %s,y %s ",x,y));
mAnimationProvider.setTouchPoint(x,y);
if (event.getAction() == MotionEvent.ACTION_DOWN){ //mAnimationProvider.setCancel(false); https://github.com/PeachBlossom/treader/issues/4
downX = (int) event.getX();
@ -194,7 +225,9 @@ public class PageWidget extends View {
isMove = true;
mTouchListener.hideAdBeforeIni() ;
if (moveX == 0 && moveY ==0) {
//Log.e(TAG,"isMove");
Log.e(TAG,"isMoveing");
//判断翻得是上一页还是下一页
if (x - downX >0){
isNext = false;
@ -202,11 +235,13 @@ public class PageWidget extends View {
isNext = true;
}
cancelPage = false;
if (isNext) {
Boolean isNext = mTouchListener.nextPage();
// calcCornerXY(downX,mScreenHeight);
mAnimationProvider.setDirection(AnimationProvider.Direction.next);
if (!isNext) {
noNext = true;
return true;
@ -220,6 +255,7 @@ public class PageWidget extends View {
return true;
}
}
//Log.e(TAG,"isNext:" + isNext);
}else{
//判断是否取消翻页
@ -301,9 +337,11 @@ public class PageWidget extends View {
if (!noNext) {
isRuning = true;
Log.d(TAG, "onTouchEvent: startanimation");
mAnimationProvider.startAnimation(mScroller);
mTouchListener.showAdAfterIni();
this.postInvalidate();
}
}
}
@ -352,4 +390,7 @@ public class PageWidget extends View {
void hideAdBeforeIni();
}
}

View File

@ -95,5 +95,11 @@ public abstract class AnimationProvider {
public boolean getCancel(){
return isCancel;
}
public void setetCurPage(Bitmap bitmap){
mCurPageBitmap =bitmap;
}
public void setetNextPage(Bitmap bitmap){
mNextPageBitmap =bitmap;
}
}

View File

@ -11,10 +11,12 @@ import android.graphics.PointF;
import android.graphics.Region;
import android.graphics.drawable.GradientDrawable;
import android.os.Build;
import android.util.Log;
import android.widget.Scroller;
public class SimulationAnimation extends AnimationProvider {
private static final String TAG=SimulationAnimation.class.getSimpleName();
private int mCornerX = 1; // 拖拽点对应的页脚
private int mCornerY = 1;
private Path mPath0;
@ -84,6 +86,8 @@ public class SimulationAnimation extends AnimationProvider {
@Override
public void drawMove(Canvas canvas) {
Log.d(TAG, "isMoveing drawMove: ");
if (getDirection().equals(Direction.next)) {
calcPoints();
drawCurrentPageArea(canvas, mCurPageBitmap, mPath0);

View File

@ -23,12 +23,14 @@
android:layout_height="wrap_content"
android:src="@drawable/ic_format_line_spacing_black_24dp"
style="@style/buttonCates"/>
</LinearLayout>-->
<TextView
android:id="@+id/tvChapts"
style="@style/TextViewNovelTitle"
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="match_parent"
android:orientation="vertical"
>
-->
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeLayout"
android:layout_width="match_parent"
@ -42,6 +44,7 @@
android:divider="@color/list_item_divider"
android:dividerHeight="1dp" />
</android.support.v4.widget.SwipeRefreshLayout>
<!--</LinearLayout>-->
<Button
android:id="@+id/btnRefresh"
android:layout_width="100dp"

View File

@ -51,14 +51,26 @@
<LinearLayout
style="@style/llOutside"
android:orientation="vertical"
android:layout_marginTop="-20dp"
android:layout_marginTop="-25dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<TextView
android:id="@+id/tvSource"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:ellipsize="end"
android:lines="1"
android:padding="0dp"
android:background="@color/white"
android:text=""
android:textColor="@color/lightgray"
android:textSize="11sp" />
<com.flyco.tablayout.SlidingTabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_height="35dp"
android:background="@color/white"
app:tl_indicator_color="@color/tabSelected"
app:tl_indicator_corner_radius="1.5dp"
@ -67,6 +79,7 @@
app:tl_textSelectColor="@color/tabSelected"
app:tl_textUnselectColor="@color/grey"
app:tl_tab_space_equal ="true"
android:paddingBottom="5dp"
/>
<android.support.v4.view.ViewPager
android:id="@+id/pager"

View File

@ -11,6 +11,7 @@
android:clipToPadding="false" android:fitsSystemWindows="true"
-->
<FrameLayout
android:id="@+id/frmContainer"
android:layout_width="match_parent"
android:layout_height="match_parent">
@ -43,7 +44,7 @@
android:gravity="bottom"
android:lines="1"
android:paddingLeft="10dp"
android:text="http://abc.om..fd"
android:text=""
android:textColor="@color/whitesmoke"
android:textSize="11sp" />
</android.support.design.widget.AppBarLayout>
@ -89,7 +90,7 @@
</LinearLayout>-->
<FrameLayout
<LinearLayout
android:id="@+id/frmAD"
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -123,7 +124,7 @@
android:visibility="visible" /> <!-- -->
</FrameLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/llShelfBottom"

View File

@ -20,7 +20,7 @@
<string name="title_activity_book">BookActivity</string>
<string name="dummy_button">Dummy Button</string>
<string name="dummy_content">DUMMY\nCONTENT</string>
<string name="announce">
<string name="announce1">
" 鉴于本服务以非人工检索方式提供无线搜索、根据您输入的关键字自动生成到第三方网页的链接,本服务会提供与其他任何互联网网站或资源的链接。由于本软件无法控制这些网站或资源的内容,您了解并同意:无论此类网站或资源是否可供利用,本软件不予负责;本软件亦对存在或源于此类网站或资源之任何内容、广告、产品或其他资料不予保证或负责。因您使用或依赖任何此类网站或资源发布的或经由此类网站或资源获得的任何内容、商品或服务所产生的任何损害或损失,本软件不负任何直接或间接责任。
因本服务搜索结果根据您键入的关键字自动搜索获得并生成,不代表本软件赞成被搜索链接到的第三方网页上的内容或立场。
@ -39,6 +39,15 @@
若您和本软件之间发生任何纠纷或争议,首先应友好协商解决;协商不成的,您同意将纠纷或争议提交本软件所在地的人民法院处理。"
</string>
<string name="announce">
" 本软件皆在为广大小说爱好者提供小说的搜索、链接服务。但软件本身不会对链接于第三方的搜索结果作任何形式的编辑、修改或存储,用户应该自行判断链接于第三方网站上的内容的真实性、完整性、准确性,本软件对用户因此造成的损失不承担任何责任。
为更好的提升在手机终端的阅读体验,本软件同时提供阅读技术转码服务,用户可以自由的选择使用或不使用此服务。
通过本软件获得的内容仅限用户个人学习、研究、欣赏,此外的任何使用行为(复制、转载等)用户均应自行获得相关权利人的许可,否则应承担全部法律责任。
用户可以免费下载、安装、使用本软件,但未经许可不得对本软件进行任何形式的方向工程、反向编译、反向汇编;不得使用任何插件、外挂等非法工具接入本软件及系统;不得擅自复制、增加、删除本软件的数据。"
</string>
<string name="title_activity_main5">Main5Activity</string>
<string name="title_on_shelf">加入书架</string>
<string name="title_read">立即阅读</string>