fix:直播准备间心愿单未自动下载礼物的问题

This commit is contained in:
zlzw 2022-10-17 10:57:35 +08:00
parent 0eb6b68b5c
commit 814e45952c

View File

@ -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<File>() {
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);
// }