修改toat样试
This commit is contained in:
parent
af4176bcb7
commit
9869a2376c
@ -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) {
|
||||
|
@ -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) {
|
||||
|
||||
|
44
common/src/main/java/com/yunbao/common/utils/ToastUtils.java
Normal file
44
common/src/main/java/com/yunbao/common/utils/ToastUtils.java
Normal 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);
|
||||
}
|
||||
}
|
26
common/src/main/res/layout/toast_utils.xml
Normal file
26
common/src/main/res/layout/toast_utils.xml
Normal 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>
|
BIN
common/src/main/res/mipmap-xxhdpi/bg_lwhqz.png
Normal file
BIN
common/src/main/res/mipmap-xxhdpi/bg_lwhqz.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
@ -208,7 +208,7 @@ public class LiveGiftAdapter extends RecyclerView.Adapter<LiveGiftAdapter.Vh> {
|
||||
mLoading.startAnimation(animation);
|
||||
LiveGiftBean bean = mList.get((Integer) v.getTag());
|
||||
GiftCacheUtil.getInstance().pause();
|
||||
GiftCacheUtil.getInstance().downloadGiftForId(bean, new CommonCallback<File>() {
|
||||
GiftCacheUtil.getInstance().downloadGiftForId(mContext,bean, new CommonCallback<File>() {
|
||||
@Override
|
||||
public void callback(File bean) {
|
||||
if(bean==null){
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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<File>() {
|
||||
GiftCacheUtil.getFile(MainActivity.this,Constants.GIF_GIFT_PREFIX + list.get(j).getId(), list.get(j).getSwf(), "0", new CommonCallback<File>() {
|
||||
@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<File>() {
|
||||
GiftCacheUtil.getFile(MainActivity.this,Constants.GIF_CAR_PREFIX + id, url1, "0", new CommonCallback<File>() {
|
||||
@Override
|
||||
public void callback(File bean) {
|
||||
// Log.e("111",bean.getPath()+"是");
|
||||
|
Loading…
Reference in New Issue
Block a user