Commit 7f90e6c6 authored by jyx's avatar jyx

代码优化

parent 17282d82
package com.mints.enjoyboxjia.common
import com.mints.enjoyboxjia.R
import android.graphics.Color
const val BOOK_BOOK_CONTENT_COLOR = "BOOK_CONTENT_COLOR"
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(R.color.book_content_color1),
BOOK_CONTENT_COLOR_2(R.color.book_content_color2),
BOOK_CONTENT_COLOR_3(R.color.book_content_color3),
BOOK_CONTENT_COLOR_4(R.color.book_content_color4),
BOOK_CONTENT_COLOR_5(R.color.book_content_color5),
BOOK_CONTENT_COLOR_6(R.color.book_content_color6),
BOOK_CONTENT_COLOR_1(Color.parseColor("#ffffff")),
BOOK_CONTENT_COLOR_2(Color.parseColor("#e7e7e7")),
BOOK_CONTENT_COLOR_3(Color.parseColor("#d4e0c6")),
BOOK_CONTENT_COLOR_4(Color.parseColor("#ccd8e4")),
BOOK_CONTENT_COLOR_5(Color.parseColor("#f9d4d4")),
BOOK_CONTENT_COLOR_6(Color.parseColor("#b1b1b1")),
}
\ No newline at end of file
package com.mints.enjoyboxjia.manager
import com.mints.enjoyboxjia.utils.AppPreferencesManager
import com.mints.enjoyboxjia.utils.TimeRender
import java.util.*
class ReadTimeCount {
companion object {
const val KEY_STORAGE_READ_TIME_COUNT = "READ_TIME_COUNT"
val instance by lazy(LazyThreadSafetyMode.NONE) {
ReadTimeCount()
}
}
private var startReadTime: Date? = null // 开始阅读时间
private var readTimeCountMap: String = ""
fun getReadTime(): Array<String> {
if (readTimeCountMap == "") {
readTimeCountMap =
AppPreferencesManager.get()
.getString(
KEY_STORAGE_READ_TIME_COUNT,
TimeRender.formatDate(Date()) + "*0"
)!!
}
val date = readTimeCountMap.split("*")[0]
if (date != TimeRender.formatDate(Date())) {
return TimeRender.ms2HMS_S(0)
}
val time = readTimeCountMap.split("*")[1].toInt()
return TimeRender.ms2HMS_S(time)
}
/**
* 存储阅读时间计时
*/
private fun setReadTimeCount(count: Int) {
if (readTimeCountMap == "") {
readTimeCountMap =
AppPreferencesManager.get()
.getString(
KEY_STORAGE_READ_TIME_COUNT,
TimeRender.formatDate(Date()) + "*0"
)!!
}
var time = readTimeCountMap.split("*")[1].toInt()
time += count
readTimeCountMap = TimeRender.formatDate(Date()) + "*" + time
AppPreferencesManager.get().put(KEY_STORAGE_READ_TIME_COUNT, readTimeCountMap)
}
/**
* 开始阅读计时
*/
fun startCountReadTime() {
startReadTime = Date()
}
/**
* 停止阅读计时
*/
fun endCountReadTime() {
if (startReadTime == null) return
val endReadTime = Date()
val count = (endReadTime.time - startReadTime!!.time).toInt()
startReadTime = null
setReadTimeCount(count)
}
}
\ No newline at end of file
......@@ -52,7 +52,7 @@ class BookReadPresenter : BasePresenter<BookReadView>() {
val vo = HashMap<String, Any>()
vo["articleId"] = bookId
AppHttpManager.getInstance(loanApplication)
.call(loanService.getBookDetail(vo),
.call(loanService.addReadRecord(vo),
object : BaseSubscriber<BaseResponse<JsonObject>>() {
override fun onCompleted() {
if (isLinkView) return
......
package com.mints.enjoyboxjia.mvp.presenters
import com.google.gson.JsonObject
import com.mints.library.net.neterror.Throwable
import com.mints.enjoyboxjia.manager.AppHttpManager
import com.mints.enjoyboxjia.mvp.model.BaseResponse
import com.mints.enjoyboxjia.mvp.model.BookListBean
import com.mints.enjoyboxjia.mvp.views.BookSearchView
import com.mints.library.net.neterror.BaseSubscriber
import java.util.HashMap
......@@ -13,16 +13,16 @@ class BookSearchPresenter : BasePresenter<BookSearchView>() {
fun getHotBook() {
val vo = HashMap<String, Any>()
vo["flag"] = "hot"
vo["quantity"] = "5"
vo["quantity"] = "8"
AppHttpManager.getInstance(loanApplication)
.call(loanService.getRecommendV1(vo),
object : BaseSubscriber<BaseResponse<JsonObject>>() {
object : BaseSubscriber<BaseResponse<BookListBean>>() {
override fun onCompleted() {
if (isLinkView) return
view.hideLoading()
}
override fun onNext(baseResponse: BaseResponse<JsonObject>) {
override fun onNext(baseResponse: BaseResponse<BookListBean>) {
if (isLinkView) return
view.hideLoading()
......@@ -44,6 +44,44 @@ class BookSearchPresenter : BasePresenter<BookSearchView>() {
view.showToast(e?.message)
view.getHotBookFail()
}
})
}
fun searchBook(searchName: String, pageNo: Int, pageSize: Int) {
val vo = HashMap<String, Any>()
vo["searchName"] = searchName
vo["pageNo"] = pageNo
vo["pageSize"] = pageSize
AppHttpManager.getInstance(loanApplication)
.call(loanService.getHomeV1List(vo),
object : BaseSubscriber<BaseResponse<BookListBean>>() {
override fun onCompleted() {
if (isLinkView) return
view.hideLoading()
}
override fun onNext(baseResponse: BaseResponse<BookListBean>) {
if (isLinkView) return
view.hideLoading()
val code = baseResponse.status
val message = baseResponse.message
when (code) {
200 -> view.getSearchBookSuc(baseResponse.data)
else -> {
view.getSearchBookFail()
view.showToast(message)
}
}
}
override fun onError(e: Throwable?) {
if (isLinkView) return
view.hideLoading()
view.showToast(e?.message)
view.getSearchBookFail()
}
})
......
......@@ -49,9 +49,9 @@ class BookShelfPresenter : BasePresenter<BookShelfView>() {
})
}
fun cancelCollect(videoId: List<String>) {
fun cancelCollect(bookId: String) {
val vo = HashMap<String, Any>()
vo["list"] = videoId
vo["articleId"] = bookId
AppHttpManager.getInstance(loanApplication)
.call(loanService.collectCancel(vo),
object : BaseSubscriber<BaseResponse<JsonObject>>() {
......
package com.mints.enjoyboxjia.mvp.views
import com.mints.enjoyboxjia.mvp.model.BookListBean
interface BookSearchView : BaseView {
fun getHotBookSuc(data: Any)
fun getHotBookSuc(data: BookListBean)
fun getHotBookFail()
fun getSearchBookSuc(data: BookListBean)
fun getSearchBookFail()
}
......@@ -179,7 +179,7 @@ public interface LoanService {
Observable<BaseResponse<Object>> collectCancel(@Body Map<String, Object> vo);
/**
* 书库列表
* 书库列表 和 搜索
*
* @return
*/
......
......@@ -2,14 +2,18 @@ package com.mints.enjoyboxjia.ui.activitys
import android.os.Bundle
import android.view.View
import androidx.core.content.ContextCompat
import com.mints.enjoyboxjia.R
import com.mints.enjoyboxjia.common.BOOK_CONTENT_COLOR
import com.mints.enjoyboxjia.common.BOOK_CONTENT_SIZE
import com.mints.enjoyboxjia.manager.ReadTimeCount
import com.mints.enjoyboxjia.mvp.model.BookContentBean
import com.mints.enjoyboxjia.mvp.presenters.BookReadPresenter
import com.mints.enjoyboxjia.mvp.views.BookReadView
import com.mints.enjoyboxjia.ui.activitys.base.BaseActivity
import com.mints.enjoyboxjia.ui.widgets.BookSettingDialog
import com.mints.enjoyboxjia.utils.AppPreferencesManager
import com.mints.library.utils.GlideUtils
import com.mints.library.utils.Utils
import kotlinx.android.synthetic.main.activity_book_read.*
import kotlinx.android.synthetic.main.header_layout.*
import net.nightwhistler.htmlspanner.HtmlSpanner
......@@ -39,14 +43,24 @@ class BookReadActivity : BaseActivity(), View.OnClickListener, BookReadView {
}
override fun initViewsAndEvents() {
tv_title.text = "书"
iv_left_icon.visibility = View.VISIBLE
iv_left_icon.setImageResource(R.mipmap.ic_arrow_back)
readPresenter.attachView(this)
initListener()
popBookSettingDialog()
}
override fun onResume() {
super.onResume()
readPresenter.getBookDetail(bookId)
readPresenter.addReadRecord(bookId)
initListener()
ReadTimeCount.instance.startCountReadTime()
}
override fun onPause() {
super.onPause()
ReadTimeCount.instance.endCountReadTime()
}
override fun onClick(v: View?) {
......@@ -56,13 +70,13 @@ class BookReadActivity : BaseActivity(), View.OnClickListener, BookReadView {
setIsCollect(!isCollect)
}
R.id.tab_setting_book -> {
popBookSettingDialog()
bookSettingDialog?.show()
}
R.id.tab_setting_share -> {
}
R.id.btn_submit -> {
readyGo(VipActivity::class.java)
}
}
}
......@@ -73,18 +87,19 @@ class BookReadActivity : BaseActivity(), View.OnClickListener, BookReadView {
BookSettingDialog.OnBookSettingCallback {
override fun onFontSize(size: Int) {
tv_content.textSize = size.toFloat()
AppPreferencesManager.get().put(BOOK_CONTENT_SIZE, size)
}
override fun onBgColor(color: Int) {
view_book.setBackgroundColor(color)
AppPreferencesManager.get().put(BOOK_CONTENT_COLOR, color)
}
})
bookSettingDialog?.show()
bookSettingDialog?.loadSetting()
}
private fun initListener() {
iv_left_icon.setOnClickListener(this)
tab_setting_collect.setOnClickListener(this)
tab_setting_share.setOnClickListener(this)
tab_setting_book.setOnClickListener(this)
......@@ -104,10 +119,22 @@ class BookReadActivity : BaseActivity(), View.OnClickListener, BookReadView {
}
private fun setBookThumb(data: BookContentBean) {
tv_title.text = "阅读:${data.title}"
GlideUtils.loadImageViewNoAnim2(this, data.avatar, image_iv)
title_tv.text = data.title
info_tv.text = data.summary
label_tv.text = data.author
if (data.isCollect == 1) {
tab_iv_bookshelf.setImageResource(R.mipmap.bookshelf)
tab_tv_bookshelf.text = "已收藏"
tab_tv_bookshelf.setTextColor(ContextCompat.getColor(this, R.color.color_goldenrod))
} else {
tab_iv_bookshelf.setImageResource(R.mipmap.bookshelf)
tab_tv_bookshelf.text = "收藏"
tab_tv_bookshelf.setTextColor(ContextCompat.getColor(this, R.color.black))
}
}
private fun setIsCollect(collect: Boolean) {
......@@ -115,10 +142,12 @@ class BookReadActivity : BaseActivity(), View.OnClickListener, BookReadView {
if (isCollect) {
tab_iv_bookshelf.setImageResource(R.mipmap.bookshelf)
tab_tv_bookshelf.text = "已收藏"
tab_tv_bookshelf.setTextColor(ContextCompat.getColor(this, R.color.color_goldenrod))
readPresenter.collect(bookId)
} else {
tab_iv_bookshelf.setImageResource(R.mipmap.bookshelf)
tab_tv_bookshelf.text = "收藏"
tab_tv_bookshelf.setTextColor(ContextCompat.getColor(this, R.color.black))
readPresenter.cancelCollect(bookId)
}
}
......
package com.mints.enjoyboxjia.ui.activitys
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.flexbox.FlexWrap
import com.google.android.flexbox.FlexboxLayoutManager
import com.google.android.flexbox.JustifyContent
import com.mints.enjoyboxjia.R
import com.mints.enjoyboxjia.common.Constant
import com.mints.enjoyboxjia.mvp.model.BookBean
import com.mints.enjoyboxjia.mvp.model.BookListBean
import com.mints.enjoyboxjia.mvp.presenters.BookSearchPresenter
import com.mints.enjoyboxjia.mvp.views.BookSearchView
import com.mints.enjoyboxjia.ui.activitys.base.BaseActivity
import com.mints.enjoyboxjia.ui.adapter.SearchBookAdapter
import com.mints.enjoyboxjia.ui.adapter.SearchHistoryAdapter
import com.mints.enjoyboxjia.ui.adapter.SearchHotBookAdapter
import com.mints.enjoyboxjia.utils.AppPreferencesManager
import com.mints.enjoyboxjia.utils.LogUtil
import com.scwang.smartrefresh.layout.api.RefreshLayout
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener
import com.scwang.smartrefresh.layout.listener.OnRefreshListener
import kotlinx.android.synthetic.main.activity_book_search.*
import kotlinx.android.synthetic.main.header_layout.*
class BookSearchActivity : BaseActivity(), View.OnClickListener, BookSearchView {
class BookSearchActivity : BaseActivity(), View.OnClickListener, BookSearchView, OnRefreshListener,
OnLoadMoreListener {
companion object {
const val BOOK_SEARCH_HISTORY = "SEARCH_HISTORY"
}
private val searchPresenter by lazy { BookSearchPresenter() }
private var searchBookAdapter: SearchBookAdapter? = null
private var searchBookData = arrayListOf<BookBean>()
private var searchPage = 1 // 分页
private var searchPageSize = Constant.PAGE_SIZE // 分页
private var searchHotBookAdapter: SearchHotBookAdapter? = null
private var searchHotBookData = arrayListOf<BookBean>()
private var searchHistoryAdapter: SearchHistoryAdapter? = null
private var searchHistoryData = arrayListOf<String>()
override fun getContentViewLayoutID() = R.layout.activity_book_search
override fun isApplyKitKatTranslucency() = false
......@@ -19,28 +54,188 @@ class BookSearchActivity : BaseActivity(), View.OnClickListener, BookSearchView
tv_title.text = "书库搜索"
iv_left_icon.visibility = View.VISIBLE
iv_left_icon.setImageResource(R.mipmap.ic_arrow_back)
searchPresenter.attachView(this)
initListener()
initSearchBookAdapter()
initSearchHotBookAdapter()
initSearchHistoryAdapter()
searchPresenter.getHotBook()
getSearchHistory()
}
private fun initSearchHistoryAdapter() {
searchHistoryAdapter = SearchHistoryAdapter(this)
searchHistoryAdapter?.setOnItemClickListener { _, _, position ->
et_search.setText(searchHistoryData[position])
}
val layoutManager = FlexboxLayoutManager(this)
layoutManager.flexWrap = FlexWrap.WRAP
layoutManager.justifyContent = JustifyContent.FLEX_START
rv_search_history.layoutManager = layoutManager
rv_search_history.adapter = searchHistoryAdapter
}
private fun initSearchHotBookAdapter() {
searchHotBookAdapter = SearchHotBookAdapter(this)
searchHotBookAdapter?.setOnItemClickListener { _, _, position ->
val bundle = Bundle()
bundle.putString(BookReadActivity.BOOK_ID, searchHotBookData[position].id)
readyGo(BookReadActivity::class.java, bundle)
}
rv_hot.layoutManager = LinearLayoutManager(this)
rv_hot.adapter = searchHotBookAdapter
}
private fun initSearchBookAdapter() {
searchBookAdapter = SearchBookAdapter(this)
searchBookAdapter?.setOnItemClickListener { _, _, position ->
val bundle = Bundle()
bundle.putString(BookReadActivity.BOOK_ID, searchBookData[position].id)
readyGo(BookReadActivity::class.java, bundle)
}
rv_search_show.layoutManager = LinearLayoutManager(this)
rv_search_show.adapter = searchBookAdapter
}
override fun onClick(v: View?) {
when (v?.id) {
R.id.iv_left_icon -> finish()
R.id.btn_search -> {
searchBook(et_search.text.toString())
}
R.id.iv_clear -> {
clearSearchHistory()
}
}
}
private fun initListener() {
srl_show.setOnRefreshListener(this)
srl_show.setOnLoadMoreListener(this)
iv_left_icon.setOnClickListener(this)
btn_search.setOnClickListener(this)
iv_clear.setOnClickListener(this)
et_search.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
if (s != null && s.toString() != "") {
addSearchHistory(s.toString())
searchBook(s.toString())
fl_main.visibility = View.GONE
fl_search_show.visibility = View.VISIBLE
} else {
fl_main.visibility = View.VISIBLE
fl_search_show.visibility = View.GONE
}
}
override fun afterTextChanged(s: Editable?) {
}
})
}
override fun getHotBookSuc(data: Any) {
private fun searchBook(book: String) {
searchPresenter.searchBook(book, searchPage, searchPageSize)
}
override fun getHotBookSuc(data: BookListBean) {
searchHotBookData.clear()
searchHotBookData.addAll(data.records)
searchHotBookAdapter?.setNewInstance(searchHotBookData)
}
override fun getHotBookFail() {
}
override fun getSearchBookSuc(data: BookListBean) {
if (searchPage == 1) {
if (data.records.size > 0) {
search_show_empty.visibility = View.GONE
srl_show.visibility = View.VISIBLE
} else {
search_show_empty.visibility = View.VISIBLE
srl_show.visibility = View.GONE
}
srl_show.finishRefresh(true)
searchBookData.clear()
searchBookData.addAll(data.records)
searchBookAdapter?.setNewInstance(data.records)
} else {
if (data.records.size < searchPageSize) {
srl_show.finishLoadMoreWithNoMoreData()
} else {
srl_show.finishLoadMore()
}
searchBookData.addAll(data.records)
searchBookAdapter?.addData(data.records)
}
}
override fun getSearchBookFail() {
search_show_empty.visibility = View.GONE
rv_search_show.visibility = View.VISIBLE
}
private fun addSearchHistory(str: String) {
LogUtil.d("XXXXXXXXXX", str)
var searchHistory = AppPreferencesManager.get().getString(BOOK_SEARCH_HISTORY, "")
searchHistory += ",$str"
AppPreferencesManager.get().put(BOOK_SEARCH_HISTORY, searchHistory)
rv_search_history.visibility = View.VISIBLE
search_empty.visibility = View.GONE
val searchList = searchHistory!!.split(",")
searchHistoryData.clear()
for (s in searchList) {
if (s != "") {
searchHistoryData.add(s)
}
}
searchHistoryAdapter?.notifyDataSetChanged()
}
private fun getSearchHistory() {
val searchHistory = AppPreferencesManager.get().getString(BOOK_SEARCH_HISTORY, "")
if (searchHistory == "") {
rv_search_history.visibility = View.GONE
search_empty.visibility = View.VISIBLE
} else {
rv_search_history.visibility = View.VISIBLE
search_empty.visibility = View.GONE
val searchList = searchHistory!!.split(",")
searchHistoryData.clear()
for (s in searchList) {
if (s != "") {
searchHistoryData.add(s)
}
}
searchHistoryAdapter?.setNewInstance(searchHistoryData)
}
}
private fun clearSearchHistory() {
AppPreferencesManager.get().put(BOOK_SEARCH_HISTORY, "")
searchHistoryData.clear()
searchHistoryAdapter?.notifyDataSetChanged()
rv_search_history.visibility = View.GONE
search_empty.visibility = View.VISIBLE
}
override fun onRefresh(refreshLayout: RefreshLayout) {
searchPage = 1
srl_show.resetNoMoreData()
searchBook(et_search.text.toString())
}
override fun onLoadMore(refreshLayout: RefreshLayout) {
++searchPage
searchBook(et_search.text.toString())
}
}
package com.mints.enjoyboxjia.ui.adapter
import android.app.Activity
import android.text.SpannableString
import android.text.SpannableStringBuilder
import android.text.Spanned
import android.view.View
import android.widget.CheckBox
import android.widget.ImageView
import android.widget.ImageView.ScaleType
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.mints.enjoyboxjia.R
import com.mints.enjoyboxjia.mvp.model.BookBean
import com.mints.enjoyboxjia.utils.RoundBackgroundColorSpan
import com.mints.library.utils.GlideUtils
/**
......@@ -21,18 +28,42 @@ class BookShelfAdapter(var activity: Activity) :
private var showEdit = false
override fun convert(holder: BaseViewHolder, item: BookBean) {
if (holder.adapterPosition == data.size - 1) {
holder.getView<ImageView>(R.id.image_iv).scaleType = ScaleType.FIT_XY
return
}
holder.getView<CheckBox>(R.id.cb).isChecked = item.isChecked
holder.getView<CheckBox>(R.id.cb).setOnCheckedChangeListener { buttonView, isChecked ->
holder.getView<CheckBox>(R.id.cb).setOnCheckedChangeListener { _, isChecked ->
item.isChecked = isChecked
}
holder.getView<View>(R.id.fm_mask).visibility = if (showEdit) View.VISIBLE else View.GONE
holder.getView<TextView>(R.id.title_tv).text = item.title
// holder.getView<TextView>(R.id.info_tv).text = "观看至第${item.seeIndex}集"
GlideUtils.loadImageView(context, item.avatar, holder.getView(R.id.image_iv))
if (item.tagList != null && item.tagList.size > 0) {
val span = SpannableStringBuilder()
for (i in 0 until item.tagList.size) {
val labelText = SpannableString(" " + item.tagList[i].name + " ")
val start = 0
val end = item.tagList[i].name.length + 4
labelText.setSpan(
RoundBackgroundColorSpan(
ContextCompat.getColor(activity, R.color.color_FEF3F3),
ContextCompat.getColor(activity, R.color.color_F1413C)
), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
span.append(labelText)
}
holder.getView<TextView>(R.id.label_tv).text = span
}
GlideUtils.loadImageViewNoAnim2(context, item.avatar, holder.getView(R.id.image_iv))
}
// 设置编辑状态
fun setEditStyle(showEdit: Boolean) {
this.showEdit = showEdit
// 清除选中状态
if (!this.showEdit) {
for (datum in data) {
......@@ -42,16 +73,4 @@ class BookShelfAdapter(var activity: Activity) :
notifyDataSetChanged()
}
// 设置编辑状态
fun getEditStyle(): Boolean {
return this.showEdit
}
// 全选
fun fullChoice() {
for (datum in data) {
datum.isChecked = true
}
notifyDataSetChanged()
}
}
\ No newline at end of file
package com.mints.enjoyboxjia.ui.adapter
import android.app.Activity
import android.text.SpannableString
import android.text.SpannableStringBuilder
import android.text.Spanned
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.mints.enjoyboxjia.R
import com.mints.enjoyboxjia.mvp.model.BookBean
import com.mints.enjoyboxjia.utils.RoundBackgroundColorSpan
import com.mints.library.utils.GlideUtils
class SearchBookAdapter(var activity: Activity) :
BaseQuickAdapter<BookBean, BaseViewHolder>(R.layout.item_hotbook) {
override fun convert(holder: BaseViewHolder, item: BookBean) {
holder.getView<TextView>(R.id.title_tv).text = item.title
holder.getView<TextView>(R.id.info_tv).text = item.summary
if (item.tagList != null && item.tagList.size > 0) {
val span = SpannableStringBuilder()
for (i in 0 until item.tagList.size) {
val labelText = SpannableString(" " + item.tagList[i].name + " ")
val start = 0
val end = item.tagList[i].name.length + 4
labelText.setSpan(
RoundBackgroundColorSpan(
ContextCompat.getColor(activity, R.color.color_FEF3F3),
ContextCompat.getColor(activity, R.color.color_F1413C)
), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
span.append(labelText)
}
holder.getView<TextView>(R.id.label_tv).text = span
}
GlideUtils.loadImageViewNoAnim2(context, item.avatar, holder.getView(R.id.image_iv))
}
}
\ No newline at end of file
package com.mints.enjoyboxjia.ui.adapter
import android.app.Activity
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.mints.enjoyboxjia.R
class SearchHistoryAdapter(var activity: Activity) :
BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_search_history) {
override fun convert(holder: BaseViewHolder, item: String) {
holder.getView<TextView>(R.id.title_tv).text = item
}
}
\ No newline at end of file
package com.mints.enjoyboxjia.ui.adapter
import android.app.Activity
import android.text.SpannableString
import android.text.SpannableStringBuilder
import android.text.Spanned
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.mints.enjoyboxjia.R
import com.mints.enjoyboxjia.mvp.model.BookBean
import com.mints.enjoyboxjia.utils.RoundBackgroundColorSpan
import com.mints.library.utils.GlideUtils
class SearchHotBookAdapter(var activity: Activity) :
BaseQuickAdapter<BookBean, BaseViewHolder>(R.layout.item_hotbook) {
override fun convert(holder: BaseViewHolder, item: BookBean) {
holder.getView<TextView>(R.id.title_tv).text = item.title
holder.getView<TextView>(R.id.info_tv).text = item.summary
if (item.tagList != null && item.tagList.size > 0) {
val span = SpannableStringBuilder()
for (i in 0 until item.tagList.size) {
val labelText = SpannableString(" " + item.tagList[i].name + " ")
val start = 0
val end = item.tagList[i].name.length + 4
labelText.setSpan(
RoundBackgroundColorSpan(
ContextCompat.getColor(activity, R.color.color_FEF3F3),
ContextCompat.getColor(activity, R.color.color_F1413C)
), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
span.append(labelText)
}
holder.getView<TextView>(R.id.label_tv).text = span
}
GlideUtils.loadImageViewNoAnim2(context, item.avatar, holder.getView(R.id.image_iv))
}
}
\ No newline at end of file
......@@ -10,7 +10,6 @@ import android.view.View
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import com.mints.enjoyboxjia.R
import com.mints.enjoyboxjia.ad.AdManager
import com.mints.enjoyboxjia.common.AppConfig
......@@ -21,6 +20,7 @@ import com.mints.enjoyboxjia.mvp.model.BookListBean
import com.mints.enjoyboxjia.mvp.presenters.BookCityPresenter
import com.mints.enjoyboxjia.mvp.views.BookCityView
import com.mints.enjoyboxjia.ui.activitys.BookReadActivity
import com.mints.enjoyboxjia.ui.activitys.BookSearchActivity
import com.mints.enjoyboxjia.ui.adapter.HotBookAdapter
import com.mints.enjoyboxjia.ui.adapter.NewBookAdapter
import com.mints.enjoyboxjia.ui.adapter.ImageTitleAdapter
......@@ -40,9 +40,9 @@ class BookCityFragment : LazyLoadBaseFragment(), BookCityView, View.OnClickListe
private val userManager by lazy { UserManager.getInstance() }
private var hotBookAdapter: HotBookAdapter? = null
private var hotBookData: MutableList<BookBean> = mutableListOf()
private var hotBookData = arrayListOf<BookBean>()
private var newBookAdapter: NewBookAdapter? = null
private var newBookData: MutableList<BookBean> = mutableListOf()
private var newBookData = arrayListOf<BookBean>()
override fun getContentViewLayoutID() = R.layout.fragment_main_bookcity
......@@ -162,11 +162,11 @@ class BookCityFragment : LazyLoadBaseFragment(), BookCityView, View.OnClickListe
}
override fun getHotBookSuc(data: BookListBean) {
// hotBookData.clear()
// hotBookData.addAll(data.records)
// hotBookData.removeAt(0)
// hotBookAdapter?.addHeaderView(getHotHeader(data.records[0]))
// hotBookAdapter?.setNewInstance(hotBookData)
hotBookData.clear()
hotBookData.addAll(data.records)
hotBookData.removeAt(0)
hotBookAdapter?.addHeaderView(getHotHeader(data.records[0]))
hotBookAdapter?.setNewInstance(hotBookData)
}
override fun getHotBookFail() {}
......@@ -175,12 +175,6 @@ class BookCityFragment : LazyLoadBaseFragment(), BookCityView, View.OnClickListe
newBookData.clear()
newBookData.addAll(data.records)
newBookAdapter?.setNewInstance(newBookData)
hotBookData.clear()
hotBookData.addAll(data.records)
hotBookData.removeAt(0)
hotBookAdapter?.addHeaderView(getHotHeader(data.records[0]))
hotBookAdapter?.setNewInstance(hotBookData)
}
override fun getNewBookFail() {}
......@@ -207,6 +201,7 @@ class BookCityFragment : LazyLoadBaseFragment(), BookCityView, View.OnClickListe
bookCityPresenter.getNewBook()
}
R.id.view_search -> {
readyGo(BookSearchActivity::class.java)
}
}
}
......
......@@ -6,6 +6,7 @@ import androidx.recyclerview.widget.GridLayoutManager
import com.mints.enjoyboxjia.R
import com.mints.enjoyboxjia.common.AppConfig
import com.mints.enjoyboxjia.common.Constant
import com.mints.enjoyboxjia.manager.ReadTimeCount
import com.mints.enjoyboxjia.mvp.model.BookBean
import com.mints.enjoyboxjia.mvp.model.BookListBean
import com.mints.enjoyboxjia.mvp.presenters.BookShelfPresenter
......@@ -16,6 +17,7 @@ import com.mints.enjoyboxjia.ui.adapter.BookShelfAdapter
import com.mints.enjoyboxjia.ui.adapter.LikeBookAdapter
import com.mints.enjoyboxjia.ui.fragment.base.LazyLoadBaseFragment
import com.mints.enjoyboxjia.utils.GridSpacingItemDecoration
import com.mints.enjoyboxjia.utils.SpanUtils
import kotlinx.android.synthetic.main.fragment_main_bookshelf.*
......@@ -26,7 +28,7 @@ class BookShelfFragment : LazyLoadBaseFragment(), BookShelfView, View.OnClickLis
private var bookShelfAdapter: BookShelfAdapter? = null
private var likeBookAdapter: LikeBookAdapter? = null
private var likeBookData: MutableList<BookBean> = mutableListOf()
private var likeBookData = arrayListOf<BookBean>()
override fun getContentViewLayoutID() = R.layout.fragment_main_bookshelf
......@@ -35,6 +37,25 @@ class BookShelfFragment : LazyLoadBaseFragment(), BookShelfView, View.OnClickLis
initListener()
initLikeAdapter()
initShelfAdapter()
}
private fun initShelfAdapter() {
bookShelfAdapter = BookShelfAdapter(requireActivity())
bookShelfAdapter?.setOnItemClickListener { _, _, position ->
if (position >= shelfBookData.size - 1) {
(requireActivity() as MainActivity).clickTab2Layout()
return@setOnItemClickListener
}
val bundle = Bundle()
bundle.putString(BookReadActivity.BOOK_ID, shelfBookData[position].id)
readyGo(BookReadActivity::class.java, bundle)
}
rv_bookshelf.layoutManager = GridLayoutManager(requireContext(), 3)
val itemDecoration = GridSpacingItemDecoration(3, 10, false)
rv_bookshelf.addItemDecoration(itemDecoration)
rv_bookshelf.adapter = bookShelfAdapter
}
private fun initLikeAdapter() {
......@@ -45,7 +66,7 @@ class BookShelfFragment : LazyLoadBaseFragment(), BookShelfView, View.OnClickLis
readyGo(BookReadActivity::class.java, bundle)
}
rv_booklike.layoutManager = GridLayoutManager(requireContext(), 4)
val itemDecoration = GridSpacingItemDecoration(5, 10, false)
val itemDecoration = GridSpacingItemDecoration(4, 10, false)
rv_booklike.addItemDecoration(itemDecoration)
rv_booklike.adapter = likeBookAdapter
}
......@@ -54,9 +75,36 @@ class BookShelfFragment : LazyLoadBaseFragment(), BookShelfView, View.OnClickLis
if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_ONE) {
bookShelfPresenter.getCollectList()
bookShelfPresenter.getArticleLike()
getReadTime()
}
}
private fun getReadTime() {
val time = ReadTimeCount.instance.getReadTime()
tv_read_hour.text = SpanUtils()
.append(time[0])
.setFontSize(20, true)
.setBold()
.append("\n小时")
.setFontSize(10, true)
.create()
tv_read_minute.text = SpanUtils()
.append(time[1])
.setFontSize(20, true)
.setBold()
.append("\n分")
.setFontSize(10, true)
.create()
tv_read_second.text = SpanUtils()
.append(time[2])
.setFontSize(20, true)
.setBold()
.append("\n秒")
.setFontSize(10, true)
.create()
}
override fun onHiddenChanged(hidden: Boolean) {
if (hidden) { // 不在最前端界面显示
onPause()
......@@ -75,13 +123,23 @@ class BookShelfFragment : LazyLoadBaseFragment(), BookShelfView, View.OnClickLis
iv_edit.setOnClickListener(this)
iv_close.setOnClickListener(this)
iv_change.setOnClickListener(this)
btn_empty.setOnClickListener(this)
}
override fun getCollectListSuc(data: BookListBean) {
shelfBookData.clear()
shelfBookData.addAll(data.records)
bookShelfAdapter?.setNewInstance(shelfBookData)
bookShelfAdapter?.setEditStyle(false)
if (data.records.size > 0) {
bookshelf_empty.visibility = View.GONE
rv_bookshelf.visibility = View.VISIBLE
shelfBookData.clear()
shelfBookData.addAll(data.records)
shelfBookData.add(BookBean())
bookShelfAdapter?.setNewInstance(shelfBookData)
bookShelfAdapter?.setEditStyle(false)
} else {
bookshelf_empty.visibility = View.VISIBLE
rv_bookshelf.visibility = View.GONE
}
}
override fun getCollectListFail() {
......@@ -99,10 +157,11 @@ class BookShelfFragment : LazyLoadBaseFragment(), BookShelfView, View.OnClickLis
override fun cancelCollectSuc() {
bookShelfPresenter.getCollectList()
(requireActivity() as MainActivity).showEdit(true)
handleEditStyle(false)
}
override fun cancelCollectFail() {
handleEditStyle(false)
}
private fun handleEditStyle(isEdit: Boolean) {
......@@ -126,10 +185,10 @@ class BookShelfFragment : LazyLoadBaseFragment(), BookShelfView, View.OnClickLis
}
fun delete() {
val strArr = arrayListOf<String>()
var strArr = ""
for (datum in shelfBookData) {
if (datum.isChecked) {
strArr.add("" + datum.id)
if (datum.isChecked && datum.id != null) {
strArr += (datum.id + ",")
}
}
bookShelfPresenter.cancelCollect(strArr)
......@@ -147,6 +206,9 @@ class BookShelfFragment : LazyLoadBaseFragment(), BookShelfView, View.OnClickLis
R.id.iv_change -> {
bookShelfPresenter.getArticleLike()
}
R.id.btn_empty -> {
(requireActivity() as MainActivity).clickTab2Layout()
}
}
}
}
......
......@@ -3,15 +3,17 @@ package com.mints.enjoyboxjia.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.RadioButton
import android.widget.SeekBar
import com.mints.enjoyboxjia.R
import com.mints.enjoyboxjia.common.BOOK_CONTENT_COLOR
import com.mints.enjoyboxjia.common.BOOK_CONTENT_SIZE
import com.mints.enjoyboxjia.common.BookConstant
import com.mints.enjoyboxjia.utils.AppPreferencesManager
import kotlinx.android.synthetic.main.dialog_book_setting.*
class BookSettingDialog(context: Context) : Dialog(context, R.style.dialog), View.OnClickListener {
class BookSettingDialog(context: Context) : Dialog(context, R.style.dialog) {
private var mOnBookSettingCallback: OnBookSettingCallback? = null
......@@ -22,21 +24,16 @@ class BookSettingDialog(context: Context) : Dialog(context, R.style.dialog), Vie
lp.gravity = Gravity.BOTTOM
lp.width = WindowManager.LayoutParams.MATCH_PARENT
lp.windowAnimations = R.style.DialogAnimBottom
// lp.dimAmount = 0f // 去背景遮盖
// lp.dimAmount = 0f // 去背景遮盖
lp.alpha = 1f//透明效果
window!!.attributes = lp
// 设置外部不可关闭
setCancelable(true)
setCanceledOnTouchOutside(true)
// setOnKeyListener { _, i, _ ->
// i == KeyEvent.KEYCODE_BACK
// }
(seekbar as SeekBar).setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
mOnBookSettingCallback?.onFontSize(progress)
tv_seek.text = "$progress"
mOnBookSettingCallback?.onFontSize(progress)
}
override fun onStartTrackingTouch(seekBar: SeekBar?) {}
......@@ -44,34 +41,82 @@ class BookSettingDialog(context: Context) : Dialog(context, R.style.dialog), Vie
override fun onStopTrackingTouch(seekBar: SeekBar?) {}
})
rb_color1.setOnClickListener(this)
rb_color2.setOnClickListener(this)
rb_color3.setOnClickListener(this)
rb_color4.setOnClickListener(this)
rb_color5.setOnClickListener(this)
rb_color6.setOnClickListener(this)
rg_color.setOnCheckedChangeListener { group, checkedId ->
for (i in 0 until group.childCount) {
val rb = group.getChildAt(i) as RadioButton
if (rb.id == checkedId) {
rb.scaleX = 1.2f
rb.scaleY = 1.2f
} else {
rb.scaleX = 1f
rb.scaleY = 1f
}
}
when (checkedId) {
R.id.rb_color1 -> {
mOnBookSettingCallback?.onBgColor(BookConstant.BOOK_CONTENT_COLOR_1.color)
}
R.id.rb_color2 -> {
mOnBookSettingCallback?.onBgColor(BookConstant.BOOK_CONTENT_COLOR_2.color)
}
R.id.rb_color3 -> {
mOnBookSettingCallback?.onBgColor(BookConstant.BOOK_CONTENT_COLOR_3.color)
}
R.id.rb_color4 -> {
mOnBookSettingCallback?.onBgColor(BookConstant.BOOK_CONTENT_COLOR_4.color)
}
R.id.rb_color5 -> {
mOnBookSettingCallback?.onBgColor(BookConstant.BOOK_CONTENT_COLOR_5.color)
}
R.id.rb_color6 -> {
mOnBookSettingCallback?.onBgColor(BookConstant.BOOK_CONTENT_COLOR_6.color)
}
else -> {}
}
}
}
override fun onClick(v: View?) {
when (v?.id) {
R.id.rb_color1 -> {
mOnBookSettingCallback?.onBgColor(BookConstant.BOOK_CONTENT_COLOR_1.color)
fun loadSetting() {
val color = AppPreferencesManager.get()
.getInt(BOOK_CONTENT_COLOR, BookConstant.BOOK_CONTENT_COLOR_1.color)
val size = AppPreferencesManager.get()
.getInt(BOOK_CONTENT_SIZE, 17)
tv_seek.text = "$size"
seekbar.progress = size
mOnBookSettingCallback?.onBgColor(color)
mOnBookSettingCallback?.onFontSize(size)
when (color) {
BookConstant.BOOK_CONTENT_COLOR_1.color -> {
rb_color1.scaleX = 1.2f
rb_color1.scaleY = 1.2f
rb_color1.isChecked = true
}
R.id.rb_color2 -> {
mOnBookSettingCallback?.onBgColor(BookConstant.BOOK_CONTENT_COLOR_2.color)
BookConstant.BOOK_CONTENT_COLOR_2.color -> {
rb_color2.scaleX = 1.2f
rb_color2.scaleY = 1.2f
rb_color2.isChecked = true
}
R.id.rb_color3 -> {
mOnBookSettingCallback?.onBgColor(BookConstant.BOOK_CONTENT_COLOR_3.color)
BookConstant.BOOK_CONTENT_COLOR_3.color -> {
rb_color3.scaleX = 1.2f
rb_color3.scaleY = 1.2f
rb_color3.isChecked = true
}
R.id.rb_color4 -> {
mOnBookSettingCallback?.onBgColor(BookConstant.BOOK_CONTENT_COLOR_4.color)
BookConstant.BOOK_CONTENT_COLOR_4.color -> {
rb_color4.scaleX = 1.2f
rb_color4.scaleY = 1.2f
rb_color4.isChecked = true
}
R.id.rb_color5 -> {
mOnBookSettingCallback?.onBgColor(BookConstant.BOOK_CONTENT_COLOR_5.color)
BookConstant.BOOK_CONTENT_COLOR_5.color -> {
rb_color5.scaleX = 1.2f
rb_color5.scaleY = 1.2f
rb_color5.isChecked = true
}
R.id.rb_color6 -> {
mOnBookSettingCallback?.onBgColor(BookConstant.BOOK_CONTENT_COLOR_6.color)
BookConstant.BOOK_CONTENT_COLOR_6.color -> {
rb_color6.scaleX = 1.2f
rb_color6.scaleY = 1.2f
rb_color6.isChecked = true
}
}
}
......
......@@ -193,19 +193,20 @@ object TimeRender {
val yearZ = split[0].toInt()
val monthZ = split[1].toInt() - 1
val dayZ = split[2].toInt()
val datePickerDialog = DatePickerDialog(context!!, OnDateSetListener { view, year, monthOfYear, dayOfMonth ->
nqMonth = if (monthOfYear + 1 < 10) {
"0" + (monthOfYear + 1)
} else {
(monthOfYear + 1).toString()
}
nqDay = if (dayOfMonth < 10) {
"0$dayOfMonth"
} else {
dayOfMonth.toString()
}
editText.setText("$year-$nqMonth-$nqDay")
}, yearZ, monthZ, dayZ)
val datePickerDialog =
DatePickerDialog(context!!, OnDateSetListener { view, year, monthOfYear, dayOfMonth ->
nqMonth = if (monthOfYear + 1 < 10) {
"0" + (monthOfYear + 1)
} else {
(monthOfYear + 1).toString()
}
nqDay = if (dayOfMonth < 10) {
"0$dayOfMonth"
} else {
dayOfMonth.toString()
}
editText.setText("$year-$nqMonth-$nqDay")
}, yearZ, monthZ, dayZ)
datePickerDialog.show()
}
......@@ -257,6 +258,27 @@ object TimeRender {
return HMStime
}
fun ms2HMS_S(ms: Int): Array<String> {
var _ms = ms
_ms /= 1000
val hour = _ms / 3600
val mint = _ms % 3600 / 60
val sed = _ms % 60
var hourStr = hour.toString()
if (hour < 10) {
hourStr = "0$hourStr"
}
var mintStr = mint.toString()
if (mint < 10) {
mintStr = "0$mintStr"
}
var sedStr = sed.toString()
if (sed < 10) {
sedStr = "0$sedStr"
}
return arrayOf(hourStr, mintStr, sedStr)
}
/**
* 时间戳转换成时间格式
*
......@@ -291,6 +313,7 @@ object TimeRender {
now[Calendar.DATE] = now[Calendar.DATE] + day
return formatDateDot(now.time)
}
fun formatDateDot(date: Date?): String {
val f = SimpleDateFormat(DEFAULT_FORMAT_DOT)
return f.format(date)
......
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/shape_book_content_color1_s" android:state_checkable="true" android:state_selected="true" />
<item android:drawable="@drawable/shape_book_content_color1" android:state_checkable="false" android:state_selected="false" />
<item android:drawable="@drawable/shape_book_content_color1_s" android:state_checked="true" />
<item android:drawable="@drawable/shape_book_content_color1" android:state_checked="false" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/shape_book_content_color2_s" android:state_checkable="true" android:state_selected="true" />
<item android:drawable="@drawable/shape_book_content_color2" android:state_checkable="false" android:state_selected="false" />
<item android:drawable="@drawable/shape_book_content_color2_s" android:state_checked="true" />
<item android:drawable="@drawable/shape_book_content_color2" android:state_checked="false" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/shape_book_content_color3_s" android:state_checkable="true" android:state_selected="true" />
<item android:drawable="@drawable/shape_book_content_color3" android:state_checkable="false" android:state_selected="false" />
<item android:drawable="@drawable/shape_book_content_color3_s" android:state_checked="true" />
<item android:drawable="@drawable/shape_book_content_color3" android:state_checked="false" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/shape_book_content_color4_s" android:state_checkable="true" android:state_selected="true" />
<item android:drawable="@drawable/shape_book_content_color4" android:state_checkable="false" android:state_selected="false" />
<item android:drawable="@drawable/shape_book_content_color4_s" android:state_checked="true" />
<item android:drawable="@drawable/shape_book_content_color4" android:state_checked="false" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/shape_book_content_color5_s" android:state_checkable="true" android:state_selected="true" />
<item android:drawable="@drawable/shape_book_content_color5" android:state_checkable="false" android:state_selected="false" />
<item android:drawable="@drawable/shape_book_content_color5_s" android:state_checked="true" />
<item android:drawable="@drawable/shape_book_content_color5" android:state_checked="false" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/shape_book_content_color6_s" android:state_checkable="true" android:state_selected="true" />
<item android:drawable="@drawable/shape_book_content_color6" android:state_checkable="false" android:state_selected="false" />
<item android:drawable="@drawable/shape_book_content_color6_s" android:state_checked="true" />
<item android:drawable="@drawable/shape_book_content_color6" android:state_checked="false" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/shape_round_blue" android:state_focused="true" />
<item android:drawable="@drawable/shape_round_gray" android:state_focused="false" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FEF3F3" />
<corners android:radius="5dip" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/gmts_blue" />
<corners android:radius="4dip" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 填充的颜色 -->
<solid android:color="@color/half_transparent" />
<!-- 设置按钮的四个角为弧形 -->
<!-- android:radius 弧形的半径 -->
<corners android:radius="10dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 填充的颜色 -->
<solid android:color="@color/full_transparent" />
<stroke
android:width="1dp"
android:color="@color/id_photo_gray" />
<!-- 设置按钮的四个角为弧形 -->
<!-- android:radius 弧形的半径 -->
<corners android:radius="4dip" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 填充的颜色 -->
<solid android:color="@color/id_photo_gray" />
<!-- 设置按钮的四个角为弧形 -->
<!-- android:radius 弧形的半径 -->
<corners android:radius="10dp" />
</shape>
\ No newline at end of file
......@@ -3,61 +3,213 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:background="@color/color_FFF7F7"
android:orientation="vertical">
<include layout="@layout/header_layout" />
<com.mints.enjoyboxjia.ui.widgets.ElasticScrollView
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:overScrollMode="never">
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="15dp">
<com.mints.enjoyboxjia.ui.widgets.ClearEditText
android:id="@+id/et_search"
android:layout_width="0dp"
android:layout_height="36dp"
android:layout_weight="1"
android:background="@drawable/selector_search_edit"
android:gravity="center_vertical"
android:hint="请输入书名或者作者名"
android:inputType="text"
android:maxLength="13"
android:maxLines="1"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:textColor="#172B54"
android:textColorHint="#BEC2CC"
android:textSize="12sp" />
<Button
android:id="@+id/btn_search"
android:layout_width="66dp"
android:layout_height="30dp"
android:layout_marginStart="10dp"
android:background="@drawable/shape_full_blue"
android:text="搜索"
android:textColor="@color/white" />
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
<com.mints.enjoyboxjia.ui.widgets.ElasticScrollView
android:id="@+id/fl_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:background="@drawable/shape_bg_write"
android:elevation="2dp"
android:orientation="vertical"
android:padding="10dp">
android:layout_height="match_parent"
android:fillViewport="true"
android:overScrollMode="never">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="36dp"
android:gravity="center_vertical"
android:orientation="horizontal">
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="0dp"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="热门推荐"
android:textColor="@color/black"
android:textSize="18sp" />
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/iv_change"
android:layout_width="wrap_content"
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="搜索历史"
android:textColor="@color/black"
android:textSize="16sp" />
<ImageView
android:id="@+id/iv_clear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_text_clear" />
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
android:background="#ededed">
<FrameLayout
android:id="@+id/search_empty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:layout_marginBottom="40dp"
android:src="@mipmap/bg_search_data" />
</FrameLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_search_history"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp" />
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="换一换" />
android:layout_margin="15dp"
android:background="@drawable/shape_bg_write"
android:elevation="2dp"
android:orientation="vertical"
android:padding="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="36dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="热门推荐"
android:textColor="@color/black"
android:textSize="18sp" />
<TextView
android:id="@+id/iv_change"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="换一换" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_hot"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</com.mints.enjoyboxjia.ui.widgets.ElasticScrollView>
<FrameLayout
android:id="@+id/fl_search_show"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_hot"
<FrameLayout
android:id="@+id/search_show_empty"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:visibility="gone">
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:layout_marginBottom="40dp"
android:src="@mipmap/bg_search_data" />
</LinearLayout>
</com.mints.enjoyboxjia.ui.widgets.ElasticScrollView>
</FrameLayout>
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/srl_show"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srlAccentColor="@color/black"
app:srlPrimaryColor="#fef3f3">
<com.scwang.smartrefresh.layout.header.ClassicsHeader
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_search_show"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp" />
<com.scwang.smartrefresh.layout.footer.ClassicsFooter
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srlAccentColor="@color/black"
app:srlPrimaryColor="#F8F8F8" />
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
</FrameLayout>
</FrameLayout>
</LinearLayout>
</LinearLayout>
......@@ -2,13 +2,14 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:background="@drawable/shape_tab_friends"
android:orientation="vertical"
android:padding="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="字体大小"
android:textColor="@color/black"
android:textSize="14sp"
......@@ -26,6 +27,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/full_transparent"
android:max="24"
android:maxHeight="5dp"
android:min="14"
......@@ -51,14 +53,15 @@
android:textSize="14sp"
android:textStyle="bold" />
<LinearLayout
<RadioGroup
android:id="@+id/rg_color"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="60dp"
android:layout_marginTop="15dp"
android:gravity="center_horizontal"
android:gravity="center"
android:orientation="horizontal">
<CheckBox
<RadioButton
android:id="@+id/rb_color1"
android:layout_width="42dp"
android:layout_height="42dp"
......@@ -67,7 +70,7 @@
android:button="@null"
android:checked="true" />
<CheckBox
<RadioButton
android:id="@+id/rb_color2"
android:layout_width="42dp"
android:layout_height="42dp"
......@@ -76,7 +79,7 @@
android:button="@null"
android:checked="false" />
<CheckBox
<RadioButton
android:id="@+id/rb_color3"
android:layout_width="42dp"
android:layout_height="42dp"
......@@ -85,7 +88,7 @@
android:button="@null"
android:checked="false" />
<CheckBox
<RadioButton
android:id="@+id/rb_color4"
android:layout_width="42dp"
android:layout_height="42dp"
......@@ -94,7 +97,7 @@
android:button="@null"
android:checked="false" />
<CheckBox
<RadioButton
android:id="@+id/rb_color5"
android:layout_width="42dp"
android:layout_height="42dp"
......@@ -103,7 +106,7 @@
android:button="@null"
android:checked="false" />
<CheckBox
<RadioButton
android:id="@+id/rb_color6"
android:layout_width="42dp"
android:layout_height="42dp"
......@@ -111,6 +114,6 @@
android:button="@null"
android:checked="false" />
</LinearLayout>
</RadioGroup>
</LinearLayout>
\ No newline at end of file
......@@ -29,7 +29,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:text="搜索"
android:text="搜索书名或者作者名"
android:textColor="#A5A5AD"
android:textSize="14sp" />
......
......@@ -28,15 +28,47 @@
android:layout_height="40dp"
android:src="@mipmap/readtext" />
<View
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
android:layout_height="40dp"
android:layout_weight="1">
<TextView
android:id="@+id/tv_read_hour"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginStart="10dp"
android:background="@drawable/shape_bg_time"
android:gravity="center"
android:lineSpacingMultiplier="0.8"
android:textColor="@color/black" />
<TextView
android:id="@+id/tv_read_minute"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginStart="10dp"
android:background="@drawable/shape_bg_time"
android:gravity="center"
android:lineSpacingMultiplier="0.8"
android:textColor="@color/black" />
<TextView
android:id="@+id/tv_read_second"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginStart="10dp"
android:background="@drawable/shape_bg_time"
android:gravity="center"
android:lineSpacingMultiplier="0.8"
android:textColor="@color/black" />
</LinearLayout>
<ImageView
android:id="@+id/iv_edit"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_width="26dp"
android:layout_height="26dp"
android:src="@mipmap/edit" />
<ImageView
......@@ -51,7 +83,33 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_bookshelf"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:visibility="gone" />
<LinearLayout
android:id="@+id/bookshelf_empty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginBottom="10dp"
android:src="@mipmap/bg_book_data" />
<Button
android:id="@+id/btn_empty"
android:layout_width="130dp"
android:layout_height="36dp"
android:layout_marginBottom="10dp"
android:background="@drawable/shape_red"
android:text="去书城看看"
android:textColor="@color/white" />
</LinearLayout>
</LinearLayout>
......
......@@ -2,19 +2,17 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="206dp"
android:layout_height="202dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="6dp"
android:orientation="vertical"
android:paddingLeft="5dp"
android:paddingRight="5dp">
android:orientation="vertical">
<ImageView
android:id="@+id/image_iv"
android:layout_width="match_parent"
android:layout_height="150dp"
android:scaleType="centerCrop"
android:src="@mipmap/ic_launcher_main"
android:src="@mipmap/bg_book_more"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
......@@ -26,19 +24,17 @@
android:layout_marginTop="10dp"
android:ellipsize="end"
android:maxLines="1"
android:text="重回80年代"
android:textColor="@color/black"
app:layout_constraintStart_toStartOf="@id/image_iv"
app:layout_constraintTop_toBottomOf="@id/image_iv" />
<TextView
android:id="@+id/info_tv"
android:id="@+id/label_tv"
android:layout_width="106dp"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:ellipsize="end"
android:maxLines="1"
android:text="重回80年代"
android:textColor="@color/gray"
android:textSize="12sp"
app:layout_constraintStart_toStartOf="@id/image_iv"
......@@ -48,7 +44,8 @@
android:id="@+id/fm_mask"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
android:background="@drawable/shape_half_trans"
android:visibility="gone">
<CheckBox
android:id="@+id/cb"
......
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="6dp"
android:layout_marginBottom="6dp"
android:orientation="horizontal">
<TextView
android:id="@+id/title_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/shape_search_gary"
android:gravity="center"
android:paddingStart="8dp"
android:paddingTop="6dp"
android:paddingEnd="8dp"
android:paddingBottom="6dp"
android:text="我去平行时空"
android:textColor="@color/gray"
android:textSize="12sp" />
</FrameLayout>
\ No newline at end of file
......@@ -36,6 +36,7 @@
<color name="color_goldenrod">#daa520</color>
<color name="color_956244">#956244</color>
<color name="color_FFF7F7">#FFF7F7</color>
<color name="book_content_color1">#fff</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