Commit 48e2cea2 authored by jyx's avatar jyx

代码优化

parent a7c3260f
......@@ -53,6 +53,13 @@ public class RecommendVideoView extends RelativeLayout {
}
public void loadData(List<VedioBean> list) {
if (this.mList != null) {
this.mList.clear();
}
if (this.mUrlList != null) {
this.mUrlList.clear();
}
this.mList = list;
List<VideoModel> videoList = new ArrayList();
for (int i = 0; i < list.size(); i++) {
......
......@@ -39,6 +39,8 @@ class TxVideoFragment : BaseFragment(), RecommendView {
override fun initViewsAndEvents() {
recommendPresenter.attachView(this)
recommendPresenter.autoList()
recommend_view.setOnVideoEndListener {
videos[recommend_view.currentPosition].recommendIndex++
LocalVedioManager.startVedioDetailActivityForType(
......@@ -61,8 +63,10 @@ class TxVideoFragment : BaseFragment(), RecommendView {
}
R.id.ll_collect -> {
if (videos[position].collect == 0) {
videos[position].collect = 1
recommendPresenter.collect("" + videos[position].vedioId)
} else {
videos[position].collect = 0
recommendPresenter.cancelCollect("" + videos[position].vedioId)
}
}
......@@ -78,7 +82,6 @@ class TxVideoFragment : BaseFragment(), RecommendView {
super.onResume()
if (AppConfig.fragmentClickFlag != Constant.FRAGMENT_CLICK_TWO) return
recommendPresenter.autoList()
recommend_view.resume()
}
......
......@@ -43,12 +43,12 @@ class TxRecommendVideoAdapter :
holder.setText(R.id.tv_collect_num, item.hot)
holder.getView<View>(R.id.ll_collect).setOnClickListener {
mOnCustomChildClickListener?.onCustomChildClick(it, holder.adapterPosition)
if (item.collect == 0) {
playCollectAnim(holder.getView(R.id.iv_collect))
} else {
playCancelCollectAnim(holder.getView(R.id.iv_collect))
}
mOnCustomChildClickListener?.onCustomChildClick(it, holder.adapterPosition)
}
holder.getView<View>(R.id.ll_bottom).setOnClickListener {
mOnCustomChildClickListener?.onCustomChildClick(it, holder.adapterPosition)
......@@ -90,6 +90,7 @@ class TxRecommendVideoAdapter :
}
private fun playCollectAnim(view: LottieAnimationView) {
view.setImageDrawable(null)
val lottieDrawable = LottieDrawable()
LottieCompositionFactory.fromAsset(context, "home_collect.json")
.addListener { result: LottieComposition? ->
......@@ -102,6 +103,7 @@ class TxRecommendVideoAdapter :
}
private fun playCancelCollectAnim(view: LottieAnimationView) {
view.setImageDrawable(null)
val lottieDrawable = LottieDrawable()
LottieCompositionFactory.fromAsset(context, "home_cancel_collect.json")
.addListener { result: LottieComposition? ->
......
......@@ -112,14 +112,6 @@
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<com.google.android.material.tabs.TabLayout
android:id="@+id/tablayout"
android:layout_width="wrap_content"
......@@ -135,6 +127,14 @@
app:tabPaddingStart="6dp"
app:tabRippleColor="@null" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/vp2"
android:layout_width="match_parent"
......
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