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 000000000..fc50e780e Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/bg_lwhqz.png differ 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()+"是");