Commit 098ce575 authored by jyx's avatar jyx

添加追剧页长按删除功能

parent 832f4751
......@@ -309,6 +309,12 @@ class MainActivity : BaseActivity(), View.OnClickListener {
}
}
fun hideEditView(show: Boolean) {
recommendFragment?.let {
(it as RecommendFragment).hideEditView(show)
}
}
fun showEdit(isEdit: Boolean) {
if (isEdit) {
ll_edit.visibility = View.VISIBLE
......
......@@ -53,7 +53,7 @@ class WatchRecordAdapter :
* @return
*/
fun isItemHeader(position: Int): Boolean {
if (data.size == 0) return false
if (data.size == 0 || position >= data.size) return false
return if (position == 0) {
true
} else {
......
......@@ -61,6 +61,12 @@ class FollowVideoFragment : BaseFragment(), FollowView {
followAdapter = FollowAdapter(requireActivity())
followAdapter?.setEmptyView(emptyView)
followAdapter?.setNewInstance(datas)
followAdapter?.setOnItemLongClickListener { adapter, view, position ->
datas[position].isChecked = true
followAdapter?.setEditStyle(true)
showEditView(false)
return@setOnItemLongClickListener false
}
followAdapter?.setOnItemClickListener { adapter, view, position ->
LocalVedioManager.startVedioDetailActivityForType(
requireActivity(),
......@@ -79,23 +85,24 @@ class FollowVideoFragment : BaseFragment(), FollowView {
followPresenter.detachView()
}
fun isListEmpty(): Boolean {
return datas.isEmpty()
}
private fun showEditView(show: Boolean) {
(requireActivity() as MainActivity).showEditView(show)
}
private fun hideEditView(hide: Boolean) {
(requireActivity() as MainActivity).hideEditView(hide)
}
override fun getCollectListSuc(bannerList: BannerList) {
datas.clear()
if (bannerList.list.isNotEmpty()) {
datas.addAll(bannerList.list)
followAdapter?.setNewInstance(datas)
showEditView(true)
} else {
hideEditView(true)
}
showEditView(true)
followAdapter?.setEditStyle(false)
// followAdapter?.notifyDataSetChanged()
}
override fun getCollectListFail() {
......@@ -104,7 +111,7 @@ class FollowVideoFragment : BaseFragment(), FollowView {
override fun cancelCollectSuc() {
followPresenter.getCollectList()
(requireActivity() as MainActivity).showEdit(false)
(requireActivity() as MainActivity).showEditView(true)
}
override fun cancelCollectFail() {
......
......@@ -70,11 +70,6 @@ class RecommendFragment : BaseFragment(), View.OnClickListener {
updateTab(tab, true, mSelectTabIndex)
if (mSelectTabIndex == 0) {
changeBottomTabColor(false)
if ((fragments[0] as FollowVideoFragment).isListEmpty()) {
iv_edit.visibility = View.GONE
} else {
iv_edit.visibility = View.VISIBLE
}
} else {
changeBottomTabColor(true)
iv_edit.visibility = View.GONE
......@@ -205,6 +200,14 @@ class RecommendFragment : BaseFragment(), View.OnClickListener {
(fragments[0] as FollowVideoFragment).delete()
}
fun hideEditView(hide: Boolean) {
if (hide) {
iv_edit.visibility = View.GONE
} else {
iv_edit.visibility = View.VISIBLE
}
}
override fun onHiddenChanged(hidden: Boolean) {
super.onHiddenChanged(hidden)
if (mSelectTabIndex == 0) return
......
......@@ -2,10 +2,10 @@
<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="wrap_content"
android:layout_marginBottom="10dp"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:layout_height="wrap_content">
android:layout_marginBottom="10dp">
<ImageView
android:id="@+id/image_iv"
......@@ -70,8 +70,9 @@
android:background="@null"
android:button="@null"
android:drawableEnd="@drawable/selector_cb"
android:paddingTop="10dp"
android:paddingEnd="6dp"
android:paddingBottom="190dp" />
android:paddingBottom="180dp" />
</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"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:id="@+id/info_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="20dp"
android:text="暂无在追剧"
android:textColor="@color/gray"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
android:textColor="@color/gray" />
<Button
android:id="@+id/btn"
android:layout_width="120dp"
android:layout_height="40dp"
android:layout_marginTop="10dp"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:background="@drawable/shape_red"
android:elevation="2dp"
android:text="去剧场"
android:textColor="@color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/info_tv" />
android:textColor="@color/white" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
</FrameLayout>
\ No newline at end of file
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