修改toat样试

This commit is contained in:
18142669586 2023-04-13 11:42:15 +08:00
parent af4176bcb7
commit 9869a2376c
9 changed files with 85 additions and 10 deletions

View File

@ -1,10 +1,12 @@
package com.yunbao.common.utils; package com.yunbao.common.utils;
import android.content.Context;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.util.Log; import android.util.Log;
import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.CommonAppContext;
import com.yunbao.common.Constants; import com.yunbao.common.Constants;
import com.yunbao.common.R; import com.yunbao.common.R;
import com.yunbao.common.bean.LiveGiftBean; 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<File> commonCallback) { public static void getFile(Context context,String fileName, String url, String forwhat, final CommonCallback<File> commonCallback) {
if (commonCallback == null) { if (commonCallback == null) {
return; return;
} }
@ -60,7 +62,9 @@ public class GiftCacheUtil {
} else { } else {
DownloadUtil downloadUtil = new DownloadUtil(); DownloadUtil downloadUtil = new DownloadUtil();
if (forwhat.equals("1")) { 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() { downloadUtil.download(CommonHttpConsts.DOWNLOAD_GIF, dir, fileName, url, new DownloadUtil.Callback() {
String TAG="下载"; String TAG="下载";
@ -141,13 +145,13 @@ public class GiftCacheUtil {
/** /**
* 插队优先下载指定id礼物 * 插队优先下载指定id礼物
*/ */
public void downloadGiftForId(LiveGiftBean bean, CommonCallback<File> mDownloadGifCallback) { public void downloadGiftForId(Context context,LiveGiftBean bean, CommonCallback<File> mDownloadGifCallback) {
if (checkGiftIsDownload(bean.getId())) { if (checkGiftIsDownload(bean.getId())) {
mDownloadGifCallback.callback(getGiftForId(bean.getId())); mDownloadGifCallback.callback(getGiftForId(bean.getId()));
return; return;
} }
clickId.add(bean.getId()+""); clickId.add(bean.getId()+"");
getFile(getDownloadSaveName(bean.getId()), bean.getSwf(), "0", new CommonCallback<File>() { getFile(context,getDownloadSaveName(bean.getId()), bean.getSwf(), "0", new CommonCallback<File>() {
@Override @Override
public void callback(File bean) { public void callback(File bean) {
if(bean!=null) { if(bean!=null) {

View File

@ -461,7 +461,7 @@ public class JavascriptInterfaceUtils {
} else { } else {
url1 = svg; url1 = svg;
} }
GiftCacheUtil.getFile(Constants.GIF_CAR_PREFIX + id, url1, "0", new CommonCallback<File>() { GiftCacheUtil.getFile(mContext,Constants.GIF_CAR_PREFIX + id, url1, "0", new CommonCallback<File>() {
@Override @Override
public void callback(File bean) { public void callback(File bean) {

View File

@ -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);
}
}

View File

@ -0,0 +1,26 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:layout_gravity="center"
android:background="@mipmap/bg_lwhqz">
<TextView
android:id="@+id/ErrorTips"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/gift_way"
android:textColor="#FFFFFF"
android:textSize="13sp"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:ellipsize="end"/>
</LinearLayout>
</FrameLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -208,7 +208,7 @@ public class LiveGiftAdapter extends RecyclerView.Adapter<LiveGiftAdapter.Vh> {
mLoading.startAnimation(animation); mLoading.startAnimation(animation);
LiveGiftBean bean = mList.get((Integer) v.getTag()); LiveGiftBean bean = mList.get((Integer) v.getTag());
GiftCacheUtil.getInstance().pause(); GiftCacheUtil.getInstance().pause();
GiftCacheUtil.getInstance().downloadGiftForId(bean, new CommonCallback<File>() { GiftCacheUtil.getInstance().downloadGiftForId(mContext,bean, new CommonCallback<File>() {
@Override @Override
public void callback(File bean) { public void callback(File bean) {
if(bean==null){ if(bean==null){

View File

@ -461,7 +461,7 @@ public class LiveEnterRoomAnimPresenter {
playText = car.getUser_nicename() + mContext.getResources().getString(R.string.enter_room); playText = car.getUser_nicename() + mContext.getResources().getString(R.string.enter_room);
} }
if (IMLoginManager.get(mContext).isMountEffect()) { 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 { } else {
mIsAnimating = false; mIsAnimating = false;
} }

View File

@ -1123,7 +1123,7 @@ public class LiveGiftAnimPresenter {
} }
}); });
} else { } else {
GiftCacheUtil.getFile(Constants.GIF_GIFT_PREFIX + bean.getGiftId(), url, "1", mDownloadGifCallback); GiftCacheUtil.getFile(mContext,Constants.GIF_GIFT_PREFIX + bean.getGiftId(), url, "1", mDownloadGifCallback);
} }
} }

View File

@ -87,6 +87,7 @@ import com.yunbao.common.utils.ProcessResultUtil;
import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.utils.SpUtil; import com.yunbao.common.utils.SpUtil;
import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.ToastUtils;
import com.yunbao.common.utils.VersionUtil; import com.yunbao.common.utils.VersionUtil;
import com.yunbao.common.utils.WordUtil; import com.yunbao.common.utils.WordUtil;
import com.yunbao.common.views.APKUpdateCustomPopup; 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()); 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<File>() { GiftCacheUtil.getFile(MainActivity.this,Constants.GIF_GIFT_PREFIX + list.get(j).getId(), list.get(j).getSwf(), "0", new CommonCallback<File>() {
@Override @Override
public void callback(File bean) { public void callback(File bean) {
@ -869,7 +870,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
Log.e("tx", id); Log.e("tx", id);
GiftCacheUtil.getFile(Constants.GIF_CAR_PREFIX + id, url1, "0", new CommonCallback<File>() { GiftCacheUtil.getFile(MainActivity.this,Constants.GIF_CAR_PREFIX + id, url1, "0", new CommonCallback<File>() {
@Override @Override
public void callback(File bean) { public void callback(File bean) {
// Log.e("111",bean.getPath()+""); // Log.e("111",bean.getPath()+"");