From fc7d0c6dc3921e5cf77811764bf3a71781b8c4d2 Mon Sep 17 00:00:00 2001 From: zlj <390057892@qq.com> Date: Fri, 10 Jan 2020 14:25:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../novel/read/activity/NovelBookDetailActivity.kt | 9 ++------- .../read/activity/NovelBookTypeListActivity.kt | 4 +--- .../com/novel/read/activity/NovelMainActivity.kt | 4 +--- .../novel/read/activity/NovelRankListActivity.kt | 4 +--- .../com/novel/read/activity/NovelReadActivity.kt | 8 +++----- .../read/activity/NovelRecommendBookListActivity.kt | 4 +--- .../com/novel/read/activity/NovelSearchActivity.kt | 4 +--- .../com/novel/read/activity/NovelSettingActivity.kt | 13 +++---------- .../main/java/com/novel/read/http/AccountManager.kt | 2 +- 9 files changed, 14 insertions(+), 38 deletions(-) diff --git a/app/src/main/java/com/novel/read/activity/NovelBookDetailActivity.kt b/app/src/main/java/com/novel/read/activity/NovelBookDetailActivity.kt index 1875937..86f1945 100644 --- a/app/src/main/java/com/novel/read/activity/NovelBookDetailActivity.kt +++ b/app/src/main/java/com/novel/read/activity/NovelBookDetailActivity.kt @@ -29,19 +29,15 @@ import kotlinx.android.synthetic.main.activity_book_detail.* import org.litepal.LitePal import java.util.* -class NovelBookDetailActivity : NovelBaseActivity(), View.OnClickListener { +class NovelBookDetailActivity(override val layoutId: Int = R.layout.activity_book_detail) : NovelBaseActivity(), View.OnClickListener { private lateinit var mAdapter: LoveLyAdapter private val mList = ArrayList() - private var mBookId: Int = 0 private var isCollected = false private var mCollBookBean: CollBookBean? = null - private lateinit var mProgressDialog: ProgressDialog - override val layoutId: Int get() = R.layout.activity_book_detail - override fun initView() { mBookId = intent.getIntExtra(Constant.Bundle.BookId, 0) rlv_lovely.layoutManager = LinearLayoutManager(this) @@ -76,8 +72,7 @@ class NovelBookDetailActivity : NovelBaseActivity(), View.OnClickListener { } else { mProgressDialog.setTitle("正在添加到书架中") mProgressDialog.show() - AccountManager.getInstance() - .getBookArticle(mBookId.toString(), "2", "1", "100000") + AccountManager.getInstance().getBookArticle(mBookId.toString()) } R.id.tv_start_read -> diff --git a/app/src/main/java/com/novel/read/activity/NovelBookTypeListActivity.kt b/app/src/main/java/com/novel/read/activity/NovelBookTypeListActivity.kt index 1eac376..4c755d6 100644 --- a/app/src/main/java/com/novel/read/activity/NovelBookTypeListActivity.kt +++ b/app/src/main/java/com/novel/read/activity/NovelBookTypeListActivity.kt @@ -15,7 +15,7 @@ import com.squareup.otto.Subscribe import kotlinx.android.synthetic.main.activity_book_type_list.* import java.util.* -class NovelBookTypeListActivity : NovelBaseActivity() { +class NovelBookTypeListActivity(override val layoutId: Int = R.layout.activity_book_type_list) : NovelBaseActivity() { private var mList: MutableList = ArrayList() private lateinit var mAdapter: BookListAdapter @@ -24,8 +24,6 @@ class NovelBookTypeListActivity : NovelBaseActivity() { private var page: Int = 1 private var loadSize: Int = 0 - override val layoutId: Int get() = R.layout.activity_book_type_list - override fun initView() { EventManager.instance.registerSubscriber(this) diff --git a/app/src/main/java/com/novel/read/activity/NovelMainActivity.kt b/app/src/main/java/com/novel/read/activity/NovelMainActivity.kt index c47a658..3d2d5e3 100644 --- a/app/src/main/java/com/novel/read/activity/NovelMainActivity.kt +++ b/app/src/main/java/com/novel/read/activity/NovelMainActivity.kt @@ -24,7 +24,7 @@ import com.novel.read.utlis.SpUtil import com.squareup.otto.Subscribe import kotlinx.android.synthetic.main.activity_main.* -class NovelMainActivity : NovelBaseActivity() { +class NovelMainActivity(override val layoutId: Int = R.layout.activity_main) : NovelBaseActivity() { private lateinit var mCurrentFrag: Fragment private lateinit var mMainFragment: BookFragment @@ -35,8 +35,6 @@ class NovelMainActivity : NovelBaseActivity() { //记录用户首次点击返回键的时间 private var firstTime: Long = 0 - override val layoutId: Int get() = R.layout.activity_main - override fun initView() { mCurrentFrag = Fragment() mMainFragment = BookFragment.newInstance() diff --git a/app/src/main/java/com/novel/read/activity/NovelRankListActivity.kt b/app/src/main/java/com/novel/read/activity/NovelRankListActivity.kt index 35121a5..e6b5d1b 100644 --- a/app/src/main/java/com/novel/read/activity/NovelRankListActivity.kt +++ b/app/src/main/java/com/novel/read/activity/NovelRankListActivity.kt @@ -18,7 +18,7 @@ import java.util.* /** * 推荐fragment中点击更多跳转来的。 */ -class NovelRankListActivity : NovelBaseActivity() { +class NovelRankListActivity(override val layoutId: Int= R.layout.activity_rank_list) : NovelBaseActivity() { private lateinit var mAdapter: RankListAdapter private var mList: MutableList = ArrayList() @@ -27,8 +27,6 @@ class NovelRankListActivity : NovelBaseActivity() { private var type: String = "" private var sex: String = "" - override val layoutId: Int get() = R.layout.activity_rank_list - override fun initView() { rlv_book_list.layoutManager = LinearLayoutManager(this) mAdapter = RankListAdapter(mList, rlv_book_list) diff --git a/app/src/main/java/com/novel/read/activity/NovelReadActivity.kt b/app/src/main/java/com/novel/read/activity/NovelReadActivity.kt index 82d93af..1d754e8 100644 --- a/app/src/main/java/com/novel/read/activity/NovelReadActivity.kt +++ b/app/src/main/java/com/novel/read/activity/NovelReadActivity.kt @@ -161,18 +161,16 @@ class NovelReadActivity : NovelBaseActivity(), DownloadService.OnDownloadListene toggleMenu(false) } - Log.e(TAG, "mBookId: $mBookId") if (isCollected) { - mPageLoader.collBook.bookChapters = - BookRepository.getInstance().getBookChaptersInRx(mBookId) + mPageLoader.collBook.bookChapters = BookRepository.getInstance().getBookChaptersInRx(mBookId) // 刷新章节列表 mPageLoader.refreshChapterList() // 如果是网络小说并被标记更新的,则从网络下载目录 if (mCollBook.isUpdate && !mCollBook.isLocal) { - AccountManager.getInstance().getBookArticle(mBookId, "2", "1", "10000") + AccountManager.getInstance().getBookArticle(mBookId) } } else { - AccountManager.getInstance().getBookArticle(mBookId, "2", "1", "10000") + AccountManager.getInstance().getBookArticle(mBookId) } } diff --git a/app/src/main/java/com/novel/read/activity/NovelRecommendBookListActivity.kt b/app/src/main/java/com/novel/read/activity/NovelRecommendBookListActivity.kt index ea8d0a8..da0c2b4 100644 --- a/app/src/main/java/com/novel/read/activity/NovelRecommendBookListActivity.kt +++ b/app/src/main/java/com/novel/read/activity/NovelRecommendBookListActivity.kt @@ -12,9 +12,7 @@ import com.novel.read.widget.VpTabLayout import kotlinx.android.synthetic.main.activity_recommend_book_list.* import java.util.* -class NovelRecommendBookListActivity : NovelBaseActivity() { - - override val layoutId: Int get() = R.layout.activity_recommend_book_list +class NovelRecommendBookListActivity(override val layoutId: Int= R.layout.activity_recommend_book_list) : NovelBaseActivity() { override fun initView() { val fragmentList = ArrayList() diff --git a/app/src/main/java/com/novel/read/activity/NovelSearchActivity.kt b/app/src/main/java/com/novel/read/activity/NovelSearchActivity.kt index 8b99635..52a935a 100644 --- a/app/src/main/java/com/novel/read/activity/NovelSearchActivity.kt +++ b/app/src/main/java/com/novel/read/activity/NovelSearchActivity.kt @@ -32,7 +32,7 @@ import kotlinx.android.synthetic.main.title_search.* import org.litepal.LitePal import java.util.* -class NovelSearchActivity : NovelBaseActivity() { +class NovelSearchActivity(override val layoutId: Int= R.layout.activity_search) : NovelBaseActivity() { private val mHotList = ArrayList() private lateinit var mHotAdapter: HotAdapter @@ -46,8 +46,6 @@ class NovelSearchActivity : NovelBaseActivity() { private var page = 1 private var loadSize: Int = 0 - override val layoutId: Int get() = R.layout.activity_search - override fun initView() { EventManager.instance.registerSubscriber(this) diff --git a/app/src/main/java/com/novel/read/activity/NovelSettingActivity.kt b/app/src/main/java/com/novel/read/activity/NovelSettingActivity.kt index ce8da58..33a1667 100644 --- a/app/src/main/java/com/novel/read/activity/NovelSettingActivity.kt +++ b/app/src/main/java/com/novel/read/activity/NovelSettingActivity.kt @@ -21,12 +21,10 @@ import com.novel.read.utlis.VersionUtil import com.squareup.otto.Subscribe import kotlinx.android.synthetic.main.activity_setting.* -class NovelSettingActivity : NovelBaseActivity(), View.OnClickListener { +class NovelSettingActivity(override val layoutId: Int = R.layout.activity_setting) : NovelBaseActivity(), View.OnClickListener { private var resp: VersionResp? = null - override val layoutId: Int get() = R.layout.activity_setting - override fun initView() { EventManager.instance.registerSubscriber(this) } @@ -63,12 +61,7 @@ class NovelSettingActivity : NovelBaseActivity(), View.OnClickListener { AlertDialog.Builder(this) .setTitle(getString(R.string.clear_cache)) .setCancelable(true) - .setMultiChoiceItems( - arrayOf( - getString(R.string.clear_cache), - getString(R.string.clear_book) - ), selected - ) { _, which, isChecked -> selected[which] = isChecked } + .setMultiChoiceItems(arrayOf(getString(R.string.clear_cache), getString(R.string.clear_book)), selected) { _, which, isChecked -> selected[which] = isChecked } .setPositiveButton(getString(R.string.sure)) { dialog, _ -> Thread { CleanCacheUtils.getInstance() @@ -89,7 +82,7 @@ class NovelSettingActivity : NovelBaseActivity(), View.OnClickListener { }.start() dialog.dismiss() } - .setNegativeButton(getString(R.string.cancel)) { dialog, which -> dialog.dismiss() } + .setNegativeButton(getString(R.string.cancel)) { dialog, _ -> dialog.dismiss() } .create().show() } R.id.tv_check -> diff --git a/app/src/main/java/com/novel/read/http/AccountManager.kt b/app/src/main/java/com/novel/read/http/AccountManager.kt index f002b3e..369fc63 100644 --- a/app/src/main/java/com/novel/read/http/AccountManager.kt +++ b/app/src/main/java/com/novel/read/http/AccountManager.kt @@ -86,7 +86,7 @@ class AccountManager private constructor() { call.enqueue(ServiceCallback(HotSearchEvent::class.java)) } - fun getBookArticle(bookId: String, hasContent: String, page: String, limit: String) { + fun getBookArticle(bookId: String, hasContent: String="2", page: String="1", limit: String="100000") { val map = HashMap() map["book_id"] = bookId map["has_content"] = hasContent