修改偶尔无法滚动问题

old
zlj 5 years ago
parent 0fa8900c43
commit 2481fa242c
  1. 14
      app/src/main/java/com/novel/read/activity/NovelBookDetailActivity.kt
  2. 1
      app/src/main/java/com/novel/read/activity/NovelReadActivity.kt
  3. 6
      app/src/main/java/com/novel/read/adapter/SearchAdapter.kt
  4. 32
      app/src/main/res/layout/activity_read.xml

@ -38,7 +38,7 @@ class NovelBookDetailActivity : NovelBaseActivity(), View.OnClickListener {
private var isCollected = false private var isCollected = false
private var mCollBookBean: CollBookBean? = null private var mCollBookBean: CollBookBean? = null
private var mProgressDialog: ProgressDialog? = null private lateinit var mProgressDialog: ProgressDialog
override val layoutId: Int get() = R.layout.activity_book_detail override val layoutId: Int get() = R.layout.activity_book_detail
@ -47,6 +47,7 @@ class NovelBookDetailActivity : NovelBaseActivity(), View.OnClickListener {
rlv_lovely.layoutManager = LinearLayoutManager(this) rlv_lovely.layoutManager = LinearLayoutManager(this)
mAdapter = LoveLyAdapter(mList) mAdapter = LoveLyAdapter(mList)
rlv_lovely.adapter = mAdapter rlv_lovely.adapter = mAdapter
mProgressDialog = ProgressDialog(this)
} }
override fun initData() { override fun initData() {
@ -73,11 +74,8 @@ class NovelBookDetailActivity : NovelBaseActivity(), View.OnClickListener {
tv_add_book.text = resources.getString(R.string.add_book) tv_add_book.text = resources.getString(R.string.add_book)
isCollected = false isCollected = false
} else { } else {
if (mProgressDialog == null) { mProgressDialog.setTitle("正在添加到书架中")
mProgressDialog = ProgressDialog(this) mProgressDialog.show()
mProgressDialog!!.setTitle("正在添加到书架中")
}
mProgressDialog!!.show()
AccountManager.getInstance() AccountManager.getInstance()
.getBookArticle(mBookId.toString(), "2", "1", "100000") .getBookArticle(mBookId.toString(), "2", "1", "100000")
@ -185,9 +183,7 @@ class NovelBookDetailActivity : NovelBaseActivity(), View.OnClickListener {
} }
private fun dismiss() { private fun dismiss() {
if (mProgressDialog != null) { mProgressDialog.dismiss()
mProgressDialog!!.dismiss()
}
} }
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {

@ -595,7 +595,6 @@ class NovelReadActivity : NovelBaseActivity(), DownloadService.OnDownloadListene
super.onDestroy() super.onDestroy()
EventManager.instance.unregisterSubscriber(this) EventManager.instance.unregisterSubscriber(this)
mPageLoader.closeBook() mPageLoader.closeBook()
// mPageLoader = null
unbindService(mConn) unbindService(mConn)
unregisterReceiver(mReceiver) unregisterReceiver(mReceiver)
} }

@ -92,10 +92,7 @@ class SearchAdapter(private val mList: List<SearchResp.BookBean>, recyclerView:
val bookBean = mList[i] val bookBean = mList[i]
viewHolder.mTvBookName.text = bookBean.title viewHolder.mTvBookName.text = bookBean.title
viewHolder.itemView.setOnClickListener { view -> viewHolder.itemView.setOnClickListener { view ->
mClickListener!!.onItemClick( mClickListener!!.onItemClick(view, i)
view,
i
)
} }
} }
is BookHolder -> { is BookHolder -> {
@ -158,7 +155,6 @@ class SearchAdapter(private val mList: List<SearchResp.BookBean>, recyclerView:
this.mClickListener = mListener this.mClickListener = mListener
} }
interface OnItemClickListener { interface OnItemClickListener {
fun onItemClick(view: View, pos: Int) fun onItemClick(view: View, pos: Int)
} }

@ -2,9 +2,9 @@
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/read_dl_slide"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/read_dl_slide"
tools:context=".activity.NovelReadActivity"> tools:context=".activity.NovelReadActivity">
@ -43,21 +43,21 @@
android:id="@+id/read_tv_brief" android:id="@+id/read_tv_brief"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:layout_toStartOf="@id/read_tv_community" android:layout_toStartOf="@id/read_tv_community"
android:drawableStart="@drawable/ic_book_detail" android:drawableStart="@drawable/ic_book_detail"
android:text="@string/brief"
android:gravity="center"
android:drawablePadding="10dp" android:drawablePadding="10dp"
android:layout_marginEnd="10dp"/> android:gravity="center"
android:text="@string/brief" />
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView
android:id="@+id/read_tv_community" android:id="@+id/read_tv_community"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:drawableStart="@drawable/ic_label"
android:drawablePadding="10dp" android:drawablePadding="10dp"
android:gravity="center" android:gravity="center"
android:drawableStart="@drawable/ic_label"
android:text="@string/label" /> android:text="@string/label" />
</RelativeLayout> </RelativeLayout>
</androidx.appcompat.widget.Toolbar> </androidx.appcompat.widget.Toolbar>
@ -72,21 +72,23 @@
tools:visibility="gone" /> tools:visibility="gone" />
<include layout="@layout/layout_download" <include
layout="@layout/layout_download"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<include <include
layout="@layout/layout_light" layout="@layout/layout_light"
app:layout_constraintBottom_toTopOf="@+id/read_ll_bottom_menu"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/read_ll_bottom_menu" />
<include layout="@layout/layout_read_mark" <include
app:layout_constraintBottom_toTopOf="@+id/read_ll_bottom_menu" layout="@layout/layout_read_mark"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="190dp" /> android:layout_height="190dp"
app:layout_constraintBottom_toTopOf="@+id/read_ll_bottom_menu" />
<!--<include--> <!--<include-->
<!--layout="@layout/layout_setting"--> <!--layout="@layout/layout_setting"-->
@ -174,12 +176,18 @@
android:text="@string/contents" android:text="@string/contents"
android:textColor="@color/black" android:textColor="@color/black"
android:textSize="20sp" /> android:textSize="20sp" />
<!-- 这里用ListView是因为它带有旁边的滚动条,加RelativeLayout是解决ListView偶尔无法滚动问题 -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<ListView <ListView
android:id="@+id/rlv_list" android:id="@+id/rlv_list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:scrollbars="vertical" /> android:scrollbars="vertical" />
</RelativeLayout>
</androidx.appcompat.widget.LinearLayoutCompat> </androidx.appcompat.widget.LinearLayoutCompat>
@ -188,8 +196,8 @@
android:id="@+id/iv_guide" android:id="@+id/iv_guide"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:src="@drawable/ic_guide"
android:scaleType="fitXY" android:scaleType="fitXY"
android:src="@drawable/ic_guide"
android:visibility="gone" /> android:visibility="gone" />
</androidx.drawerlayout.widget.DrawerLayout> </androidx.drawerlayout.widget.DrawerLayout>
Loading…
Cancel
Save