From 814e45952cedf0e19f7e001d6aa34dde32de1bd6 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Mon, 17 Oct 2022 10:57:35 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E7=9B=B4=E6=92=AD=E5=87=86?= =?UTF-8?q?=E5=A4=87=E9=97=B4=E5=BF=83=E6=84=BF=E5=8D=95=E6=9C=AA=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E4=B8=8B=E8=BD=BD=E7=A4=BC=E7=89=A9=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LiveGiftDialogFragment4Wishlist.java | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveGiftDialogFragment4Wishlist.java b/live/src/main/java/com/yunbao/live/dialog/LiveGiftDialogFragment4Wishlist.java index fc01f9676..eca3de6de 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveGiftDialogFragment4Wishlist.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveGiftDialogFragment4Wishlist.java @@ -27,8 +27,11 @@ import com.yunbao.common.CommonAppConfig; import com.yunbao.common.bean.LiveGiftBean; import com.yunbao.common.dialog.AbsDialogFragment; import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DpUtil; +import com.yunbao.common.utils.GiftCacheUtil; import com.yunbao.live.R; import com.yunbao.live.adapter.LiveGiftCountAdapter; import com.yunbao.live.adapter.LiveGiftPagerAdapter; @@ -37,7 +40,10 @@ import com.yunbao.live.http.LiveHttpConsts; import com.yunbao.live.http.LiveHttpUtil; import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; +import java.io.File; import java.util.List; /** @@ -104,6 +110,7 @@ public class LiveGiftDialogFragment4Wishlist extends AbsDialogFragment implement @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); + Bus.getOn(this); mCoin = (TextView) mRootView.findViewById(R.id.coin); mLoading = mRootView.findViewById(R.id.loading); mArrow = mRootView.findViewById(R.id.arrow); @@ -226,11 +233,34 @@ public class LiveGiftDialogFragment4Wishlist extends AbsDialogFragment implement } mRadioGroup.addView(radioButton); } - } + if(!GiftCacheUtil.getInstance().isDownloading()){ + GiftCacheUtil.getInstance().setDownloadList(list); + GiftCacheUtil.getInstance().setCallback(new CommonCallback() { + int index = 0; + @Override + public void callback(File bean) { + if (bean != null) { + index++; + Bus.get().post(new GiftCacheUtil.GiftDownloadStatus(index, list.size(), GiftCacheUtil.getIdForFileName(bean.getName()))); + } + } + }); + GiftCacheUtil.getInstance().downloadAllGift(); + } + } + /** + * 收到礼物下载完成的通知 + * @param status + */ + @Subscribe(threadMode = ThreadMode.MAIN) + public void updateDownload(GiftCacheUtil.GiftDownloadStatus status) { + mLiveGiftPagerAdapter.refreshId(status.getId()); + } @Override public void onDestroy() { + Bus.getOff(this); // if (mHandler != null) { // mHandler.removeCallbacksAndMessages(null); // }