Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -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<Uri> 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();
|
||||
}
|
||||
}
|
||||
|
||||
169
common/src/main/java/com/yunbao/common/bean/MusicBean.java
Normal file
169
common/src/main/java/com/yunbao/common/bean/MusicBean.java
Normal file
@@ -0,0 +1,169 @@
|
||||
package com.yunbao.common.bean;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/6/20.
|
||||
*/
|
||||
|
||||
public class MusicBean implements Parcelable {
|
||||
private int id;
|
||||
private String title;
|
||||
private String author;
|
||||
private String imgUrl;
|
||||
private String length;
|
||||
private String fileUrl;
|
||||
private String useNum;
|
||||
private String localPath;//本地存储的路径
|
||||
private int collect;//是否收藏
|
||||
private boolean expand;
|
||||
private long mDuration;
|
||||
|
||||
public MusicBean() {
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
@JSONField(name = "img_url")
|
||||
public String getImgUrl() {
|
||||
return imgUrl;
|
||||
}
|
||||
|
||||
@JSONField(name = "img_url")
|
||||
public void setImgUrl(String imgUrl) {
|
||||
this.imgUrl = imgUrl;
|
||||
}
|
||||
|
||||
public String getLength() {
|
||||
return length;
|
||||
}
|
||||
|
||||
public void setLength(String length) {
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
@JSONField(name = "file_url")
|
||||
public String getFileUrl() {
|
||||
return fileUrl;
|
||||
}
|
||||
|
||||
@JSONField(name = "file_url")
|
||||
public void setFileUrl(String fileUrl) {
|
||||
this.fileUrl = fileUrl;
|
||||
}
|
||||
|
||||
@JSONField(name = "use_nums")
|
||||
public String getUseNum() {
|
||||
return useNum;
|
||||
}
|
||||
|
||||
@JSONField(name = "use_nums")
|
||||
public void setUseNum(String useNum) {
|
||||
this.useNum = useNum;
|
||||
}
|
||||
|
||||
|
||||
public String getLocalPath() {
|
||||
return localPath;
|
||||
}
|
||||
|
||||
public void setLocalPath(String localPath) {
|
||||
this.localPath = localPath;
|
||||
}
|
||||
|
||||
public boolean isExpand() {
|
||||
return expand;
|
||||
}
|
||||
|
||||
public void setExpand(boolean expand) {
|
||||
this.expand = expand;
|
||||
}
|
||||
|
||||
@JSONField(name = "iscollect")
|
||||
public int getCollect() {
|
||||
return collect;
|
||||
}
|
||||
|
||||
@JSONField(name = "iscollect")
|
||||
public void setCollect(int collect) {
|
||||
this.collect = collect;
|
||||
}
|
||||
|
||||
public long getDuration() {
|
||||
return mDuration;
|
||||
}
|
||||
|
||||
public void setDuration(long duration) {
|
||||
mDuration = duration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public MusicBean(Parcel in) {
|
||||
this.id = in.readInt();
|
||||
this.title = in.readString();
|
||||
this.author = in.readString();
|
||||
this.imgUrl = in.readString();
|
||||
this.length = in.readString();
|
||||
this.fileUrl = in.readString();
|
||||
this.useNum = in.readString();
|
||||
this.localPath = in.readString();
|
||||
this.collect = in.readInt();
|
||||
this.mDuration=in.readLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(this.id);
|
||||
dest.writeString(this.title);
|
||||
dest.writeString(this.author);
|
||||
dest.writeString(this.imgUrl);
|
||||
dest.writeString(this.length);
|
||||
dest.writeString(this.fileUrl);
|
||||
dest.writeString(this.useNum);
|
||||
dest.writeString(this.localPath);
|
||||
dest.writeInt(this.collect);
|
||||
dest.writeLong(this.mDuration);
|
||||
}
|
||||
|
||||
public static final Creator<MusicBean> CREATOR = new Creator<MusicBean>() {
|
||||
@Override
|
||||
public MusicBean[] newArray(int size) {
|
||||
return new MusicBean[size];
|
||||
}
|
||||
|
||||
@Override
|
||||
public MusicBean createFromParcel(Parcel in) {
|
||||
return new MusicBean(in);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.yunbao.common.bean;
|
||||
|
||||
public class ReportCommunityBean {
|
||||
String dynamic_id;
|
||||
String community_type;
|
||||
String comment_id;
|
||||
|
||||
public String getDynamic_id() {
|
||||
return dynamic_id;
|
||||
}
|
||||
|
||||
public void setDynamic_id(String dynamic_id) {
|
||||
this.dynamic_id = dynamic_id;
|
||||
}
|
||||
|
||||
public String getCommunity_type() {
|
||||
return community_type;
|
||||
}
|
||||
|
||||
public void setCommunity_type(String community_type) {
|
||||
this.community_type = community_type;
|
||||
}
|
||||
|
||||
public String getComment_id() {
|
||||
return comment_id;
|
||||
}
|
||||
|
||||
public void setComment_id(String comment_id) {
|
||||
this.comment_id = comment_id;
|
||||
}
|
||||
}
|
||||
350
common/src/main/java/com/yunbao/common/bean/VideoBean.java
Normal file
350
common/src/main/java/com/yunbao/common/bean/VideoBean.java
Normal file
@@ -0,0 +1,350 @@
|
||||
package com.yunbao.common.bean;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2017/10/25.
|
||||
*/
|
||||
|
||||
public class VideoBean implements Parcelable {
|
||||
private String id;
|
||||
private String uid;
|
||||
private String title;
|
||||
private String thumb;
|
||||
private String thumbs;
|
||||
private String href;
|
||||
private String likeNum;
|
||||
private String viewNum;
|
||||
private String commentNum;
|
||||
private String stepNum;
|
||||
private String shareNum;
|
||||
private String addtime;
|
||||
private String lat;
|
||||
private String lng;
|
||||
private String city;
|
||||
private UserBean userBean;
|
||||
private String datetime;
|
||||
private String distance;
|
||||
private int step;//是否踩过
|
||||
private int like;//是否赞过
|
||||
private int attent;//是否关注过作者
|
||||
private int status;
|
||||
private int musicId;
|
||||
private MusicBean musicInfo;
|
||||
|
||||
public VideoBean() {
|
||||
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public void setUid(String uid) {
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getThumb() {
|
||||
return thumb;
|
||||
}
|
||||
|
||||
public void setThumb(String thumb) {
|
||||
this.thumb = thumb;
|
||||
}
|
||||
|
||||
@JSONField(name = "thumb_s")
|
||||
public String getThumbs() {
|
||||
return thumbs;
|
||||
}
|
||||
|
||||
@JSONField(name = "thumb_s")
|
||||
public void setThumbs(String thumbs) {
|
||||
this.thumbs = thumbs;
|
||||
}
|
||||
|
||||
public String getHref() {
|
||||
return href;
|
||||
}
|
||||
|
||||
public void setHref(String href) {
|
||||
this.href = href;
|
||||
}
|
||||
|
||||
@JSONField(name = "likes")
|
||||
public String getLikeNum() {
|
||||
return likeNum;
|
||||
}
|
||||
|
||||
@JSONField(name = "likes")
|
||||
public void setLikeNum(String likeNum) {
|
||||
this.likeNum = likeNum;
|
||||
}
|
||||
|
||||
@JSONField(name = "views")
|
||||
public String getViewNum() {
|
||||
return viewNum;
|
||||
}
|
||||
|
||||
@JSONField(name = "views")
|
||||
public void setViewNum(String viewNum) {
|
||||
this.viewNum = viewNum;
|
||||
}
|
||||
|
||||
@JSONField(name = "comments")
|
||||
public String getCommentNum() {
|
||||
return commentNum;
|
||||
}
|
||||
|
||||
@JSONField(name = "comments")
|
||||
public void setCommentNum(String commentNum) {
|
||||
this.commentNum = commentNum;
|
||||
}
|
||||
|
||||
@JSONField(name = "steps")
|
||||
public String getStepNum() {
|
||||
return stepNum;
|
||||
}
|
||||
|
||||
@JSONField(name = "steps")
|
||||
public void setStepNum(String stepNum) {
|
||||
this.stepNum = stepNum;
|
||||
}
|
||||
|
||||
@JSONField(name = "shares")
|
||||
public String getShareNum() {
|
||||
return shareNum;
|
||||
}
|
||||
|
||||
@JSONField(name = "shares")
|
||||
public void setShareNum(String shareNum) {
|
||||
this.shareNum = shareNum;
|
||||
}
|
||||
|
||||
public String getAddtime() {
|
||||
return addtime;
|
||||
}
|
||||
|
||||
public void setAddtime(String addtime) {
|
||||
this.addtime = addtime;
|
||||
}
|
||||
|
||||
public String getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(String lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public String getLng() {
|
||||
return lng;
|
||||
}
|
||||
|
||||
public void setLng(String lng) {
|
||||
this.lng = lng;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
|
||||
@JSONField(name = "userinfo")
|
||||
public UserBean getUserBean() {
|
||||
return userBean;
|
||||
}
|
||||
|
||||
@JSONField(name = "userinfo")
|
||||
public void setUserBean(UserBean userBean) {
|
||||
this.userBean = userBean;
|
||||
}
|
||||
|
||||
public String getDatetime() {
|
||||
return datetime;
|
||||
}
|
||||
|
||||
public void setDatetime(String datetime) {
|
||||
this.datetime = datetime;
|
||||
}
|
||||
|
||||
@JSONField(name = "isstep")
|
||||
public int getStep() {
|
||||
return step;
|
||||
}
|
||||
|
||||
@JSONField(name = "isstep")
|
||||
public void setStep(int step) {
|
||||
this.step = step;
|
||||
}
|
||||
|
||||
@JSONField(name = "islike")
|
||||
public int getLike() {
|
||||
return like;
|
||||
}
|
||||
|
||||
@JSONField(name = "islike")
|
||||
public void setLike(int like) {
|
||||
this.like = like;
|
||||
}
|
||||
|
||||
@JSONField(name = "isattent")
|
||||
public int getAttent() {
|
||||
return attent;
|
||||
}
|
||||
|
||||
@JSONField(name = "isattent")
|
||||
public void setAttent(int attent) {
|
||||
this.attent = attent;
|
||||
}
|
||||
|
||||
public String getDistance() {
|
||||
return distance;
|
||||
}
|
||||
|
||||
public void setDistance(String distance) {
|
||||
this.distance = distance;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@JSONField(name = "music_id")
|
||||
public int getMusicId() {
|
||||
return musicId;
|
||||
}
|
||||
|
||||
@JSONField(name = "music_id")
|
||||
public void setMusicId(int musicId) {
|
||||
this.musicId = musicId;
|
||||
}
|
||||
|
||||
@JSONField(name = "musicinfo")
|
||||
public MusicBean getMusicInfo() {
|
||||
return musicInfo;
|
||||
}
|
||||
|
||||
@JSONField(name = "musicinfo")
|
||||
public void setMusicInfo(MusicBean musicInfo) {
|
||||
this.musicInfo = musicInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(this.id);
|
||||
dest.writeString(this.uid);
|
||||
dest.writeString(this.title);
|
||||
dest.writeString(this.thumb);
|
||||
dest.writeString(this.thumbs);
|
||||
dest.writeString(this.href);
|
||||
dest.writeString(this.likeNum);
|
||||
dest.writeString(this.viewNum);
|
||||
dest.writeString(this.commentNum);
|
||||
dest.writeString(this.stepNum);
|
||||
dest.writeString(this.shareNum);
|
||||
dest.writeString(this.addtime);
|
||||
dest.writeString(this.lat);
|
||||
dest.writeString(this.lng);
|
||||
dest.writeString(this.city);
|
||||
dest.writeString(this.datetime);
|
||||
dest.writeInt(this.like);
|
||||
dest.writeInt(this.attent);
|
||||
dest.writeString(this.distance);
|
||||
dest.writeInt(this.step);
|
||||
dest.writeParcelable(this.userBean, flags);
|
||||
dest.writeInt(this.status);
|
||||
dest.writeInt(this.musicId);
|
||||
dest.writeParcelable(this.musicInfo, flags);
|
||||
}
|
||||
|
||||
|
||||
public VideoBean(Parcel in) {
|
||||
this.id = in.readString();
|
||||
this.uid = in.readString();
|
||||
this.title = in.readString();
|
||||
this.thumb = in.readString();
|
||||
this.thumbs = in.readString();
|
||||
this.href = in.readString();
|
||||
this.likeNum = in.readString();
|
||||
this.viewNum = in.readString();
|
||||
this.commentNum = in.readString();
|
||||
this.stepNum = in.readString();
|
||||
this.shareNum = in.readString();
|
||||
this.addtime = in.readString();
|
||||
this.lat = in.readString();
|
||||
this.lng = in.readString();
|
||||
this.city = in.readString();
|
||||
this.datetime = in.readString();
|
||||
this.like = in.readInt();
|
||||
this.attent = in.readInt();
|
||||
this.distance = in.readString();
|
||||
this.step = in.readInt();
|
||||
this.userBean = in.readParcelable(UserBean.class.getClassLoader());
|
||||
this.status = in.readInt();
|
||||
this.musicId = in.readInt();
|
||||
this.musicInfo = in.readParcelable(MusicBean.class.getClassLoader());
|
||||
}
|
||||
|
||||
|
||||
public static final Creator<VideoBean> CREATOR = new Creator<VideoBean>() {
|
||||
@Override
|
||||
public VideoBean[] newArray(int size) {
|
||||
return new VideoBean[size];
|
||||
}
|
||||
|
||||
@Override
|
||||
public VideoBean createFromParcel(Parcel in) {
|
||||
return new VideoBean(in);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "VideoBean{" +
|
||||
"title='" + title + '\'' +
|
||||
",href='" + href + '\'' +
|
||||
",id='" + id + '\'' +
|
||||
",uid='" + uid + '\'' +
|
||||
",userNiceName='" + userBean.getUserNiceName() + '\'' +
|
||||
",thumb='" + thumb + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
||||
public String getTag() {
|
||||
return "VideoBean" + this.getId() + this.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<VideoBean> 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<VideoBean> getVideoBeanList() {
|
||||
return videoBeanList;
|
||||
}
|
||||
|
||||
public JavascriptInterfaceEvent setVideoBeanList(List<VideoBean> 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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.yunbao.common.event;
|
||||
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
|
||||
/**
|
||||
* web跳转聊天页面
|
||||
*/
|
||||
public class MainHomeCommunityToChatEvent extends BaseModel {
|
||||
private String targetId = "";
|
||||
|
||||
public String getTargetId() {
|
||||
return targetId;
|
||||
}
|
||||
|
||||
public MainHomeCommunityToChatEvent setTargetId(String targetId) {
|
||||
this.targetId = targetId;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -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<VideoListBean> videoList = JSON.parseArray(videoListString, VideoListBean.class);
|
||||
List<VideoBean> 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));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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登录
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user