Commit 6c6fcdaa authored by jyx's avatar jyx

优化章节页样式

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