调整客服页面返回键交给h5处理(含系统按键/手势)
统一客服页面为同一个WebView 调整短剧与社区使用原生分开加载 调整送礼-包裹接口为新接口 调整粉丝团礼物送礼为新接口 修复战令-兑换-列表页面在名字过长晴空下高度不统一
This commit is contained in:
parent
b175e42ee1
commit
1759757176
@ -20,6 +20,14 @@ public class LiveClassBean {
|
||||
@SerializedName("channel_show")
|
||||
private int channel_show;
|
||||
|
||||
public LiveClassBean() {
|
||||
}
|
||||
|
||||
public LiveClassBean(String chinese, String english) {
|
||||
this.chinese = chinese;
|
||||
this.english = english;
|
||||
}
|
||||
|
||||
public String getChinese() {
|
||||
return chinese;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.yunbao.common.bean;
|
||||
import android.view.View;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/12.
|
||||
@ -18,6 +19,8 @@ public class LiveGiftBean {
|
||||
// public static final int MARK_LUCK = 3;
|
||||
|
||||
private int id;
|
||||
@SerializedName("gift_id")
|
||||
private int gift_id;//包裹礼物id
|
||||
private int type;//0 普通礼物 1是贵族 2守护 3粉丝团 5盲盒礼物
|
||||
private int mark;// 0 普通 1热门 2守护 3幸运
|
||||
private String name;
|
||||
@ -34,6 +37,7 @@ public class LiveGiftBean {
|
||||
private String isweek;
|
||||
private String end_time;
|
||||
private String tag;
|
||||
private boolean isPageGift;
|
||||
@JSONField(name = "blind_box_type")
|
||||
private int blind_box_type = 0;
|
||||
//礼物角标
|
||||
@ -71,6 +75,14 @@ public class LiveGiftBean {
|
||||
@JSONField(name = "blind_box_ticket_id")
|
||||
private int blindBoxTicketId;
|
||||
|
||||
public boolean isPageGift() {
|
||||
return isPageGift;
|
||||
}
|
||||
|
||||
public void setPageGift(boolean pageGift) {
|
||||
isPageGift = pageGift;
|
||||
}
|
||||
|
||||
public int getBlindBoxTicketId() {
|
||||
return blindBoxTicketId;
|
||||
}
|
||||
@ -80,6 +92,14 @@ public class LiveGiftBean {
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getGift_id() {
|
||||
return gift_id;
|
||||
}
|
||||
|
||||
public void setGift_id(int gift_id) {
|
||||
this.gift_id = gift_id;
|
||||
}
|
||||
|
||||
public int getBlindBoxTicket() {
|
||||
return blindBoxTicket;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.MD5Util;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.VersionUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@ -644,7 +645,40 @@ public class LiveHttpUtil {
|
||||
.params("appVersion", CommonAppConfig.getInstance().getVersion())
|
||||
.execute(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* 观众给主播送礼物 - 包裹
|
||||
*
|
||||
* @param isContactGift 是否为联系方式礼物
|
||||
*/
|
||||
public static void sendGiftForPage(String by, String liveUid, String stream, int giftId, String giftCount, int isContactGift, boolean isFansGroupGift, HttpCallback callback) {
|
||||
HttpClient.getInstance().get("Live.sendPackGift", LiveHttpConsts.SEND_GIFT)
|
||||
.params("liveuid", liveUid)
|
||||
.params("stream", stream)
|
||||
.params("giftid", giftId)
|
||||
.params("isContactGift", isContactGift)
|
||||
.params("giftcount", giftCount)
|
||||
.params("isprank", by)
|
||||
.params("fans_exclusive_pack", isFansGroupGift ? "1" : "0")
|
||||
.params("appVersion", CommonAppConfig.getInstance().getVersion())
|
||||
.execute(callback);
|
||||
}
|
||||
/**
|
||||
* 观众给主播送礼物 - 粉丝团
|
||||
*
|
||||
* @param isContactGift 是否为联系方式礼物
|
||||
*/
|
||||
public static void sendGiftForFansGroup(String by, String liveUid, String stream, int giftId, String giftCount, int isContactGift, boolean isFansGroupGift, HttpCallback callback) {
|
||||
HttpClient.getInstance().get("Live.fansExclusivePack", LiveHttpConsts.SEND_GIFT)
|
||||
.params("liveuid", liveUid)
|
||||
.params("stream", stream)
|
||||
.params("giftid", giftId)
|
||||
.params("isContactGift", isContactGift)
|
||||
.params("giftcount", giftCount)
|
||||
.params("isprank", by)
|
||||
.params("fans_exclusive_pack", isFansGroupGift ? "1" : "0")
|
||||
.params("appVersion", CommonAppConfig.getInstance().getVersion())
|
||||
.execute(callback);
|
||||
}
|
||||
public static void sendBlindBoxTicket(String by, String liveUid, String stream, int giftId, HttpCallback callback) {
|
||||
HttpClient.getInstance().get("Live.sendBlindBoxTicket", LiveHttpConsts.SEND_GIFT)
|
||||
.params("liveuid", liveUid)
|
||||
@ -1003,5 +1037,13 @@ public class LiveHttpUtil {
|
||||
.execute(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取短剧Url
|
||||
*/
|
||||
public static void getCoolydrama(HttpCallback callback){
|
||||
HttpClient.getInstance().get("cool.register", "Home.getFollow")
|
||||
.params("lang", WordUtil.isNewZh()?"zh_CN":"en")
|
||||
.execute(callback);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -44,13 +44,14 @@ public class GoogleUtils {
|
||||
|
||||
|
||||
public boolean getGoogleService() {
|
||||
boolean flag;
|
||||
boolean flag =false;
|
||||
try {
|
||||
Class<?> clz = mActivity.getClassLoader().loadClass("com.shayu.lib_google.utils.GoogleBillingManage");
|
||||
googlePay = clz.getConstructor(Activity.class).newInstance(mActivity);
|
||||
flag = (boolean) googlePay.getClass().getMethod("getGoogleService").invoke(googlePay);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
e.printStackTrace();
|
||||
// throw new RuntimeException(e);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
@ -607,7 +607,7 @@ public class JavascriptInterfaceUtils {
|
||||
public void androidClickToTaskPage() {
|
||||
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() + "&tabIndex=1"+ "&isZh=" + (WordUtil.isNewZh() ? "1" : "0")).navigation();
|
||||
+ "&token=" + CommonAppConfig.getInstance().getToken() + "&tabIndex=1" + "&isZh=" + (WordUtil.isNewZh() ? "1" : "0")).navigation();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
@ -678,4 +678,8 @@ public class JavascriptInterfaceUtils {
|
||||
});
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void androidGotoCustomerService(String url) {
|
||||
RouteUtil.forwardCustomerService(url);
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ public class LiveParcelItemAdapter extends RecyclerView.Adapter {
|
||||
frameGiftViewHolder.giftSelect(giftJson.get(position), position, mStream, mLiveUid, new LiveParcelItemViewHolder.FrameGiftClickListener() {
|
||||
@Override
|
||||
public void onCallBack(int position, LiveGiftBean model) {
|
||||
model.setPageGift(true);
|
||||
Bus.get().post(new LiveGiftItemEvent().setLiveGiftModel(model));
|
||||
giftSelect(model);
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class LiveFansGroupSendGiftDialog extends AbsDialogCenterPopupWindow {
|
||||
recyclerView = findViewById(R.id.giftList);
|
||||
adapter = new LiveFansGroupSendGiftAdapter(mContext);
|
||||
adapter.setOnItemClickListener((bean, position) -> {
|
||||
LiveHttpUtil.sendGift("0",
|
||||
LiveHttpUtil.sendGiftForFansGroup("0",
|
||||
liveUid,
|
||||
mStream,
|
||||
bean.getId(),
|
||||
|
@ -129,7 +129,7 @@ public class LiveGiftPopup extends AbsDialogFragment {
|
||||
private MarqueeTextView giftDescription, namingName;
|
||||
private boolean isPk;
|
||||
|
||||
private FragmentTransaction transaction=null;
|
||||
private FragmentTransaction transaction = null;
|
||||
private FragmentManager fragmentManager;
|
||||
private Fragment contentFragment;
|
||||
|
||||
@ -137,8 +137,8 @@ public class LiveGiftPopup extends AbsDialogFragment {
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
if(transaction==null){
|
||||
transaction=getChildFragmentManager().beginTransaction();
|
||||
if (transaction == null) {
|
||||
transaction = getChildFragmentManager().beginTransaction();
|
||||
}
|
||||
Bus.getOn(this);
|
||||
initView();
|
||||
@ -243,8 +243,8 @@ public class LiveGiftPopup extends AbsDialogFragment {
|
||||
giftTitleAdapter.uncheck();
|
||||
liveWrap.setAlpha(1.0f);
|
||||
liveWrap.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
|
||||
transaction=getTransaction();
|
||||
contentFragment=LiveParcelFragment.newInstance(mStream, mLiveUid);
|
||||
transaction = getTransaction();
|
||||
contentFragment = LiveParcelFragment.newInstance(mStream, mLiveUid);
|
||||
transaction.replace(R.id.context_layout_gift, contentFragment);
|
||||
transaction.commitAllowingStateLoss();
|
||||
isWrap = true;
|
||||
@ -328,13 +328,13 @@ public class LiveGiftPopup extends AbsDialogFragment {
|
||||
.append(userInfo.getToken())
|
||||
.append("&no_back=1")
|
||||
.append("&type=")
|
||||
.append(blindBoxType-1)
|
||||
.append(blindBoxType - 1)
|
||||
|
||||
.append("&isZh=")
|
||||
.append(WordUtil.isNewZh() ? "1" : 0);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", htmlUrl.toString());
|
||||
// System.out.println("盲盒页面 = "+htmlUrl.toString());
|
||||
// System.out.println("盲盒页面 = "+htmlUrl.toString());
|
||||
LiveHDDialogFragment fragment = new LiveHDDialogFragment();
|
||||
fragment.setArguments(bundle);
|
||||
fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
|
||||
@ -399,7 +399,7 @@ public class LiveGiftPopup extends AbsDialogFragment {
|
||||
.append(userInfo.getId())
|
||||
.append("&token=")
|
||||
.append(userInfo.getToken())
|
||||
.append("&for") .append("&isZh=")
|
||||
.append("&for").append("&isZh=")
|
||||
.append(WordUtil.isNewZh() ? "1" : 0);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", htmlUrl.toString());
|
||||
@ -480,8 +480,8 @@ public class LiveGiftPopup extends AbsDialogFragment {
|
||||
List<LiveGiftBean> liveGiftBeans = JSONArray.parseArray(giftJson, LiveGiftBean.class);
|
||||
for (LiveGiftBean model : liveGiftBeans) {
|
||||
if (TextUtils.equals(model.getId() + "", mWishGiftId)) {
|
||||
transaction=getTransaction();
|
||||
contentFragment=LiveGiftFragment.newInstance(giftJson,
|
||||
transaction = getTransaction();
|
||||
contentFragment = LiveGiftFragment.newInstance(giftJson,
|
||||
liveGiftList.getJSONObject(i).getString("name"),
|
||||
mStream, mLiveUid, mWishGiftId);
|
||||
transaction.replace(R.id.context_layout_gift, contentFragment);
|
||||
@ -495,11 +495,11 @@ public class LiveGiftPopup extends AbsDialogFragment {
|
||||
|
||||
JSONObject obj2 = liveGiftList.getJSONObject(0);
|
||||
String giftJson = obj2.getString("giftlist");
|
||||
transaction=getTransaction();
|
||||
contentFragment= LiveGiftFragment.newInstance(giftJson,
|
||||
transaction = getTransaction();
|
||||
contentFragment = LiveGiftFragment.newInstance(giftJson,
|
||||
liveGiftList.getJSONObject(0).getString("name"),
|
||||
mStream, mLiveUid, mWishGiftId);
|
||||
transaction.replace(R.id.context_layout_gift,contentFragment);
|
||||
transaction.replace(R.id.context_layout_gift, contentFragment);
|
||||
transaction.commitAllowingStateLoss();
|
||||
}
|
||||
|
||||
@ -620,7 +620,11 @@ public class LiveGiftPopup extends AbsDialogFragment {
|
||||
if (isWrap && liveGiftModel.getType() == 7) {
|
||||
sendBlindBoxTicket();
|
||||
} else {
|
||||
sendGift();
|
||||
if (liveGiftModel.isPageGift()) {
|
||||
sendGiftForPage();
|
||||
} else {
|
||||
sendGift();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -636,7 +640,7 @@ public class LiveGiftPopup extends AbsDialogFragment {
|
||||
LiveHttpUtil.sendBlindBoxTicket((by != null ? "1" : "0"),
|
||||
mLiveUid,
|
||||
mStream,
|
||||
isWrap ? liveGiftModel.getId() : liveGiftModel.getBlindBoxTicketId(), new HttpCallback() {
|
||||
isWrap ? liveGiftModel.getGift_id() : liveGiftModel.getBlindBoxTicketId(), new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
@ -755,6 +759,16 @@ public class LiveGiftPopup extends AbsDialogFragment {
|
||||
}
|
||||
}
|
||||
|
||||
private void sendGiftForPage() {
|
||||
if (liveGiftModel == null) return;
|
||||
SendGiftCallback callback = new SendGiftCallback(liveGiftModel);
|
||||
if (by != null) {
|
||||
LiveHttpUtil.sendGiftForPage("1", mLiveUid, mStream, liveGiftModel.getGift_id(), mCount, 0, false, callback);
|
||||
} else {
|
||||
LiveHttpUtil.sendGiftForPage("0", mLiveUid, mStream, liveGiftModel.getGift_id(), mCount, 0, false, callback);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到我的钻石
|
||||
*/
|
||||
@ -888,8 +902,8 @@ public class LiveGiftPopup extends AbsDialogFragment {
|
||||
giftNumberLayout.setVisibility(View.INVISIBLE);
|
||||
JSONObject obj2 = liveGiftList.getJSONObject(event.getmPosition());
|
||||
String giftJson = obj2.getString("giftlist");
|
||||
transaction=getTransaction();
|
||||
contentFragment=LiveGiftFragment.newInstance(giftJson, event.getGiftTitle(), mStream, mLiveUid, mWishGiftId);
|
||||
transaction = getTransaction();
|
||||
contentFragment = LiveGiftFragment.newInstance(giftJson, event.getGiftTitle(), mStream, mLiveUid, mWishGiftId);
|
||||
transaction.replace(R.id.context_layout_gift, contentFragment);
|
||||
transaction.commitAllowingStateLoss();
|
||||
isWrap = false;
|
||||
@ -1115,12 +1129,12 @@ public class LiveGiftPopup extends AbsDialogFragment {
|
||||
}
|
||||
if (!TextUtils.isEmpty(event.getDressName()) && !TextUtils.isEmpty(event.getDressMsg())) {
|
||||
SpannableStringBuilder stringBuilder = new SpannableStringBuilder();
|
||||
String boxBlindMsg = String.format(mContext.getString(R.string.random_availability2), WordUtil.isNewZh()?event.getGiftname():event.getGiftname_en(),WordUtil.isNewZh()? event.getDressName():event.getDress_nameen());
|
||||
String boxBlindMsg = String.format(mContext.getString(R.string.random_availability2), WordUtil.isNewZh() ? event.getGiftname() : event.getGiftname_en(), WordUtil.isNewZh() ? event.getDressName() : event.getDress_nameen());
|
||||
stringBuilder.append(boxBlindMsg);
|
||||
int dressNameIndex = boxBlindMsg.indexOf(WordUtil.isNewZh()? event.getDressName():event.getDress_nameen());
|
||||
int dressNameSize =(WordUtil.isNewZh()? event.getDressName():event.getDress_nameen()).length();
|
||||
int giftNameIndex = boxBlindMsg.indexOf(WordUtil.isNewZh()?event.getGiftname():event.getGiftname_en());
|
||||
int giftNameSize = (WordUtil.isNewZh()?event.getGiftname():event.getGiftname_en()).length();
|
||||
int dressNameIndex = boxBlindMsg.indexOf(WordUtil.isNewZh() ? event.getDressName() : event.getDress_nameen());
|
||||
int dressNameSize = (WordUtil.isNewZh() ? event.getDressName() : event.getDress_nameen()).length();
|
||||
int giftNameIndex = boxBlindMsg.indexOf(WordUtil.isNewZh() ? event.getGiftname() : event.getGiftname_en());
|
||||
int giftNameSize = (WordUtil.isNewZh() ? event.getGiftname() : event.getGiftname_en()).length();
|
||||
stringBuilder.setSpan(new ForegroundColorSpan(Color.parseColor(event.getDressColour())),
|
||||
dressNameIndex,
|
||||
dressNameIndex + dressNameSize,
|
||||
@ -1132,11 +1146,11 @@ public class LiveGiftPopup extends AbsDialogFragment {
|
||||
stringBuilders.add(stringBuilder);
|
||||
} else {
|
||||
SpannableStringBuilder stringBuilder = new SpannableStringBuilder();
|
||||
String boxBlindMsg = String.format(mContext.getString(R.string.random_availability3), WordUtil.isNewZh()?event.getGiftname():event.getGiftname_en());
|
||||
String boxBlindMsg = String.format(mContext.getString(R.string.random_availability3), WordUtil.isNewZh() ? event.getGiftname() : event.getGiftname_en());
|
||||
stringBuilder.append(boxBlindMsg);
|
||||
if (!TextUtils.isEmpty(event.getGiftname_en())){
|
||||
int giftNameIndex = boxBlindMsg.indexOf(WordUtil.isNewZh()?event.getGiftname():event.getGiftname_en());
|
||||
int giftNameSize = (WordUtil.isNewZh()?event.getGiftname():event.getGiftname_en()).length();
|
||||
if (!TextUtils.isEmpty(event.getGiftname_en())) {
|
||||
int giftNameIndex = boxBlindMsg.indexOf(WordUtil.isNewZh() ? event.getGiftname() : event.getGiftname_en());
|
||||
int giftNameSize = (WordUtil.isNewZh() ? event.getGiftname() : event.getGiftname_en()).length();
|
||||
stringBuilder.setSpan(new ForegroundColorSpan(Color.parseColor(event.getGiftColour())),
|
||||
giftNameIndex,
|
||||
giftNameIndex + giftNameSize,
|
||||
@ -1446,15 +1460,16 @@ public class LiveGiftPopup extends AbsDialogFragment {
|
||||
}
|
||||
}
|
||||
}
|
||||
private FragmentTransaction getTransaction(){
|
||||
if(contentFragment!=null && transaction!=null){
|
||||
|
||||
private FragmentTransaction getTransaction() {
|
||||
if (contentFragment != null && transaction != null) {
|
||||
transaction.remove(contentFragment);
|
||||
contentFragment=null;
|
||||
contentFragment = null;
|
||||
}
|
||||
if(fragmentManager==null){
|
||||
fragmentManager=getChildFragmentManager();
|
||||
if (fragmentManager == null) {
|
||||
fragmentManager = getChildFragmentManager();
|
||||
}
|
||||
transaction=fragmentManager.beginTransaction();
|
||||
transaction = fragmentManager.beginTransaction();
|
||||
return transaction;
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import android.os.Build;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.ValueCallback;
|
||||
@ -234,12 +235,25 @@ public class CustomerServiceWebViewActivity extends AbsActivity {
|
||||
}
|
||||
|
||||
protected boolean canGoBack() {
|
||||
return mWebView != null && mWebView.canGoBack();
|
||||
// return mWebView != null && mWebView.canGoBack();
|
||||
ToastUtil.showDebug("2调用js userBackShowPraise");
|
||||
mWebView.loadUrl("javascript:userBackShowPraise()");
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
// finish();
|
||||
ToastUtil.showDebug("调用js userBackShowPraise");
|
||||
mWebView.loadUrl("javascript:userBackShowPraise()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
finish();
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if(keyCode==KeyEvent.KEYCODE_ESCAPE || keyCode==KeyEvent.KEYCODE_BACK){
|
||||
onBackPressed();
|
||||
return false;
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -388,7 +388,8 @@ public class EntryActivity extends AppCompatActivity {
|
||||
public void onClick(View v) {
|
||||
if (!"".equals(kefuUrl)) {
|
||||
Constants.LoginKefu = true;
|
||||
WebViewActivity.forward(EntryActivity.this, kefuUrl, false);
|
||||
// WebViewActivity.forward(EntryActivity.this, kefuUrl, false);
|
||||
RouteUtil.forwardCustomerService(kefuUrl);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -0,0 +1,443 @@
|
||||
package com.yunbao.main.fragment;
|
||||
|
||||
import static android.content.Context.CLIPBOARD_SERVICE;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.CookieManager;
|
||||
import android.webkit.ValueCallback;
|
||||
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 androidx.annotation.RequiresApi;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.momo.mcamera.util.JsonUtil;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.HtmlConfig;
|
||||
import com.yunbao.common.bean.CoolConfig;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.common.bean.NativeCallbackModel;
|
||||
import com.yunbao.common.dialog.CinemaTicketPopupWindow;
|
||||
import com.yunbao.common.event.JavascriptInterfaceEvent;
|
||||
import com.yunbao.common.fragment.BaseFragment;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.LiveHttpUtil;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DeviceUtils;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.JavascriptInterfacePlayLetUtils;
|
||||
import com.yunbao.common.utils.JavascriptInterfaceUtils;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.views.LoadingView;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.activity.MainActivity;
|
||||
import com.yunbao.main.activity.MyWalletActivity;
|
||||
import com.yunbao.main.dialog.EncourageDialog;
|
||||
import com.yunbao.main.utils.BottomBarUtil;
|
||||
import com.yunbao.share.ui.SharePopDialog;
|
||||
import com.yunbao.video.activity.VideoPlayActivity;
|
||||
import com.yunbao.video.utils.VideoStorge;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
|
||||
public class MainHomeCommunityFragment extends BaseFragment {
|
||||
private ProgressBar mProgressBar;
|
||||
private WebView mWebView;
|
||||
public final int CHOOSE = 100;//Android 5.0以下的
|
||||
public final int CHOOSE_ANDROID_5 = 200;//Android 5.0以上的
|
||||
public ValueCallback<Uri> mValueCallback;
|
||||
public ValueCallback<Uri[]> mValueCallback2;
|
||||
private MainActivity nowMainActivity;
|
||||
Context mContext;
|
||||
|
||||
public MainHomeCommunityFragment(MainActivity nowMainActivity) {
|
||||
super();
|
||||
this.nowMainActivity=nowMainActivity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||
return inflater.inflate(R.layout.view_main_encourage, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initVariables(Bundle bundle) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews(Bundle savedInstanceState, View contentView) {
|
||||
//Bus.getOn(MainHomeCommunityFragment.this);
|
||||
mContext = contentView.getContext();
|
||||
nowMainActivity= (MainActivity) mContext;
|
||||
String url = HtmlConfig.ENCOURAGE + "?t=" + Math.random() + "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()
|
||||
+ "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0");
|
||||
// String url = "https://api.coolydrama.com/?agentCode=186279";
|
||||
final LinearLayout rootView = (LinearLayout) findViewById(R.id.rootView);
|
||||
mProgressBar = (ProgressBar) findViewById(R.id.progressbar);
|
||||
mWebView = new WebView(mContext);
|
||||
int aa = BottomBarUtil.getNavigationBarHeightIfRoom(mContext);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
params.topMargin = DpUtil.dp2px(1);
|
||||
mWebView.setLayoutParams(params);
|
||||
mWebView.setOverScrollMode(View.OVER_SCROLL_NEVER);
|
||||
|
||||
LoadingView loadingView = new LoadingView(mContext);
|
||||
loadingView.show();
|
||||
|
||||
rootView.addView(loadingView);
|
||||
|
||||
mWebView.getSettings().setJavaScriptEnabled(true);
|
||||
mWebView.getSettings().setDomStorageEnabled(true);
|
||||
CookieManager cookieManager = CookieManager.getInstance();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
cookieManager.setAcceptThirdPartyCookies(mWebView, true);
|
||||
} else {
|
||||
cookieManager.setAcceptCookie(true);
|
||||
}
|
||||
String appCachePath = mContext.getCacheDir().getAbsolutePath();
|
||||
// mWebView.getSettings().setAppCachePath(appCachePath);
|
||||
mWebView.getSettings().setAllowFileAccess(true);
|
||||
mWebView.getSettings().setUseWideViewPort(true); // 关键点
|
||||
mWebView.getSettings().setAllowFileAccess(true); // 允许访问文件
|
||||
mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);// 不加载缓存内容
|
||||
|
||||
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
|
||||
mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(nowMainActivity, mWebView), "androidObject");
|
||||
//短剧
|
||||
// mWebView.addJavascriptInterface(JavascriptInterfacePlayLetUtils.getInstance().setmContext(nowMainActivity, mWebView), "jsBridge");
|
||||
mWebView.getSettings().setSupportMultipleWindows(true);
|
||||
rootView.addView(mWebView);
|
||||
|
||||
mWebView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
L.e("H5-------->" + url);
|
||||
if (url.startsWith(Constants.COPY_PREFIX)) {
|
||||
String content = url.substring(Constants.COPY_PREFIX.length());
|
||||
if (!TextUtils.isEmpty(content)) {
|
||||
copy(content);
|
||||
}
|
||||
} else {
|
||||
view.loadUrl(url);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
super.onPageFinished(view, url);
|
||||
setTitle(view.getTitle());
|
||||
if (url.contains("for")) {
|
||||
mWebView.loadUrl("javascript:goAnchorTab()");
|
||||
}
|
||||
|
||||
String userAgent = "shixinzhang";
|
||||
String js = "window.localStorage.setItem('userAgent','" + userAgent + "');";
|
||||
String jsUrl = "javascript:(function({ var localStorage = window.localStorage; localStorage.setItem('userAgent','" + userAgent + "') })()";
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
view.evaluateJavascript(js, null);
|
||||
} else {
|
||||
view.loadUrl(jsUrl);
|
||||
view.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
mWebView.setWebChromeClient(new WebChromeClient() {
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
if (newProgress == 100) {
|
||||
loadingView.hide();
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
loadingView.show();
|
||||
mProgressBar.setProgress(newProgress);
|
||||
}
|
||||
}
|
||||
|
||||
//以下是在各个Android版本中 WebView调用文件选择器的方法
|
||||
// For Android < 3.0
|
||||
public void openFileChooser(ValueCallback<Uri> valueCallback) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
// For Android >= 3.0
|
||||
public void openFileChooser(ValueCallback valueCallback, String acceptType) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
//For Android >= 4.1
|
||||
public void openFileChooser(ValueCallback<Uri> valueCallback,
|
||||
String acceptType, String capture) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
// For Android >= 5.0
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public boolean onShowFileChooser(WebView webView,
|
||||
ValueCallback<Uri[]> filePathCallback,
|
||||
FileChooserParams fileChooserParams) {
|
||||
mValueCallback2 = filePathCallback;
|
||||
WebChromeClient.FileChooserParams mFileChooserParams;
|
||||
mFileChooserParams = fileChooserParams;
|
||||
String at = Arrays.toString(mFileChooserParams.getAcceptTypes());
|
||||
String type;
|
||||
if (at.contains("image/")) {//图片
|
||||
type = "image/*";
|
||||
} else if (at.contains("video/")) {
|
||||
type = "video/*";
|
||||
} else {
|
||||
type = "*/*";
|
||||
}
|
||||
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.setType(type);
|
||||
nowMainActivity.startActivityMain2(intent, CHOOSE_ANDROID_5);
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
}
|
||||
mWebView.loadUrl(url);
|
||||
findViewById(R.id.native_callback).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void setTitle(String title) {
|
||||
TextView titleView = (TextView) findViewById(R.id.titleView);
|
||||
if (titleView != null) {
|
||||
titleView.setText(title);
|
||||
}
|
||||
}
|
||||
|
||||
private void gotoLive(final String live_id) {
|
||||
LiveHttpUtil.getLiveInfo(live_id + "", new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
|
||||
|
||||
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
|
||||
@Override
|
||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckError(String contextError) {
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
||||
RouteUtil.forwardUserHome(mContext, String.valueOf(live_id), 0);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void openImageChooserActivity(ValueCallback<Uri> valueCallback) {
|
||||
mValueCallback = valueCallback;
|
||||
Intent intent = new Intent();
|
||||
if (Build.VERSION.SDK_INT < 19) {
|
||||
intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||
} else {
|
||||
intent.setAction(Intent.ACTION_PICK);
|
||||
intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
}
|
||||
intent.setType("image/*");
|
||||
nowMainActivity.startActivityMain(Intent.createChooser(intent, mContext.getString(R.string.choose_flie)), CHOOSE);
|
||||
// startActivityForResult(Intent.createChooser(intent,mContext.getString(R.string.choose_flie)), CHOOSE);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
// Bus.getOff(MainHomeCommunityFragment.this);
|
||||
if (mWebView != null) {
|
||||
ViewGroup parent = (ViewGroup) mWebView.getParent();
|
||||
if (parent != null) {
|
||||
parent.removeView(mWebView);
|
||||
}
|
||||
mWebView.reload();
|
||||
mWebView.destroy();
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制到剪贴板
|
||||
*/
|
||||
private void copy(String content) {
|
||||
ClipboardManager cm = (ClipboardManager) mContext.getSystemService(CLIPBOARD_SERVICE);
|
||||
ClipData clipData = ClipData.newPlainText("text", content);
|
||||
cm.setPrimaryClip(clipData);
|
||||
ToastUtil.show(mContext.getString(R.string.copy_success));
|
||||
}
|
||||
|
||||
public void closeFinger() {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
mWebView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String method = "Left()";//拼接参数,就可以把数据传递给js
|
||||
mWebView.evaluateJavascript(method, new ValueCallback<String>() {
|
||||
@Override
|
||||
public void onReceiveValue(String value) {
|
||||
Log.i("Log", "Left()js返回" + value);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mWebView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mWebView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
super.onPageFinished(view, url);
|
||||
mWebView.loadUrl("javascript:Left()");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onJavascriptInterfaceEvent2(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(), "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());
|
||||
} else if (TextUtils.equals(event.getMethod(), "isCloseNavigation")) {
|
||||
if (nowMainActivity != null) {
|
||||
nowMainActivity.isClose(event.getIsClose());
|
||||
}
|
||||
} else if (TextUtils.equals(event.getMethod(), "androidCommunityShare")) {
|
||||
JSONObject json = JSONObject.parseObject(event.getData());
|
||||
new SharePopDialog(mContext)
|
||||
.setShareLink(CommonAppConfig.HOST + json.getString("link"))
|
||||
.setAnchorAvatar(json.getString("avatar"))
|
||||
.showDialog();
|
||||
} else if (TextUtils.equals(event.getMethod(), "postWeakBalance")) {
|
||||
LiveNetManager.get(mContext).
|
||||
getCoolConfig(new com.yunbao.common.http.base.HttpCallback<CoolConfig>() {
|
||||
@Override
|
||||
public void onSuccess(CoolConfig data) {
|
||||
new XPopup.Builder(mContext)
|
||||
.enableDrag(false)
|
||||
.autoOpenSoftInput(false)
|
||||
.maxWidth(DeviceUtils.getScreenHeight((Activity) mContext) - DpUtil.dp2px(34))
|
||||
.asCustom(new CinemaTicketPopupWindow(mContext, data.setTicketCount(event.getCoolConfig().getTicketCount()), new CinemaTicketPopupWindow.CinemaTicketPopupWindowCallBack() {
|
||||
@Override
|
||||
public void onCallBack(String data) {
|
||||
if (TextUtils.equals(data, "2")) {
|
||||
DialogUitl.showSimpleDialog(mContext, mContext.getString(com.yunbao.live.R.string.live_coin_not_enough), false,
|
||||
new DialogUitl.SimpleCallback2() {
|
||||
@Override
|
||||
public void onConfirmClick(Dialog dialog, String content) {
|
||||
mContext.startActivity(new Intent(mContext, MyWalletActivity.class).putExtra("p", 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancelClick() {
|
||||
|
||||
}
|
||||
});
|
||||
} else if (TextUtils.equals(data, "1")) {
|
||||
ToastUtil.show(WordUtil.isNewZh() ? "兑换成功" : "Successful exchange");
|
||||
mWebView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
NativeCallbackModel model = new NativeCallbackModel();
|
||||
model.setUid(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()));
|
||||
String nativeJson = new JsonUtil().toJson(model);
|
||||
mWebView.evaluateJavascript("javascript:nativeCallback('" + nativeJson + "')", new ValueCallback<String>() {
|
||||
@Override
|
||||
public void onReceiveValue(String value) {
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
})).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadData() {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,200 @@
|
||||
package com.yunbao.main.fragment;
|
||||
|
||||
import static android.content.Context.CLIPBOARD_SERVICE;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.CookieManager;
|
||||
import android.webkit.ValueCallback;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.momo.mcamera.util.JsonUtil;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.CoolConfig;
|
||||
import com.yunbao.common.bean.NativeCallbackModel;
|
||||
import com.yunbao.common.dialog.CinemaTicketPopupWindow;
|
||||
import com.yunbao.common.event.JavascriptInterfaceEvent;
|
||||
import com.yunbao.common.fragment.BaseFragment;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.LiveHttpUtil;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.DeviceUtils;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.JavascriptInterfacePlayLetUtils;
|
||||
import com.yunbao.common.utils.JavascriptInterfaceUtils;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.activity.MyWalletActivity;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class MainHomeCommunityVideoFragment extends BaseFragment {
|
||||
WebView mWebView;
|
||||
private Context mContext;
|
||||
|
||||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||
return inflater.inflate(R.layout.view_main_community_video, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initVariables(Bundle bundle) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews(Bundle savedInstanceState, View contentView) {
|
||||
mContext = getActivity();
|
||||
mWebView = findViewById(R.id.webView);
|
||||
mWebView.getSettings().setJavaScriptEnabled(true);
|
||||
mWebView.getSettings().setDomStorageEnabled(true);
|
||||
CookieManager cookieManager = CookieManager.getInstance();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
cookieManager.setAcceptThirdPartyCookies(mWebView, true);
|
||||
} else {
|
||||
cookieManager.setAcceptCookie(true);
|
||||
}
|
||||
mWebView.getSettings().setAllowFileAccess(true);
|
||||
mWebView.getSettings().setUseWideViewPort(true); // 关键点
|
||||
mWebView.getSettings().setAllowFileAccess(true); // 允许访问文件
|
||||
mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);// 不加载缓存内容
|
||||
|
||||
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
|
||||
//短剧
|
||||
mWebView.addJavascriptInterface(JavascriptInterfacePlayLetUtils.getInstance().setmContext(getActivity(), mWebView), "jsBridge");
|
||||
mWebView.getSettings().setSupportMultipleWindows(true);
|
||||
|
||||
mWebView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
L.e("H5-------->" + url);
|
||||
if (url.startsWith(Constants.COPY_PREFIX)) {
|
||||
String content = url.substring(Constants.COPY_PREFIX.length());
|
||||
if (!TextUtils.isEmpty(content)) {
|
||||
copy(content);
|
||||
}
|
||||
} else {
|
||||
view.loadUrl(url);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
super.onPageFinished(view, url);
|
||||
if (url.contains("for")) {
|
||||
mWebView.loadUrl("javascript:goAnchorTab()");
|
||||
}
|
||||
|
||||
String userAgent = "shixinzhang";
|
||||
String js = "window.localStorage.setItem('userAgent','" + userAgent + "');";
|
||||
String jsUrl = "javascript:(function({ var localStorage = window.localStorage; localStorage.setItem('userAgent','" + userAgent + "') })()";
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
view.evaluateJavascript(js, null);
|
||||
} else {
|
||||
view.loadUrl(jsUrl);
|
||||
view.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void copy(String content) {
|
||||
ClipboardManager cm = (ClipboardManager) getActivity().getSystemService(CLIPBOARD_SERVICE);
|
||||
ClipData clipData = ClipData.newPlainText("text", content);
|
||||
cm.setPrimaryClip(clipData);
|
||||
ToastUtil.show(getActivity().getString(R.string.copy_success));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadData() {
|
||||
LiveHttpUtil.getCoolydrama(new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
System.out.println("code = " + code + ", msg = " + msg + ", info = " + Arrays.toString(info));
|
||||
if (code == 0) {
|
||||
mWebView.loadUrl(JSONObject.parseObject(info[0]).getString("url"));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onJavascriptInterfaceEvent2(JavascriptInterfaceEvent event) {
|
||||
if (TextUtils.equals(event.getMethod(), "postWeakBalance")) {
|
||||
LiveNetManager.get(mContext).
|
||||
getCoolConfig(new com.yunbao.common.http.base.HttpCallback<CoolConfig>() {
|
||||
@Override
|
||||
public void onSuccess(CoolConfig data) {
|
||||
new XPopup.Builder(mContext)
|
||||
.enableDrag(false)
|
||||
.autoOpenSoftInput(false)
|
||||
.maxWidth(DeviceUtils.getScreenHeight((Activity) mContext) - DpUtil.dp2px(34))
|
||||
.asCustom(new CinemaTicketPopupWindow(mContext, data.setTicketCount(event.getCoolConfig().getTicketCount()), new CinemaTicketPopupWindow.CinemaTicketPopupWindowCallBack() {
|
||||
@Override
|
||||
public void onCallBack(String data) {
|
||||
if (TextUtils.equals(data, "2")) {
|
||||
DialogUitl.showSimpleDialog(mContext, mContext.getString(com.yunbao.live.R.string.live_coin_not_enough), false,
|
||||
new DialogUitl.SimpleCallback2() {
|
||||
@Override
|
||||
public void onConfirmClick(Dialog dialog, String content) {
|
||||
mContext.startActivity(new Intent(mContext, MyWalletActivity.class).putExtra("p", 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancelClick() {
|
||||
|
||||
}
|
||||
});
|
||||
} else if (TextUtils.equals(data, "1")) {
|
||||
ToastUtil.show(WordUtil.isNewZh() ? "兑换成功" : "Successful exchange");
|
||||
mWebView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
NativeCallbackModel model = new NativeCallbackModel();
|
||||
model.setUid(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()));
|
||||
String nativeJson = new JsonUtil().toJson(model);
|
||||
mWebView.evaluateJavascript("javascript:nativeCallback('" + nativeJson + "')", new ValueCallback<String>() {
|
||||
@Override
|
||||
public void onReceiveValue(String value) {
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
})).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
@ -27,7 +28,15 @@ import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@ -38,10 +47,12 @@ import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.HtmlConfig;
|
||||
import com.yunbao.common.bean.CoolConfig;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.common.bean.LiveClassBean;
|
||||
import com.yunbao.common.bean.NativeCallbackModel;
|
||||
import com.yunbao.common.dialog.CinemaTicketPopupWindow;
|
||||
import com.yunbao.common.dialog.WarOrderExchangeDetailsPopupWindow;
|
||||
import com.yunbao.common.event.JavascriptInterfaceEvent;
|
||||
import com.yunbao.common.fragment.BaseFragment;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.LiveHttpUtil;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
@ -62,16 +73,33 @@ import com.yunbao.live.views.LoadingView;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.activity.MainActivity;
|
||||
import com.yunbao.main.activity.MyWalletActivity;
|
||||
import com.yunbao.main.adapter.MainHomeLivesClassAdapter;
|
||||
import com.yunbao.main.dialog.EncourageDialog;
|
||||
import com.yunbao.main.fragment.BattlePassRewardFragment;
|
||||
import com.yunbao.main.fragment.MainHomeCommunityFragment;
|
||||
import com.yunbao.main.fragment.MainHomeCommunityVideoFragment;
|
||||
import com.yunbao.main.fragment.SearchResultsFragment;
|
||||
import com.yunbao.main.utils.BottomBarUtil;
|
||||
import com.yunbao.share.ui.SharePopDialog;
|
||||
import com.yunbao.video.activity.VideoPlayActivity;
|
||||
import com.yunbao.video.utils.VideoStorge;
|
||||
|
||||
import net.lucode.hackware.magicindicator.MagicIndicator;
|
||||
import net.lucode.hackware.magicindicator.ViewPagerHelper;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerIndicator;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerTitleView;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.ColorTransitionPagerTitleView;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.SimplePagerTitleView;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
@ -88,359 +116,156 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl
|
||||
public ValueCallback<Uri> mValueCallback;
|
||||
public ValueCallback<Uri[]> mValueCallback2;
|
||||
private MainActivity nowMainActivity;
|
||||
List<BaseFragment> fragments;
|
||||
ViewPager2 viewPager;
|
||||
private MagicIndicator mIndicator;
|
||||
|
||||
|
||||
public MainHomeCommunityViewHolder(Context context, ViewGroup parentView, MainActivity mainActivity) {
|
||||
super(context, parentView);
|
||||
mContext = context;
|
||||
nowMainActivity = mainActivity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.view_main_encourage;
|
||||
return R.layout.view_main_community;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
Bus.getOn(this);
|
||||
String url = HtmlConfig.ENCOURAGE + "?t=" + Math.random() + "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()
|
||||
+ "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0");
|
||||
// String url = "https://api.coolydrama.com/?agentCode=186279";
|
||||
final LinearLayout rootView = (LinearLayout) findViewById(R.id.rootView);
|
||||
mProgressBar = (ProgressBar) findViewById(R.id.progressbar);
|
||||
mWebView = new WebView(mContext);
|
||||
int aa = BottomBarUtil.getNavigationBarHeightIfRoom(mContext);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
params.topMargin = DpUtil.dp2px(1);
|
||||
mWebView.setLayoutParams(params);
|
||||
mWebView.setOverScrollMode(View.OVER_SCROLL_NEVER);
|
||||
|
||||
LoadingView loadingView = new LoadingView(mContext);
|
||||
loadingView.show();
|
||||
|
||||
rootView.addView(loadingView);
|
||||
|
||||
mWebView.getSettings().setJavaScriptEnabled(true);
|
||||
mWebView.getSettings().setDomStorageEnabled(true);
|
||||
CookieManager cookieManager = CookieManager.getInstance();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
cookieManager.setAcceptThirdPartyCookies(mWebView, true);
|
||||
} else {
|
||||
cookieManager.setAcceptCookie(true);
|
||||
}
|
||||
String appCachePath = mContext.getCacheDir().getAbsolutePath();
|
||||
// mWebView.getSettings().setAppCachePath(appCachePath);
|
||||
mWebView.getSettings().setAllowFileAccess(true);
|
||||
mWebView.getSettings().setUseWideViewPort(true); // 关键点
|
||||
mWebView.getSettings().setAllowFileAccess(true); // 允许访问文件
|
||||
mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);// 不加载缓存内容
|
||||
|
||||
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
|
||||
mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(nowMainActivity, mWebView), "androidObject");
|
||||
//短剧
|
||||
mWebView.addJavascriptInterface(JavascriptInterfacePlayLetUtils.getInstance().setmContext(nowMainActivity, mWebView), "jsBridge");
|
||||
mWebView.getSettings().setSupportMultipleWindows(true);
|
||||
rootView.addView(mWebView);
|
||||
|
||||
mWebView.setWebViewClient(new WebViewClient() {
|
||||
mIndicator = (MagicIndicator) findViewById(R.id.indicator);
|
||||
viewPager = (ViewPager2) findViewById(R.id.community_viewpager);
|
||||
fragments = new ArrayList<>();
|
||||
fragments.add(new MainHomeCommunityFragment(nowMainActivity));
|
||||
fragments.add(new MainHomeCommunityVideoFragment());
|
||||
viewPager.setAdapter(new FragmentStateAdapter(((AppCompatActivity) mContext)) {
|
||||
@NonNull
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
L.e("H5-------->" + url);
|
||||
if (url.startsWith(Constants.COPY_PREFIX)) {
|
||||
String content = url.substring(Constants.COPY_PREFIX.length());
|
||||
if (!TextUtils.isEmpty(content)) {
|
||||
copy(content);
|
||||
public Fragment createFragment(int position) {
|
||||
return fragments.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return fragments.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return super.getItemId(position);
|
||||
}
|
||||
});
|
||||
viewPager.setUserInputEnabled(false);
|
||||
initTab();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
}
|
||||
|
||||
String[] titles;
|
||||
|
||||
private void initTab() {
|
||||
titles = new String[]{"社區", "短劇"};
|
||||
if (!WordUtil.isNewZh()) {
|
||||
titles = new String[]{"Community", "Theater"};
|
||||
}
|
||||
CommonNavigator commonNavigator = new CommonNavigator(mContext);
|
||||
commonNavigator.setAdjustMode(true);
|
||||
commonNavigator.setAdapter(new CommonNavigatorAdapter() {
|
||||
@Override
|
||||
public int getCount() {
|
||||
return titles.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPagerTitleView getTitleView(Context context, int index) {
|
||||
SimplePagerTitleView simplePagerTitleView = new ColorTransitionPagerTitleView(context);
|
||||
simplePagerTitleView.setNormalColor(Color.parseColor("#B1B1B1"));
|
||||
simplePagerTitleView.setSelectedColor(Color.parseColor("#FFC621"));
|
||||
simplePagerTitleView.setText(titles[index]);
|
||||
simplePagerTitleView.setTextSize(18);
|
||||
simplePagerTitleView.getPaint().setFakeBoldText(true);
|
||||
simplePagerTitleView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (viewPager != null) {
|
||||
viewPager.setCurrentItem(index);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
view.loadUrl(url);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
return simplePagerTitleView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
super.onPageFinished(view, url);
|
||||
setTitle(view.getTitle());
|
||||
if (url.contains("for")) {
|
||||
mWebView.loadUrl("javascript:goAnchorTab()");
|
||||
}
|
||||
|
||||
String userAgent = "shixinzhang";
|
||||
String js = "window.localStorage.setItem('userAgent','" + userAgent + "');";
|
||||
String jsUrl = "javascript:(function({ var localStorage = window.localStorage; localStorage.setItem('userAgent','" + userAgent + "') })()";
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
view.evaluateJavascript(js, null);
|
||||
} else {
|
||||
view.loadUrl(jsUrl);
|
||||
view.reload();
|
||||
}
|
||||
public IPagerIndicator getIndicator(Context context) {
|
||||
LinePagerIndicator linePagerIndicator = new LinePagerIndicator(context);
|
||||
linePagerIndicator.setMode(LinePagerIndicator.MODE_WRAP_CONTENT);
|
||||
linePagerIndicator.setXOffset(DpUtil.dp2px(5));
|
||||
linePagerIndicator.setRoundRadius(DpUtil.dp2px(2));
|
||||
linePagerIndicator.setColors(Color.parseColor("#FFC621"));
|
||||
return linePagerIndicator;
|
||||
}
|
||||
});
|
||||
mWebView.setWebChromeClient(new WebChromeClient() {
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
if (newProgress == 100) {
|
||||
loadingView.hide();
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
loadingView.show();
|
||||
mProgressBar.setProgress(newProgress);
|
||||
}
|
||||
}
|
||||
|
||||
//以下是在各个Android版本中 WebView调用文件选择器的方法
|
||||
// For Android < 3.0
|
||||
public void openFileChooser(ValueCallback<Uri> valueCallback) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
// For Android >= 3.0
|
||||
public void openFileChooser(ValueCallback valueCallback, String acceptType) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
//For Android >= 4.1
|
||||
public void openFileChooser(ValueCallback<Uri> valueCallback,
|
||||
String acceptType, String capture) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
// For Android >= 5.0
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public boolean onShowFileChooser(WebView webView,
|
||||
ValueCallback<Uri[]> filePathCallback,
|
||||
FileChooserParams fileChooserParams) {
|
||||
mValueCallback2 = filePathCallback;
|
||||
WebChromeClient.FileChooserParams mFileChooserParams;
|
||||
mFileChooserParams = fileChooserParams;
|
||||
String at = Arrays.toString(mFileChooserParams.getAcceptTypes());
|
||||
String type;
|
||||
if (at.contains("image/")) {//图片
|
||||
type = "image/*";
|
||||
} else if (at.contains("video/")) {
|
||||
type = "video/*";
|
||||
} else {
|
||||
type = "*/*";
|
||||
}
|
||||
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.setType(type);
|
||||
nowMainActivity.startActivityMain2(intent, CHOOSE_ANDROID_5);
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
}
|
||||
mWebView.loadUrl(url);
|
||||
findViewById(R.id.native_callback).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
}
|
||||
});
|
||||
}//战令等级
|
||||
mIndicator.setNavigator(commonNavigator);
|
||||
bind(mIndicator, viewPager);
|
||||
mIndicator.onPageSelected(0);
|
||||
viewPager.setCurrentItem(0);
|
||||
}
|
||||
|
||||
public void loadNewUrl() {
|
||||
}
|
||||
|
||||
|
||||
protected void setTitle(String title) {
|
||||
TextView titleView = (TextView) findViewById(R.id.titleView);
|
||||
if (titleView != null) {
|
||||
titleView.setText(title);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(LiveBean bean, int position) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void gotoLive(final String live_id) {
|
||||
LiveHttpUtil.getLiveInfo(live_id + "", new HttpCallback() {
|
||||
public static void bind(final MagicIndicator magicIndicator, ViewPager2 viewPager) {
|
||||
viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
|
||||
|
||||
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
|
||||
@Override
|
||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckError(String contextError) {
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
||||
RouteUtil.forwardUserHome(mContext, String.valueOf(live_id), 0);
|
||||
}
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
magicIndicator.onPageScrolled(position, positionOffset, positionOffsetPixels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
super.onPageSelected(position);
|
||||
magicIndicator.onPageSelected(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
super.onPageScrollStateChanged(state);
|
||||
magicIndicator.onPageScrollStateChanged(state);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void openImageChooserActivity(ValueCallback<Uri> valueCallback) {
|
||||
mValueCallback = valueCallback;
|
||||
Intent intent = new Intent();
|
||||
if (Build.VERSION.SDK_INT < 19) {
|
||||
intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||
} else {
|
||||
intent.setAction(Intent.ACTION_PICK);
|
||||
intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
}
|
||||
intent.setType("image/*");
|
||||
nowMainActivity.startActivityMain(Intent.createChooser(intent, mContext.getString(R.string.choose_flie)), CHOOSE);
|
||||
// startActivityForResult(Intent.createChooser(intent,mContext.getString(R.string.choose_flie)), CHOOSE);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
Bus.getOff(this);
|
||||
if (mWebView != null) {
|
||||
ViewGroup parent = (ViewGroup) mWebView.getParent();
|
||||
if (parent != null) {
|
||||
parent.removeView(mWebView);
|
||||
}
|
||||
mWebView.reload();
|
||||
mWebView.destroy();
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制到剪贴板
|
||||
*/
|
||||
private void copy(String content) {
|
||||
ClipboardManager cm = (ClipboardManager) mContext.getSystemService(CLIPBOARD_SERVICE);
|
||||
ClipData clipData = ClipData.newPlainText("text", content);
|
||||
cm.setPrimaryClip(clipData);
|
||||
ToastUtil.show(mContext.getString(R.string.copy_success));
|
||||
}
|
||||
|
||||
public void closeFinger() {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
mWebView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String method = "Left()";//拼接参数,就可以把数据传递给js
|
||||
mWebView.evaluateJavascript(method, new ValueCallback<String>() {
|
||||
@Override
|
||||
public void onReceiveValue(String value) {
|
||||
Log.i("Log", "Left()js返回" + value);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mWebView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mWebView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
super.onPageFinished(view, url);
|
||||
mWebView.loadUrl("javascript:Left()");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
BaseFragment fragment = fragments.get(viewPager.getCurrentItem());
|
||||
if (fragment instanceof MainHomeCommunityFragment) {
|
||||
((MainHomeCommunityFragment) fragment).closeFinger();
|
||||
}
|
||||
}
|
||||
|
||||
@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(), "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());
|
||||
} else if (TextUtils.equals(event.getMethod(), "isCloseNavigation")) {
|
||||
if (nowMainActivity != null) {
|
||||
nowMainActivity.isClose(event.getIsClose());
|
||||
}
|
||||
} else if (TextUtils.equals(event.getMethod(), "androidCommunityShare")) {
|
||||
JSONObject json = JSONObject.parseObject(event.getData());
|
||||
new SharePopDialog(mContext)
|
||||
.setShareLink(CommonAppConfig.HOST + json.getString("link"))
|
||||
.setAnchorAvatar(json.getString("avatar"))
|
||||
.showDialog();
|
||||
} else if (TextUtils.equals(event.getMethod(), "postWeakBalance")) {
|
||||
LiveNetManager.get(mContext).
|
||||
getCoolConfig(new com.yunbao.common.http.base.HttpCallback<CoolConfig>() {
|
||||
@Override
|
||||
public void onSuccess(CoolConfig data) {
|
||||
new XPopup.Builder(mContext)
|
||||
.enableDrag(false)
|
||||
.autoOpenSoftInput(false)
|
||||
.maxWidth(DeviceUtils.getScreenHeight((Activity) mContext) - DpUtil.dp2px(34))
|
||||
.asCustom(new CinemaTicketPopupWindow(mContext, data.setTicketCount(event.getCoolConfig().getTicketCount()), new CinemaTicketPopupWindow.CinemaTicketPopupWindowCallBack() {
|
||||
@Override
|
||||
public void onCallBack(String data) {
|
||||
if (TextUtils.equals(data, "2")) {
|
||||
DialogUitl.showSimpleDialog(mContext, mContext.getString(com.yunbao.live.R.string.live_coin_not_enough), false,
|
||||
new DialogUitl.SimpleCallback2() {
|
||||
@Override
|
||||
public void onConfirmClick(Dialog dialog, String content) {
|
||||
mContext.startActivity(new Intent(mContext, MyWalletActivity.class).putExtra("p", 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancelClick() {
|
||||
|
||||
}
|
||||
});
|
||||
} else if (TextUtils.equals(data, "1")) {
|
||||
ToastUtil.show(WordUtil.isNewZh() ? "兑换成功" : "Successful exchange");
|
||||
mWebView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
NativeCallbackModel model = new NativeCallbackModel();
|
||||
model.setUid(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()));
|
||||
String nativeJson = new JsonUtil().toJson(model);
|
||||
mWebView.evaluateJavascript("javascript:nativeCallback('" + nativeJson + "')", new ValueCallback<String>() {
|
||||
@Override
|
||||
public void onReceiveValue(String value) {
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
})).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(error);
|
||||
}
|
||||
});
|
||||
public void setValueCallback2(Uri[] results) {
|
||||
BaseFragment fragment = fragments.get(viewPager.getCurrentItem());
|
||||
if (fragment instanceof MainHomeCommunityFragment) {
|
||||
if (((MainHomeCommunityFragment) fragment).mValueCallback2 == null) {
|
||||
return;
|
||||
}
|
||||
((MainHomeCommunityFragment) fragment).mValueCallback2.onReceiveValue(results);
|
||||
((MainHomeCommunityFragment) fragment).mValueCallback2 = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="100dp"
|
||||
android:gravity="center"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="200dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_marginTop="10dp">
|
||||
|
||||
@ -64,9 +64,10 @@
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="彩鑽之翼(92天)"
|
||||
tools:text="彩鑽之翼(92天)"
|
||||
android:gravity="center"
|
||||
android:layout_gravity="center"
|
||||
android:textColor="#0D21B2"
|
||||
|
29
main/src/main/res/layout/view_main_community.xml
Normal file
29
main/src/main/res/layout/view_main_community.xml
Normal file
@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:paddingTop="36dp"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<net.lucode.hackware.magicindicator.MagicIndicator
|
||||
android:id="@+id/indicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="45dp"
|
||||
android:overScrollMode="never"
|
||||
android:layout_gravity="center"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
</net.lucode.hackware.magicindicator.MagicIndicator>
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/community_viewpager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/indicator" />
|
||||
</LinearLayout>
|
16
main/src/main/res/layout/view_main_community_video.xml
Normal file
16
main/src/main/res/layout/view_main_community_video.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<WebView
|
||||
android:id="@+id/webView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="68dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -1,8 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingTop="36dp">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/rootView"
|
||||
|
Loading…
Reference in New Issue
Block a user