Merge branch 'dev_6.5.6' into master_tmp1
This commit is contained in:
commit
f3195bbcf8
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 + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
@ -40,6 +40,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;
|
||||
@ -969,5 +970,11 @@ public interface PDLiveApi {
|
||||
@GET("/api/public/?service=gift.getGiftNamingInfo")
|
||||
Observable<ResponseModel<GiftNamingInfoModel>> getGiftNamingInfo(@Query("gift_id") String giftId);
|
||||
|
||||
/**
|
||||
* 活动弹窗
|
||||
*/
|
||||
@GET("/api/public/?service=Home.activityPopup")
|
||||
Observable<ResponseModel<List<OpenAdModel>>> activityPopup();
|
||||
|
||||
|
||||
}
|
||||
|
@ -39,6 +39,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;
|
||||
@ -2194,6 +2195,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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 直播间取消网络请求
|
||||
*/
|
||||
|
@ -0,0 +1,175 @@
|
||||
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;
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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){
|
||||
|
29
common/src/main/res/layout/dialog_open_bottom_ad.xml
Normal file
29
common/src/main/res/layout/dialog_open_bottom_ad.xml
Normal file
@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/img"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleType="fitXY"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:adjustViewBounds="true"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:srcCompat="@mipmap/background_gift_wall" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/close"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginEnd="14dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/img"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:srcCompat="@mipmap/ic_open_ad_close" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
32
common/src/main/res/layout/dialog_open_center_ad.xml
Normal file
32
common/src/main/res/layout/dialog_open_center_ad.xml
Normal file
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/img"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:scaleType="fitEnd"
|
||||
app:layout_constraintBottom_toTopOf="@+id/close"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:srcCompat="@drawable/type1" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/close"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginBottom="202dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="@+id/img"
|
||||
app:layout_constraintStart_toStartOf="@+id/img"
|
||||
app:srcCompat="@mipmap/ic_open_ad_close" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
BIN
common/src/main/res/mipmap-mdpi/ic_open_ad_close.png
Normal file
BIN
common/src/main/res/mipmap-mdpi/ic_open_ad_close.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 807 B |
@ -76,6 +76,7 @@ import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.http.main.MainNetManager;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.manager.OpenAdManager;
|
||||
import com.yunbao.common.pay.PayCallback;
|
||||
import com.yunbao.common.pay.PayPresenter;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
@ -95,6 +96,7 @@ import com.yunbao.live.R;
|
||||
import com.yunbao.live.adapter.VerticalPagerAdapter;
|
||||
import com.yunbao.live.bean.ImUserBean;
|
||||
import com.yunbao.live.bean.LiveChatBean;
|
||||
import com.yunbao.live.bean.LiveGuardInfo;
|
||||
import com.yunbao.live.dialog.LiveFansFragment;
|
||||
import com.yunbao.live.dialog.LiveGameDialogFragment;
|
||||
import com.yunbao.live.dialog.LiveGiftPopup;
|
||||
@ -560,6 +562,7 @@ public class LiveAudienceActivity extends LiveActivity {
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
MobclickAgent.onEvent(mContext, "live_room_close", "退出直播间");
|
||||
OpenAdManager.getInstance().dismiss();
|
||||
try {
|
||||
manager.onBackPressed();
|
||||
if (MicStatusManager.getInstance().getMicStatus() == MicStatusManager.MIC_TYPE_REQUEST) {
|
||||
@ -776,6 +779,10 @@ public class LiveAudienceActivity extends LiveActivity {
|
||||
}
|
||||
}
|
||||
GiftCacheUtil.getInstance().restart();
|
||||
if (manager.isEnterRoom()) {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> OpenAdManager.getInstance().show(OpenAdManager.TYPE_LIVE,
|
||||
LiveGuardInfo.isGuard(mLiveGuardInfo)), 400);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3,6 +3,8 @@ package com.yunbao.live.bean;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.yunbao.common.Constants;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/11/14.
|
||||
*/
|
||||
@ -72,5 +74,8 @@ public class LiveGuardInfo implements Parcelable {
|
||||
}
|
||||
};
|
||||
|
||||
public static boolean isGuard(LiveGuardInfo info){
|
||||
return info != null && info.getMyGuardType() != Constants.GUARD_TYPE_NONE;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -689,13 +689,13 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
}
|
||||
});
|
||||
} else if ("inviteMic".equals(str)) {
|
||||
String content="邀請您進行語音連麥";
|
||||
String confirm="接受";
|
||||
String cancel="拒絕";
|
||||
if(!WordUtil.isNewZh()){
|
||||
content="You are invited to join the voice connection";
|
||||
confirm="accept";
|
||||
cancel="cancel";
|
||||
String content = "邀請您進行語音連麥";
|
||||
String confirm = "接受";
|
||||
String cancel = "拒絕";
|
||||
if (!WordUtil.isNewZh()) {
|
||||
content = "You are invited to join the voice connection";
|
||||
confirm = "accept";
|
||||
cancel = "cancel";
|
||||
}
|
||||
DialogUitl.Builder builder = new DialogUitl.Builder(mContext)
|
||||
.setContent(content)
|
||||
@ -708,12 +708,12 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
public void onConfirmClick(Dialog dialog, String content) {
|
||||
String[] permissions;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
permissions=new String[]{
|
||||
permissions = new String[]{
|
||||
Manifest.permission.READ_MEDIA_IMAGES,
|
||||
Manifest.permission.RECORD_AUDIO
|
||||
};
|
||||
}else{
|
||||
permissions=new String[]{
|
||||
} else {
|
||||
permissions = new String[]{
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.RECORD_AUDIO
|
||||
@ -780,9 +780,9 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
onPrepared();
|
||||
rcrtcRoom = null;
|
||||
MicStatusManager.getInstance().clear();
|
||||
if(WordUtil.isNewZh()) {
|
||||
if (WordUtil.isNewZh()) {
|
||||
ToastUtil.show("已成功退出語音連麥");
|
||||
}else{
|
||||
} else {
|
||||
ToastUtil.show("You have successfully exited the voice connection");
|
||||
}
|
||||
resumePlay();
|
||||
@ -867,10 +867,10 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
}
|
||||
|
||||
private void showToast() {
|
||||
if(WordUtil.isNewZh()) {
|
||||
if (WordUtil.isNewZh()) {
|
||||
DialogUitl.showToast(mContext, "設置成功\n" +
|
||||
"正在為你轉換中", 3000);
|
||||
}else{
|
||||
} else {
|
||||
DialogUitl.showToast(mContext, "successful\n" +
|
||||
"It's being converted for you", 3000);
|
||||
}
|
||||
|
@ -59,6 +59,7 @@ import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.HttpClient;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.manager.OpenAdManager;
|
||||
import com.yunbao.common.utils.AppManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
@ -262,6 +263,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
public void run() {
|
||||
loading.setVisibility(View.GONE);
|
||||
enterRoomLeaveHandler.post(enterRoomLeaveRunnable);
|
||||
OpenAdManager.getInstance().show(OpenAdManager.TYPE_LIVE, LiveGuardInfo.isGuard(mLiveGuardInfo));
|
||||
}
|
||||
};
|
||||
final Runnable loadTimeoutRunnableGone = new Runnable() {
|
||||
@ -293,7 +295,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
mLiveRyLinkMicPkPresenter.release();
|
||||
mLiveRyLinkMicPkPresenter = null;
|
||||
}
|
||||
|
||||
OpenAdManager.getInstance().dismiss();
|
||||
mLiveBean = data;
|
||||
mLiveSDK = liveSdk;
|
||||
mLiveType = liveType;
|
||||
@ -2098,4 +2100,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
mLiveRoomViewHolder.setGiftWall(giftWallLightenNumber, giftWallLightenTotal);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEnterRoom() {
|
||||
return isEnterRoom;
|
||||
}
|
||||
}
|
||||
|
@ -88,6 +88,7 @@ import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.manager.APKManager;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.manager.NoviceInstructorManager;
|
||||
import com.yunbao.common.manager.OpenAdManager;
|
||||
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
@ -210,13 +211,14 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
|
||||
OpenAdManager.getInstance().dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
ActivityCompat.postponeEnterTransition(this);
|
||||
ConversationIMListManager.get(this);
|
||||
OpenAdManager.getInstance();
|
||||
//在请求一下这个接口给我后台版本号
|
||||
CommonHttpUtil.getConfig(mContext, new CommonCallback<ConfigBean>() {
|
||||
@Override
|
||||
@ -526,7 +528,6 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
//获取指导员账号
|
||||
ConversationIMListManager.get(this).getUserInstructor(this);
|
||||
checkVersion();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -875,7 +876,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
NoviceInstructorManager.get(mContext).getNoviceInstructor();
|
||||
NoviceInstructorManager.get(mContext).checktHomeZdyPop();
|
||||
initAnchorRecommendBanner();
|
||||
|
||||
OpenAdManager.getInstance().show(OpenAdManager.TYPE_HOME, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1074,6 +1075,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
if (EasyFloat.isShow("LiveFloatView")) {
|
||||
EasyFloat.dismiss("LiveFloatView", true);
|
||||
}
|
||||
OpenAdManager.getInstance().reset();
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user