Commit 48e2cea2 authored by jyx's avatar jyx

代码优化

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