Commit 6c6fcdaa authored by jyx's avatar jyx

优化章节页样式

parent 0dead3f6
...@@ -186,6 +186,7 @@ public class YPageView extends View implements SlideAnim.OnPageChangeListener { ...@@ -186,6 +186,7 @@ public class YPageView extends View implements SlideAnim.OnPageChangeListener {
if (isMove) { if (isMove) {
// if (isNext) mPageLoader.nextPage(); // if (isNext) mPageLoader.nextPage();
// else mPageLoader.prePage(); // else mPageLoader.prePage();
if (listener != null) listener.touPage();
isNext = true; isNext = true;
isMove = !isMove; isMove = !isMove;
...@@ -238,6 +239,8 @@ public class YPageView extends View implements SlideAnim.OnPageChangeListener { ...@@ -238,6 +239,8 @@ public class YPageView extends View implements SlideAnim.OnPageChangeListener {
/*********************interface implements*************************/ /*********************interface implements*************************/
public interface OnCenterClickListener { public interface OnCenterClickListener {
void centerClicked(); void centerClicked();
void touPage();
} }
......
...@@ -3,6 +3,7 @@ package com.duben.infinitefunjia.read.anim; ...@@ -3,6 +3,7 @@ package com.duben.infinitefunjia.read.anim;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect; import android.graphics.Rect;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
...@@ -21,6 +22,8 @@ public abstract class PageAnim { ...@@ -21,6 +22,8 @@ public abstract class PageAnim {
//需要动画的视图 //需要动画的视图
View mView; View mView;
private Paint paint;
private int bgColor = Color.parseColor("#E0E4E7");
//视图的尺寸 //视图的尺寸
protected int mViewWidth; protected int mViewWidth;
protected int mViewHeight; protected int mViewHeight;
...@@ -61,10 +64,16 @@ public abstract class PageAnim { ...@@ -61,10 +64,16 @@ public abstract class PageAnim {
/***********************************public***********************************/ /***********************************public***********************************/
//初始化数据 //初始化数据
protected void initData() { protected void initData() {
paint = new Paint(Paint.DITHER_FLAG);
paint.setColor(bgColor);
mViewWidth = mView.getWidth(); mViewWidth = mView.getWidth();
mViewHeight = mView.getHeight(); mViewHeight = mView.getHeight();
mCurBitmap = Bitmap.createBitmap(mView.getWidth(), mView.getHeight(), Bitmap.Config.RGB_565); // mCurBitmap = Bitmap.createBitmap(mView.getWidth(), mView.getHeight(), Bitmap.Config.RGB_565);
mNextBitmap = Bitmap.createBitmap(mView.getWidth(), mView.getHeight(), Bitmap.Config.RGB_565); // mNextBitmap = Bitmap.createBitmap(mView.getWidth(), mView.getHeight(), Bitmap.Config.RGB_565);
mCurBitmap = createBitmap(mView.getWidth(), mView.getHeight());
mNextBitmap = createBitmap(mView.getWidth(), mView.getHeight());
mSrcRect = new Rect(0, 0, mViewWidth, mViewHeight); mSrcRect = new Rect(0, 0, mViewWidth, mViewHeight);
mDestRect = new Rect(0, 0, mViewWidth, mViewHeight); mDestRect = new Rect(0, 0, mViewWidth, mViewHeight);
slop = ViewConfiguration.get(mView.getContext()).getScaledTouchSlop(); slop = ViewConfiguration.get(mView.getContext()).getScaledTouchSlop();
...@@ -86,6 +95,15 @@ public abstract class PageAnim { ...@@ -86,6 +95,15 @@ public abstract class PageAnim {
} }
private Bitmap createBitmap(int width, int height) {
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
bitmap.eraseColor(bgColor);
Canvas canvas = new Canvas(bitmap);
canvas.drawColor(bgColor);
canvas.drawBitmap(bitmap, null, new Rect(0, 0, width, height), paint);
return bitmap;
}
public void changePage() { public void changePage() {
Bitmap bitmap = mCurBitmap; Bitmap bitmap = mCurBitmap;
......
...@@ -17,6 +17,7 @@ import com.duben.infinitefunjia.mvp.views.BookReadView ...@@ -17,6 +17,7 @@ import com.duben.infinitefunjia.mvp.views.BookReadView
import com.duben.infinitefunjia.read.AnimType import com.duben.infinitefunjia.read.AnimType
import com.duben.infinitefunjia.read.PageLoader import com.duben.infinitefunjia.read.PageLoader
import com.duben.infinitefunjia.read.ReadChaptersAdapter import com.duben.infinitefunjia.read.ReadChaptersAdapter
import com.duben.infinitefunjia.read.YPageView.OnCenterClickListener
import com.duben.infinitefunjia.read.models.BookModel import com.duben.infinitefunjia.read.models.BookModel
import com.duben.infinitefunjia.read.models.BookRecordModel import com.duben.infinitefunjia.read.models.BookRecordModel
import com.duben.infinitefunjia.read.models.TxtChapterModel import com.duben.infinitefunjia.read.models.TxtChapterModel
...@@ -36,7 +37,7 @@ class LongBookReadActivity : BaseActivity(), View.OnClickListener, BookReadView ...@@ -36,7 +37,7 @@ class LongBookReadActivity : BaseActivity(), View.OnClickListener, BookReadView
private var mBookModel: BookModel? = null private var mBookModel: BookModel? = null
private var mPageLoader: PageLoader? = null private var mPageLoader: PageLoader? = null
private var isShowSetting = false private var isShowSetting = true
private var bookSettingDialog: LongBookSettingDialog? = null private var bookSettingDialog: LongBookSettingDialog? = null
private var bookVipDialog: BookVipDialog? = null private var bookVipDialog: BookVipDialog? = null
...@@ -61,6 +62,8 @@ class LongBookReadActivity : BaseActivity(), View.OnClickListener, BookReadView ...@@ -61,6 +62,8 @@ class LongBookReadActivity : BaseActivity(), View.OnClickListener, BookReadView
initListener() initListener()
popBookSettingDialog() popBookSettingDialog()
popBookVipDialog() popBookVipDialog()
readPresenter.attachView(this)
mBookModel?.let { readPresenter.addReadRecord(it.bookId) }
} }
override fun onResume() { override fun onResume() {
...@@ -176,22 +179,36 @@ class LongBookReadActivity : BaseActivity(), View.OnClickListener, BookReadView ...@@ -176,22 +179,36 @@ class LongBookReadActivity : BaseActivity(), View.OnClickListener, BookReadView
} }
} }
} else { } else {
mPageLoader?.setPageBgColor(BookConstant.BOOK_CONTENT_COLOR_1.color) mPageLoader?.let {
mPageLoader?.setTextSize(18) it.setPageBgColor(BookConstant.BOOK_CONTENT_COLOR_1.color)
mPageLoader?.textColor = Color.BLACK it.setTextSize(18)
it.textColor = Color.BLACK
}
// pageview.animType = AnimType.SLIDE
bookSettingDialog?.setSetting(BookConstant.BOOK_CONTENT_COLOR_1.color, 18) bookSettingDialog?.setSetting(BookConstant.BOOK_CONTENT_COLOR_1.color, 18)
} }
pageview.setOnCenterClickListener { pageview.setOnCenterClickListener(object : OnCenterClickListener {
if (isShowSetting) { override fun centerClicked() {
view_setting.visibility = View.VISIBLE if (isShowSetting) {
tab_setting_top.visibility = View.VISIBLE view_setting.visibility = View.VISIBLE
} else { tab_setting_top.visibility = View.VISIBLE
view_setting.visibility = View.GONE } else {
tab_setting_top.visibility = View.GONE view_setting.visibility = View.GONE
tab_setting_top.visibility = View.GONE
}
isShowSetting = !isShowSetting
} }
isShowSetting = !isShowSetting
} override fun touPage() {
if (isShowSetting) {
view_setting.visibility = View.GONE
tab_setting_top.visibility = View.GONE
isShowSetting = false
}
}
})
//初始化目录 //初始化目录
initChapterRecyclerView() initChapterRecyclerView()
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
android:orientation="horizontal" android:orientation="horizontal"
android:paddingTop="5dp" android:paddingTop="5dp"
android:paddingBottom="5dp" android:paddingBottom="5dp"
android:visibility="gone"> android:visibility="visible">
<LinearLayout <LinearLayout
android:id="@+id/tab_setting_chapter" android:id="@+id/tab_setting_chapter"
...@@ -109,7 +109,7 @@ ...@@ -109,7 +109,7 @@
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingTop="25dp" android:paddingTop="25dp"
android:visibility="gone"> android:visibility="visible">
<ImageView <ImageView
android:id="@+id/iv_back" android:id="@+id/iv_back"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment