修改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;
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<File> commonCallback) {
public static void getFile(Context context,String fileName, String url, String forwhat, final CommonCallback<File> 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<File> mDownloadGifCallback) {
public void downloadGiftForId(Context context,LiveGiftBean bean, CommonCallback<File> mDownloadGifCallback) {
if (checkGiftIsDownload(bean.getId())) {
mDownloadGifCallback.callback(getGiftForId(bean.getId()));
return;
}
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
public void callback(File bean) {
if(bean!=null) {

View File

@@ -461,7 +461,7 @@ public class JavascriptInterfaceUtils {
} else {
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
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