From 9869a2376c1800c0fec5bdac0fd1b85b47f85a4c Mon Sep 17 00:00:00 2001 From: 18142669586 <1669783059@qq.com> Date: Thu, 13 Apr 2023 11:42:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9toat=E6=A0=B7=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunbao/common/utils/GiftCacheUtil.java | 12 +++-- .../utils/JavascriptInterfaceUtils.java | 2 +- .../com/yunbao/common/utils/ToastUtils.java | 44 ++++++++++++++++++ common/src/main/res/layout/toast_utils.xml | 26 +++++++++++ .../src/main/res/mipmap-xxhdpi/bg_lwhqz.png | Bin 0 -> 1618 bytes .../yunbao/live/adapter/LiveGiftAdapter.java | 2 +- .../presenter/LiveEnterRoomAnimPresenter.java | 2 +- .../live/presenter/LiveGiftAnimPresenter.java | 2 +- .../yunbao/main/activity/MainActivity.java | 5 +- 9 files changed, 85 insertions(+), 10 deletions(-) create mode 100644 common/src/main/java/com/yunbao/common/utils/ToastUtils.java create mode 100644 common/src/main/res/layout/toast_utils.xml create mode 100644 common/src/main/res/mipmap-xxhdpi/bg_lwhqz.png diff --git a/common/src/main/java/com/yunbao/common/utils/GiftCacheUtil.java b/common/src/main/java/com/yunbao/common/utils/GiftCacheUtil.java index 207accd38..1a42452e7 100644 --- a/common/src/main/java/com/yunbao/common/utils/GiftCacheUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/GiftCacheUtil.java @@ -1,10 +1,12 @@ package com.yunbao.common.utils; +import android.content.Context; import android.os.Handler; import android.os.Looper; import android.util.Log; import com.yunbao.common.CommonAppConfig; +import com.yunbao.common.CommonAppContext; import com.yunbao.common.Constants; import com.yunbao.common.R; import com.yunbao.common.bean.LiveGiftBean; @@ -43,7 +45,7 @@ public class GiftCacheUtil { /** * 单独下载 */ - public static void getFile(String fileName, String url, String forwhat, final CommonCallback commonCallback) { + public static void getFile(Context context,String fileName, String url, String forwhat, final CommonCallback commonCallback) { if (commonCallback == null) { return; } @@ -60,7 +62,9 @@ public class GiftCacheUtil { } else { DownloadUtil downloadUtil = new DownloadUtil(); if (forwhat.equals("1")) { - ToastUtil.show(R.string.gift_way); + ToastUtils toastUtil = new ToastUtils(context); + toastUtil.InitToast(); + toastUtil.show(); } downloadUtil.download(CommonHttpConsts.DOWNLOAD_GIF, dir, fileName, url, new DownloadUtil.Callback() { String TAG="下载"; @@ -141,13 +145,13 @@ public class GiftCacheUtil { /** * 插队优先下载指定id礼物 */ - public void downloadGiftForId(LiveGiftBean bean, CommonCallback mDownloadGifCallback) { + public void downloadGiftForId(Context context,LiveGiftBean bean, CommonCallback mDownloadGifCallback) { if (checkGiftIsDownload(bean.getId())) { mDownloadGifCallback.callback(getGiftForId(bean.getId())); return; } clickId.add(bean.getId()+""); - getFile(getDownloadSaveName(bean.getId()), bean.getSwf(), "0", new CommonCallback() { + getFile(context,getDownloadSaveName(bean.getId()), bean.getSwf(), "0", new CommonCallback() { @Override public void callback(File bean) { if(bean!=null) { diff --git a/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java b/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java index 6b30e98aa..930cb2f8a 100644 --- a/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java +++ b/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java @@ -461,7 +461,7 @@ public class JavascriptInterfaceUtils { } else { url1 = svg; } - GiftCacheUtil.getFile(Constants.GIF_CAR_PREFIX + id, url1, "0", new CommonCallback() { + GiftCacheUtil.getFile(mContext,Constants.GIF_CAR_PREFIX + id, url1, "0", new CommonCallback() { @Override public void callback(File bean) { diff --git a/common/src/main/java/com/yunbao/common/utils/ToastUtils.java b/common/src/main/java/com/yunbao/common/utils/ToastUtils.java new file mode 100644 index 000000000..12d7412df --- /dev/null +++ b/common/src/main/java/com/yunbao/common/utils/ToastUtils.java @@ -0,0 +1,44 @@ +package com.yunbao.common.utils; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.TextView; +import android.widget.Toast; + +import com.yunbao.common.R; + +public class ToastUtils { + private Context context; + private TextView tipsText; + private Toast toast = null; + + public ToastUtils(Context context){ + this.context = context; + } + public void InitToast(){ + if (toast == null) { + toast = new Toast(context); + View view = LayoutInflater.from(context).inflate(R.layout.toast_utils, null, false); + toast.setView(view); + } + } + public void setGravity(int gravity){ + toast.setGravity(gravity, 0, 0); + } + public void setText(String tips){ + tipsText.setText(tips); + } + public void show(){ + toast.show(); + } + public void setShowTime(int time){ + toast.setDuration(time); + } + public void setTextColor(int color){ + tipsText.setTextColor(context.getResources().getColor(color)); + } + public void setTextSize(float size){ + tipsText.setTextSize(size); + } +} diff --git a/common/src/main/res/layout/toast_utils.xml b/common/src/main/res/layout/toast_utils.xml new file mode 100644 index 000000000..8696ad3e1 --- /dev/null +++ b/common/src/main/res/layout/toast_utils.xml @@ -0,0 +1,26 @@ + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/mipmap-xxhdpi/bg_lwhqz.png b/common/src/main/res/mipmap-xxhdpi/bg_lwhqz.png new file mode 100644 index 0000000000000000000000000000000000000000..fc50e780e255d570157a727fc5e5798da8faaa7a GIT binary patch literal 1618 zcma)7X;c$e7|p!QkT3z6K#-uUQfmZ(pa=-0jgbIRP!tLg5JqqpZH~Ah6lcN#qeXBz zY7lILoPrdUt#Y8U3`&K%V5}RWz+fxx7{#MhkaS4@_w>&@?|$EX_q*SD+y1DfVV3AL zl*M9MD#Alnuvida<~Y}k89%^T7g#Jadqv2?nB7UQA4Q&tSu3R8wmEa%|2{Tj`Qj$` zzGKee@j-T5=3)n?DoTa9d9m1<4LTQP$YOcoVHKaB(y$@5>biAgZ{`s&{8kw-V{o(r- z83IJ|N|2pUGW%&&;@lWd_E0K6y^0+6SAFr>Ja~E7n_k18vo| zR3LuIaZkEaEQFl2(NuOiQvHFsxV@oVLJoBw@tmzEr0*^Imq>DqzW4jxG;MYufvB`> z_9>2%lIxI^zV=XhLxx{z3)Zo3uSX3bo?zhO+Ph8NhEs~`Bf3%2Ct*Vyc+5(!#YxD8fMV%28WjAdAjR8NM&9y_Hkwi zUt3bn`}25;KO*Q_LMPzS0`*F2E602!a4fV+YOM*fP1eY2e9!r<2!)V$f*vdvkNk9y z3^vb?hmfxh%CLH*a8oG(9-s~dvKlMxDNmC0&{5At@WAd9rA0dFJ&?1UTd+0~H=rVY ze8d`8F<;P?NXZUm0AVX|#a+c#f+$LcPZ8+|2}qYhNVBh)!-RZHARbJadXkHZ7~W*i ziCmx~K+-fV8x_$)6JYWTFccE?X6w`dRdTOGh@d9SBzVGXhyZ9ns0rlcn!x5sAhlL~ z(#J$ep$e-T44nZE{{x8N#4y~8G5XR}MCE8QaNf;iZ3jFl-&jCRD&6Os90rT`4W_gpb zu3b|nXoO#d+W>!PyF2WI3ne)hK3LR6IOGgFlh4dMR$Un*l_4=zm>|fTox~{*AbP$o zTK&aJZikS{pmSp2Jd0nW3w7hC<8dgJ@@o3 z=28WeiA&Dj^w0;9*C>`@rm8eJNPH*Z=Xmbb>K~8p;aF8<+9YP(xoETX8Y%#_;m?-Q zSPd^AdS7|54C{10k=;rA(0qDfrumMZzBuyXm)MfrLiQ}?SyRyQePz26xCeF~7?`IS z@NIO~7CY4w&zDN>NgRi(rD3G-bK$q2lW$8v=i~17JD=N>Ppt7XWk$=1O_zrvKV7zA P{tA{tzBJ^#3|IdH@(_<} literal 0 HcmV?d00001 diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveGiftAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveGiftAdapter.java index b32479146..854e04856 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveGiftAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveGiftAdapter.java @@ -208,7 +208,7 @@ public class LiveGiftAdapter extends RecyclerView.Adapter { mLoading.startAnimation(animation); LiveGiftBean bean = mList.get((Integer) v.getTag()); GiftCacheUtil.getInstance().pause(); - GiftCacheUtil.getInstance().downloadGiftForId(bean, new CommonCallback() { + GiftCacheUtil.getInstance().downloadGiftForId(mContext,bean, new CommonCallback() { @Override public void callback(File bean) { if(bean==null){ diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveEnterRoomAnimPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveEnterRoomAnimPresenter.java index 8612ab8d2..65a73b842 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveEnterRoomAnimPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveEnterRoomAnimPresenter.java @@ -461,7 +461,7 @@ public class LiveEnterRoomAnimPresenter { playText = car.getUser_nicename() + mContext.getResources().getString(R.string.enter_room); } if (IMLoginManager.get(mContext).isMountEffect()) { - GiftCacheUtil.getFile(Constants.GIF_CAR_PREFIX + id, url1, "0", mDownloadGifCallback); + GiftCacheUtil.getFile(mContext,Constants.GIF_CAR_PREFIX + id, url1, "0", mDownloadGifCallback); } else { mIsAnimating = false; } diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveGiftAnimPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveGiftAnimPresenter.java index 9d03bcd4f..fb2b2ea0c 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveGiftAnimPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveGiftAnimPresenter.java @@ -1123,7 +1123,7 @@ public class LiveGiftAnimPresenter { } }); } else { - GiftCacheUtil.getFile(Constants.GIF_GIFT_PREFIX + bean.getGiftId(), url, "1", mDownloadGifCallback); + GiftCacheUtil.getFile(mContext,Constants.GIF_GIFT_PREFIX + bean.getGiftId(), url, "1", mDownloadGifCallback); } } diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java index 88bda75c5..f4a8498fb 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -87,6 +87,7 @@ import com.yunbao.common.utils.ProcessResultUtil; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.SpUtil; import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.utils.ToastUtils; import com.yunbao.common.utils.VersionUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.common.views.APKUpdateCustomPopup; @@ -828,7 +829,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene Log.e("--->", list.get(j).getGiftname() + list.get(j).getSwf()); - GiftCacheUtil.getFile(Constants.GIF_GIFT_PREFIX + list.get(j).getId(), list.get(j).getSwf(), "0", new CommonCallback() { + GiftCacheUtil.getFile(MainActivity.this,Constants.GIF_GIFT_PREFIX + list.get(j).getId(), list.get(j).getSwf(), "0", new CommonCallback() { @Override public void callback(File bean) { @@ -869,7 +870,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene Log.e("tx", id); - GiftCacheUtil.getFile(Constants.GIF_CAR_PREFIX + id, url1, "0", new CommonCallback() { + GiftCacheUtil.getFile(MainActivity.this,Constants.GIF_CAR_PREFIX + id, url1, "0", new CommonCallback() { @Override public void callback(File bean) { // Log.e("111",bean.getPath()+"是");