Merge branch 'master' into master_sud
# Conflicts: # common/src/main/java/com/yunbao/common/http/PDLiveApi.java # common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java # common/src/main/res/values-en-rUS/string.xml # common/src/main/res/values-zh-rHK/strings.xml # common/src/main/res/values-zh-rTW/strings.xml # common/src/main/res/values-zh/strings.xml # common/src/main/res/values/strings.xml # config.gradle
This commit is contained in:
169
common/src/main/java/com/yunbao/common/bean/OpenAdModel.java
Normal file
169
common/src/main/java/com/yunbao/common/bean/OpenAdModel.java
Normal file
@@ -0,0 +1,169 @@
|
||||
package com.yunbao.common.bean;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
public class OpenAdModel extends BaseModel {
|
||||
public static final int TYPE_HOME = 1;//主页
|
||||
public static final int TYPE_LIVE = 2;//直播间
|
||||
public static final int TYPE_LIVE_DELAY = 3;//直播间延迟
|
||||
public static final int MODEL_SQUARE = 1;//正方形
|
||||
public static final int MODEL_RECTANGLE = 2;//长方形
|
||||
public static final int MODEL_BOTTOM = 3;//底部
|
||||
@SerializedName("id")
|
||||
private int id;
|
||||
@SerializedName("popup_location")
|
||||
private int type = TYPE_HOME;
|
||||
@SerializedName("activity_url")
|
||||
private String url;
|
||||
@SerializedName("image_url")
|
||||
private String imageUrl;
|
||||
@SerializedName("display_time")
|
||||
private int showTime; //持续展示时间
|
||||
@SerializedName("delay_show_time")
|
||||
private int delayShowTime;//延迟展示时间
|
||||
@SerializedName("popup_model")
|
||||
private int model = MODEL_SQUARE;
|
||||
@SerializedName("start_show_time")
|
||||
private String startTime;//活动开始时间
|
||||
@SerializedName("end_show_time")
|
||||
private String endTime;//活动结束时间
|
||||
@SerializedName("popup_permission")
|
||||
private int permission;
|
||||
|
||||
|
||||
public OpenAdModel() {
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
if (!url.startsWith("http://") || !url.startsWith("https://")) {
|
||||
url = CommonAppConfig.HOST + url;
|
||||
}
|
||||
return url + "?t=" + System.currentTimeMillis() / 1000;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public int getShowTime() {
|
||||
return showTime * 1000;
|
||||
}
|
||||
|
||||
public void setShowTime(int showTime) {
|
||||
this.showTime = showTime;
|
||||
}
|
||||
|
||||
public int getDelayShowTime() {
|
||||
return delayShowTime * 1000;
|
||||
}
|
||||
|
||||
public void setDelayShowTime(int delayShowTime) {
|
||||
this.delayShowTime = delayShowTime;
|
||||
}
|
||||
|
||||
public String getImageUrl() {
|
||||
return imageUrl;
|
||||
}
|
||||
|
||||
public void setImageUrl(String imageUrl) {
|
||||
this.imageUrl = imageUrl;
|
||||
}
|
||||
|
||||
public int getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
public String getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(String startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public String getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(String endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public void setModel(int model) {
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getPermission() {
|
||||
return permission;
|
||||
}
|
||||
|
||||
public void setPermission(int permission) {
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
public boolean isInTime() {
|
||||
if (StringUtil.isEmpty(startTime, endTime)) {
|
||||
return true;
|
||||
}
|
||||
Date startTime = null;
|
||||
Date endTime = null;
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
|
||||
|
||||
try {
|
||||
startTime = sdf.parse(this.startTime);
|
||||
endTime = sdf.parse(this.endTime);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
long time = System.currentTimeMillis();
|
||||
return startTime.getTime() <= time && time <= endTime.getTime();
|
||||
}
|
||||
|
||||
public boolean userIsPermission(boolean isGuard) {
|
||||
if (permission == 4 && !isGuard) {//守护不可见
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OpenAdModel{" +
|
||||
"id=" + id +
|
||||
", type=" + type +
|
||||
", url='" + url + '\'' +
|
||||
", imageUrl='" + imageUrl + '\'' +
|
||||
", showTime=" + showTime +
|
||||
", delayShowTime=" + delayShowTime +
|
||||
", model=" + model +
|
||||
", startTime='" + startTime + '\'' +
|
||||
", endTime='" + endTime + '\'' +
|
||||
", permission='" + permission + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,8 @@ public class PkRankBean extends BaseModel {
|
||||
public String clickUrl;
|
||||
@SerializedName("vs_img")
|
||||
public String vsImgUrl;
|
||||
@SerializedName("new_rank_name_en")
|
||||
public String newRankNameEn;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
@@ -94,6 +96,14 @@ public class PkRankBean extends BaseModel {
|
||||
this.vsImgUrl = vsImgUrl;
|
||||
}
|
||||
|
||||
public String getNewRankNameEn() {
|
||||
return newRankNameEn;
|
||||
}
|
||||
|
||||
public void setNewRankNameEn(String newRankNameEn) {
|
||||
this.newRankNameEn = newRankNameEn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PkRankBean{" +
|
||||
@@ -105,6 +115,7 @@ public class PkRankBean extends BaseModel {
|
||||
", pkTopImgUrl='" + pkTopImgUrl + '\'' +
|
||||
", clickUrl='" + clickUrl + '\'' +
|
||||
", vsImgUrl='" + vsImgUrl + '\'' +
|
||||
", newRankNameEn='" + newRankNameEn + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.yunbao.common.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.lxj.xpopup.impl.FullScreenPopupView;
|
||||
|
||||
/**
|
||||
* 居中弹窗
|
||||
*/
|
||||
public abstract class AbsDialogFullScreenPopupWindow extends FullScreenPopupView {
|
||||
public final Context mContext;
|
||||
|
||||
public AbsDialogFullScreenPopupWindow(@NonNull Context context) {
|
||||
super(context);
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
/**
|
||||
* <a href="https://github.com/li-xiaojun/XPopup/wiki/5.-%E5%B8%B8%E7%94%A8%E8%AE%BE%E7%BD%AE">参考配置</a>
|
||||
*/
|
||||
public abstract void buildDialog(XPopup.Builder builder);
|
||||
public abstract int bindLayoutId();
|
||||
|
||||
@Override
|
||||
protected int getImplLayoutId() {
|
||||
return bindLayoutId();
|
||||
}
|
||||
|
||||
public void showDialog() {
|
||||
XPopup.Builder builder = new XPopup.Builder(mContext);
|
||||
builder.isDestroyOnDismiss(true);
|
||||
builder.enableDrag(false);
|
||||
buildDialog(builder);
|
||||
builder.asCustom(this).show();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.yunbao.common.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.activity.WebViewActivity;
|
||||
import com.yunbao.common.bean.OpenAdModel;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
|
||||
public class OpenAdBottomDialogPopup extends AbsDialogPopupWindow {
|
||||
private ImageView mImageView;
|
||||
private ImageView mClose;
|
||||
private OpenAdModel model;
|
||||
private OnItemClickListener<OpenAdModel> mListener;
|
||||
|
||||
public OpenAdBottomDialogPopup(@NonNull Context context, OpenAdModel model) {
|
||||
super(context);
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void buildDialog(XPopup.Builder builder) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int bindLayoutId() {
|
||||
return R.layout.dialog_open_bottom_ad;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
super.dismiss();
|
||||
if (mListener != null) {
|
||||
mListener.onItemClick(model, 0);
|
||||
mListener = null;
|
||||
}
|
||||
}
|
||||
|
||||
public OpenAdBottomDialogPopup setListener(OnItemClickListener<OpenAdModel> mListener) {
|
||||
this.mListener = mListener;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate() {
|
||||
super.onCreate();
|
||||
mImageView = findViewById(R.id.img);
|
||||
mClose = findViewById(R.id.close);
|
||||
mImageView.setOnClickListener(v -> {
|
||||
WebViewActivity.forward(mContext, model.getUrl(), model.getType() != OpenAdModel.TYPE_HOME);
|
||||
if (mListener != null) {
|
||||
mListener.onItemClick(model, 1);
|
||||
mListener = null;
|
||||
}
|
||||
dismiss();
|
||||
});
|
||||
mClose.setOnClickListener(v -> dismiss());
|
||||
ImgLoader.display(mContext, model.getImageUrl(), mImageView);
|
||||
if (model.getShowTime() > 0) {
|
||||
mClose.postDelayed(this::dismiss, model.getShowTime());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.yunbao.common.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.activity.WebViewActivity;
|
||||
import com.yunbao.common.bean.OpenAdModel;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.ScreenDimenUtil;
|
||||
|
||||
public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow {
|
||||
private ImageView mImageView;
|
||||
private ImageView mClose;
|
||||
private OpenAdModel model;
|
||||
private OnItemClickListener<OpenAdModel> mListener;
|
||||
|
||||
public OpenAdCenterDialogPopup(@NonNull Context context, OpenAdModel model) {
|
||||
super(context);
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public OpenAdCenterDialogPopup setListener(OnItemClickListener<OpenAdModel> mListener) {
|
||||
this.mListener = mListener;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildDialog(XPopup.Builder builder) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int bindLayoutId() {
|
||||
return R.layout.dialog_open_center_ad;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
super.dismiss();
|
||||
if (mListener != null) {
|
||||
mListener.onItemClick(model, 0);
|
||||
mListener = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate() {
|
||||
super.onCreate();
|
||||
mImageView = findViewById(R.id.img);
|
||||
mClose = findViewById(R.id.close);
|
||||
findViewById(R.id.layout).setOnClickListener(v -> dismiss());
|
||||
mImageView.setOnClickListener(v -> {
|
||||
WebViewActivity.forward(mContext, model.getUrl(), model.getType() != OpenAdModel.TYPE_HOME);
|
||||
if (mListener != null) {
|
||||
mListener.onItemClick(model, 1);
|
||||
mListener = null;
|
||||
}
|
||||
dismiss();
|
||||
});
|
||||
mClose.setOnClickListener(v -> dismiss());
|
||||
ImgLoader.display(mContext, model.getImageUrl(), mImageView);
|
||||
int width = ScreenDimenUtil.getInstance().getScreenWdith() - DpUtil.dp2px(40);
|
||||
int height = (int) (width * 1.4);
|
||||
if (model.getModel() == OpenAdModel.MODEL_SQUARE) {
|
||||
height = width;
|
||||
}
|
||||
ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) mImageView.getLayoutParams();
|
||||
params.width = width;
|
||||
params.height = height;
|
||||
mImageView.setLayoutParams(params);
|
||||
if (model.getShowTime() > 0) {
|
||||
mClose.postDelayed(this::dismiss, model.getShowTime());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.HintCustomPopup;
|
||||
import com.yunbao.common.views.LiveNewWishGiftPopup;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
@@ -149,7 +150,7 @@ public class LiveNewWishListFragment extends BaseFragment {
|
||||
setWishlistV2(type, gson.toJson(wishList2), new HttpCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String data) {
|
||||
ToastUtil.show("修改成功");
|
||||
ToastUtil.show(WordUtil.isNewZh()?"修改成功":"Success");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -181,7 +182,7 @@ public class LiveNewWishListFragment extends BaseFragment {
|
||||
setWishlistV2(type, gson.toJson(wishList2), new HttpCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String data) {
|
||||
ToastUtil.show("修改成功");
|
||||
ToastUtil.show(WordUtil.isNewZh()?"修改成功":"Success");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -200,7 +201,7 @@ public class LiveNewWishListFragment extends BaseFragment {
|
||||
setWishlistV2(type, gson.toJson(wishList2), new HttpCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String data) {
|
||||
ToastUtil.show("修改成功");
|
||||
ToastUtil.show(WordUtil.isNewZh()?"修改成功":"Success");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.lzy.okgo.callback.StringCallback;
|
||||
import com.lzy.okgo.model.Response;
|
||||
import com.lzy.okgo.request.PostRequest;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.CommonAppContext;
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.activity.ErrorActivity;
|
||||
import com.yunbao.common.bean.ConfigBean;
|
||||
@@ -260,6 +261,8 @@ public class CommonHttpUtil {
|
||||
AppManager.getInstance().AppExit();
|
||||
}
|
||||
}).build().show();
|
||||
} else {
|
||||
ToastUtil.show(CommonAppContext.getTopActivity().getString(R.string.net_error) + "code:" + code + " msg:" + msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ import com.yunbao.common.bean.MsgSwitchDetailModel;
|
||||
import com.yunbao.common.bean.NewPeopleInfo;
|
||||
import com.yunbao.common.bean.NobleRankHideUserListModel;
|
||||
import com.yunbao.common.bean.NobleTrumpetModel;
|
||||
import com.yunbao.common.bean.OpenAdModel;
|
||||
import com.yunbao.common.bean.PkRankBean;
|
||||
import com.yunbao.common.bean.PrankGiftBean;
|
||||
import com.yunbao.common.bean.PrankHttpTurntableBean;
|
||||
@@ -1033,5 +1034,11 @@ public interface PDLiveApi {
|
||||
@Query("room_id") String roomId
|
||||
);
|
||||
|
||||
/**
|
||||
* 活动弹窗
|
||||
*/
|
||||
@GET("/api/public/?service=Home.activityPopup")
|
||||
Observable<ResponseModel<List<OpenAdModel>>> activityPopup();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ import com.yunbao.common.bean.LiveUserMailBoxModel;
|
||||
import com.yunbao.common.bean.MedalAchievementModel;
|
||||
import com.yunbao.common.bean.NobleRankHideUserListModel;
|
||||
import com.yunbao.common.bean.NobleTrumpetModel;
|
||||
import com.yunbao.common.bean.OpenAdModel;
|
||||
import com.yunbao.common.bean.PkRankBean;
|
||||
import com.yunbao.common.bean.PrankGiftBean;
|
||||
import com.yunbao.common.bean.PrankHttpTurntableBean;
|
||||
@@ -2197,6 +2198,29 @@ public class LiveNetManager {
|
||||
}).isDisposed();
|
||||
}
|
||||
|
||||
public void activityPopup(HttpCallback<List<OpenAdModel>> callback) {
|
||||
API.get().pdLiveApi(mContext)
|
||||
.activityPopup()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Consumer<ResponseModel<List<OpenAdModel>>>() {
|
||||
@Override
|
||||
public void accept(ResponseModel<List<OpenAdModel>> listResponseModel) throws Exception {
|
||||
if (callback != null) {
|
||||
callback.onSuccess(listResponseModel.getData().getInfo());
|
||||
}
|
||||
}
|
||||
}, new Consumer<Throwable>() {
|
||||
@Override
|
||||
public void accept(Throwable throwable) throws Exception {
|
||||
throwable.printStackTrace();
|
||||
if (callback != null) {
|
||||
callback.onError(mContext.getString(R.string.net_error));
|
||||
}
|
||||
}
|
||||
}).isDisposed();
|
||||
}
|
||||
|
||||
public void getCode(HttpCallback<List<SudgameCodeModel>> callback) {
|
||||
API.get().pdLiveApi(mContext)
|
||||
.getCode()
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -100,7 +101,11 @@ public class IMRTCManager {
|
||||
public void onSuccess() {
|
||||
callback.onSuccess();
|
||||
if (!RandomPkManager.getInstance().isRandomModel()) {
|
||||
ToastUtil.show("发起邀请成功");
|
||||
if(WordUtil.isNewZh()) {
|
||||
ToastUtil.show("发起邀请成功");
|
||||
}else{
|
||||
ToastUtil.show("successful");
|
||||
}
|
||||
}
|
||||
requestUid.add(liveUid);
|
||||
startRequestTimeoutTask(liveUid);
|
||||
@@ -109,7 +114,11 @@ public class IMRTCManager {
|
||||
@Override
|
||||
public void onFailed(RTCErrorCode errorCode) {
|
||||
if (!RandomPkManager.getInstance().isRandomModel()) {
|
||||
ToastUtil.show("邀请失败 " + errorCode.getValue());
|
||||
if(WordUtil.isNewZh()) {
|
||||
ToastUtil.show("邀请失败 " + errorCode.getValue());
|
||||
}else{
|
||||
ToastUtil.show("invite failed:" +errorCode.getValue());
|
||||
}
|
||||
}
|
||||
if (RandomPkManager.getInstance().isRequestPk()) {
|
||||
RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_REFUSE);
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
package com.yunbao.common.manager;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
|
||||
import com.yunbao.common.CommonAppContext;
|
||||
import com.yunbao.common.bean.OpenAdModel;
|
||||
import com.yunbao.common.dialog.OpenAdBottomDialogPopup;
|
||||
import com.yunbao.common.dialog.OpenAdCenterDialogPopup;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class OpenAdManager {
|
||||
public static final int TYPE_HOME = 1;
|
||||
public static final int TYPE_LIVE = 2;
|
||||
private static final String TAG = "-----弹窗-----";
|
||||
private Map<Integer, Boolean> showMap;
|
||||
private List<OpenAdModel> list = null;
|
||||
private Handler handler = new Handler(Looper.getMainLooper());
|
||||
private Map<Integer, AdRunnable> runnableMap = new HashMap<>();
|
||||
private int showType;
|
||||
|
||||
private OpenAdManager() {
|
||||
showMap = new HashMap<>();
|
||||
init(false);
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
dismiss();
|
||||
runnableMap.clear();
|
||||
showMap.clear();
|
||||
list.clear();
|
||||
}
|
||||
|
||||
private static final class MInstanceHolder {
|
||||
static final OpenAdManager mInstance = new OpenAdManager();
|
||||
}
|
||||
|
||||
public static OpenAdManager getInstance() {
|
||||
return MInstanceHolder.mInstance;
|
||||
}
|
||||
|
||||
private void init(boolean isShow) {
|
||||
if (list != null && list.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if(CommonAppContext.getTopActivity()==null){
|
||||
return;
|
||||
}
|
||||
LiveNetManager.get(CommonAppContext.getTopActivity())
|
||||
.activityPopup(new HttpCallback<List<OpenAdModel>>() {
|
||||
@Override
|
||||
public void onSuccess(List<OpenAdModel> data) {
|
||||
if (data == null || data.isEmpty()) {
|
||||
Log.i(TAG, "onSuccess: 没有数据");
|
||||
list = new ArrayList<>();
|
||||
return;
|
||||
}
|
||||
list = data;
|
||||
if (isShow) {
|
||||
show(TYPE_HOME, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
System.err.println("弹框列表:" + error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public synchronized void show(int type, boolean isGuard) {
|
||||
if (list == null) {
|
||||
init(true);
|
||||
return;
|
||||
}
|
||||
showType = type;
|
||||
for (OpenAdModel model : list) {
|
||||
if (model.getType() == type) {
|
||||
if (type == OpenAdModel.TYPE_LIVE && !model.userIsPermission(isGuard)) {
|
||||
continue;
|
||||
}
|
||||
if (runnableMap.containsKey(model.getId())) {
|
||||
AdRunnable runnable = runnableMap.get(model.getId());
|
||||
if (runnable != null) {
|
||||
Log.d(TAG, "reset: " + model);
|
||||
handler.removeCallbacks(runnable);
|
||||
runnableMap.remove(model.getId());
|
||||
}
|
||||
}
|
||||
|
||||
if (!isShow(model)) {
|
||||
Log.i(TAG, "show: " + model);
|
||||
handler.postDelayed(new AdRunnable(model), model.getDelayShowTime());
|
||||
} else {
|
||||
Log.i(TAG, "notshow: " + model);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Log.i(TAG, "------------------------------");
|
||||
|
||||
}
|
||||
|
||||
public synchronized void dismiss() {
|
||||
Log.d(TAG, "准备dismiss:" + runnableMap.size());
|
||||
for (Integer model : runnableMap.keySet()) {
|
||||
AdRunnable runnable = runnableMap.get(model);
|
||||
Log.d(TAG, "dismiss:" + runnable);
|
||||
if (runnable != null) {
|
||||
runnable.dismiss();
|
||||
handler.removeCallbacks(runnable);
|
||||
}
|
||||
}
|
||||
runnableMap.clear();
|
||||
}
|
||||
|
||||
private synchronized boolean isShow(OpenAdModel type) {
|
||||
if (showMap.containsKey(type.getId()) && showMap.get(type.getId()) != null) {
|
||||
return Boolean.TRUE.equals(showMap.get(type.getId()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private class AdRunnable implements Runnable {
|
||||
OpenAdModel model;
|
||||
|
||||
public AdRunnable(OpenAdModel model) {
|
||||
this.model = model;
|
||||
runnableMap.put(model.getId(), this);
|
||||
}
|
||||
|
||||
public void dismiss() {
|
||||
Log.e(TAG, "dismiss: " + model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void run() {
|
||||
Log.i(TAG, "run: " + model);
|
||||
if (model == null) {
|
||||
ToastUtil.showDebug("model为空");
|
||||
return;
|
||||
}
|
||||
if (!model.isInTime()) {
|
||||
ToastUtil.showDebug("不在展示时间内:" + model.getStartTime() + "|" + model.getEndTime());
|
||||
return;
|
||||
}
|
||||
if (isShow(model)) {
|
||||
ToastUtil.showDebug(model.getId() + "|model展示过了");
|
||||
return;
|
||||
}
|
||||
if (model.getType() != showType) {
|
||||
return;
|
||||
}
|
||||
showMap.put(model.getId(), true);
|
||||
if (model.getModel() == OpenAdModel.MODEL_BOTTOM) {
|
||||
new OpenAdBottomDialogPopup(CommonAppContext.getTopActivity(), model)
|
||||
.setListener((bean, position) -> {
|
||||
})
|
||||
.showDialog();
|
||||
} else {
|
||||
new OpenAdCenterDialogPopup(CommonAppContext.getTopActivity(), model)
|
||||
.setListener((bean, position) -> {
|
||||
})
|
||||
.showDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import static com.yunbao.common.CommonAppConfig.isGetNewWrap;
|
||||
import static com.yunbao.common.utils.RouteUtil.PATH_COIN;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.View;
|
||||
@@ -643,4 +644,19 @@ public class JavascriptInterfaceUtils {
|
||||
Bus.get().post(new JavascriptInterfaceEvent()
|
||||
.setMethod("androidCancelAnchorAttention"));
|
||||
}
|
||||
@JavascriptInterface
|
||||
public void androidLnsufficientBalanceClick(String msg){
|
||||
DialogUitl.showSimpleDialog(mContext, msg, new DialogUitl.SimpleCallback2() {
|
||||
@Override
|
||||
public void onCancelClick() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfirmClick(Dialog dialog, String content) {
|
||||
dialog.dismiss();
|
||||
ARouter.getInstance().build(PATH_COIN).withInt("p", 0).navigation();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class NobleUtil {
|
||||
case 1:return "男爵";
|
||||
case 2:return "子爵";
|
||||
case 3:return "侯爵";
|
||||
case 4:return "公爵";
|
||||
case 4:return "公爵";
|
||||
case 5:return "国王";
|
||||
case 6:return "皇帝";
|
||||
case 7:return "超皇";
|
||||
@@ -39,15 +39,15 @@ public class NobleUtil {
|
||||
}
|
||||
public static String nobleIdToStringNameForEn(int id){
|
||||
switch (id){
|
||||
case 1:return "baron";
|
||||
case 2:return "viscount";
|
||||
case 3:return "marquis";
|
||||
case 4:return "duke";
|
||||
case 5:return "king";
|
||||
case 6:return "emperor";
|
||||
case 7:return "SuperEmperor";
|
||||
case 1:return "Baron";
|
||||
case 2:return "Viscount";
|
||||
case 3:return "Marquis";
|
||||
case 4:return "Duke";
|
||||
case 5:return "King";
|
||||
case 6:return "Emperor";
|
||||
case 7:return "SuperKing";
|
||||
}
|
||||
return "Not Opened";
|
||||
return "Not opened";
|
||||
}
|
||||
public static int getNobleBackgroundId(int id){
|
||||
switch (id){
|
||||
|
||||
@@ -49,17 +49,17 @@ public class PluginManager {
|
||||
}
|
||||
|
||||
public boolean isDownloadApk() {
|
||||
if(!CommonAppConfig.IS_PLUGIN_MODEL){
|
||||
if (!CommonAppConfig.IS_PLUGIN_MODEL) {
|
||||
return true;
|
||||
}
|
||||
return new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin_download" + File.separator + "anchorPlugin.apk").exists();
|
||||
return new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin_download" + File.separator + "anchorPlugin.apk.lock").exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载主播插件
|
||||
*/
|
||||
public void loadAnchorPlugin(DialogInterface.OnDismissListener dismissListener) {
|
||||
if(!CommonAppConfig.IS_PLUGIN_MODEL){
|
||||
if (!CommonAppConfig.IS_PLUGIN_MODEL) {
|
||||
dismissListener.onDismiss(null);
|
||||
return;
|
||||
}
|
||||
@@ -73,7 +73,8 @@ public class PluginManager {
|
||||
e.printStackTrace();
|
||||
}
|
||||
File sdk = new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin_download" + File.separator + "anchorPlugin.apk");
|
||||
if (!sdk.exists()) {
|
||||
if (!new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin_download" + File.separator + "anchorPlugin.apk.lock").exists() || !sdk.exists()) {
|
||||
Log.i(TAG, "loadAnchorPlugin: 插件未下载");
|
||||
if (StringUtil.isEmpty(anchorPluginDownloadUrl)) {
|
||||
Log.e(TAG, "主播下载地址为空");
|
||||
return;
|
||||
@@ -97,8 +98,12 @@ public class PluginManager {
|
||||
* @param outDir 解压路径
|
||||
*/
|
||||
private void loadFaceSo(File plugin, String outDir) {
|
||||
if(!new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin"+File.separator+"lib").exists()) {
|
||||
unzip(plugin.getAbsolutePath(), outDir, ".so");
|
||||
if (!new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin" + File.separator + "lib.lock").exists()) {
|
||||
Log.i(TAG, "loadFaceSo: lib插件未解压");
|
||||
if (unzip(plugin.getAbsolutePath(), outDir, ".so")) {
|
||||
new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin" + File.separator + "lib.lock").mkdirs();
|
||||
Log.i(TAG, "loadFaceSo: lib插件解压");
|
||||
}
|
||||
}
|
||||
String[] abis = Build.SUPPORTED_ABIS;
|
||||
String abi = Arrays.asList(abis).contains("arm64-v8a") ? "arm64-v8a" : "armeabi-v7a";
|
||||
@@ -108,8 +113,8 @@ public class PluginManager {
|
||||
try {
|
||||
Field field = Class.forName("com.faceunity.wrapper.faceunity$LoadConfig").getDeclaredField("sLoadedLibrary");
|
||||
field.setAccessible(true);
|
||||
field.set(null,true);
|
||||
}catch (Exception e){
|
||||
field.set(null, true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -121,8 +126,12 @@ public class PluginManager {
|
||||
* @param outDir 解压路径
|
||||
*/
|
||||
private void loadFaceBundle(File plugin, String outDir) {
|
||||
if(!new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin"+File.separator+"assets").exists()) {
|
||||
unzip(plugin.getAbsolutePath(), outDir, ".bundle");
|
||||
if (!new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin" + File.separator + "assets.lock").exists()) {
|
||||
Log.i(TAG, "loadFaceBundle: bundle未解压");
|
||||
if (unzip(plugin.getAbsolutePath(), outDir, ".bundle")) {
|
||||
Log.i(TAG, "loadFaceBundle: bundle解压");
|
||||
new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin" + File.separator + "assets.lock").mkdirs();
|
||||
}
|
||||
}
|
||||
try {
|
||||
Object BUNDLE_AI_FACE = Class.forName("com.yunbao.faceunity.utils.FURenderer").getField("BUNDLE_AI_FACE").get(null);
|
||||
@@ -131,6 +140,7 @@ public class PluginManager {
|
||||
Class.forName("com.yunbao.faceunity.utils.FaceUnityConfig").getField("BUNDLE_FACE_BEAUTIFICATION").set(null, outDir + File.separator + "assets" + File.separator + BUNDLE_FACE_BEAUTIFICATION);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin" + File.separator + "assets.lock").delete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,10 +153,12 @@ public class PluginManager {
|
||||
private void loadSo(File dir, String file) {
|
||||
file += ".so";
|
||||
if (new File(dir.getAbsolutePath() + File.separator + file).exists()) {
|
||||
Log.d(TAG, "加载 " + dir.getAbsolutePath() + File.separator + file);
|
||||
System.load(dir + File.separator + file);
|
||||
Log.d(TAG, "加载成功 " + dir + File.separator + file);
|
||||
} else {
|
||||
Log.e(TAG, "不存在 " + dir + File.separator + file);
|
||||
new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin" + File.separator + "lib.lock").delete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,6 +171,7 @@ public class PluginManager {
|
||||
@Override
|
||||
public void onSuccess(File file) {
|
||||
Log.d(TAG, "下载成功 " + file);
|
||||
new File(CommonAppContext.sInstance.getFilesDir().getAbsolutePath() + File.separator + "plugin_download" + File.separator + "anchorPlugin.apk.lock").mkdirs();
|
||||
loadAnchorPlugin(dismissListener);
|
||||
}
|
||||
|
||||
@@ -169,7 +182,7 @@ public class PluginManager {
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
downloadAnchorSdk(dismissListener);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -186,13 +199,14 @@ public class PluginManager {
|
||||
FileOutputStream out;
|
||||
byte buffer[] = new byte[1024];
|
||||
try {
|
||||
Log.i(TAG, "unzip: " + outDir);
|
||||
ZipInputStream zis = new ZipInputStream(new FileInputStream(zip));
|
||||
ZipEntry entry = zis.getNextEntry();
|
||||
while (entry != null) {
|
||||
String name = entry.getName();
|
||||
if (entry.isDirectory()) {
|
||||
File newDir = new File(outDir + entry.getName());
|
||||
newDir.mkdir();
|
||||
newDir.mkdirs();
|
||||
} else if (name.endsWith(suffix)) {
|
||||
File outputFile = new File(outDir + File.separator + name);
|
||||
String outputPath = outputFile.getCanonicalPath();
|
||||
@@ -205,7 +219,7 @@ public class PluginManager {
|
||||
outputFile = new File(outputPath, name);
|
||||
outputFile.createNewFile();
|
||||
out = new FileOutputStream(outputFile);
|
||||
|
||||
Log.i(TAG, "unzip: >>" + outputFile.getAbsolutePath());
|
||||
int tmp = 0;
|
||||
while ((tmp = zis.read(buffer)) > 0) {
|
||||
out.write(buffer, 0, tmp);
|
||||
|
||||
@@ -43,7 +43,7 @@ public class ToastUtil {
|
||||
|
||||
|
||||
public static void show(int res) {
|
||||
show(WordUtil.getString(res));
|
||||
show(WordUtil.getNewString(res));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,7 +80,7 @@ public class ToastUtil {
|
||||
}
|
||||
public static void showDebug(String s){
|
||||
if(BuildConfig.DEBUG){
|
||||
show(s);
|
||||
show("开发模式:"+s);
|
||||
}
|
||||
}
|
||||
public static void showDebug(int s){
|
||||
@@ -92,6 +92,7 @@ public class ToastUtil {
|
||||
if (TextUtils.isEmpty(s)) {
|
||||
return;
|
||||
}
|
||||
Log.i("Toast", "Toast show: "+s);
|
||||
Log.i("ts","ll");
|
||||
Toast.makeText(CommonAppContext.sInstance,s,Toast.LENGTH_SHORT).show();
|
||||
Log.i("ts","22");
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.lxj.xpopup.animator.PopupAnimator;
|
||||
import com.lxj.xpopup.core.CenterPopupView;
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
/**
|
||||
@@ -85,7 +86,7 @@ public class InputCustomPopup extends CenterPopupView {
|
||||
public void onViewClicks() {
|
||||
String textContent = content.getText().toString();
|
||||
if (TextUtils.isEmpty(textContent)) {
|
||||
ToastUtil.show("输入内容不可为空");
|
||||
ToastUtil.show(WordUtil.isNewZh()?"输入内容不可为空":"The input cannot be empty");
|
||||
return;
|
||||
}
|
||||
if (listener != null) {
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@@ -332,7 +333,7 @@ public class LiveNewWishListPopup extends BottomPopupView {
|
||||
setWishlistV2(type, gson.toJson(wishList2), new HttpCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String data) {
|
||||
ToastUtil.show("修改成功");
|
||||
ToastUtil.show(WordUtil.isNewZh()?"修改成功":"Success");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user