diff --git a/common/src/main/java/com/yunbao/common/bean/OpenAdModel.java b/common/src/main/java/com/yunbao/common/bean/OpenAdModel.java new file mode 100644 index 000000000..0189513be --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/OpenAdModel.java @@ -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 + '\'' + + '}'; + } +} diff --git a/common/src/main/java/com/yunbao/common/dialog/AbsDialogFullScreenPopupWindow.java b/common/src/main/java/com/yunbao/common/dialog/AbsDialogFullScreenPopupWindow.java new file mode 100644 index 000000000..76a7e48cb --- /dev/null +++ b/common/src/main/java/com/yunbao/common/dialog/AbsDialogFullScreenPopupWindow.java @@ -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; + } + + /** + * 参考配置 + */ + 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(); + } +} diff --git a/common/src/main/java/com/yunbao/common/dialog/OpenAdBottomDialogPopup.java b/common/src/main/java/com/yunbao/common/dialog/OpenAdBottomDialogPopup.java new file mode 100644 index 000000000..b4f0dc002 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/dialog/OpenAdBottomDialogPopup.java @@ -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 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 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()); + } + } +} diff --git a/common/src/main/java/com/yunbao/common/dialog/OpenAdCenterDialogPopup.java b/common/src/main/java/com/yunbao/common/dialog/OpenAdCenterDialogPopup.java new file mode 100644 index 000000000..5e92f5f10 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/dialog/OpenAdCenterDialogPopup.java @@ -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 mListener; + + public OpenAdCenterDialogPopup(@NonNull Context context, OpenAdModel model) { + super(context); + this.model = model; + } + + public OpenAdCenterDialogPopup setListener(OnItemClickListener 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()); + } + } +} diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java index c7adca890..204a13d7b 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -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> getGiftNamingInfo(@Query("gift_id") String giftId); + /** + * 活动弹窗 + */ + @GET("/api/public/?service=Home.activityPopup") + Observable>> activityPopup(); + } diff --git a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java index d63b8dcff..4943589da 100644 --- a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java +++ b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java @@ -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> callback) { + API.get().pdLiveApi(mContext) + .activityPopup() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>>() { + @Override + public void accept(ResponseModel> listResponseModel) throws Exception { + if (callback != null) { + callback.onSuccess(listResponseModel.getData().getInfo()); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + throwable.printStackTrace(); + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } + /** * 直播间取消网络请求 */ diff --git a/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java b/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java new file mode 100644 index 000000000..4003b6a17 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java @@ -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 showMap; + private List list = null; + private Handler handler = new Handler(Looper.getMainLooper()); + private Map 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>() { + @Override + public void onSuccess(List 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(); + } + } + } +} diff --git a/common/src/main/java/com/yunbao/common/utils/ToastUtil.java b/common/src/main/java/com/yunbao/common/utils/ToastUtil.java index 764297b5a..d2240037d 100644 --- a/common/src/main/java/com/yunbao/common/utils/ToastUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/ToastUtil.java @@ -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){ diff --git a/common/src/main/res/layout/dialog_open_bottom_ad.xml b/common/src/main/res/layout/dialog_open_bottom_ad.xml new file mode 100644 index 000000000..192f2d295 --- /dev/null +++ b/common/src/main/res/layout/dialog_open_bottom_ad.xml @@ -0,0 +1,29 @@ + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/dialog_open_center_ad.xml b/common/src/main/res/layout/dialog_open_center_ad.xml new file mode 100644 index 000000000..217d47e2b --- /dev/null +++ b/common/src/main/res/layout/dialog_open_center_ad.xml @@ -0,0 +1,32 @@ + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/mipmap-mdpi/ic_open_ad_close.png b/common/src/main/res/mipmap-mdpi/ic_open_ad_close.png new file mode 100644 index 000000000..62d53f0ef Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/ic_open_ad_close.png differ diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java index 0f59a4142..02e55bd3a 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -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 diff --git a/live/src/main/java/com/yunbao/live/bean/LiveGuardInfo.java b/live/src/main/java/com/yunbao/live/bean/LiveGuardInfo.java index 0e07e4734..1015a6de7 100644 --- a/live/src/main/java/com/yunbao/live/bean/LiveGuardInfo.java +++ b/live/src/main/java/com/yunbao/live/bean/LiveGuardInfo.java @@ -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; + } } diff --git a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java index 0fab5e098..1cc6f6313 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java @@ -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); } diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java index 46b3479d5..3a748e4ca 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -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; + } } diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java index b53cdb8c4..1693facbf 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -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() { @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(); } }