Commit 0dead3f6 authored by jyx's avatar jyx

代码优化

parent 0a0207dc
......@@ -120,7 +120,8 @@
<activity
android:name=".ui.activitys.LongBookReadActivity"
android:exported="false"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/AppTheme.TranslucentSplish" />
<activity
android:name=".ui.activitys.WxLoginActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
......
......@@ -6,7 +6,7 @@ const val BOOK_CONTENT_COLOR = "BOOK_CONTENT_COLOR"
const val BOOK_CONTENT_SIZE = "BOOK_CONTENT_SIZE"
enum class BookConstant(var color: Int) {
BOOK_CONTENT_COLOR_1(Color.parseColor("#ffffff")),
BOOK_CONTENT_COLOR_1(Color.parseColor("#E0E4E7")),
BOOK_CONTENT_COLOR_2(Color.parseColor("#e7e7e7")),
BOOK_CONTENT_COLOR_3(Color.parseColor("#d4e0c6")),
BOOK_CONTENT_COLOR_4(Color.parseColor("#ccd8e4")),
......
package com.duben.infinitefunjia.read;
import android.text.TextUtils;
import android.util.Log;
import com.duben.infinitefunjia.MintsApplication;
......@@ -62,7 +63,10 @@ public class NetworkPageLoader extends PageLoader {
@Override
public void loadChapters() {
//已缓存
if (mChapterList != null && !mChapterList.isEmpty()) return;
if (mChapterList != null && !mChapterList.isEmpty()) {
loadCurrentChapter(curChapterIndex);
return;
}
Map<String, Object> params = new HashMap<>();
params.put("id", bookModel.getBookId());
......@@ -76,11 +80,19 @@ public class NetworkPageLoader extends PageLoader {
public void onNext(BaseResponse<BookContentBean> baseResponse) {
List<BookContentBean.ArticleChapterList> articleChapterList =
baseResponse.getData().getArticleChapterList();
BookContentBean contentBean = baseResponse.getData();
bookModel.setBookTitle(contentBean.getTitle());
for (BookContentBean.ArticleChapterList chapterList : articleChapterList) {
TxtChapterModel txtChapterModel = new TxtChapterModel();
txtChapterModel.setChapterId("" + chapterList.getId());
txtChapterModel.setBook_id(bookModel.getId());
txtChapterModel.setTitle("第" + chapterList.getChapterNum() + "章节");
txtChapterModel.setLock(chapterList.getIsVip() == 1);
if (TextUtils.isEmpty(chapterList.getChapterName())) {
txtChapterModel.setTitle("第" + chapterList.getChapterNum() + "章");
} else {
txtChapterModel.setTitle(chapterList.getChapterName());
}
mChapterList.add(txtChapterModel);
}
......@@ -213,7 +225,7 @@ public class NetworkPageLoader extends PageLoader {
chapterChangeListener.requestChapters(chapters);
loadChapter(String.valueOf(bookModel.getBookId()), chapters);
} else {
if (isSkip) isSkip = !isSkip;
if (isSkip) isSkip = false;
pageView.showContent();
}
}
......@@ -236,6 +248,7 @@ public class NetworkPageLoader extends PageLoader {
for (int i = 0; i < size; ++i) {
TxtChapterModel bookChapter = bookChapters.get(i);
if (!bookChapter.isLock) {
Log.v("yzll", "缓存章节:" + bookChapter.getTitle());
Map<String, Object> params = new HashMap<>();
params.put("articleId", bookModel.getBookId());
......@@ -244,6 +257,7 @@ public class NetworkPageLoader extends PageLoader {
chapterInfos.add(chapterInfoSingle);
titles.add(bookChapter.getTitle());
}
}
Flowable<BaseResponse<BookChapterBean>> concat = Single.concat(chapterInfos);
concat.subscribeOn(Schedulers.io())
......@@ -273,7 +287,7 @@ public class NetworkPageLoader extends PageLoader {
@Override
public void onComplete() {
if (isSkip) {
isSkip = !isSkip;
isSkip = false;
skipToChapterReal(curChapterIndex);
} else {
pageView.showContent();
......
......@@ -9,10 +9,10 @@ import android.graphics.RectF;
import android.graphics.Typeface;
import android.text.TextPaint;
import com.duben.infinitefunjia.manager.UserManager;
import com.duben.infinitefunjia.read.models.BookModel;
import com.duben.infinitefunjia.read.models.TxtChapterModel;
import com.duben.infinitefunjia.read.models.TxtPageModel;
import com.duben.infinitefunjia.utils.LogUtil;
import com.duben.infinitefunjia.utils.StringUtils;
import com.duben.library.utils.Utils;
......@@ -46,11 +46,13 @@ public abstract class PageLoader {
//当前页面位置
int curPageIndex = 0;
//行间距
private int mTextInterval;
//标题的行间距
private int mTitleInterval;
private int mTopPadding;
//书籍绘制区域的宽高
private int mVisibleWidth;
private int mVisibleHeight;
......@@ -110,8 +112,10 @@ public abstract class PageLoader {
mDisplayWidth = pageView.getWidth();
mVisibleWidth = pageView.getWidth() - mMarginWidth * 2;
mVisibleHeight = pageView.getHeight() - mMarginHeight;
mTitleInterval = (int) (mTitleTextPaint.getTextSize() / 1.6);
mTextInterval = (int) (mContentTextPaint.getTextSize() / 1.6);
mTitleInterval = (int) (mTitleTextPaint.getTextSize() / 2);
mTextInterval = (int) (mContentTextPaint.getTextSize() / 2);
mTopPadding = 200;
}
//初始化画笔
......@@ -188,12 +192,13 @@ public abstract class PageLoader {
boolean showTitle = true;
String paragraph = chapter.getTitle();//默认展示标题
int titleLinesCount = 0;
// 减去上边距
readHeight -= mTopPadding;
//流式读取书籍数据
try {
while (showTitle || (paragraph = br.readLine()) != null) {
//一行的字数
int wordCount = 0;
int wordCount;
//一行的内容
paragraph = paragraph.replace("&nbsp", " ")
.replace("<br/>", " ")
......@@ -207,7 +212,6 @@ public abstract class PageLoader {
} else {
readHeight -= mContentTextPaint.getTextSize();
}
// 一页已经填充满了,创建 TextPage
if (readHeight <= 0) {
// 创建Page
......@@ -220,6 +224,7 @@ public abstract class PageLoader {
// 重置Lines
lines.clear();
readHeight = mVisibleHeight;
readHeight -= mTopPadding;
titleLinesCount = 0;
continue;
......@@ -233,6 +238,7 @@ public abstract class PageLoader {
wordCount = mContentTextPaint.breakText(paragraph,
true, mVisibleWidth, null);
}
//截取一行的内容
lineContent = paragraph.substring(0, wordCount);
if (!lineContent.equals("\n")) {
......@@ -241,7 +247,6 @@ public abstract class PageLoader {
//设置段落间距
if (showTitle) {
titleLinesCount += 1;
readHeight -= mTitleInterval;
showTitle = false;
} else {
readHeight -= mTextInterval;
......@@ -251,16 +256,12 @@ public abstract class PageLoader {
paragraph = paragraph.substring(wordCount);
}
//增加段落的间距
// if (!showTitle && lines.size() != 0) {
// readHeight = readHeight - mTextInterval;
// }
if (showTitle) {
readHeight = readHeight - mTitleInterval;
showTitle = false;
}
}
//处理尾页
if (lines.size() != 0) {
//创建Page
......@@ -352,8 +353,8 @@ public abstract class PageLoader {
//绘制内容
private void drawContent(Canvas canvas) {
if (mCurPage == null) return;
float top = mMarginHeight;
String str = null;
float top = mTopPadding;
String str;
//确定距离
int contentInterval = (int) mContentTextPaint.getTextSize() + mTextInterval;
......@@ -368,11 +369,9 @@ public abstract class PageLoader {
top += 10;
}
//计算文字显示的起始点
int start = (int) (mVisibleWidth - mTitleTextPaint.measureText(str)) / 2;
//进行绘制
canvas.drawText(str, start, top, mTitleTextPaint);
// canvas.drawText(str, 50, 100, mTitleTextPaint);
canvas.drawText(str, 50, mTopPadding, mTitleTextPaint);
// canvas.drawText(str, 50, 200, mTitleTextPaint);
//设置尾部间距
if (i == mCurPage.titleLines - 1) {
......@@ -431,12 +430,23 @@ public abstract class PageLoader {
if (curPageIndex >= 0 && curPageIndex < mCurPageList.size() - 1) {
curPageIndex++;
} else {
List<TxtPageModel> tempPageList = loadPageList(curChapterIndex + 2);
if (curChapterIndex >= mChapterList.size() - 1) return false;
// 是否未解锁
if (mChapterList.get(curChapterIndex + 1).isLock && !UserManager.getInstance().getVipFlag()) {
if (chapterChangeListener != null) {
chapterChangeListener.onIsVipPage();
}
return false;
}
// 预加载下一章
List<TxtPageModel> tempPageList = loadPageList(curChapterIndex + 1);
if (tempPageList == null) {
loadNextChapters();
return false;
}
if (curChapterIndex >= mChapterList.size() - 1) return false;
lastChapterIndex = curChapterIndex++;
mPrePageList = mCurPageList;
mCurPageList = mNextPageList;
......@@ -530,6 +540,14 @@ public abstract class PageLoader {
//跳转到某一章
public void skipToChapter(int pos) {
// // 是否未解锁
// if (mChapterList.get(pos).isLock && !UserManager.getInstance().getVipFlag()) {
// if (chapterChangeListener != null) {
// chapterChangeListener.onIsVipPage();
// }
// return;
// }
curChapterIndex = pos;
if (chapterChangeListener != null) {
chapterChangeListener.onChapterChange(curChapterIndex);
......@@ -579,7 +597,6 @@ public abstract class PageLoader {
//设置字体大小
public void setTextSize(int textSize) {
mTextSize = textSize;
}
//更新字体大小
......@@ -591,9 +608,11 @@ public abstract class PageLoader {
}
private void updateCurPage() {
LogUtil.d("XXXXXXXXX", mCurPageList.toString());
LogUtil.d("XXXXXXXXX" + curPageIndex);
if (curPageIndex >= mCurPageList.size()) {
mCurPage = mCurPageList.get(0);
} else {
mCurPage = mCurPageList.get(curPageIndex);
}
pageView.drawNextPage();
pageView.invalidate();
}
......@@ -630,6 +649,10 @@ public abstract class PageLoader {
return textColor;
}
public String getBookTitle() {
return bookModel.getBookTitle();
}
/********************************abstract***********************************/
public abstract BufferedReader getChapterReader(TxtChapterModel chapterModel) throws IOException;
......@@ -650,5 +673,7 @@ public abstract class PageLoader {
void requestChapters(List<TxtChapterModel> requestChapters);
void finishedLoadChapters(List<TxtChapterModel> bookChapters);
void onIsVipPage();
}
}
......@@ -5,6 +5,7 @@ import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
......@@ -12,6 +13,7 @@ import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.duben.infinitefunjia.R;
import com.duben.infinitefunjia.manager.UserManager;
import com.duben.infinitefunjia.read.models.TxtChapterModel;
import java.util.List;
......@@ -40,6 +42,7 @@ public class ReadChaptersAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
View root = LayoutInflater.from(parent.getContext()).inflate(R.layout.read_chapters_item, parent, false);
ChapterViewHolder viewHolder = new ChapterViewHolder(root);
viewHolder.chapterTextView = root.findViewById(R.id.tv_title);
viewHolder.lockImageView = root.findViewById(R.id.iv_lock);
return viewHolder;
}
......@@ -48,18 +51,19 @@ public class ReadChaptersAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
final ChapterViewHolder viewHolder = (ChapterViewHolder) holder;
//显示数据
viewHolder.chapterTextView.setText("· " + chapterModels.get(position).getTitle());
if (chapterModels.get(position).isLock && !UserManager.getInstance().getVipFlag()) {
viewHolder.lockImageView.setVisibility(View.VISIBLE);
} else {
viewHolder.lockImageView.setVisibility(View.GONE);
}
if (position == selectedChapterIndex) {
viewHolder.setSelectedChapter();
} else {
viewHolder.chapterTextView.setTextColor(Color.BLACK);
}
viewHolder.chapterTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
listener.onItemClick(viewHolder.getAdapterPosition());
}
});
viewHolder.chapterTextView.setOnClickListener(v -> listener.onItemClick(viewHolder.getAdapterPosition()));
}
@Override
......@@ -71,6 +75,7 @@ public class ReadChaptersAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
//item类
class ChapterViewHolder extends RecyclerView.ViewHolder {
TextView chapterTextView;
ImageView lockImageView;
public ChapterViewHolder(View itemView) {
super(itemView);
......
......@@ -3,7 +3,6 @@ package com.duben.infinitefunjia.read;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.util.Log;
......@@ -45,7 +44,6 @@ public class YPageView extends View implements SlideAnim.OnPageChangeListener {
boolean isNext = true;
//翻页动画
AnimType animType = AnimType.SLIDE;
PageAnim pageAnim;
public YPageView(Context context) {
......@@ -92,7 +90,6 @@ public class YPageView extends View implements SlideAnim.OnPageChangeListener {
protected void onDraw(Canvas canvas) {
// mPageLoader.drawPage(coverAnimation.getmNextBitmap());
if (pageAnim == null) return;
// canvas.drawColor(Color.WHITE);
pageAnim.drawViewPages(canvas);
}
......
......@@ -8,7 +8,7 @@ import java.util.Date;
/**
* 小说的章节
* */
*/
public class TxtChapterModel extends LitePalSupport {
@SerializedName("Local_id")
long id;
......@@ -23,6 +23,8 @@ public class TxtChapterModel extends LitePalSupport {
//章节的起始和结束位置
public long start;
public long end;
// vip
public boolean isLock;
//书籍id
private long book_id;
......@@ -63,6 +65,7 @@ public class TxtChapterModel extends LitePalSupport {
public TxtChapterModel(long book_id) {
this.book_id = book_id;
}
public TxtChapterModel(String title) {
this.title = title;
}
......@@ -176,4 +179,12 @@ public class TxtChapterModel extends LitePalSupport {
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public boolean isLock() {
return isLock;
}
public void setLock(boolean lock) {
isLock = lock;
}
}
package com.duben.infinitefunjia.ui.activitys
import android.app.Dialog
import android.graphics.Color
import android.os.Bundle
import android.view.View
import android.view.WindowManager
import androidx.core.view.GravityCompat
import androidx.recyclerview.widget.LinearLayoutManager
import com.duben.infinitefunjia.R
import com.duben.infinitefunjia.common.BookConstant
import com.duben.infinitefunjia.common.Constant
import com.duben.infinitefunjia.manager.ReadTimeCount
import com.duben.infinitefunjia.manager.UserManager
import com.duben.infinitefunjia.mvp.model.BookContentBean
import com.duben.infinitefunjia.mvp.presenters.BookReadPresenter
import com.duben.infinitefunjia.mvp.views.BookReadView
......@@ -19,17 +21,12 @@ import com.duben.infinitefunjia.read.models.BookModel
import com.duben.infinitefunjia.read.models.BookRecordModel
import com.duben.infinitefunjia.read.models.TxtChapterModel
import com.duben.infinitefunjia.ui.activitys.base.BaseActivity
import com.duben.infinitefunjia.ui.widgets.BookVipDialog
import com.duben.infinitefunjia.ui.widgets.DialogListener
import com.duben.infinitefunjia.ui.widgets.LongBookSettingDialog
import kotlinx.android.synthetic.main.activity_long_book_read.*
import org.litepal.LitePal
import org.litepal.crud.LitePalSupport
import java.lang.String
import kotlin.Int
import kotlin.getValue
import kotlin.lazy
import kotlin.let
import kotlin.run
import kotlin.toString
class LongBookReadActivity : BaseActivity(), View.OnClickListener, BookReadView {
......@@ -39,7 +36,10 @@ class LongBookReadActivity : BaseActivity(), View.OnClickListener, BookReadView
private var mBookModel: BookModel? = null
private var mPageLoader: PageLoader? = null
private var isShowSetting = false
private var bookSettingDialog: LongBookSettingDialog? = null
private var bookVipDialog: BookVipDialog? = null
//目录适配器
private var readChaptersAdapter: ReadChaptersAdapter? = null
......@@ -60,6 +60,7 @@ class LongBookReadActivity : BaseActivity(), View.OnClickListener, BookReadView
initWidgets()
initListener()
popBookSettingDialog()
popBookVipDialog()
}
override fun onResume() {
......@@ -71,7 +72,7 @@ class LongBookReadActivity : BaseActivity(), View.OnClickListener, BookReadView
super.onPause()
ReadTimeCount.instance.endCountReadTime()
//保存阅读记录
if (LitePal.where("book_id=?", String.valueOf(mBookModel?.id))
if (LitePal.where("book_id=?", (mBookModel?.id).toString())
.findFirst(TxtChapterModel::class.java) == null
) {
mPageLoader?.let { LitePal.saveAll<LitePalSupport>(it.mChapterList) }
......@@ -81,31 +82,36 @@ class LongBookReadActivity : BaseActivity(), View.OnClickListener, BookReadView
mPageLoader?.let {
bookRecord.chapterPos = it.curChapterIndex
bookRecord.pagePos = it.curPageIndex
bookRecord.book_id = String.valueOf(mBookModel?.id)
bookRecord.book_id = (mBookModel?.id).toString()
bookRecord.page_color = it.bgColor
bookRecord.text_color = it.textColor
bookRecord.text_size = it.getmTextSize()
bookRecord.anim_type = pageview.animType.type
bookRecord.saveOrUpdate("book_id=?", String.valueOf(mBookModel?.id))
bookRecord.saveOrUpdate("book_id=?", (mBookModel?.id).toString())
}
}
override fun onClick(v: View?) {
when (v?.id) {
R.id.iv_left_icon -> finish()
R.id.iv_back -> finish()
R.id.tab_setting_chapter -> {
openChaptersCategory()
isShowSetting = false
view_setting.visibility = View.GONE
tab_setting_top.visibility = View.GONE
}
R.id.tab_setting_book -> {
popBookSettingDialog()
bookSettingDialog?.show()
isShowSetting = false
view_setting.visibility = View.GONE
tab_setting_top.visibility = View.GONE
}
R.id.tab_setting_share -> {}
R.id.btn_submit -> {
val bundle = Bundle()
bundle.putBoolean(VipActivity.IS_RECOMMEND, true)
readyGo(VipActivity::class.java, bundle)
readyGo(VipActivity::class.java)
}
}
}
......@@ -116,17 +122,31 @@ class LongBookReadActivity : BaseActivity(), View.OnClickListener, BookReadView
LongBookSettingDialog.OnLongBookSettingCallback {
override fun onFontSize(size: Int) {
mPageLoader?.updateTextSize(size)
bookSettingDialog?.setSetting(null, size)
}
override fun onBgColor(color: Int) {
bookSettingDialog?.setSetting(color)
mPageLoader?.setPageStyle(color, Color.BLACK)
}
})
}
private fun popBookVipDialog() {
bookVipDialog = BookVipDialog(this, object : DialogListener() {
override fun onClick(dialog: Dialog?, v: View?) {
super.onClick(dialog, v)
dialog?.dismiss()
readyGo(VipActivity::class.java)
}
})
}
private fun initWidgets() {
//隐藏状态栏
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
val view = window.decorView
view.systemUiVisibility =
(View.SYSTEM_UI_FLAG_FULLSCREEN or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_IMMERSIVE)
//书籍
mPageLoader = pageview.getPageLoader(mBookModel)
......@@ -156,10 +176,21 @@ class LongBookReadActivity : BaseActivity(), View.OnClickListener, BookReadView
}
}
} else {
mPageLoader?.setPageBgColor(Color.WHITE)
mPageLoader?.setPageBgColor(BookConstant.BOOK_CONTENT_COLOR_1.color)
mPageLoader?.setTextSize(18)
mPageLoader?.textColor = Color.BLACK
bookSettingDialog?.setSetting(Color.WHITE, 18)
bookSettingDialog?.setSetting(BookConstant.BOOK_CONTENT_COLOR_1.color, 18)
}
pageview.setOnCenterClickListener {
if (isShowSetting) {
view_setting.visibility = View.VISIBLE
tab_setting_top.visibility = View.VISIBLE
} else {
view_setting.visibility = View.GONE
tab_setting_top.visibility = View.GONE
}
isShowSetting = !isShowSetting
}
//初始化目录
......@@ -169,9 +200,15 @@ class LongBookReadActivity : BaseActivity(), View.OnClickListener, BookReadView
private fun initChapterRecyclerView() {
read_rv_category.layoutManager = LinearLayoutManager(this)
readChaptersAdapter = ReadChaptersAdapter(mPageLoader?.mChapterList, this) { pos ->
mPageLoader?.let {
if (it.mChapterList[pos].isLock && !UserManager.getInstance().vipFlag) {
bookVipDialog?.show()
} else {
mPageLoader?.skipToChapter(pos)
}
read_drawer.closeDrawers()
}
}
//章节回调
mPageLoader?.setChapterChangeListener(object : PageLoader.OnChapterChangeListener {
......@@ -181,9 +218,16 @@ class LongBookReadActivity : BaseActivity(), View.OnClickListener, BookReadView
override fun requestChapters(requestChapters: List<TxtChapterModel>) {}
override fun finishedLoadChapters(bookChapters: List<TxtChapterModel>) {
mPageLoader?.pageView?.showCategory()
mPageLoader?.let {
tv_title.text = "阅读:${it.bookTitle}"
it.pageView.showCategory()
}
readChaptersAdapter?.setChapterModels(bookChapters)
}
override fun onIsVipPage() {
bookVipDialog?.show()
}
})
read_rv_category.adapter = readChaptersAdapter
}
......@@ -200,7 +244,7 @@ class LongBookReadActivity : BaseActivity(), View.OnClickListener, BookReadView
tab_setting_chapter.setOnClickListener(this)
tab_setting_share.setOnClickListener(this)
tab_setting_book.setOnClickListener(this)
btn_submit.setOnClickListener(this)
iv_back.setOnClickListener(this)
}
override fun getBookDetailSuc(data: BookContentBean) {
......@@ -214,4 +258,8 @@ class LongBookReadActivity : BaseActivity(), View.OnClickListener, BookReadView
super.onDestroy()
readPresenter.detachView()
}
override fun isApplyStatusBarTranslucency(): Boolean {
return true
}
}
package com.duben.infinitefunjia.ui.widgets
import android.app.Dialog
import android.content.Context
import android.view.Gravity
import android.view.KeyEvent
import android.view.View
import android.view.WindowManager
import android.widget.ImageView
import android.widget.RelativeLayout
import android.widget.TextView
import com.duben.infinitefunjia.R
class BookVipDialog(private val context: Context, private val listener: DialogListener) : Dialog(
context, R.style.dialog
) {
private val lp: WindowManager.LayoutParams
private val tv_dialog_vip_next: TextView
private val tv_dialog_vip_count: TextView
private val iv_dialog_vip_quit: ImageView
private val rl_dialog_vip_bg: RelativeLayout
init {
setContentView(R.layout.dialog_book_vip)
// 设置window属性
lp = window!!.attributes
lp.gravity = Gravity.CENTER
lp.width = WindowManager.LayoutParams.MATCH_PARENT
lp.windowAnimations = R.style.DialogAnimBottom
window!!.attributes = lp
// 设置外部不可关闭
setCancelable(false)
setCanceledOnTouchOutside(false)
setOnKeyListener { dialogInterface, i, keyEvent ->
i == KeyEvent.KEYCODE_BACK
}
listener.setDialog(this)
// 查找View
iv_dialog_vip_quit = findViewById<View>(R.id.iv_dialog_vip_quit) as ImageView
tv_dialog_vip_next = findViewById<View>(R.id.tv_dialog_vip_next) as TextView
tv_dialog_vip_count = findViewById<View>(R.id.tv_dialog_vip_count) as TextView
rl_dialog_vip_bg = findViewById<View>(R.id.rl_dialog_vip_bg) as RelativeLayout
iv_dialog_vip_quit.setOnClickListener { dismiss() }
tv_dialog_vip_next.setOnClickListener(listener)
}
}
\ No newline at end of file
......@@ -73,10 +73,12 @@ class LongBookSettingDialog(context: Context) : Dialog(context, R.style.dialog)
}
}
fun setSetting(color: Int, size: Int) {
fun setSetting(color: Int? = null, size: Int? = null) {
tv_seek.text = "$size"
seekbar.progress = size
size?.let {
tv_seek.text = "$it"
seekbar.progress = it
}
when (color) {
BookConstant.BOOK_CONTENT_COLOR_1.color -> {
......
......@@ -4,67 +4,25 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
android:layout_height="match_parent">
<com.duben.infinitefunjia.read.YPageView
android:id="@+id/pageview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout
android:id="@+id/view_vip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:orientation="vertical"
android:visibility="gone">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:text="后续内容更精彩,充值后继续阅读"
android:textColor="@color/color_goldenrod" />
<TextView
android:id="@+id/btn_submit"
android:layout_width="300dp"
android:layout_height="38dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="40dp"
android:background="@drawable/btn_bg_gold"
android:gravity="center"
android:text="开通会员,免费阅读本书"
android:textColor="@color/color_goldenrod"
android:textSize="18sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:text="1.目前充值会员暂不支持退款,一经购买不可退换\n\n2.未满18岁的未成年人需要在监护人主导,同意下进行相关付费操作\n\n3.充值一般在5分钟内到账,如未到账请提供支付截图在'我的'页面联系客服\n\n4.之前充值账户请登录后继续阅读"
android:textColor="@color/color_956244" />
</LinearLayout>
</FrameLayout>
<LinearLayout
android:id="@+id/view_setting"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@color/white"
android:orientation="horizontal"
android:paddingTop="5dp"
android:paddingBottom="5dp">
android:paddingBottom="5dp"
android:visibility="gone">
<LinearLayout
android:id="@+id/tab_setting_chapter"
......@@ -79,7 +37,7 @@
android:layout_width="20dp"
android:layout_height="20dp"
android:contentDescription="@null"
android:paddingTop="2dp" />
android:src="@mipmap/ic_book_chapter" />
<TextView
android:id="@+id/tab_tv_bookshelf"
......@@ -95,7 +53,6 @@
<LinearLayout
android:id="@+id/tab_setting_book"
android:layout_width="0dp"
android:background="@color/white"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
......@@ -143,7 +100,41 @@
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/tab_setting_top"
android:layout_width="match_parent"
android:layout_height="65dp"
android:background="@color/white"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingTop="25dp"
android:visibility="gone">
<ImageView
android:id="@+id/iv_back"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginStart="10dp"
android:src="@mipmap/ic_arrow_back" />
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:ellipsize="end"
android:lines="1"
android:maxLength="13"
android:text="阅读:"
android:textColor="@color/black"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
</FrameLayout>
<!--侧滑栏-->
<LinearLayout
android:layout_width="220dp"
......
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/rl_dialog_vip_bg"
android:layout_width="match_parent"
android:layout_height="450dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="36dp"
android:layout_marginTop="-50dp"
android:layout_marginEnd="36dp"
android:background="@mipmap/bg_pay_yes"
android:orientation="vertical">
<ImageView
android:id="@+id/iv_dialog_vip_quit"
android:layout_width="26dp"
android:layout_height="26dp"
android:layout_alignParentEnd="true"
android:layout_marginTop="124dp"
android:layout_marginEnd="15dp"
android:layout_marginRight="20dp"
android:src="@mipmap/ic_vip_back" />
<TextView
android:id="@+id/tv_dialog_vip_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="150dp"
android:text="解锁全集"
android:textColor="#FFF0D4"
android:textSize="16sp" />
<TextView
android:id="@+id/tv_dialog_vip_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="30dp"
android:background="@mipmap/ic_vip_pay_btn" />
</RelativeLayout>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_width="0dp"
android:layout_height="20dp"
android:layout_marginStart="15dp"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
android:layout_weight="1"
android:ellipsize="end"
android:lines="1"
android:textAlignment="textStart"
android:textSize="16sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
android:textSize="16sp" />
<ImageView
android:id="@+id/iv_lock"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginEnd="10dp"
android:src="@mipmap/ic_lock" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
</LinearLayout>
\ No newline at end of file
......@@ -39,7 +39,7 @@
<color name="color_FFF7F7">#FFF7F7</color>
<color name="book_content_color1">#fff</color>
<color name="book_content_color1">#E0E4E7</color>
<color name="book_content_color2">#e7e7e7</color>
<color name="book_content_color3">#d4e0c6</color>
<color name="book_content_color4">#ccd8e4</color>
......
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