diff --git a/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java b/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java index 3639ce194..604bb9feb 100644 --- a/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java +++ b/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java @@ -1,7 +1,5 @@ package com.yunbao.common.activity; -import static com.yunbao.common.utils.RouteUtil.PATH_ZHUANGBANACTIVITY; - import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; @@ -9,14 +7,9 @@ import android.content.Intent; import android.net.Uri; import android.os.Build; import android.provider.MediaStore; - -import androidx.annotation.RequiresApi; - import android.text.TextUtils; -import android.util.Log; import android.view.View; import android.view.ViewGroup; -import android.webkit.JavascriptInterface; import android.webkit.ValueCallback; import android.webkit.WebChromeClient; import android.webkit.WebSettings; @@ -27,17 +20,22 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ProgressBar; -import com.alibaba.android.arouter.launcher.ARouter; +import androidx.annotation.RequiresApi; + import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; import com.yunbao.common.R; +import com.yunbao.common.event.JavascriptInterfaceEvent; import com.yunbao.common.utils.AndroidBug5497Workaround; import com.yunbao.common.utils.DpUtil; +import com.yunbao.common.utils.JavascriptInterfaceUtils; import com.yunbao.common.utils.L; -import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + /** * Created by cxf on 2018/9/25. */ @@ -141,7 +139,7 @@ public class WebViewActivity extends AbsActivity { } }); - mWebView.addJavascriptInterface(new JsInteration(), "androidObject"); + mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, mWebView).setPageClose(true).setLiveZhuangBana(false), "androidObject"); mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口 mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setDomStorageEnabled(true); @@ -170,76 +168,6 @@ public class WebViewActivity extends AbsActivity { } } - //js调用原生 - public class JsInteration { - @JavascriptInterface - public void onBack() { - finish(); - } - - @JavascriptInterface - public void modifyMydata() { - indexInto = 1; - RouteUtil.forwardEditProfileActivity(); - } - - @JavascriptInterface - public void reportUser(String touid) { - RouteUtil.forwardLiveReportActivity(touid); - } - - @JavascriptInterface - public void gotoHomePage(String indexStr) { - Log.e("tgasss", "indexStr4" + indexStr); - - if (!"".equals(indexStr) && indexStr != null) { - int index = -1; - if ("0".equals(indexStr)) { - index = 0; - } else if ("1".equals(indexStr)) { - index = 1; - } else if ("2".equals(indexStr)) { - index = 2; - } else if ("3".equals(indexStr)) { - index = 3; - } - if (index != -1) { - finish(); - Constants.isShowPage = index; - } - } - } - - @JavascriptInterface - public void openWebView(String url) { - Constants.isTitle = false; - RouteUtil.forwardZhuangBanActivity(url); - } - - @JavascriptInterface - public void openWebViewTitle(String url) { - Constants.isTitle = true; - RouteUtil.forwardZhuangBanActivity(url); - } - - /** - * 新跳转 - * - * @param url 跳转的url - * @param title 有标题的展示标题 - */ - @JavascriptInterface - public void androidClickToNewH5PageView(String url, String title) { - url = CommonAppConfig.HOST + url; - Log.i("tag", url); - ARouter.getInstance().build(PATH_ZHUANGBANACTIVITY) - .withString("url",url) - .withString("title", title) - .withBoolean("isFull", false) - .navigation(); - - } - } private void openImageChooserActivity(ValueCallback valueCallback) { mValueCallback = valueCallback; @@ -371,11 +299,10 @@ public class WebViewActivity extends AbsActivity { if (Constants.isShowPage != -1) { finish(); } -// new Handler().postDelayed(new Runnable() { -// @Override -// public void run() { -// mWebView.reload(); -// } -// }, 100); + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) { + indexInto = event.getIndexInto(); } } diff --git a/video/src/main/java/com/yunbao/video/bean/MusicBean.java b/common/src/main/java/com/yunbao/common/bean/MusicBean.java similarity index 99% rename from video/src/main/java/com/yunbao/video/bean/MusicBean.java rename to common/src/main/java/com/yunbao/common/bean/MusicBean.java index 9b25293ae..4102e9d90 100644 --- a/video/src/main/java/com/yunbao/video/bean/MusicBean.java +++ b/common/src/main/java/com/yunbao/common/bean/MusicBean.java @@ -1,4 +1,4 @@ -package com.yunbao.video.bean; +package com.yunbao.common.bean; import android.os.Parcel; import android.os.Parcelable; diff --git a/live/src/main/java/com/yunbao/live/bean/ReportCommunityBean.java b/common/src/main/java/com/yunbao/common/bean/ReportCommunityBean.java similarity index 95% rename from live/src/main/java/com/yunbao/live/bean/ReportCommunityBean.java rename to common/src/main/java/com/yunbao/common/bean/ReportCommunityBean.java index ad6ceaf3e..3d4f3e3e1 100644 --- a/live/src/main/java/com/yunbao/live/bean/ReportCommunityBean.java +++ b/common/src/main/java/com/yunbao/common/bean/ReportCommunityBean.java @@ -1,4 +1,4 @@ -package com.yunbao.live.bean; +package com.yunbao.common.bean; public class ReportCommunityBean { String dynamic_id; diff --git a/video/src/main/java/com/yunbao/video/bean/VideoBean.java b/common/src/main/java/com/yunbao/common/bean/VideoBean.java similarity index 99% rename from video/src/main/java/com/yunbao/video/bean/VideoBean.java rename to common/src/main/java/com/yunbao/common/bean/VideoBean.java index d2e8e9b20..f33948198 100644 --- a/video/src/main/java/com/yunbao/video/bean/VideoBean.java +++ b/common/src/main/java/com/yunbao/common/bean/VideoBean.java @@ -1,10 +1,9 @@ -package com.yunbao.video.bean; +package com.yunbao.common.bean; import android.os.Parcel; import android.os.Parcelable; import com.alibaba.fastjson.annotation.JSONField; -import com.yunbao.common.bean.UserBean; /** * Created by cxf on 2017/10/25. diff --git a/common/src/main/java/com/yunbao/common/event/JavascriptInterfaceEvent.java b/common/src/main/java/com/yunbao/common/event/JavascriptInterfaceEvent.java new file mode 100644 index 000000000..c60cee8f3 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/event/JavascriptInterfaceEvent.java @@ -0,0 +1,150 @@ +package com.yunbao.common.event; + +import com.yunbao.common.bean.BaseModel; +import com.yunbao.common.bean.VideoBean; + +import java.util.ArrayList; +import java.util.List; + +public class JavascriptInterfaceEvent extends BaseModel { + private String method = ""; + private String svg = ""; + private String postsId = ""; + private String isClose; + private List videoBeanList = new ArrayList<>(); + private int position; + private String liveId; + private String userId; + private int indexInto; + private String productId; + private String orderNumber; + private String moneyUsd; + private boolean isUpdataUser; + private String data; + + public String getUserId() { + return userId; + } + + public JavascriptInterfaceEvent setUserId(String userId) { + this.userId = userId; + return this; + } + + public String getData() { + return data; + } + + public JavascriptInterfaceEvent setData(String data) { + this.data = data; + return this; + } + + public boolean isUpdataUser() { + return isUpdataUser; + } + + public JavascriptInterfaceEvent setUpdataUser(boolean updataUser) { + isUpdataUser = updataUser; + return this; + } + + public String getProductId() { + return productId; + } + + public JavascriptInterfaceEvent setProductId(String productId) { + this.productId = productId; + return this; + } + + public String getOrderNumber() { + return orderNumber; + } + + public JavascriptInterfaceEvent setOrderNumber(String orderNumber) { + this.orderNumber = orderNumber; + return this; + } + + public String getMoneyUsd() { + return moneyUsd; + } + + public JavascriptInterfaceEvent setMoneyUsd(String moneyUsd) { + this.moneyUsd = moneyUsd; + return this; + } + + public int getIndexInto() { + return indexInto; + } + + public JavascriptInterfaceEvent setIndexInto(int indexInto) { + this.indexInto = indexInto; + return this; + } + + public String getLiveId() { + return liveId; + } + + public JavascriptInterfaceEvent setLiveId(String liveId) { + this.liveId = liveId; + return this; + } + + public List getVideoBeanList() { + return videoBeanList; + } + + public JavascriptInterfaceEvent setVideoBeanList(List videoBeanList) { + this.videoBeanList = videoBeanList; + return this; + } + + public int getPosition() { + return position; + } + + public JavascriptInterfaceEvent setPosition(int position) { + this.position = position; + return this; + } + + public String getIsClose() { + return isClose; + } + + public JavascriptInterfaceEvent setIsClose(String isClose) { + this.isClose = isClose; + return this; + } + + public String getPostsId() { + return postsId; + } + + public JavascriptInterfaceEvent setPostsId(String postsId) { + this.postsId = postsId; + return this; + } + + public String getSvg() { + return svg; + } + + public JavascriptInterfaceEvent setSvg(String svg) { + this.svg = svg; + return this; + } + + public String getMethod() { + return method; + } + + public JavascriptInterfaceEvent setMethod(String method) { + this.method = method; + return this; + } +} diff --git a/main/src/main/java/com/yunbao/main/event/MainHomeCommunityToChatEvent.java b/common/src/main/java/com/yunbao/common/event/MainHomeCommunityToChatEvent.java similarity index 91% rename from main/src/main/java/com/yunbao/main/event/MainHomeCommunityToChatEvent.java rename to common/src/main/java/com/yunbao/common/event/MainHomeCommunityToChatEvent.java index cf43b1f16..0d74cacb8 100644 --- a/main/src/main/java/com/yunbao/main/event/MainHomeCommunityToChatEvent.java +++ b/common/src/main/java/com/yunbao/common/event/MainHomeCommunityToChatEvent.java @@ -1,4 +1,4 @@ -package com.yunbao.main.event; +package com.yunbao.common.event; import com.yunbao.common.bean.BaseModel; diff --git a/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java b/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java new file mode 100644 index 000000000..c0414a708 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java @@ -0,0 +1,381 @@ +package com.yunbao.common.utils; + +import static com.yunbao.common.CommonAppConfig.isGetNewWrap; +import static com.yunbao.common.utils.RouteUtil.PATH_COIN; + +import android.app.Activity; +import android.webkit.JavascriptInterface; +import android.webkit.WebView; + +import com.alibaba.android.arouter.launcher.ARouter; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.yunbao.common.CommonAppConfig; +import com.yunbao.common.Constants; +import com.yunbao.common.bean.IMLoginModel; +import com.yunbao.common.bean.JsWishBean; +import com.yunbao.common.bean.ReportCommunityBean; +import com.yunbao.common.bean.UserBean; +import com.yunbao.common.bean.VideoBean; +import com.yunbao.common.bean.VideoListBean; +import com.yunbao.common.event.JavascriptInterfaceEvent; +import com.yunbao.common.event.MainHomeCommunityToChatEvent; +import com.yunbao.common.manager.IMLoginManager; + +import org.greenrobot.eventbus.EventBus; + +import java.util.ArrayList; +import java.util.List; + +//网页调用Android工具类 +public class JavascriptInterfaceUtils { + private Activity mContext; + private WebView mWebView; + //判断是页面关闭还是网页回退 + private boolean pageClose = false; + //同名activity跳转问题 + private boolean LiveZhuangBana = true; + + public JavascriptInterfaceUtils setPageClose(boolean pageClose) { + this.pageClose = pageClose; + return this; + } + + public JavascriptInterfaceUtils setLiveZhuangBana(boolean liveZhuangBana) { + LiveZhuangBana = liveZhuangBana; + return this; + } + + public JavascriptInterfaceUtils(Activity mContext, WebView mWebView) { + this.mContext = mContext; + this.mWebView = mWebView; + } + + + @JavascriptInterface + public void androidOpeningNoble(String svg) { + Bus.get().post(new JavascriptInterfaceEvent() + .setMethod("androidOpeningNoble") + .setSvg(svg)); + } + + @JavascriptInterface + public void androidGoBack() { + if (pageClose) { + mContext.finish(); + } else { + mContext.runOnUiThread(() -> mWebView.goBack()); + } + + } + + @JavascriptInterface + public void AndroidAdjustConsume() { + Bus.get().post(new JavascriptInterfaceEvent() + .setMethod("AndroidAdjustConsume")); + } + + @JavascriptInterface + public void androidGoToRe() { + ARouter.getInstance().build(PATH_COIN).withInt("p", 1).navigation(); + } + + @JavascriptInterface + public void onBack() { + mContext.finish(); + } + + @JavascriptInterface + public void androidClickToNewH5PageView(String url) { + url = CommonAppConfig.HOST + url; + url += "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + + CommonAppConfig.getInstance().getToken(); + if (LiveZhuangBana) { + RouteUtil.forwardLiveZhuangBanActivity(url, false); + } else { + RouteUtil.forwardZhuangBanActivity(url, false); + } + } + + /** + * 新跳转 + * + * @param url 跳转的url + * @param title 有标题的展示标题 + */ + @JavascriptInterface + public void androidClickToNewH5PageView(String url, String title) { + url = CommonAppConfig.HOST + url; + url += "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + + CommonAppConfig.getInstance().getToken(); + if (LiveZhuangBana) { + RouteUtil.forwardLiveZhuangBanActivity(url, title); + } else { + RouteUtil.forwardZhuangBanActivity(url, title); + } + } + + /** + * 设置超皇字体颜色 + * + * @param startColor 渐变色 + * @param endColor 渐变色 + * @param contentColor 内容颜色 + */ + @JavascriptInterface + public void androidSetColor(String startColor, String endColor, String contentColor) { + IMLoginModel model = IMLoginManager.get(mContext).getUserInfo(); + model.setStartColor("#" + startColor) + .setEndColor("#" + endColor) + .setContentColor("#" + contentColor); + IMLoginManager.get(mContext).upDataUserInfo(model); + } + + @JavascriptInterface + public void androidCommunityGift(String postsId) { + Bus.get().post(new JavascriptInterfaceEvent() + .setMethod("androidCommunityGift") + .setPostsId(postsId)); + } + + @JavascriptInterface + public void reportCommunity(String info) { + ReportCommunityBean reportCommunityBean = JSON.parseObject(info, ReportCommunityBean.class); + RouteUtil.forwardLiveReportActivity(reportCommunityBean.getDynamic_id(), 1, reportCommunityBean.getCommunity_type(), reportCommunityBean.getComment_id()); + } + + @JavascriptInterface + public void reportUser(String touid) { + RouteUtil.forwardLiveReportActivity(touid); + } + + @JavascriptInterface + public void isCloseNavigation(String isClose) { + Bus.get().post(new JavascriptInterfaceEvent() + .setMethod("isCloseNavigation") + .setIsClose(isClose)); + } + + @JavascriptInterface + public void androidPlayVideo(String list) { + list.toString(); + if (!"undefined".equals(list)) { + JSONObject obj = JSON.parseObject(list); + int position = obj.getIntValue("video_index"); + String videoListString = obj.getString("video_list"); + List videoList = JSON.parseArray(videoListString, VideoListBean.class); + List videoBeanList = new ArrayList<>(); + for (VideoListBean videoListBean : videoList) { + JSONObject obj2 = JSON.parseObject(videoListBean.getContent()); + String msg = obj2.getString("msg"); + VideoBean videoBean = new VideoBean(); + videoBean.setHref(videoListBean.getVideo()); + videoBean.setCity(""); + videoBean.setCommentNum(videoListBean.getComment_num()); + videoBean.setAddtime(videoListBean.getCreate_time()); + videoBean.setDatetime(""); + videoBean.setDistance(""); + videoBean.setId(videoListBean.getId()); + videoBean.setLat(""); + videoBean.setLike(0); + videoBean.setTitle(msg); + if ("2".endsWith(videoListBean.getIs_attention()) || "0".endsWith(videoListBean.getIs_attention())) { + videoBean.setAttent(2); + } else if ("1".endsWith(videoListBean.getIs_attention())) { + videoBean.setAttent(1); + } else { + videoBean.setAttent(-1); + } + UserBean userBean = new UserBean(); + userBean.setAvatar(videoListBean.getUser_avatar()); + userBean.setUserNiceName(videoListBean.getUser_name()); + userBean.setId(videoListBean.getUser_id()); + videoBean.setUserBean(userBean); + + videoBean.setUid(videoListBean.getUser_id()); + videoBeanList.add(videoBean); + } + Bus.get().post(new JavascriptInterfaceEvent() + .setMethod("androidPlayVideo") + .setVideoBeanList(videoBeanList) + .setPosition(position)); + } + } + + @JavascriptInterface + public void androidClickSayHiBack(String uid, String name, String img) { + Bus.get().post(new JavascriptInterfaceEvent() + .setMethod("androidClickSayHiBack")); + EventBus.getDefault().post(new MainHomeCommunityToChatEvent().setTargetId(uid)); + } + + @JavascriptInterface + public void androidMethodLookToLive(String liveId) { + Bus.get().post(new JavascriptInterfaceEvent() + .setMethod("androidMethodLookToLive") + .setLiveId(liveId)); + } + + @JavascriptInterface + public void androidClickFansList(String uid) { + RouteUtil.forwardFansActivity(uid); + } + + @JavascriptInterface + public String androidMethod(String data) { + Bus.get().post(new JavascriptInterfaceEvent().setMethod("androidMethod").setData(data)); + + + return ""; + } + + @JavascriptInterface + public String androidGetNewWrap(String data) { + if (data != null && !data.isEmpty()) { + isGetNewWrap = true; + } + return ""; + } + + @JavascriptInterface + public void androidMethodBack() { + mContext.finish(); + } + + + @JavascriptInterface + public void modifyMydata() { + Bus.get().post(new JavascriptInterfaceEvent().setMethod("modifyMydata").setIndexInto(1)); + RouteUtil.forwardEditProfileActivity(); + } + + @JavascriptInterface + public void gotoHomePage(String indexStr) { + if (!"".equals(indexStr) && indexStr != null) { + int index = -1; + if ("0".equals(indexStr)) { + index = 0; + } else if ("1".equals(indexStr)) { + index = 1; + } else if ("2".equals(indexStr)) { + index = 2; + } else if ("3".equals(indexStr)) { + index = 3; + } + if (index != -1) { + mContext.finish(); + Constants.isShowPage = index; + } + } + } + + @JavascriptInterface + public void openWebView(String url) { + Constants.isTitle = false; + RouteUtil.forwardZhuangBanActivity(url); + } + + @JavascriptInterface + public void openWebViewTitle(String url) { + Constants.isTitle = true; + RouteUtil.forwardZhuangBanActivity(url); + } + + @JavascriptInterface + public void androidNewGoToGooglePay(String ProductId, String OrderNumber, String MoneyUsd) { + Bus.get().post(new JavascriptInterfaceEvent() + .setMethod("androidNewGoToGooglePay") + .setProductId(ProductId) + .setMoneyUsd(MoneyUsd) + .setOrderNumber(OrderNumber)); + } + + //拉黑不感兴趣 + @JavascriptInterface + public void androidLoseInterest() { + EventBus.getDefault().post("blacklist"); + } + + @JavascriptInterface + public void AndroidFellow() { + Bus.get().post(new JavascriptInterfaceEvent() + .setMethod("AndroidFellow")); + } + + //跳转修改昵称 + @JavascriptInterface + public void openUpdataName() { + Constants.myIntoIndex = 2; + Bus.get().post(new JavascriptInterfaceEvent() + .setMethod("openUpdataName") + .setUpdataUser(true)); + RouteUtil.forwardMyWebViewActivity2(CommonAppConfig.HOST + "/h5/table/Modify-information.html" + "?token=" + CommonAppConfig.getInstance().getToken() + "&uid=" + CommonAppConfig.getInstance().getUid()); + } + + //跳转修改头像 + @JavascriptInterface + public void openUpdataAvater() { + Bus.get().post(new JavascriptInterfaceEvent() + .setMethod("openUpdataAvater")); + + } + + //跳转修改签名 + @JavascriptInterface + public void openUpdataAutograph() { + Bus.get().post(new JavascriptInterfaceEvent() + .setMethod("openUpdataAutograph")); + + } + + @JavascriptInterface + public void androidGoTopUp() { + Bus.get().post(new JavascriptInterfaceEvent() + .setMethod("androidGoTopUp")); + //我们的 + ARouter.getInstance().build(PATH_COIN).withInt("p", 0).withString("tag", "&first_page=1").navigation(); + + } + + @JavascriptInterface + public String androidMethodLookLive(String uId, String liveId, String isLiving) { + //跳转个人主页 + RouteUtil.forwardUserHome(mContext, liveId, 0); + + return ""; + } + + @JavascriptInterface + public void AndroidClose() { + Bus.get().post(new JavascriptInterfaceEvent() + .setMethod("AndroidClose")); + + } + + @JavascriptInterface + public void sendFansCard(String id) { + Bus.get().post(new JavascriptInterfaceEvent() + .setMethod("sendFansCard") + .setLiveId(id)); + + } + + @JavascriptInterface + public String androidMethodClickUser(String userId, String liveId) { + + Bus.get().post(new JavascriptInterfaceEvent() + .setMethod("androidMethodClickUser") + .setLiveId(liveId) + .setUserId(userId)); + + return ""; + } + + @JavascriptInterface + public void onTrickerySendGift(String id) { + Bus.get().post(new JavascriptInterfaceEvent() + .setMethod("onTrickerySendGift") + .setUserId(id)); + + } +} diff --git a/common/src/main/java/com/yunbao/common/utils/RouteUtil.java b/common/src/main/java/com/yunbao/common/utils/RouteUtil.java index 0cb37ef5b..738227174 100644 --- a/common/src/main/java/com/yunbao/common/utils/RouteUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/RouteUtil.java @@ -24,11 +24,26 @@ public class RouteUtil { public static final String PATH_LIVEREPORT = "/live/LiveReportActivity"; public static final String PATH_MYWEBVIEWACTIVTITY = "/main/MyWebViewActivity"; public static final String PATH_ZHUANGBANACTIVITY = "/main/ZhuangBanActivity"; + public static final String PATH_LiveZHUANGBANACTIVITY = "/live/ZhuangBanActivity"; public static final String PATH_FACEBOOKACTIVITY = "/baidu/FacebookLoginActivity"; public static final String PATH_MAIN = "/main/MainActivity"; public static final String PATH_ENTRY = "/main/EntryActivity"; public static final String PATH_LIVE_AUDIENCE = "/live/LiveAudienceActivity"; public static final String PATH_SETTING = "/main/SettingActivity"; + public static final String PATH_FANSACTIVITY = "/main/FansActivity"; + public static final String PATH_MYWEBVIEWACTIVTITY2 = "/main/MyWebViewActivity2"; + + public static void forwardFansActivity(String uid) { + ARouter.getInstance().build(PATH_FANSACTIVITY) + .withString(Constants.TO_UID, uid) + .navigation(); + } + + public static void forwardMyWebViewActivity2(String url) { + ARouter.getInstance().build(PATH_MYWEBVIEWACTIVTITY2) + .withString(Constants.URL, url) + .navigation(); + } /** * 启动页 @@ -98,6 +113,47 @@ public class RouteUtil { .navigation(); } + /** + * 跳转到装扮 + */ + public static void forwardZhuangBanActivity(String url, boolean isFull) { + ARouter.getInstance().build(PATH_ZHUANGBANACTIVITY) + .withString("title", "") + .navigation(); + } + + /** + * 跳转到装扮 + */ + public static void forwardLiveZhuangBanActivity(String url, boolean isFull) { + ARouter.getInstance().build(PATH_LiveZHUANGBANACTIVITY) + .withString("url", url) + .withBoolean("isFull", isFull) + .navigation(); + } + + /** + * 跳转到装扮 + */ + public static void forwardLiveZhuangBanActivity(String url, String title) { + ARouter.getInstance().build(PATH_LiveZHUANGBANACTIVITY) + .withString("url", url) + .withString("title", title) + .withBoolean("isFull", false) + .navigation(); + } + + /** + * 跳转到装扮 + */ + public static void forwardZhuangBanActivity(String url, String title) { + ARouter.getInstance().build(PATH_ZHUANGBANACTIVITY) + .withString("url", url) + .withString("title", title) + .withBoolean("isFull", false) + .navigation(); + } + /** * 跳转到充值页面 */ @@ -114,6 +170,7 @@ public class RouteUtil { ARouter.getInstance().build(PATH_EDITPROFILE) .navigation(); } + /** * 修改个人资料 */ @@ -121,6 +178,7 @@ public class RouteUtil { ARouter.getInstance().build(PATH_SETTING) .navigation(); } + /** * 打开直播页面 */ @@ -142,6 +200,15 @@ public class RouteUtil { .navigation(); } + public static void forwardLiveReportActivity(String dynamicId, int intoIndex, String communityType, String commentId) { + ARouter.getInstance().build(PATH_LIVEREPORT) + .withString(Constants.TO_UID, dynamicId) + .withInt(Constants.INTOINDEX, intoIndex) + .withString("community_type", communityType) + .withString("comment_id", commentId) + .navigation(); + } + /** * 进入facebook登录 */ diff --git a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java index 80ca224cc..a8fd702d6 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java @@ -1228,7 +1228,7 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL */ public void openFansWindow() { - LiveFansFragment fragment = new LiveFansFragment(); + LiveFansFragment fragment = new LiveFansFragment(mContext); Bundle bundle = new Bundle(); //粉絲團粉絲團 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 2aa5cb62d..696fd758b 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -751,6 +751,7 @@ public class LiveAudienceActivity extends LiveActivity { .setType(LiveAudienceEvent.LiveAudienceType.FAN_CLUB)); } } + @Override public void showerHtml(String htmlUrl, boolean screen) { if (!screen) { @@ -895,7 +896,7 @@ public class LiveAudienceActivity extends LiveActivity { break; case FAN_CLUB: - LiveFansFragment liveFansFragment = new LiveFansFragment(); + LiveFansFragment liveFansFragment = new LiveFansFragment(mContext); //粉絲團粉絲團 //不是粉絲 if (LiveAudienceActivity.is_fans != null && LiveAudienceActivity.is_fans.equals("2")) { diff --git a/live/src/main/java/com/yunbao/live/activity/WebViewActivityMedal.java b/live/src/main/java/com/yunbao/live/activity/WebViewActivityMedal.java index df4dffae0..802dc0332 100644 --- a/live/src/main/java/com/yunbao/live/activity/WebViewActivityMedal.java +++ b/live/src/main/java/com/yunbao/live/activity/WebViewActivityMedal.java @@ -8,11 +8,9 @@ import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.provider.MediaStore; -import androidx.annotation.RequiresApi; import android.text.TextUtils; import android.view.View; import android.view.ViewGroup; -import android.webkit.JavascriptInterface; import android.webkit.ValueCallback; import android.webkit.WebChromeClient; import android.webkit.WebSettings; @@ -22,23 +20,30 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ProgressBar; +import androidx.annotation.RequiresApi; + import com.alibaba.fastjson.JSON; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; import com.yunbao.common.HtmlConfig; import com.yunbao.common.R; import com.yunbao.common.activity.AbsActivity; +import com.yunbao.common.bean.LiveBean; +import com.yunbao.common.event.JavascriptInterfaceEvent; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.utils.DpUtil; +import com.yunbao.common.utils.JavascriptInterfaceUtils; import com.yunbao.common.utils.L; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; -import com.yunbao.common.bean.LiveBean; import com.yunbao.live.dialog.LiveUserDialogFragment; import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.presenter.LiveRoomCheckLivePresenter; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + /** * Created by cxf on 2018/9/25. * 我的徽章 h5页面 @@ -133,7 +138,7 @@ public class WebViewActivityMedal extends AbsActivity { } }); - mWebView.addJavascriptInterface(new JsInteration(), "androidObject"); + mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, mWebView), "androidObject"); mWebView.getSettings().setJavaScriptEnabled(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); @@ -150,23 +155,6 @@ public class WebViewActivityMedal extends AbsActivity { }); } - //js调用原生 - public class JsInteration { - @JavascriptInterface - public String androidMethodLookLive(String uId, String liveId, String isLiving) { - //跳转个人主页 - RouteUtil.forwardUserHome(mContext, liveId, 0); - - return ""; - } - - @JavascriptInterface - public void androidMethodLookToLive(String liveId) { - //看直播 - gotoLive(liveId); - - } - } private LiveRoomCheckLivePresenter mCheckLivePresenter; @@ -192,7 +180,7 @@ public class WebViewActivityMedal extends AbsActivity { } mCheckLivePresenter.checkLive(liveBean); } else { - RouteUtil.forwardUserHome(mContext, live_id,0); + RouteUtil.forwardUserHome(mContext, live_id, 0); } } }); @@ -332,4 +320,13 @@ public class WebViewActivityMedal extends AbsActivity { ToastUtil.show(getString(R.string.copy_success)); } -} + @Subscribe(threadMode = ThreadMode.MAIN) + public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) { + if (!TextUtils.isEmpty(event.getMethod())) { + if (TextUtils.equals(event.getMethod(), "androidMethodLookToLive")) { + //看直播 + gotoLive(event.getLiveId()); + } + } + } +} \ No newline at end of file diff --git a/live/src/main/java/com/yunbao/live/activity/ZhuangBanActivity.java b/live/src/main/java/com/yunbao/live/activity/ZhuangBanActivity.java index 98de19317..2eaab3ec1 100644 --- a/live/src/main/java/com/yunbao/live/activity/ZhuangBanActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/ZhuangBanActivity.java @@ -2,7 +2,6 @@ package com.yunbao.live.activity; import static com.yunbao.common.CommonAppContext.logger; import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics; -import static com.yunbao.common.utils.RouteUtil.PATH_COIN; import android.content.ClipData; import android.content.ClipboardManager; @@ -15,7 +14,6 @@ import android.text.TextUtils; import android.util.Log; import android.view.View; import android.view.ViewGroup; -import android.webkit.JavascriptInterface; import android.webkit.ValueCallback; import android.webkit.WebChromeClient; import android.webkit.WebSettings; @@ -31,7 +29,7 @@ import androidx.annotation.RequiresApi; import com.adjust.sdk.Adjust; import com.adjust.sdk.AdjustEvent; -import com.alibaba.android.arouter.launcher.ARouter; +import com.alibaba.android.arouter.facade.annotation.Route; import com.opensource.svgaplayer.SVGACallback; import com.opensource.svgaplayer.SVGADrawable; import com.opensource.svgaplayer.SVGAImageView; @@ -40,18 +38,24 @@ import com.opensource.svgaplayer.SVGAVideoEntity; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; import com.yunbao.common.activity.AbsActivity; -import com.yunbao.common.bean.IMLoginModel; -import com.yunbao.common.manager.IMLoginManager; +import com.yunbao.common.event.JavascriptInterfaceEvent; +import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DpUtil; +import com.yunbao.common.utils.JavascriptInterfaceUtils; import com.yunbao.common.utils.L; +import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.live.R; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + import java.net.MalformedURLException; import java.net.URL; +@Route(path = RouteUtil.PATH_LiveZHUANGBANACTIVITY) public class ZhuangBanActivity extends AbsActivity { private ProgressBar mProgressBar; @@ -72,6 +76,7 @@ public class ZhuangBanActivity extends AbsActivity { @Override protected void main() { + Bus.getOn(this); String url = getIntent().getStringExtra(Constants.URL); String titleString = getIntent().getStringExtra("title"); L.e("H5---2s>" + url); @@ -172,7 +177,9 @@ public class ZhuangBanActivity extends AbsActivity { } }); - mWebView.addJavascriptInterface(new JsInteration(), "androidObject"); + mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, mWebView) + .setPageClose(true) + .setLiveZhuangBana(true), "androidObject"); mWebView.getSettings().setJavaScriptEnabled(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); @@ -180,141 +187,6 @@ public class ZhuangBanActivity extends AbsActivity { mWebView.loadUrl(url); } - //js调用原生 - public class JsInteration { - @JavascriptInterface - public void androidOpeningNoble(String svg) { - Log.e("Zhu", "svg" + svg); - try { - new SVGAParser(mContext).parse(new URL(svg), new SVGAParser.ParseCompletion() { - @Override - public void onComplete(SVGAVideoEntity videoItem) { - svga.setVisibility(View.VISIBLE); - SVGADrawable drawable = new SVGADrawable(videoItem); - svga.setImageDrawable(drawable); - svga.setLoops(1); - SVGAViewUtils.playEndClear(svga); - } - - @Override - public void onError() { - } - }); - svga.setCallback(new SVGACallback() { - @Override - public void onPause() { - - } - - @Override - public void onFinished() { - svga.clear(); - svga.setVisibility(View.GONE); - } - - @Override - public void onRepeat() { - - } - - @Override - public void onStep(int i, double v) { - - } - }); - } catch (MalformedURLException e) { - e.printStackTrace(); - } - } - - @JavascriptInterface - public void androidGoBack() { - ZhuangBanActivity.this.finish(); - } - - @JavascriptInterface - public void AndroidAdjustConsume() { - mFirebaseAnalytics.logEvent("FS_event_interaction", null); - logger.logEvent("FB_event_interaction", null); - AdjustEvent adjustEvent1 = new AdjustEvent("rq2c5n"); - Adjust.trackEvent(adjustEvent1); - } - - @JavascriptInterface - public void androidGoToRe() { - ARouter.getInstance().build(PATH_COIN).withInt("p", 1).navigation(); - } - - @JavascriptInterface - public void onBack() { - finish(); - } - - @JavascriptInterface - public void androidClickToNewH5PageView(String url) { - url = CommonAppConfig.HOST + url; - url += "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" - + CommonAppConfig.getInstance().getToken(); - Log.i("tag", url); - Intent intent = new Intent(mContext, ZhuangBanActivity.class); - intent.putExtra("url", url); - intent.putExtra("isFull", false); - mContext.startActivity(intent); - - } - - /** - * 新跳转 - * - * @param url 跳转的url - * @param title 有标题的展示标题 - */ - @JavascriptInterface - public void androidClickToNewH5PageView(String url, String title) { - url = CommonAppConfig.HOST + url; - url += "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" - + CommonAppConfig.getInstance().getToken(); - Log.i("tag", url); - Intent intent = new Intent(mContext, ZhuangBanActivity.class); - intent.putExtra("url", url); - intent.putExtra("title", title); - mContext.startActivity(intent); - - } - - /** - * 设置超皇字体颜色 - * - * @param startColor 渐变色 - * @param endColor 渐变色 - * @param contentColor 内容颜色 - */ - @JavascriptInterface - public void androidSetColor(String startColor, String endColor, String contentColor) { - IMLoginModel model = IMLoginManager.get(mContext).getUserInfo(); - model.setStartColor("#"+startColor) - .setEndColor("#"+endColor) - .setContentColor("#"+contentColor); - IMLoginManager.get(mContext).upDataUserInfo(model); - } - - } - -// //js调用原生 -// public class JsInteration { -// @JavascriptInterface -// public String androidMethodLookLive(String liveId,String isLiving) { -// //进入直播间 -// if (!TextUtils.isEmpty(isLiving) ) { -// if (isLiving.equals("1")){ -// //跳转直播间 -// }else { -// //打开主播个人主页 -// } -// } -// return ""; -// } -// } private void openImageChooserActivity(ValueCallback valueCallback) { mValueCallback = valueCallback; @@ -418,6 +290,7 @@ public class ZhuangBanActivity extends AbsActivity { @Override protected void onDestroy() { + Bus.getOff(this); if (mWebView != null) { ViewGroup parent = (ViewGroup) mWebView.getParent(); if (parent != null) { @@ -438,4 +311,54 @@ public class ZhuangBanActivity extends AbsActivity { ToastUtil.show(getString(R.string.copy_success)); } + @Subscribe(threadMode = ThreadMode.MAIN) + public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) { + if (!TextUtils.isEmpty(event.getMethod())) { + if (TextUtils.equals(event.getMethod(), "androidOpeningNoble")) { + try { + new SVGAParser(mContext).parse(new URL(event.getSvg()), new SVGAParser.ParseCompletion() { + @Override + public void onComplete(SVGAVideoEntity videoItem) { + svga.setVisibility(View.VISIBLE); + SVGADrawable drawable = new SVGADrawable(videoItem); + svga.setImageDrawable(drawable); + svga.setLoops(1); + SVGAViewUtils.playEndClear(svga); + } + + @Override + public void onError() { + } + }); + svga.setCallback(new SVGACallback() { + @Override + public void onPause() { + } + + @Override + public void onFinished() { + svga.clear(); + svga.setVisibility(View.GONE); + } + + @Override + public void onRepeat() { + } + + @Override + public void onStep(int i, double v) { + } + }); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + } else if (TextUtils.equals(event.getMethod(), "AndroidAdjustConsume")) { + mFirebaseAnalytics.logEvent("FS_event_interaction", null); + logger.logEvent("FB_event_interaction", null); + AdjustEvent adjustEvent1 = new AdjustEvent("rq2c5n"); + Adjust.trackEvent(adjustEvent1); + } + } + + } } diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveFansFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveFansFragment.java index 8be0c2b97..f9859630f 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveFansFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveFansFragment.java @@ -1,30 +1,43 @@ package com.yunbao.live.dialog; +import android.app.Activity; import android.os.Build; import android.os.Bundle; +import android.text.TextUtils; import android.util.Log; import android.view.Gravity; import android.view.View; import android.view.Window; import android.view.WindowManager; -import android.webkit.JavascriptInterface; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; +import androidx.annotation.Nullable; + import com.yunbao.common.Constants; import com.yunbao.common.dialog.AbsDialogFragment; +import com.yunbao.common.event.JavascriptInterfaceEvent; +import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DpUtil; +import com.yunbao.common.utils.JavascriptInterfaceUtils; import com.yunbao.common.utils.L; import com.yunbao.common.utils.ToastUtil; import com.yunbao.live.R; -import com.yunbao.live.activity.LiveActivity; import com.yunbao.live.activity.LiveAudienceActivity; import com.yunbao.live.views.LiveRoomViewHolder; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + public class LiveFansFragment extends AbsDialogFragment { private WebView mWebView; + private Activity mContext; + + public LiveFansFragment(Activity mContext) { + this.mContext = mContext; + } @Override protected int getLayoutId() { @@ -51,6 +64,18 @@ public class LiveFansFragment extends AbsDialogFragment { window.setAttributes(params); } + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + Bus.getOn(this); + } + + @Override + public void onDetach() { + super.onDetach(); + Bus.getOff(this); + } + @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); @@ -59,7 +84,7 @@ public class LiveFansFragment extends AbsDialogFragment { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { L.e("H5-------->" + url); - view.loadUrl(url); + view.loadUrl(url); return false; } @@ -70,8 +95,7 @@ public class LiveFansFragment extends AbsDialogFragment { }); mWebView.getSettings().setJavaScriptEnabled(true); // 是否开启JS支持 -// mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口 - mWebView.addJavascriptInterface(new JsInteration(),"androidObject"); + mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, mWebView).setPageClose(false), "androidObject"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); } @@ -79,56 +103,35 @@ public class LiveFansFragment extends AbsDialogFragment { if (bundle == null) { return; } - Log.e("tag",bundle.getString(Constants.URL)); + Log.e("tag", bundle.getString(Constants.URL)); mWebView.loadUrl(bundle.getString(Constants.URL)); } - //js调用原生 - public class JsInteration { - @JavascriptInterface - public void androidGoBack() { - ((LiveActivity) mContext).runOnUiThread(new Runnable() { - @Override - public void run() { - mWebView.goBack(); - } - }); - mWebView.goBack(); - } - @JavascriptInterface - public void AndroidClose() { - ((LiveActivity) mContext).runOnUiThread(new Runnable() { - @Override - public void run() { - LiveAudienceActivity.is_fans = "2"; - int num = LiveAudienceActivity.fansNum-1; - LiveRoomViewHolder.setFansNum(num); - ToastUtil.show("退出成功"); - dismiss(); - } - }); - - } - @JavascriptInterface - public void sendFansCard(String id) { - ((LiveActivity) mContext).runOnUiThread(new Runnable() { - @Override - public void run() { - if(LiveRoomViewHolder.mBtnFollow.getVisibility() == View.VISIBLE) { - LiveRoomViewHolder.follow(); - } - } - }); - - //点击 开通粉丝勋章,打开礼物列表送礼物 - ((LiveAudienceActivity) mContext).openGiftWindow(id,"0"); - dismiss(); - } - } @Override public void onDestroy() { super.onDestroy(); mContext = null; } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) { + if (!TextUtils.isEmpty(event.getMethod())) { + if (TextUtils.equals(event.getMethod(), "AndroidClose")) { + LiveAudienceActivity.is_fans = "2"; + int num = LiveAudienceActivity.fansNum - 1; + LiveRoomViewHolder.setFansNum(num); + ToastUtil.show("退出成功"); + dismiss(); + } else if (TextUtils.equals(event.getMethod(), "sendFansCard")) { + if (LiveRoomViewHolder.mBtnFollow.getVisibility() == View.VISIBLE) { + LiveRoomViewHolder.follow(); + } + //点击 开通粉丝勋章,打开礼物列表送礼物 + ((LiveAudienceActivity) mContext).openGiftWindow(event.getLiveId(), "0"); + dismiss(); + } + } + + } } diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveOneDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveOneDialogFragment.java index 76a8e5b9b..a7601e236 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveOneDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveOneDialogFragment.java @@ -1,26 +1,37 @@ package com.yunbao.live.dialog; +import android.app.Activity; import android.os.Build; import android.os.Bundle; +import android.text.TextUtils; import android.view.Gravity; import android.view.Window; import android.view.WindowManager; -import android.webkit.JavascriptInterface; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; -import com.alibaba.android.arouter.launcher.ARouter; +import androidx.annotation.Nullable; + import com.yunbao.common.dialog.AbsDialogFragment; +import com.yunbao.common.event.JavascriptInterfaceEvent; +import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DpUtil; +import com.yunbao.common.utils.JavascriptInterfaceUtils; import com.yunbao.common.utils.L; import com.yunbao.live.R; -import static com.yunbao.common.utils.RouteUtil.PATH_COIN; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; public class LiveOneDialogFragment extends AbsDialogFragment { private WebView mWebView; + private Activity mContext; + + public LiveOneDialogFragment(Activity mContext) { + this.mContext = mContext; + } @Override protected int getLayoutId() { @@ -48,12 +59,24 @@ public class LiveOneDialogFragment extends AbsDialogFragment { window.setAttributes(params); } + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + Bus.getOn(this); + + } + + @Override + public void onDetach() { + super.onDetach(); + Bus.getOff(this); + } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - mWebView = (WebView)findViewById(R.id.rlWebview); - mWebView.addJavascriptInterface(new JsInteration(),"androidObject"); + mWebView = (WebView) findViewById(R.id.rlWebview); + mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, mWebView), "androidObject"); mWebView.getSettings().setJavaScriptEnabled(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); @@ -71,7 +94,7 @@ public class LiveOneDialogFragment extends AbsDialogFragment { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { L.e("H5-------->" + url); - view.loadUrl(url); + view.loadUrl(url); return true; } @@ -83,19 +106,13 @@ public class LiveOneDialogFragment extends AbsDialogFragment { } - - - - //js调用原生 - public class JsInteration { - @JavascriptInterface - public void androidGoTopUp() { - - //我们的 - ARouter.getInstance().build(PATH_COIN).withInt("p",0).withString("tag","&first_page=1").navigation(); - - dismiss(); + @Subscribe(threadMode = ThreadMode.MAIN) + public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) { + if (!TextUtils.isEmpty(event.getMethod())) { + if (TextUtils.equals(event.getMethod(), "androidCommunityGift")) { + dismiss(); + } } - } + } } diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveTurnTableDialogFragment4Audience.java b/live/src/main/java/com/yunbao/live/dialog/LiveTurnTableDialogFragment4Audience.java index cc6e2937b..2e2945509 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveTurnTableDialogFragment4Audience.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveTurnTableDialogFragment4Audience.java @@ -11,8 +11,6 @@ import com.yunbao.common.CommonAppContext; import com.yunbao.common.Constants; import com.yunbao.common.HtmlConfig; import com.yunbao.common.bean.JsTurnTableBean; -import com.yunbao.common.bean.JsTurnTableBean2; -import com.yunbao.common.bean.JsWishBean; import com.yunbao.common.dialog.AbsDialogFragment; import com.yunbao.live.R; import com.yunbao.live.views.TurnTableWebViewHolder; @@ -29,10 +27,10 @@ import cn.qqtheme.framework.util.ScreenUtils; * 观众查看 转盘弹窗 */ -public class LiveTurnTableDialogFragment4Audience extends AbsDialogFragment { +public class LiveTurnTableDialogFragment4Audience extends AbsDialogFragment { protected TurnTableWebViewHolder mTurnTableViewHolder; - private String mLiveUid=""; + private String mLiveUid = ""; @Override protected int getLayoutId() { @@ -56,14 +54,13 @@ public class LiveTurnTableDialogFragment4Audience extends AbsDialogFragment { WindowManager.LayoutParams params = window.getAttributes(); params.width = WindowManager.LayoutParams.MATCH_PARENT; // params.height = DpUtil.dp2px(400); - params.height =(int)(ScreenUtils.heightPixels(CommonAppContext.sInstance)*0.8); + params.height = (int) (ScreenUtils.heightPixels(CommonAppContext.sInstance) * 0.8); params.gravity = Gravity.BOTTOM; window.setAttributes(params); } - @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); @@ -72,12 +69,12 @@ public class LiveTurnTableDialogFragment4Audience extends AbsDialogFragment { mLiveUid = bundle.getString(Constants.LIVE_UID); } EventBus.getDefault().register(this); - RelativeLayout rlWebview= (RelativeLayout) findViewById(R.id.rlWebview); + RelativeLayout rlWebview = (RelativeLayout) findViewById(R.id.rlWebview); if (mTurnTableViewHolder == null) { - String url=HtmlConfig.TURNTABLE_URL; + String url = HtmlConfig.TURNTABLE_URL; url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" - + CommonAppConfig.getInstance().getToken() + "&liveUid="+mLiveUid; - mTurnTableViewHolder = new TurnTableWebViewHolder(mContext, rlWebview, url); + + CommonAppConfig.getInstance().getToken() + "&liveUid=" + mLiveUid; + mTurnTableViewHolder = new TurnTableWebViewHolder(getActivity(), rlWebview, url); mTurnTableViewHolder.subscribeActivityLifeCycle(); mTurnTableViewHolder.addToParent(); } @@ -88,14 +85,12 @@ public class LiveTurnTableDialogFragment4Audience extends AbsDialogFragment { @Subscribe(threadMode = ThreadMode.MAIN) public void onGotoOnlineShop(JsTurnTableBean bean) { - if (bean!=null){ + if (bean != null) { dismiss(); } } - - @Override public void onDestroy() { super.onDestroy(); diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPresenter.java index 5675e9843..b6e427e10 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPresenter.java @@ -2,6 +2,7 @@ package com.yunbao.live.presenter; import android.Manifest; import android.annotation.SuppressLint; +import android.app.Activity; import android.app.Dialog; import android.content.Context; import android.graphics.drawable.ColorDrawable; @@ -252,7 +253,7 @@ public class LiveLinkMicPresenter implements View.OnClickListener { String url = CommonAppConfig.HOST + "/h5/activity/firstTopUp/index.html?&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken(); Bundle bundle = new Bundle(); bundle.putString("url", url); - LiveOneDialogFragment fragment = new LiveOneDialogFragment(); + LiveOneDialogFragment fragment = new LiveOneDialogFragment((Activity) mContext); fragment.setArguments(bundle); fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveOneDialogFragment"); } diff --git a/live/src/main/java/com/yunbao/live/views/TurnTableWebViewHolder.java b/live/src/main/java/com/yunbao/live/views/TurnTableWebViewHolder.java index b9cc8907e..a077b38af 100644 --- a/live/src/main/java/com/yunbao/live/views/TurnTableWebViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/TurnTableWebViewHolder.java @@ -1,13 +1,11 @@ package com.yunbao.live.views; -import android.content.Context; +import android.app.Activity; import android.graphics.Color; import android.os.Build; -import android.os.Bundle; import android.text.TextUtils; import android.view.View; import android.view.ViewGroup; -import android.webkit.JavascriptInterface; import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; @@ -15,22 +13,18 @@ import android.webkit.WebViewClient; import android.widget.LinearLayout; import android.widget.ProgressBar; -import com.yunbao.common.CommonAppConfig; -import com.yunbao.common.Constants; import com.yunbao.common.HtmlConfig; import com.yunbao.common.activity.WebViewActivity; import com.yunbao.common.bean.JsTurnTableBean; -import com.yunbao.common.bean.JsTurnTableBean2; -import com.yunbao.common.bean.JsWishBean; +import com.yunbao.common.event.JavascriptInterfaceEvent; +import com.yunbao.common.utils.Bus; +import com.yunbao.common.utils.JavascriptInterfaceUtils; import com.yunbao.common.utils.L; import com.yunbao.live.R; -import com.yunbao.live.activity.LiveActivity; -import com.yunbao.live.activity.LiveAudienceActivity; -import com.yunbao.live.dialog.LiveUserDialogFragment; import org.greenrobot.eventbus.EventBus; - -import static com.yunbao.common.CommonAppConfig.isGetNewWrap; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; /** * Created by cxf on 2018/10/15. @@ -42,9 +36,11 @@ public class TurnTableWebViewHolder extends AbsLivePageViewHolder implements Vie private ProgressBar mProgressBar; private WebView mWebView; private String mUrl; + private Activity mContext; - public TurnTableWebViewHolder(Context context, ViewGroup parentView, String url) { + public TurnTableWebViewHolder(Activity context, ViewGroup parentView, String url) { super(context, parentView, url); + mContext = context; } @Override @@ -60,6 +56,7 @@ public class TurnTableWebViewHolder extends AbsLivePageViewHolder implements Vie @Override public void init() { super.init(); + Bus.getOn(this); mProgressBar = (ProgressBar) findViewById(R.id.progressbar); mWebView = new WebView(mContext); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); @@ -78,7 +75,7 @@ public class TurnTableWebViewHolder extends AbsLivePageViewHolder implements Vie }); - mWebView.addJavascriptInterface(new JsInteration(),"androidObject"); + mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, mWebView), "androidObject"); mWebView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { @@ -92,25 +89,6 @@ public class TurnTableWebViewHolder extends AbsLivePageViewHolder implements Vie ((LinearLayout) mContentView).addView(mWebView); } - //js调用原生 - public class JsInteration { - @JavascriptInterface - public String androidMethod(String data) { - if (data != null && !data.isEmpty()) { - WebViewActivity.forward(mContext, HtmlConfig.SHOP); - EventBus.getDefault().post(new JsTurnTableBean(data)); - } - return ""; - } - - @JavascriptInterface - public String androidGetNewWrap(String data) { - if (data != null && !data.isEmpty()) { - isGetNewWrap = true; - } - return ""; - } - } @Override public void loadData() { @@ -124,6 +102,7 @@ public class TurnTableWebViewHolder extends AbsLivePageViewHolder implements Vie @Override public void release() { + Bus.getOff(this); super.release(); if (mWebView != null) { ViewGroup parent = (ViewGroup) mWebView.getParent(); @@ -140,4 +119,16 @@ public class TurnTableWebViewHolder extends AbsLivePageViewHolder implements Vie public void onHide() { } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) { + if (!TextUtils.isEmpty(event.getMethod())) { + if (TextUtils.equals(event.getMethod(), "androidMethod")) { + if (event.getData() != null && !event.getData().isEmpty()) { + WebViewActivity.forward(mContext, HtmlConfig.SHOP); + EventBus.getDefault().post(new JsTurnTableBean(event.getData())); + } + } + } + } } diff --git a/live/src/main/java/com/yunbao/live/views/WishlistWebViewHolder.java b/live/src/main/java/com/yunbao/live/views/WishlistWebViewHolder.java index 03bc7eb98..2202af9d1 100644 --- a/live/src/main/java/com/yunbao/live/views/WishlistWebViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/WishlistWebViewHolder.java @@ -1,35 +1,33 @@ package com.yunbao.live.views; +import android.app.Activity; import android.content.Context; import android.graphics.Color; import android.os.Build; import android.os.Bundle; import android.text.TextUtils; -import android.util.Log; import android.view.View; import android.view.ViewGroup; -import android.webkit.JavascriptInterface; import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.LinearLayout; import android.widget.ProgressBar; -import android.widget.TextView; -import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; import com.yunbao.common.bean.JsWishBean; -import com.yunbao.common.utils.DpUtil; +import com.yunbao.common.event.JavascriptInterfaceEvent; +import com.yunbao.common.utils.Bus; +import com.yunbao.common.utils.JavascriptInterfaceUtils; import com.yunbao.common.utils.L; -import com.yunbao.common.utils.RouteUtil; import com.yunbao.live.R; import com.yunbao.live.activity.LiveActivity; -import com.yunbao.live.activity.LiveAudienceActivity; -import com.yunbao.live.dialog.LiveTrickeryDialogFragment4Audience; import com.yunbao.live.dialog.LiveUserDialogFragment; import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; /** * Created by cxf on 2018/10/15. @@ -59,6 +57,7 @@ public class WishlistWebViewHolder extends AbsLivePageViewHolder implements View @Override public void init() { super.init(); + Bus.getOn(this); mProgressBar = (ProgressBar) findViewById(R.id.progressbar); mWebView = new WebView(mContext); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); @@ -98,7 +97,7 @@ public class WishlistWebViewHolder extends AbsLivePageViewHolder implements View // 自适应 屏幕大小界面 webSettings.setLoadWithOverviewMode(true); - mWebView.addJavascriptInterface(new JsInteration(),"androidObject"); + mWebView.addJavascriptInterface(new JavascriptInterfaceUtils((Activity) mContext, mWebView).setPageClose(false), "androidObject"); mWebView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { @@ -112,35 +111,11 @@ public class WishlistWebViewHolder extends AbsLivePageViewHolder implements View ((LinearLayout) mContentView).addView(mWebView); } - //js调用原生 - public class JsInteration { - @JavascriptInterface - public String androidMethod(String data) { - if (data != null && !data.isEmpty()) { - EventBus.getDefault().post(new JsWishBean(data)); - } - return ""; - } - @JavascriptInterface - public String androidMethodClickUser(String userId,String liveId) { - //点击用户头像 - if (!TextUtils.isEmpty(userId) && !TextUtils.isEmpty(liveId)) { - showUserDialog(userId, liveId); - } - return ""; - } - @JavascriptInterface - public void onTrickerySendGift(String id) { - if (id != null) { - EventBus.getDefault().post(new JsWishBean(id)); - } - } - } /** * 显示个人资料弹窗 */ - private void showUserDialog(String toUid,String liveId) { + private void showUserDialog(String toUid, String liveId) { if (!TextUtils.isEmpty(liveId) && !TextUtils.isEmpty(toUid)) { LiveUserDialogFragment fragment = new LiveUserDialogFragment(); Bundle bundle = new Bundle(); @@ -151,6 +126,7 @@ public class WishlistWebViewHolder extends AbsLivePageViewHolder implements View fragment.show(((LiveActivity) mContext).getSupportFragmentManager(), "LiveUserDialogFragment"); } } + @Override public void loadData() { if (!mLoad) { @@ -163,6 +139,7 @@ public class WishlistWebViewHolder extends AbsLivePageViewHolder implements View @Override public void release() { + Bus.getOff(this); super.release(); if (mWebView != null) { ViewGroup parent = (ViewGroup) mWebView.getParent(); @@ -179,4 +156,24 @@ public class WishlistWebViewHolder extends AbsLivePageViewHolder implements View public void onHide() { } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) { + if (!TextUtils.isEmpty(event.getMethod())) { + if (TextUtils.equals(event.getMethod(), "androidMethod")) { + if (event.getData() != null && !event.getData().isEmpty()) { + EventBus.getDefault().post(new JsWishBean(event.getData())); + } + } else if (TextUtils.equals(event.getMethod(), "androidMethodClickUser")) { + //点击用户头像 + if (!TextUtils.isEmpty(event.getUserId()) && !TextUtils.isEmpty(event.getLiveId())) { + showUserDialog(event.getUserId(), event.getLiveId()); + } + } else if (TextUtils.equals(event.getMethod(), "onTrickerySendGift")) { + if (event.getUserId() != null) { + EventBus.getDefault().post(new JsWishBean(event.getUserId())); + } + } + } + } } diff --git a/main/src/main/java/com/yunbao/main/activity/FansActivity.java b/main/src/main/java/com/yunbao/main/activity/FansActivity.java index 42c3181b6..9a8ea0be8 100644 --- a/main/src/main/java/com/yunbao/main/activity/FansActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/FansActivity.java @@ -5,6 +5,7 @@ import android.content.Intent; import androidx.recyclerview.widget.LinearLayoutManager; import android.text.TextUtils; +import com.alibaba.android.arouter.facade.annotation.Route; import com.alibaba.fastjson.JSON; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; @@ -33,7 +34,7 @@ import java.util.List; * Created by cxf on 2018/9/29. * 我的粉丝 TA的粉丝 */ - +@Route(path = RouteUtil.PATH_FANSACTIVITY) public class FansActivity extends AbsActivity implements OnItemClickListener { public static void forward(Context context, String toUid) { diff --git a/main/src/main/java/com/yunbao/main/activity/GoogleFragment.java b/main/src/main/java/com/yunbao/main/activity/GoogleFragment.java index 9dc2964b0..0b6a35e1e 100644 --- a/main/src/main/java/com/yunbao/main/activity/GoogleFragment.java +++ b/main/src/main/java/com/yunbao/main/activity/GoogleFragment.java @@ -6,17 +6,18 @@ import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics; import static com.yunbao.main.activity.MyWalletActivity.dis; import android.annotation.SuppressLint; -import android.app.ProgressDialog; +import android.app.Activity; import android.os.Bundle; import android.os.Handler; +import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.webkit.JavascriptInterface; import android.webkit.WebSettings; import android.webkit.WebView; +import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import com.adjust.sdk.Adjust; @@ -27,13 +28,19 @@ import com.google.android.gms.ads.identifier.AdvertisingIdClient; import com.google.android.gms.common.GooglePlayServicesNotAvailableException; import com.google.android.gms.common.GooglePlayServicesRepairableException; import com.yunbao.common.CommonAppConfig; +import com.yunbao.common.event.JavascriptInterfaceEvent; import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.GoogleBillingUtilNew; +import com.yunbao.common.utils.JavascriptInterfaceUtils; import com.yunbao.common.utils.ToastUtil; import com.yunbao.main.R; import com.yunbao.main.views.TestWebViewClient; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + import java.io.IOException; import java.util.List; @@ -47,11 +54,24 @@ public class GoogleFragment extends Fragment { private WebView rlWebview; private String url; String adid = null; + private Activity mContext; @SuppressLint("ValidFragment") - public GoogleFragment(String urls) { + public GoogleFragment(Activity context, String urls) { url = urls; - Log.e("google", "111aa"); + mContext = context; + } + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + Bus.getOn(this); + } + + @Override + public void onDetach() { + super.onDetach(); + Bus.getOff(this); } @Override @@ -90,7 +110,7 @@ public class GoogleFragment extends Fragment { webSettings.setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口 - rlWebview.addJavascriptInterface(new JsInteration(), "androidObject"); + rlWebview.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, rlWebview).setPageClose(true), "androidObject"); TestWebViewClient testWebViewClient = new TestWebViewClient(getActivity(), rlWebview); @@ -107,121 +127,106 @@ public class GoogleFragment extends Fragment { } - private Handler payHandler = new Handler(); - //js调用原生 - public class JsInteration { - - - @JavascriptInterface - public void androidNewGoToGooglePay(String ProductId, String OrderNumber, String MoneyUsd) { - Log.e(TAG, "ProductId" + ProductId + "OrderNumber" + OrderNumber + "MoneyUsd" + MoneyUsd); - mProductId = ProductId; - mOrderid = OrderNumber; - MoneyUsds = MoneyUsd; -// googleBillingUtil.purchaseInApp(getActivity(), mProductId); - GoogleBillingUtilNew.getInstance().setBillingListener(new GoogleBillingUtilNew.GoogleBillingListener() { - @Override - public void onPaySuccess(List list) { - for (Purchase purchase : list) { - for (int i = 0; i < list.size(); i++) { - int finalI = i; - payHandler.post(new Runnable() { - @Override - public void run() { - CommonHttpUtil.notifyGoogle(list.get(finalI).getPurchaseToken(), list.get(finalI).getOrderId(), mProductId, mOrderid, adid, new HttpCallback() { - @Override - public void onSuccess(int code, String msg, String[] info) { - if (code == 0) { - Bundle params = new Bundle(); - params.putString("currency", "HKD"); - params.putString("money", MoneyUsds); - logger.logEvent("FB_iap_Play", params); - - - Bundle fb_params = new Bundle(); - fb_params.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, "HKD"); - fb_params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID, mProductId); - - //fb官方事件记录充值 - logger.logEvent(AppEventsConstants.EVENT_NAME_PURCHASED, - Double.parseDouble(MoneyUsds), - fb_params); - - //Google官方充值通知 - Bundle google_params = new Bundle(); - google_params.putString("currency", "HKD"); - google_params.putString("product_id", mProductId); - google_params.putString("transaction_id", mOrderid); - google_params.putString("value", MoneyUsds); - google_params.putString("price", MoneyUsds); - google_params.putString("quantity", "1"); - - mFirebaseAnalytics.logEvent("FS_iap_Play", google_params); - - - AdjustEvent adjustEvent1 = new AdjustEvent("cgssol"); - Adjust.trackEvent(adjustEvent1); - CommonHttpUtil.setAdvertisingChannels("cgssol", new HttpCallback() { - @Override - public void onSuccess(int code, String msg, String[] info) { - if (code == 0) { - logger.logEvent("FB_iap_users", null); - mFirebaseAnalytics.logEvent("FS_iap_users", null); - } - } - }); - - AdjustEvent adjustEvent2 = new AdjustEvent("tr8lb9"); - adjustEvent2.setRevenue(Double.parseDouble(MoneyUsds),"HKD"); - adjustEvent2.addCallbackParameter("GOrderid",purchase.getOrderId()); - adjustEvent2.addCallbackParameter("POrderid",mOrderid); - adjustEvent2.addCallbackParameter("Uid", CommonAppConfig.getInstance().getUid()); - adjustEvent2.addCallbackParameter("GADid",adid); - adjustEvent2.setOrderId(mOrderid); - Adjust.trackEvent(adjustEvent2); - - dis(); - ToastUtil.show("支付成功"); - } - } - }); - } - }); - } - Log.e("谷歌支付", purchase.toString()); - } - } - - @Override - public void onPayFailed(int code, String msg) { - - } - }).checkSku(ProductId) - ; - //下单 - Bundle params = new Bundle(); - params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID, mProductId); - params.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, "HKD"); - logger.logEvent(AppEventsConstants.EVENT_NAME_INITIATED_CHECKOUT, Double.parseDouble(MoneyUsds), - params); - - } - - @JavascriptInterface - public void androidMethodBack() { - getActivity().onBackPressed(); - - } - - @JavascriptInterface - public void androidGoBack() { - getActivity().onBackPressed(); - } - } public void release() { } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) { + if (!TextUtils.isEmpty(event.getMethod())) { + if (TextUtils.equals(event.getMethod(), "androidNewGoToGooglePay")) { + mProductId = event.getProductId(); + mOrderid = event.getOrderNumber(); + MoneyUsds = event.getMoneyUsd(); + GoogleBillingUtilNew.getInstance().setBillingListener(new GoogleBillingUtilNew.GoogleBillingListener() { + @Override + public void onPaySuccess(List list) { + for (Purchase purchase : list) { + for (int i = 0; i < list.size(); i++) { + int finalI = i; + payHandler.post(new Runnable() { + @Override + public void run() { + CommonHttpUtil.notifyGoogle(list.get(finalI).getPurchaseToken(), list.get(finalI).getOrderId(), mProductId, mOrderid, adid, new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0) { + Bundle params = new Bundle(); + params.putString("currency", "HKD"); + params.putString("money", MoneyUsds); + logger.logEvent("FB_iap_Play", params); + + + Bundle fb_params = new Bundle(); + fb_params.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, "HKD"); + fb_params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID, mProductId); + + //fb官方事件记录充值 + logger.logEvent(AppEventsConstants.EVENT_NAME_PURCHASED, + Double.parseDouble(MoneyUsds), + fb_params); + + //Google官方充值通知 + Bundle google_params = new Bundle(); + google_params.putString("currency", "HKD"); + google_params.putString("product_id", mProductId); + google_params.putString("transaction_id", mOrderid); + google_params.putString("value", MoneyUsds); + google_params.putString("price", MoneyUsds); + google_params.putString("quantity", "1"); + + mFirebaseAnalytics.logEvent("FS_iap_Play", google_params); + + + AdjustEvent adjustEvent1 = new AdjustEvent("cgssol"); + Adjust.trackEvent(adjustEvent1); + CommonHttpUtil.setAdvertisingChannels("cgssol", new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0) { + logger.logEvent("FB_iap_users", null); + mFirebaseAnalytics.logEvent("FS_iap_users", null); + } + } + }); + + AdjustEvent adjustEvent2 = new AdjustEvent("tr8lb9"); + adjustEvent2.setRevenue(Double.parseDouble(MoneyUsds), "HKD"); + adjustEvent2.addCallbackParameter("GOrderid", purchase.getOrderId()); + adjustEvent2.addCallbackParameter("POrderid", mOrderid); + adjustEvent2.addCallbackParameter("Uid", CommonAppConfig.getInstance().getUid()); + adjustEvent2.addCallbackParameter("GADid", adid); + adjustEvent2.setOrderId(mOrderid); + Adjust.trackEvent(adjustEvent2); + + dis(); + ToastUtil.show("支付成功"); + } + } + }); + } + }); + } + Log.e("谷歌支付", purchase.toString()); + } + } + + @Override + public void onPayFailed(int code, String msg) { + + } + }).checkSku(event.getPostsId()) + ; + //下单 + Bundle params = new Bundle(); + params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID, mProductId); + params.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, "HKD"); + logger.logEvent(AppEventsConstants.EVENT_NAME_INITIATED_CHECKOUT, Double.parseDouble(MoneyUsds), + params); + } + } + } } 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 7184633c5..6387c7c62 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -29,7 +29,6 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; -import androidx.fragment.app.FragmentActivity; import androidx.viewpager.widget.ViewPager; import com.alibaba.android.arouter.facade.annotation.Route; @@ -42,7 +41,6 @@ import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.jakewharton.rxbinding3.view.RxView; import com.lzf.easyfloat.EasyFloat; -import com.lzf.easyfloat.interfaces.OnPermissionResult; import com.lzf.easyfloat.permission.PermissionUtils; import com.tencent.imsdk.v2.V2TIMCallback; import com.tencent.imsdk.v2.V2TIMManager; @@ -102,7 +100,7 @@ import com.yunbao.main.R; import com.yunbao.main.dialog.MainStartDialogFragment; import com.yunbao.main.dialog.ReturnUserDialog; import com.yunbao.main.dialog.SigninDialog; -import com.yunbao.main.event.MainHomeCommunityToChatEvent; +import com.yunbao.common.event.MainHomeCommunityToChatEvent; import com.yunbao.main.event.PDLiveConversationListEvent; import com.yunbao.main.http.MainHttpConsts; import com.yunbao.main.http.MainHttpUtil; diff --git a/main/src/main/java/com/yunbao/main/activity/MyWalletActivity.java b/main/src/main/java/com/yunbao/main/activity/MyWalletActivity.java index 962e0756e..0317e9bd5 100644 --- a/main/src/main/java/com/yunbao/main/activity/MyWalletActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MyWalletActivity.java @@ -121,28 +121,27 @@ public class MyWalletActivity extends AbsActivity { Log.i("tss", "首充"); if (CommonAppConfig.IS_GOOGLE_PLAY == false) { //链接版本 - fragments = new Fragment[]{new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&first_page=1&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()+ "&package_name=pd"), - new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()+ "&package_name=pd"), - new WalletFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()+ "&package_name=pd")}; -// fragments = new Fragment[]{new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&first_page=1&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()), new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()), new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken())}; + fragments = new Fragment[]{new GoogleFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&first_page=1&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), + new GoogleFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), + new WalletFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd")}; } else { rView.setVisibility(View.VISIBLE); - fragments = new Fragment[]{new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), - new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaygole&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), - new WalletFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken())}; + fragments = new Fragment[]{new GoogleFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), + new GoogleFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaygole&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), + new WalletFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken())}; } } else { if (CommonAppConfig.IS_GOOGLE_PLAY == false) { Log.i("tss", "不是首充"); //链接版本 - fragments = new Fragment[]{new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()+ "&package_name=pd"), - new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()+ "&package_name=pd"), - new WalletFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()+ "&package_name=pd")}; + fragments = new Fragment[]{new GoogleFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), + new GoogleFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), + new WalletFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd")}; } else { rView.setVisibility(View.VISIBLE); - fragments = new Fragment[]{new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), - new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaygole&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), - new WalletFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken())}; + fragments = new Fragment[]{new GoogleFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), + new GoogleFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaygole&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), + new WalletFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken())}; } } MagicIndicator magicIndicator = (MagicIndicator) findViewById(R.id.magic_indicator); diff --git a/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity.java b/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity.java index 6afb32fd1..d201bdef0 100644 --- a/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity.java @@ -1,5 +1,8 @@ package com.yunbao.main.activity; +import static com.yunbao.common.CommonAppContext.logger; +import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics; + import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; @@ -7,16 +10,11 @@ import android.content.Intent; import android.net.Uri; import android.os.Build; import android.os.Handler; -import android.os.Looper; import android.provider.MediaStore; - -import androidx.annotation.RequiresApi; - import android.text.TextUtils; import android.util.Log; import android.view.View; import android.view.ViewGroup; -import android.webkit.JavascriptInterface; import android.webkit.ValueCallback; import android.webkit.WebChromeClient; import android.webkit.WebSettings; @@ -27,6 +25,8 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ProgressBar; +import androidx.annotation.RequiresApi; + import com.adjust.sdk.Adjust; import com.adjust.sdk.AdjustEvent; import com.alibaba.android.arouter.facade.annotation.Route; @@ -39,43 +39,38 @@ import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; import com.yunbao.common.R; import com.yunbao.common.activity.AbsActivity; +import com.yunbao.common.bean.LiveBean; import com.yunbao.common.bean.UserBean; -import com.yunbao.common.bean.VideoListBean; +import com.yunbao.common.event.JavascriptInterfaceEvent; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.interfaces.ActivityResultCallback; import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.interfaces.ImageResultCallback; +import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.DpUtil; +import com.yunbao.common.utils.JavascriptInterfaceUtils; import com.yunbao.common.utils.L; import com.yunbao.common.utils.ProcessImageUtil; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.live.activity.LiveAudienceActivity; -import com.yunbao.live.activity.LiveReportActivity; -import com.yunbao.common.bean.LiveBean; -import com.yunbao.live.bean.ReportCommunityBean; import com.yunbao.live.event.LiveRoomChangeEvent; import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.presenter.LiveRoomCheckLivePresenter; import com.yunbao.live.views.LiveRoomViewHolder; import com.yunbao.main.dialog.EncourageDialog; import com.yunbao.main.http.MainHttpUtil; -import com.yunbao.main.manager.imrongcloud.ConversationIMListManager; import com.yunbao.video.activity.VideoPlayActivity; -import com.yunbao.video.bean.VideoBean; import com.yunbao.video.utils.VideoStorge; import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; import java.io.File; -import java.util.ArrayList; import java.util.Arrays; -import java.util.List; - -import static com.yunbao.common.CommonAppContext.logger; -import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics; /** * Created by Chen Haoxuan on 2022/4/19. @@ -105,6 +100,7 @@ public class MyWebViewActivity extends AbsActivity { @Override protected void main() { + Bus.getOn(this); mContext = this; urlNow = getIntent().getStringExtra(Constants.URL); Log.e("bb22", "1121212"); @@ -203,7 +199,7 @@ public class MyWebViewActivity extends AbsActivity { } }); - mWebView.addJavascriptInterface(new JsInteration(), "androidObject"); + mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, mWebView).setPageClose(true), "androidObject"); mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口 mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setDomStorageEnabled(true); @@ -246,183 +242,6 @@ public class MyWebViewActivity extends AbsActivity { updataImg(); } - //js调用原生 - public class JsInteration { - @JavascriptInterface - public void androidCommunityGift(String postsId) { - Constants.nowPostsId = postsId; - new Handler(Looper.getMainLooper()).post(new Runnable() { - public void run() { - EncourageDialog fragment = new EncourageDialog(); - fragment.show(((MyWebViewActivity) mContext).getSupportFragmentManager(), "EncourageDialog"); - }});} - - @JavascriptInterface - public void reportCommunity(String info) { - ReportCommunityBean reportCommunityBean = JSON.parseObject(info, ReportCommunityBean.class); - LiveReportActivity.forward3(mContext, reportCommunityBean.getDynamic_id(), 1, reportCommunityBean.getCommunity_type(), reportCommunityBean.getComment_id()); - } - - @JavascriptInterface - public void onBack() { - finish(); - } - - //拉黑不感兴趣 - @JavascriptInterface - public void androidLoseInterest() { - EventBus.getDefault().post("blacklist"); - } - - @JavascriptInterface - public void modifyMydata() { - indexInto = 1; - RouteUtil.forwardEditProfileActivity(); - } - - @JavascriptInterface - public void reportUser(String touid) { - RouteUtil.forwardLiveReportActivity(touid); - } - - @JavascriptInterface - public void androidMethodLookToLive(String liveId) { - //看直播 - gotoLive(liveId); - } - - @JavascriptInterface - public void AndroidFellow() { - mFirebaseAnalytics.logEvent("FS_Follow", null); - logger.logEvent("FB_Follow", null); - AdjustEvent adjustEvent1 = new AdjustEvent("oess6a"); - Adjust.trackEvent(adjustEvent1); - } - - @JavascriptInterface - public void androidClickSayHiBack(String uid, String name, String img) { - Constants.firstInto = 0; - ConversationIMListManager.get(mContext).jumpConversation(mContext, uid); - } - - @JavascriptInterface - public void androidClickFansList(String uid) { - FansActivity.forward(mContext, uid); - } - - @JavascriptInterface - public void androidPlayVideo(String list) { - list.toString(); - if (!"undefined".equals(list)) { - JSONObject obj = JSON.parseObject(list); - int position = obj.getIntValue("video_index"); - String videoListString = obj.getString("video_list"); - List videoList = JSON.parseArray(videoListString, VideoListBean.class); - List videoBeanList = new ArrayList<>(); - for (VideoListBean videoListBean : videoList) { - JSONObject obj2 = JSON.parseObject(videoListBean.getContent()); - String msg = obj2.getString("msg"); - VideoBean videoBean = new VideoBean(); - videoBean.setHref(videoListBean.getVideo()); - videoBean.setCity(""); - videoBean.setCommentNum(videoListBean.getComment_num()); - videoBean.setAddtime(videoListBean.getCreate_time()); - videoBean.setDatetime(""); - videoBean.setDistance(""); - videoBean.setId(videoListBean.getId()); - videoBean.setLat(""); - videoBean.setLike(0); - videoBean.setTitle(msg); - if ("2".endsWith(videoListBean.getIs_attention()) || "0".endsWith(videoListBean.getIs_attention())) { - videoBean.setAttent(2); - } else if ("1".endsWith(videoListBean.getIs_attention())) { - videoBean.setAttent(1); - } else { - videoBean.setAttent(-1); - } - UserBean userBean = new UserBean(); - userBean.setAvatar(videoListBean.getUser_avatar()); - userBean.setUserNiceName(videoListBean.getUser_name()); - userBean.setId(videoListBean.getUser_id()); - videoBean.setUserBean(userBean); - - videoBean.setUid(videoListBean.getUser_id()); - videoBeanList.add(videoBean); - } - VideoStorge.getInstance().put(Constants.VIDEO_COMMUNITY, videoBeanList); - VideoPlayActivity.forward(mContext, position, Constants.VIDEO_COMMUNITY, 1); - } - } - - @JavascriptInterface - public void gotoHomePage(String indexStr) { - if (!"".equals(indexStr) && indexStr != null) { - int index = -1; - if ("0".equals(indexStr)) { - index = 0; - } else if ("1".equals(indexStr)) { - index = 1; - } else if ("2".equals(indexStr)) { - index = 2; - } else if ("3".equals(indexStr)) { - index = 3; - } - if (index != -1) { - finish(); - Constants.isShowPage = index; - } - } - } - - //打开无头部 - @JavascriptInterface - public void openWebView(String url) { - Constants.isTitle = false; - RouteUtil.forwardZhuangBanActivity(url); - } - - //打开有头部 - @JavascriptInterface - public void openWebViewTitle(String url) { - Constants.isTitle = true; - RouteUtil.forwardZhuangBanActivity(url); - } - - //跳转修改昵称 - @JavascriptInterface - public void openUpdataName() { - isUpdataUser = true; - Constants.myIntoIndex = 2; - Intent intent = new Intent(mContext, MyWebViewActivity2.class); - intent.putExtra(Constants.URL, CommonAppConfig.HOST + "/h5/table/Modify-information.html" + "?token=" + CommonAppConfig.getInstance().getToken() + "&uid=" + CommonAppConfig.getInstance().getUid()); - startActivity(intent); - } - - //跳转修改头像 - @JavascriptInterface - public void openUpdataAvater() { - isUpdataUser = true; - DialogUitl.showStringArrayDialog(mContext, new Integer[]{ - com.yunbao.main.R.string.camera, com.yunbao.main.R.string.alumb}, new DialogUitl.StringArrayDialogCallback() { - @Override - public void onItemClick(String text, int tag) { - if (tag == com.yunbao.main.R.string.camera) { - mImageUtil.getImageByCamera(); - } else { - mImageUtil.getImageByAlumb(); - } - } - }); -// RouteUtil.forwardEditProfileActivity(); - } - - //跳转修改签名 - @JavascriptInterface - public void openUpdataAutograph() { - isUpdataUser = true; - forwardSign(); - } - } private LiveRoomCheckLivePresenter mCheckLivePresenter; @@ -603,6 +422,7 @@ public class MyWebViewActivity extends AbsActivity { @Override protected void onDestroy() { + Bus.getOff(this); if (mWebView != null) { ViewGroup parent = (ViewGroup) mWebView.getParent(); if (parent != null) { @@ -719,4 +539,49 @@ public class MyWebViewActivity extends AbsActivity { public void onBackPressed() { closeFinger(); } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) { + if (!TextUtils.isEmpty(event.getMethod())) { + if (TextUtils.equals(event.getMethod(), "androidCommunityGift")) { + Constants.nowPostsId = event.getPostsId(); + EncourageDialog fragment = new EncourageDialog(); + fragment.show(((MyWebViewActivity) mContext).getSupportFragmentManager(), "EncourageDialog"); + } + } else if (TextUtils.equals(event.getMethod(), "modifyMydata")) { + indexInto = event.getIndexInto(); + } else if (TextUtils.equals(event.getMethod(), "androidMethodLookToLive")) { + //看直播 + gotoLive(event.getLiveId()); + } else if (TextUtils.equals(event.getMethod(), "AndroidFellow")) { + mFirebaseAnalytics.logEvent("FS_Follow", null); + logger.logEvent("FB_Follow", null); + AdjustEvent adjustEvent1 = new AdjustEvent("oess6a"); + Adjust.trackEvent(adjustEvent1); + + } else if (TextUtils.equals(event.getMethod(), "androidClickSayHiBack")) { + Constants.firstInto = 0; + } else if (TextUtils.equals(event.getMethod(), "androidPlayVideo")) { + VideoStorge.getInstance().put(Constants.VIDEO_COMMUNITY, event.getVideoBeanList()); + VideoPlayActivity.forward(mContext, event.getPosition(), Constants.VIDEO_COMMUNITY, 1); + } else if (TextUtils.equals(event.getMethod(), "openUpdataName")) { + isUpdataUser = event.isUpdataUser(); + } else if (TextUtils.equals(event.getMethod(), "openUpdataAutograph")) { + isUpdataUser = true; + forwardSign(); + } else if (TextUtils.equals(event.getMethod(), "openUpdataAvater")) { + isUpdataUser = true; + DialogUitl.showStringArrayDialog(mContext, new Integer[]{ + com.yunbao.main.R.string.camera, com.yunbao.main.R.string.alumb}, new DialogUitl.StringArrayDialogCallback() { + @Override + public void onItemClick(String text, int tag) { + if (tag == com.yunbao.main.R.string.camera) { + mImageUtil.getImageByCamera(); + } else { + mImageUtil.getImageByAlumb(); + } + } + }); + } + } } diff --git a/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity2.java b/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity2.java index 14ed6c6c0..583ed6fd7 100644 --- a/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity2.java +++ b/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity2.java @@ -24,6 +24,7 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ProgressBar; +import com.alibaba.android.arouter.facade.annotation.Route; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.yunbao.common.CommonAppConfig; @@ -42,14 +43,14 @@ import com.yunbao.live.activity.LiveAudienceActivity; import com.yunbao.live.activity.LiveReportActivity; import com.yunbao.live.activity.SystemMessageActivity; import com.yunbao.common.bean.LiveBean; -import com.yunbao.live.bean.ReportCommunityBean; +import com.yunbao.common.bean.ReportCommunityBean; import com.yunbao.live.event.LiveRoomChangeEvent; import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.presenter.LiveRoomCheckLivePresenter; import com.yunbao.live.views.LiveRoomViewHolder; import com.yunbao.main.dialog.EncourageDialog; import com.yunbao.video.activity.VideoPlayActivity; -import com.yunbao.video.bean.VideoBean; +import com.yunbao.common.bean.VideoBean; import com.yunbao.video.utils.VideoStorge; import org.greenrobot.eventbus.EventBus; @@ -61,6 +62,7 @@ import java.util.List; /** * Created by Chen Haoxuan on 2022/4/19. */ +@Route(path = RouteUtil.PATH_MYWEBVIEWACTIVTITY2) public class MyWebViewActivity2 extends AbsActivity { private FrameLayout ft_title; diff --git a/main/src/main/java/com/yunbao/main/activity/RechargeActivity.java b/main/src/main/java/com/yunbao/main/activity/RechargeActivity.java index f9871a9b0..bf8986c3d 100644 --- a/main/src/main/java/com/yunbao/main/activity/RechargeActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/RechargeActivity.java @@ -1,18 +1,16 @@ package com.yunbao.main.activity; -import android.os.Bundle; -import androidx.appcompat.app.AppCompatActivity; +import static android.util.Log.i; -import android.webkit.JavascriptInterface; +import android.os.Bundle; import android.webkit.WebSettings; import android.webkit.WebView; import com.yunbao.common.activity.AbsActivity; +import com.yunbao.common.utils.JavascriptInterfaceUtils; import com.yunbao.main.R; import com.yunbao.main.views.TestWebViewClient; -import static android.util.Log.i; - //充值h5 public class RechargeActivity extends AbsActivity { @@ -32,61 +30,20 @@ public class RechargeActivity extends AbsActivity { webSettings.setJavaScriptEnabled(true); // 是否开启JS支持 webSettings.setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口 -// -// webSettings.setUseWideViewPort(true); // 缩放至屏幕大小 -// webSettings.setLoadWithOverviewMode(true); // 缩放至屏幕大小 -// webSettings.setSupportZoom(true); // 是否支持缩放 -// webSettings.setBuiltInZoomControls(true); // 是否支持缩放变焦,前提是支持缩放 -// webSettings.setDisplayZoomControls(false); // 是否隐藏缩放控件 -// -// webSettings.setAllowFileAccess(true); // 是否允许访问文件 -// webSettings.setDomStorageEnabled(false); // 是否节点缓存 -// webSettings.setDatabaseEnabled(false); // 是否数据缓存 -// webSettings.setAppCacheEnabled(false); // 是否应用缓存 -// -// webSettings.setMediaPlaybackRequiresUserGesture(false); // 是否要手势触发媒体 -// webSettings.setStandardFontFamily("sans-serif"); // 设置字体库格式 -// webSettings.setFixedFontFamily("monospace"); // 设置字体库格式 -// webSettings.setSansSerifFontFamily("sans-serif"); // 设置字体库格式 -// webSettings.setSerifFontFamily("sans-serif"); // 设置字体库格式 -// webSettings.setCursiveFontFamily("cursive"); // 设置字体库格式 -// webSettings.setFantasyFontFamily("fantasy"); // 设置字体库格式 -// webSettings.setTextZoom(100); // 设置文本缩放的百分比 -// webSettings.setMinimumFontSize(8); // 设置文本字体的最小值(1~72) -// webSettings.setDefaultFontSize(16); // 设置文本字体默认的大小 -// -// webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); // 按规则重新布局 -// webSettings.setLoadsImagesAutomatically(true); // 是否自动加载图片 -// webSettings.setDefaultTextEncodingName("UTF-8"); // 设置编码格式 -// webSettings.setNeedInitialFocus(true); // 是否需要获取焦点 -// webSettings.setGeolocationEnabled(false); // 设置开启定位功能 -// webSettings.setBlockNetworkLoads(false); // 是否从网络获取资源 -// rlWebview.addJavascriptInterface(new JsInteration(), "androidObject"); -// rlWebview.setWebContentsDebuggingEnabled(true); - rlWebview.addJavascriptInterface(new JsInteration(),"androidObject"); + rlWebview.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, rlWebview).setPageClose(true), "androidObject"); - TestWebViewClient testWebViewClient = new TestWebViewClient(this,rlWebview); + TestWebViewClient testWebViewClient = new TestWebViewClient(this, rlWebview); rlWebview.setWebViewClient(testWebViewClient); } - //js调用原生 - public class JsInteration { - @JavascriptInterface - public void androidMethodBack() { - RechargeActivity.this.finish(); - } - @JavascriptInterface - public void androidGoBack() { - RechargeActivity.this.finish(); - } - } + @Override protected int getLayoutId() { - return R.layout.activity_recharge; + return R.layout.activity_recharge; } private void initView() { diff --git a/main/src/main/java/com/yunbao/main/activity/WalletFragment.java b/main/src/main/java/com/yunbao/main/activity/WalletFragment.java index 9afb322e2..2c15d7f44 100644 --- a/main/src/main/java/com/yunbao/main/activity/WalletFragment.java +++ b/main/src/main/java/com/yunbao/main/activity/WalletFragment.java @@ -2,55 +2,45 @@ package com.yunbao.main.activity; import android.annotation.SuppressLint; +import android.app.Activity; import android.os.Bundle; -import androidx.fragment.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.webkit.JavascriptInterface; import android.webkit.WebSettings; import android.webkit.WebView; +import androidx.fragment.app.Fragment; + +import com.yunbao.common.utils.JavascriptInterfaceUtils; import com.yunbao.main.R; import com.yunbao.main.views.TestWebViewClient; -import static android.util.Log.i; - @SuppressLint("ValidFragment") public class WalletFragment extends Fragment { - private View view; private WebView rlWebview; private String url; + private Activity mContext; + @SuppressLint("ValidFragment") - public WalletFragment(String urls) { - Log.e("google","222aa"); + public WalletFragment(Activity context, String urls) { + Log.e("google", "222aa"); url = urls; + mContext = context; } - //js调用原生 - public class JsInteration { - @JavascriptInterface - public void androidMethodBack() { - MyWalletActivity.dis(); - } - @JavascriptInterface - public void androidGoBack() { - MyWalletActivity.dis(); - } - } - @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { //通过参数中的布局填充获取对应布局 - view =inflater.inflate(R.layout.activity_recharge,container,false); + view = inflater.inflate(R.layout.activity_recharge, container, false); rlWebview = (WebView) view.findViewById(R.id.rlWebview); - Log.e("ttt",url); + Log.e("ttt", url); rlWebview.loadUrl(url); WebSettings webSettings = rlWebview.getSettings(); @@ -61,58 +51,16 @@ public class WalletFragment extends Fragment { webSettings.setJavaScriptEnabled(true); // 是否开启JS支持 webSettings.setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口 -// - webSettings.setUseWideViewPort(true); // 缩放至屏幕大小 - webSettings.setLoadWithOverviewMode(true); // 缩放至屏幕大小 - webSettings.setSupportZoom(true); // 是否支持缩放 - webSettings.setBuiltInZoomControls(true); // 是否支持缩放变焦,前提是支持缩放 -// webSettings.setDisplayZoomControls(false); // 是否隐藏缩放控件 -// -// webSettings.setAllowFileAccess(true); // 是否允许访问文件 -// webSettings.setDomStorageEnabled(false); // 是否节点缓存 -// webSettings.setDatabaseEnabled(false); // 是否数据缓存 -// webSettings.setAppCacheEnabled(false); // 是否应用缓存 -// -// webSettings.setMediaPlaybackRequiresUserGesture(false); // 是否要手势触发媒体 -// webSettings.setStandardFontFamily("sans-serif"); // 设置字体库格式 -// webSettings.setFixedFontFamily("monospace"); // 设置字体库格式 -// webSettings.setSansSerifFontFamily("sans-serif"); // 设置字体库格式 -// webSettings.setSerifFontFamily("sans-serif"); // 设置字体库格式 -// webSettings.setCursiveFontFamily("cursive"); // 设置字体库格式 -// webSettings.setFantasyFontFamily("fantasy"); // 设置字体库格式 -// webSettings.setTextZoom(100); // 设置文本缩放的百分比 -// webSettings.setMinimumFontSize(8); // 设置文本字体的最小值(1~72) -// webSettings.setDefaultFontSize(16); // 设置文本字体默认的大小 -// -// webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); // 按规则重新布局 -// webSettings.setLoadsImagesAutomatically(true); // 是否自动加载图片 -// webSettings.setDefaultTextEncodingName("UTF-8"); // 设置编码格式 -// webSettings.setNeedInitialFocus(true); // 是否需要获取焦点 -// webSettings.setGeolocationEnabled(false); // 设置开启定位功能 -// webSettings.setBlockNetworkLoads(false); // 是否从网络获取资源 -// rlWebview.addJavascriptInterface(new JsInteration(), "androidObject"); -// rlWebview.setWebContentsDebuggingEnabled(true); - rlWebview.addJavascriptInterface(new JsInteration(),"androidObject"); + rlWebview.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, rlWebview).setPageClose(true), "androidObject"); - TestWebViewClient testWebViewClient = new TestWebViewClient(getActivity(),rlWebview); + TestWebViewClient testWebViewClient = new TestWebViewClient(getActivity(), rlWebview); rlWebview.setWebViewClient(testWebViewClient); return view; } -// -// //js调用原生 -// public class JsInteration { -// @JavascriptInterface -// public void androidMethodBack() { -// RechargeActivity.this.finish(); -// } -// @JavascriptInterface -// public void androidGoBack() { -// RechargeActivity.this.finish(); -// } -// } + } diff --git a/main/src/main/java/com/yunbao/main/activity/WeekWebViewActivity.java b/main/src/main/java/com/yunbao/main/activity/WeekWebViewActivity.java index 17cd55ab5..ab9955c7d 100644 --- a/main/src/main/java/com/yunbao/main/activity/WeekWebViewActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/WeekWebViewActivity.java @@ -6,14 +6,11 @@ import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Build; -import android.provider.MediaStore; -import androidx.annotation.RequiresApi; - import android.os.Bundle; +import android.provider.MediaStore; import android.text.TextUtils; import android.view.View; import android.view.ViewGroup; -import android.webkit.JavascriptInterface; import android.webkit.ValueCallback; import android.webkit.WebChromeClient; import android.webkit.WebSettings; @@ -23,24 +20,32 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ProgressBar; +import androidx.annotation.RequiresApi; + import com.alibaba.fastjson.JSON; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; import com.yunbao.common.activity.AbsActivity; +import com.yunbao.common.bean.LiveBean; +import com.yunbao.common.event.JavascriptInterfaceEvent; import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DpUtil; +import com.yunbao.common.utils.JavascriptInterfaceUtils; import com.yunbao.common.utils.L; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.live.activity.LiveAudienceActivity; import com.yunbao.live.activity.WebViewActivityMedal; -import com.yunbao.common.bean.LiveBean; import com.yunbao.live.dialog.LiveUserDialogFragment; import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.presenter.LiveRoomCheckLivePresenter; import com.yunbao.main.R; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + public class WeekWebViewActivity extends AbsActivity { private ProgressBar mProgressBar; @@ -50,6 +55,7 @@ public class WeekWebViewActivity extends AbsActivity { private ValueCallback mValueCallback; private ValueCallback mValueCallback2; private ImageView mIvQuestion; + @Override protected int getLayoutId() { return R.layout.activity_week_web_view; @@ -57,6 +63,7 @@ public class WeekWebViewActivity extends AbsActivity { @Override protected void main() { + Bus.getOn(this); String url = getIntent().getStringExtra(Constants.URL); L.e("H5---6>" + url); LinearLayout rootView = (LinearLayout) findViewById(com.yunbao.common.R.id.rootView); @@ -128,7 +135,7 @@ public class WeekWebViewActivity extends AbsActivity { } }); - mWebView.addJavascriptInterface(new JsInteration(),"androidObject"); + mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, mWebView).setPageClose(true), "androidObject"); mWebView.getSettings().setJavaScriptEnabled(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); @@ -137,27 +144,9 @@ public class WeekWebViewActivity extends AbsActivity { } - - //js调用原生 - public class JsInteration { - @JavascriptInterface - public String androidMethodLookLive(String uId,String liveId,String isLiving) { - //跳转个人主页 - RouteUtil.forwardUserHome(mContext, liveId,0); - - return ""; - } - @JavascriptInterface - public void androidMethodLookToLive(String liveId) { - //看直播 - gotoLive(liveId); - - } - } - private LiveRoomCheckLivePresenter mCheckLivePresenter; - private void gotoLive(final String live_id){ + private void gotoLive(final String live_id) { LiveHttpUtil.getLiveInfo(live_id, new HttpCallback() { @Override public void onSuccess(int code, String msg, String[] info) { @@ -178,8 +167,8 @@ public class WeekWebViewActivity extends AbsActivity { }); } mCheckLivePresenter.checkLive(liveBean); - }else{ - RouteUtil.forwardUserHome(mContext, live_id,0); + } else { + RouteUtil.forwardUserHome(mContext, live_id, 0); } } }); @@ -189,7 +178,7 @@ public class WeekWebViewActivity extends AbsActivity { /** * 显示个人资料弹窗 */ - private void showUserDialog(String toUid,String liveId) { + private void showUserDialog(String toUid, String liveId) { if (!TextUtils.isEmpty(liveId) && !TextUtils.isEmpty(toUid)) { LiveUserDialogFragment fragment = new LiveUserDialogFragment(); Bundle bundle = new Bundle(); @@ -299,6 +288,7 @@ public class WeekWebViewActivity extends AbsActivity { @Override protected void onDestroy() { + Bus.getOff(this); if (mWebView != null) { ViewGroup parent = (ViewGroup) mWebView.getParent(); if (parent != null) { @@ -319,4 +309,13 @@ public class WeekWebViewActivity extends AbsActivity { ToastUtil.show(getString(com.yunbao.common.R.string.copy_success)); } + @Subscribe(threadMode = ThreadMode.MAIN) + public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) { + if (!TextUtils.isEmpty(event.getMethod())) { + if (TextUtils.equals(event.getMethod(), "androidMethodLookToLive")) { + //看直播 + gotoLive(event.getLiveId()); + } + } + } } diff --git a/main/src/main/java/com/yunbao/main/adapter/MainHomeVideoAdapter.java b/main/src/main/java/com/yunbao/main/adapter/MainHomeVideoAdapter.java index f249f5b57..4fddd73d4 100644 --- a/main/src/main/java/com/yunbao/main/adapter/MainHomeVideoAdapter.java +++ b/main/src/main/java/com/yunbao/main/adapter/MainHomeVideoAdapter.java @@ -14,7 +14,7 @@ import com.yunbao.common.adapter.RefreshAdapter; import com.yunbao.common.bean.UserBean; import com.yunbao.common.glide.ImgLoader; import com.yunbao.main.R; -import com.yunbao.video.bean.VideoBean; +import com.yunbao.common.bean.VideoBean; import java.util.List; diff --git a/main/src/main/java/com/yunbao/main/adapter/VideoHomeAdapter.java b/main/src/main/java/com/yunbao/main/adapter/VideoHomeAdapter.java index 59bf02ef7..89a1f6b09 100644 --- a/main/src/main/java/com/yunbao/main/adapter/VideoHomeAdapter.java +++ b/main/src/main/java/com/yunbao/main/adapter/VideoHomeAdapter.java @@ -12,7 +12,7 @@ import android.widget.TextView; import com.yunbao.common.adapter.RefreshAdapter; import com.yunbao.common.glide.ImgLoader; import com.yunbao.main.R; -import com.yunbao.video.bean.VideoBean; +import com.yunbao.common.bean.VideoBean; /** * Created by cxf on 2018/12/14. diff --git a/main/src/main/java/com/yunbao/main/dialog/EncourageDialog.java b/main/src/main/java/com/yunbao/main/dialog/EncourageDialog.java index 4e6d97238..f4d5a6cd7 100644 --- a/main/src/main/java/com/yunbao/main/dialog/EncourageDialog.java +++ b/main/src/main/java/com/yunbao/main/dialog/EncourageDialog.java @@ -47,6 +47,12 @@ public class EncourageDialog extends AbsDialogFragment implements View.OnClickLi private String id, giftId; private GridLayoutManager gridLayoutManager; + + public EncourageDialog setId(String id) { + this.id = id; + return this; + } + @Override protected int getLayoutId() { return R.layout.dialog_encourage; @@ -89,8 +95,6 @@ public class EncourageDialog extends AbsDialogFragment implements View.OnClickLi findViewById(R.id.lt_gift1).setOnClickListener(this); findViewById(R.id.lt_gift2).setOnClickListener(this); findViewById(R.id.lt_gift3).setOnClickListener(this); - - id = Constants.nowPostsId; encourageList = new ArrayList<>(); getData(); } diff --git a/main/src/main/java/com/yunbao/main/dialog/SigninDialog.java b/main/src/main/java/com/yunbao/main/dialog/SigninDialog.java index 92fbce3ef..ed72b3b45 100644 --- a/main/src/main/java/com/yunbao/main/dialog/SigninDialog.java +++ b/main/src/main/java/com/yunbao/main/dialog/SigninDialog.java @@ -1,36 +1,23 @@ package com.yunbao.main.dialog; -import android.os.Build; +import static com.yunbao.common.utils.RouteUtil.PATH_REWARD; + import android.os.Bundle; -import android.util.Log; import android.view.Gravity; import android.view.View; import android.view.Window; import android.view.WindowManager; -import android.webkit.JavascriptInterface; -import android.webkit.WebSettings; -import android.webkit.WebView; -import android.webkit.WebViewClient; import android.widget.Button; import android.widget.TextView; import com.alibaba.android.arouter.launcher.ARouter; import com.yunbao.common.CommonAppConfig; -import com.yunbao.common.Constants; import com.yunbao.common.dialog.AbsDialogFragment; import com.yunbao.common.utils.DpUtil; -import com.yunbao.common.utils.L; -import com.yunbao.common.utils.ToastUtil; -import com.yunbao.live.activity.LiveActivity; -import com.yunbao.live.activity.LiveAudienceActivity; -import com.yunbao.live.dialog.LiveFansFragment; -import com.yunbao.live.views.LiveRoomViewHolder; import com.yunbao.main.R; -import static com.yunbao.common.utils.RouteUtil.PATH_REWARD; - public class SigninDialog extends AbsDialogFragment { - TextView gold,sign_day; + TextView gold, sign_day; @Override protected int getLayoutId() { @@ -68,7 +55,7 @@ public class SigninDialog extends AbsDialogFragment { goto_sign.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - ARouter.getInstance().build(PATH_REWARD).withString("url", CommonAppConfig.HOST +"/index.php?g=Appapi&m=task&a=index"+ "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()).navigation(); + ARouter.getInstance().build(PATH_REWARD).withString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=task&a=index" + "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()).navigation(); dismiss(); } @@ -85,7 +72,7 @@ public class SigninDialog extends AbsDialogFragment { if (bundle == null) { return; } - gold.setText(bundle.getString("send_gold")+"金豆+"+bundle.getString("send_exp")+"EXP"); - sign_day.setText("本月您已累積簽到"+bundle.getString("sign_day")+"天,"); + gold.setText(bundle.getString("send_gold") + "金豆+" + bundle.getString("send_exp") + "EXP"); + sign_day.setText("本月您已累積簽到" + bundle.getString("sign_day") + "天,"); } } diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java index 1c1e53fb3..7223dfd32 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java @@ -1,5 +1,8 @@ package com.yunbao.main.views; +import static android.content.Context.CLIPBOARD_SERVICE; +import static com.yunbao.common.utils.WordUtil.getString; + import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; @@ -9,14 +12,10 @@ import android.os.Build; import android.os.Handler; import android.os.Looper; import android.provider.MediaStore; - -import androidx.annotation.RequiresApi; - import android.text.TextUtils; import android.util.Log; import android.view.View; import android.view.ViewGroup; -import android.webkit.JavascriptInterface; import android.webkit.ValueCallback; import android.webkit.WebChromeClient; import android.webkit.WebSettings; @@ -26,45 +25,38 @@ import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.TextView; +import androidx.annotation.RequiresApi; + import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; import com.yunbao.common.HtmlConfig; -import com.yunbao.common.bean.UserBean; -import com.yunbao.common.bean.VideoListBean; +import com.yunbao.common.bean.LiveBean; +import com.yunbao.common.event.JavascriptInterfaceEvent; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DpUtil; +import com.yunbao.common.utils.JavascriptInterfaceUtils; import com.yunbao.common.utils.L; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.live.activity.LiveAudienceActivity; -import com.yunbao.live.activity.LiveReportActivity; -import com.yunbao.common.bean.LiveBean; -import com.yunbao.live.bean.ReportCommunityBean; import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.presenter.LiveRoomCheckLivePresenter; import com.yunbao.live.views.LoadingView; import com.yunbao.main.R; -import com.yunbao.main.activity.FansActivity; import com.yunbao.main.activity.MainActivity; import com.yunbao.main.dialog.EncourageDialog; -import com.yunbao.main.event.MainHomeCommunityToChatEvent; import com.yunbao.main.utils.BottomBarUtil; import com.yunbao.video.activity.VideoPlayActivity; -import com.yunbao.video.bean.VideoBean; import com.yunbao.video.utils.VideoStorge; -import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; -import java.util.ArrayList; import java.util.Arrays; -import java.util.List; - -import static android.content.Context.CLIPBOARD_SERVICE; -import static com.yunbao.common.utils.WordUtil.getString; /** * Created by Chen Haoxuan on 2022/3/25. @@ -93,9 +85,8 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl @Override public void init() { + Bus.getOn(this); String url = HtmlConfig.ENCOURAGE + "?t=" + Math.random() + "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken(); - - L.e("H5---9>" + url); final LinearLayout rootView = (LinearLayout) findViewById(R.id.rootView); mProgressBar = (ProgressBar) findViewById(R.id.progressbar); mWebView = new WebView(mContext); @@ -120,7 +111,7 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);// 不加载缓存内容 mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口 - mWebView.addJavascriptInterface(new JsInteration(), "androidObject"); + mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(nowMainActivity, mWebView), "androidObject"); rootView.addView(mWebView); @@ -223,100 +214,6 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl public void loadNewUrl() { } - //js调用原生 - public class JsInteration { - @JavascriptInterface - public void androidCommunityGift(String postsId) { - Constants.nowPostsId = postsId; - new Handler(Looper.getMainLooper()).post(new Runnable() { - public void run() { - EncourageDialog fragment = new EncourageDialog(); - if (mContext instanceof MainActivity) { - fragment.show(((MainActivity) mContext).getSupportFragmentManager(), "EncourageDialog"); - } - } - }); - } - - @JavascriptInterface - public void reportCommunity(String info) { - ReportCommunityBean reportCommunityBean = JSON.parseObject(info, ReportCommunityBean.class); - LiveReportActivity.forward3(mContext, reportCommunityBean.getDynamic_id(), 1, reportCommunityBean.getCommunity_type(), reportCommunityBean.getComment_id()); - } - - @JavascriptInterface - public void reportUser(String touid) { - LiveReportActivity.forward(mContext, touid); - } - - @JavascriptInterface - public void isCloseNavigation(String isClose) { - if(nowMainActivity!=null) { - nowMainActivity.isClose(isClose); - } - } - - @JavascriptInterface - public void androidPlayVideo(String list) { - list.toString(); - if (!"undefined".equals(list)) { - JSONObject obj = JSON.parseObject(list); - int position = obj.getIntValue("video_index"); - String videoListString = obj.getString("video_list"); - List videoList = JSON.parseArray(videoListString, VideoListBean.class); - List videoBeanList = new ArrayList<>(); - for (VideoListBean videoListBean : videoList) { - JSONObject obj2 = JSON.parseObject(videoListBean.getContent()); - String msg = obj2.getString("msg"); - VideoBean videoBean = new VideoBean(); - videoBean.setHref(videoListBean.getVideo()); - videoBean.setCity(""); - videoBean.setCommentNum(videoListBean.getComment_num()); - videoBean.setAddtime(videoListBean.getCreate_time()); - videoBean.setDatetime(""); - videoBean.setDistance(""); - videoBean.setId(videoListBean.getId()); - videoBean.setLat(""); - videoBean.setLike(0); - videoBean.setTitle(msg); - if ("2".endsWith(videoListBean.getIs_attention()) || "0".endsWith(videoListBean.getIs_attention())) { - videoBean.setAttent(2); - } else if ("1".endsWith(videoListBean.getIs_attention())) { - videoBean.setAttent(1); - } else { - videoBean.setAttent(-1); - } - UserBean userBean = new UserBean(); - userBean.setAvatar(videoListBean.getUser_avatar()); - userBean.setUserNiceName(videoListBean.getUser_name()); - userBean.setId(videoListBean.getUser_id()); - videoBean.setUserBean(userBean); - - videoBean.setUid(videoListBean.getUser_id()); - videoBeanList.add(videoBean); - } - VideoStorge.getInstance().put(Constants.VIDEO_COMMUNITY, videoBeanList); - VideoPlayActivity.forward(mContext, position, Constants.VIDEO_COMMUNITY, 1); - } - } - - @JavascriptInterface - public void androidClickSayHiBack(String uid, String name, String img) { - EventBus.getDefault().post(new MainHomeCommunityToChatEvent().setTargetId(uid)); - - } - - @JavascriptInterface - public void androidMethodLookToLive(String liveId) { - //看直播 - gotoLive(liveId); - } - - @JavascriptInterface - public void androidClickFansList(String uid) { - FansActivity.forward(mContext, uid); - } - } protected void setTitle(String title) { TextView titleView = (TextView) findViewById(R.id.titleView); @@ -378,6 +275,7 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl @Override public void onDestroy() { + Bus.getOff(this); if (mWebView != null) { ViewGroup parent = (ViewGroup) mWebView.getParent(); if (parent != null) { @@ -429,4 +327,30 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl } } + @Subscribe(threadMode = ThreadMode.MAIN) + public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) { + if (!TextUtils.isEmpty(event.getMethod())) { + if (TextUtils.equals(event.getMethod(), "androidCommunityGift")) { + new Handler(Looper.getMainLooper()).post(new Runnable() { + public void run() { + EncourageDialog fragment = new EncourageDialog(); + fragment.setId(event.getPostsId()); + if (mContext instanceof MainActivity) { + fragment.show(((MainActivity) mContext).getSupportFragmentManager(), "EncourageDialog"); + } + } + }); + } else if (TextUtils.equals(event.getMethod(), "isCloseNavigation")) { + if (nowMainActivity != null) { + nowMainActivity.isClose(event.getIsClose()); + } + } else if (TextUtils.equals(event.getMethod(), "androidPlayVideo")) { + VideoStorge.getInstance().put(Constants.VIDEO_COMMUNITY, event.getVideoBeanList()); + VideoPlayActivity.forward(mContext, event.getPosition(), Constants.VIDEO_COMMUNITY, 1); + } else if (TextUtils.equals(event.getMethod(), "androidMethodLookToLive")) { + //看直播 + gotoLive(event.getLiveId()); + } + } + } } diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeVideoViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeVideoViewHolder.java index e584be46b..1da3860f0 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeVideoViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeVideoViewHolder.java @@ -15,7 +15,7 @@ import com.yunbao.common.interfaces.OnItemClickListener; import com.yunbao.main.R; import com.yunbao.main.adapter.MainHomeVideoAdapter; import com.yunbao.video.activity.VideoPlayActivity; -import com.yunbao.video.bean.VideoBean; +import com.yunbao.common.bean.VideoBean; import com.yunbao.video.event.VideoDeleteEvent; import com.yunbao.video.event.VideoScrollPageEvent; import com.yunbao.video.http.VideoHttpConsts; diff --git a/main/src/main/java/com/yunbao/main/views/VideoHomeViewHolder.java b/main/src/main/java/com/yunbao/main/views/VideoHomeViewHolder.java index 3aeb8bf1c..758cc94ba 100644 --- a/main/src/main/java/com/yunbao/main/views/VideoHomeViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/VideoHomeViewHolder.java @@ -17,7 +17,7 @@ import com.yunbao.live.views.AbsUserHomeViewHolder; import com.yunbao.main.R; import com.yunbao.main.adapter.VideoHomeAdapter; import com.yunbao.video.activity.VideoPlayActivity; -import com.yunbao.video.bean.VideoBean; +import com.yunbao.common.bean.VideoBean; import com.yunbao.video.event.VideoDeleteEvent; import com.yunbao.video.event.VideoScrollPageEvent; import com.yunbao.video.http.VideoHttpConsts; diff --git a/video/src/main/java/com/yunbao/video/activity/AbsVideoPlayActivity.java b/video/src/main/java/com/yunbao/video/activity/AbsVideoPlayActivity.java index ba1a36adf..7a5a90f3d 100644 --- a/video/src/main/java/com/yunbao/video/activity/AbsVideoPlayActivity.java +++ b/video/src/main/java/com/yunbao/video/activity/AbsVideoPlayActivity.java @@ -9,10 +9,7 @@ import android.media.MediaMetadataRetriever; import android.text.TextUtils; import android.view.WindowManager; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; import com.yunbao.common.CommonAppConfig; -import com.yunbao.common.HtmlConfig; import com.yunbao.common.bean.ConfigBean; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.interfaces.CommonCallback; @@ -23,9 +20,8 @@ import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.video.R; -import com.yunbao.video.bean.VideoBean; +import com.yunbao.common.bean.VideoBean; import com.yunbao.video.event.VideoDeleteEvent; -import com.yunbao.video.event.VideoShareEvent; import com.yunbao.video.http.VideoHttpConsts; import com.yunbao.video.http.VideoHttpUtil; import com.yunbao.video.utils.VideoLocalUtil; diff --git a/video/src/main/java/com/yunbao/video/activity/VideoEditActivity.java b/video/src/main/java/com/yunbao/video/activity/VideoEditActivity.java index e3d25c8da..3ee2e0d5d 100644 --- a/video/src/main/java/com/yunbao/video/activity/VideoEditActivity.java +++ b/video/src/main/java/com/yunbao/video/activity/VideoEditActivity.java @@ -26,7 +26,7 @@ import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.video.R; -import com.yunbao.video.bean.MusicBean; +import com.yunbao.common.bean.MusicBean; import com.yunbao.video.utils.VideoLocalUtil; import com.yunbao.video.views.VideoEditCutViewHolder; import com.yunbao.video.views.VideoEditFilterViewHolder; diff --git a/video/src/main/java/com/yunbao/video/activity/VideoPlayActivity.java b/video/src/main/java/com/yunbao/video/activity/VideoPlayActivity.java index c52d015d1..817990d5f 100644 --- a/video/src/main/java/com/yunbao/video/activity/VideoPlayActivity.java +++ b/video/src/main/java/com/yunbao/video/activity/VideoPlayActivity.java @@ -14,7 +14,7 @@ import com.yunbao.common.Constants; import com.yunbao.common.utils.L; import com.yunbao.common.utils.SpUtil; import com.yunbao.video.R; -import com.yunbao.video.bean.VideoBean; +import com.yunbao.common.bean.VideoBean; import com.yunbao.video.utils.LottieComponent; import com.yunbao.video.utils.VideoStorge; import com.yunbao.video.views.VideoScrollViewHolder; diff --git a/video/src/main/java/com/yunbao/video/adapter/MusicAdapter.java b/video/src/main/java/com/yunbao/video/adapter/MusicAdapter.java index bcfa9b8cb..f323ceb86 100644 --- a/video/src/main/java/com/yunbao/video/adapter/MusicAdapter.java +++ b/video/src/main/java/com/yunbao/video/adapter/MusicAdapter.java @@ -16,7 +16,7 @@ import com.alibaba.fastjson.JSON; import com.yunbao.common.Constants; import com.yunbao.common.adapter.RefreshAdapter; import com.yunbao.video.R; -import com.yunbao.video.bean.MusicBean; +import com.yunbao.common.bean.MusicBean; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.HttpCallback; import com.yunbao.video.http.VideoHttpConsts; diff --git a/video/src/main/java/com/yunbao/video/adapter/VideoScrollAdapter.java b/video/src/main/java/com/yunbao/video/adapter/VideoScrollAdapter.java index 92dcc6f59..949832707 100644 --- a/video/src/main/java/com/yunbao/video/adapter/VideoScrollAdapter.java +++ b/video/src/main/java/com/yunbao/video/adapter/VideoScrollAdapter.java @@ -18,7 +18,7 @@ import com.yunbao.common.utils.ClickUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.video.R; import com.yunbao.video.activity.AbsVideoPlayActivity; -import com.yunbao.video.bean.VideoBean; +import com.yunbao.common.bean.VideoBean; import com.yunbao.video.utils.VideoIconUtil; import com.yunbao.video.views.VideoPlayWrapViewHolder; diff --git a/video/src/main/java/com/yunbao/video/dialog/VideoMusicClassDialog.java b/video/src/main/java/com/yunbao/video/dialog/VideoMusicClassDialog.java index 32ffc0702..6d4b7a7ed 100644 --- a/video/src/main/java/com/yunbao/video/dialog/VideoMusicClassDialog.java +++ b/video/src/main/java/com/yunbao/video/dialog/VideoMusicClassDialog.java @@ -17,7 +17,7 @@ import com.yunbao.common.custom.CommonRefreshView; import com.yunbao.common.http.HttpCallback; import com.yunbao.video.R; import com.yunbao.video.adapter.MusicAdapter; -import com.yunbao.video.bean.MusicBean; +import com.yunbao.common.bean.MusicBean; import com.yunbao.video.http.VideoHttpConsts; import com.yunbao.video.http.VideoHttpUtil; import com.yunbao.video.interfaces.VideoMusicActionListener; diff --git a/video/src/main/java/com/yunbao/video/dialog/VideoShareDialogFragment.java b/video/src/main/java/com/yunbao/video/dialog/VideoShareDialogFragment.java index 8fec8eab8..2ef5ea9d8 100644 --- a/video/src/main/java/com/yunbao/video/dialog/VideoShareDialogFragment.java +++ b/video/src/main/java/com/yunbao/video/dialog/VideoShareDialogFragment.java @@ -12,7 +12,7 @@ import com.yunbao.common.Constants; import com.yunbao.common.bean.ConfigBean; import com.yunbao.common.dialog.AbsDialogFragment; import com.yunbao.video.R; -import com.yunbao.video.bean.VideoBean; +import com.yunbao.common.bean.VideoBean; /** * Created by cxf on 2018/10/19. diff --git a/video/src/main/java/com/yunbao/video/interfaces/VideoMusicActionListener.java b/video/src/main/java/com/yunbao/video/interfaces/VideoMusicActionListener.java index 7933e3e27..9a2f47298 100644 --- a/video/src/main/java/com/yunbao/video/interfaces/VideoMusicActionListener.java +++ b/video/src/main/java/com/yunbao/video/interfaces/VideoMusicActionListener.java @@ -1,7 +1,7 @@ package com.yunbao.video.interfaces; import com.yunbao.video.adapter.MusicAdapter; -import com.yunbao.video.bean.MusicBean; +import com.yunbao.common.bean.MusicBean; /** * Created by cxf on 2018/12/7. diff --git a/video/src/main/java/com/yunbao/video/utils/VideoStorge.java b/video/src/main/java/com/yunbao/video/utils/VideoStorge.java index 47f171de9..473f45356 100644 --- a/video/src/main/java/com/yunbao/video/utils/VideoStorge.java +++ b/video/src/main/java/com/yunbao/video/utils/VideoStorge.java @@ -1,6 +1,6 @@ package com.yunbao.video.utils; -import com.yunbao.video.bean.VideoBean; +import com.yunbao.common.bean.VideoBean; import com.yunbao.video.interfaces.VideoScrollDataHelper; import java.util.HashMap; diff --git a/video/src/main/java/com/yunbao/video/views/VideoEditMusicViewHolder.java b/video/src/main/java/com/yunbao/video/views/VideoEditMusicViewHolder.java index b503acc7c..2e4c8ce93 100644 --- a/video/src/main/java/com/yunbao/video/views/VideoEditMusicViewHolder.java +++ b/video/src/main/java/com/yunbao/video/views/VideoEditMusicViewHolder.java @@ -8,7 +8,7 @@ import android.widget.TextView; import com.yunbao.common.utils.StringUtil; import com.yunbao.common.views.AbsViewHolder; import com.yunbao.video.R; -import com.yunbao.video.bean.MusicBean; +import com.yunbao.common.bean.MusicBean; import com.yunbao.video.custom.RangeSlider; /** diff --git a/video/src/main/java/com/yunbao/video/views/VideoMusicCollectViewHolder.java b/video/src/main/java/com/yunbao/video/views/VideoMusicCollectViewHolder.java index 2ba8f7fa5..e3c6f879b 100644 --- a/video/src/main/java/com/yunbao/video/views/VideoMusicCollectViewHolder.java +++ b/video/src/main/java/com/yunbao/video/views/VideoMusicCollectViewHolder.java @@ -9,7 +9,7 @@ import com.yunbao.common.custom.CommonRefreshView; import com.yunbao.common.http.HttpCallback; import com.yunbao.video.R; import com.yunbao.video.adapter.MusicAdapter; -import com.yunbao.video.bean.MusicBean; +import com.yunbao.common.bean.MusicBean; import com.yunbao.video.http.VideoHttpUtil; import com.yunbao.video.interfaces.VideoMusicActionListener; diff --git a/video/src/main/java/com/yunbao/video/views/VideoMusicHotViewHolder.java b/video/src/main/java/com/yunbao/video/views/VideoMusicHotViewHolder.java index 99d390fcf..85af03b68 100644 --- a/video/src/main/java/com/yunbao/video/views/VideoMusicHotViewHolder.java +++ b/video/src/main/java/com/yunbao/video/views/VideoMusicHotViewHolder.java @@ -9,7 +9,7 @@ import com.yunbao.common.custom.CommonRefreshView; import com.yunbao.common.http.HttpCallback; import com.yunbao.video.R; import com.yunbao.video.adapter.MusicAdapter; -import com.yunbao.video.bean.MusicBean; +import com.yunbao.common.bean.MusicBean; import com.yunbao.video.http.VideoHttpUtil; import com.yunbao.video.interfaces.VideoMusicActionListener; diff --git a/video/src/main/java/com/yunbao/video/views/VideoMusicSearchViewHolder.java b/video/src/main/java/com/yunbao/video/views/VideoMusicSearchViewHolder.java index e658e75f4..f8ff6f896 100644 --- a/video/src/main/java/com/yunbao/video/views/VideoMusicSearchViewHolder.java +++ b/video/src/main/java/com/yunbao/video/views/VideoMusicSearchViewHolder.java @@ -10,7 +10,7 @@ import com.yunbao.common.custom.CommonRefreshView; import com.yunbao.common.http.HttpCallback; import com.yunbao.video.R; import com.yunbao.video.adapter.MusicAdapter; -import com.yunbao.video.bean.MusicBean; +import com.yunbao.common.bean.MusicBean; import com.yunbao.video.http.VideoHttpUtil; import com.yunbao.video.interfaces.VideoMusicActionListener; diff --git a/video/src/main/java/com/yunbao/video/views/VideoMusicViewHolder.java b/video/src/main/java/com/yunbao/video/views/VideoMusicViewHolder.java index 34280fc30..1731f69cb 100644 --- a/video/src/main/java/com/yunbao/video/views/VideoMusicViewHolder.java +++ b/video/src/main/java/com/yunbao/video/views/VideoMusicViewHolder.java @@ -34,7 +34,7 @@ import com.yunbao.common.views.AbsViewHolder; import com.yunbao.video.R; import com.yunbao.video.adapter.MusicAdapter; import com.yunbao.video.adapter.MusicClassAdapter; -import com.yunbao.video.bean.MusicBean; +import com.yunbao.common.bean.MusicBean; import com.yunbao.video.bean.MusicClassBean; import com.yunbao.video.dialog.VideoMusicClassDialog; import com.yunbao.video.http.VideoHttpConsts; diff --git a/video/src/main/java/com/yunbao/video/views/VideoPlayViewHolder.java b/video/src/main/java/com/yunbao/video/views/VideoPlayViewHolder.java index f235b08d4..1750df210 100644 --- a/video/src/main/java/com/yunbao/video/views/VideoPlayViewHolder.java +++ b/video/src/main/java/com/yunbao/video/views/VideoPlayViewHolder.java @@ -18,7 +18,7 @@ import com.tencent.rtmp.ui.TXCloudVideoView; import com.yunbao.common.utils.L; import com.yunbao.common.views.AbsViewHolder; import com.yunbao.video.R; -import com.yunbao.video.bean.VideoBean; +import com.yunbao.common.bean.VideoBean; import com.yunbao.video.http.VideoHttpConsts; import com.yunbao.video.http.VideoHttpUtil; diff --git a/video/src/main/java/com/yunbao/video/views/VideoPlayWrapViewHolder.java b/video/src/main/java/com/yunbao/video/views/VideoPlayWrapViewHolder.java index e52766761..231aea3ed 100644 --- a/video/src/main/java/com/yunbao/video/views/VideoPlayWrapViewHolder.java +++ b/video/src/main/java/com/yunbao/video/views/VideoPlayWrapViewHolder.java @@ -28,7 +28,7 @@ import com.yunbao.common.views.AbsViewHolder; import com.yunbao.live.activity.LiveReportActivity; import com.yunbao.video.R; import com.yunbao.video.activity.AbsVideoPlayActivity; -import com.yunbao.video.bean.VideoBean; +import com.yunbao.common.bean.VideoBean; import com.yunbao.video.dialog.VideoShareDialogFragment; import com.yunbao.video.event.VideoLikeEvent; import com.yunbao.video.http.VideoHttpUtil; diff --git a/video/src/main/java/com/yunbao/video/views/VideoScrollViewHolder.java b/video/src/main/java/com/yunbao/video/views/VideoScrollViewHolder.java index cca1dc95b..8e3466515 100644 --- a/video/src/main/java/com/yunbao/video/views/VideoScrollViewHolder.java +++ b/video/src/main/java/com/yunbao/video/views/VideoScrollViewHolder.java @@ -12,7 +12,7 @@ import com.yunbao.common.views.AbsViewHolder; import com.yunbao.video.R; import com.yunbao.video.activity.AbsVideoPlayActivity; import com.yunbao.video.adapter.VideoScrollAdapter; -import com.yunbao.video.bean.VideoBean; +import com.yunbao.common.bean.VideoBean; import com.yunbao.video.custom.VideoLoadingBar; import com.yunbao.video.event.VideoCommentEvent; import com.yunbao.video.event.VideoLikeEvent;