From b9164b6a08c087b1700b8fd41b51d226ce594d8c Mon Sep 17 00:00:00 2001 From: Martin <13046765170@163.com> Date: Thu, 18 Jul 2024 13:19:30 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A4=BC=E7=89=A9=E5=A2=99=20=E7=AC=AC?= =?UTF-8?q?=E4=B8=89=E6=96=B9=E7=99=BB=E5=BD=95-=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunbao/live/bean/LiveReceiveGiftBean.java | 10 +- .../yunbao/live/socket/SocketSwClient.java | 1 + .../live/views/FrameGiftViewHolder.java | 2 +- .../yunbao/live/views/LiveGiftViewHolder.java | 4 +- .../yunbao/main/activity/EntryActivity.java | 145 +++++++++++++----- main/src/main/res/layout/activity_entry.xml | 8 + 6 files changed, 121 insertions(+), 49 deletions(-) diff --git a/live/src/main/java/com/yunbao/live/bean/LiveReceiveGiftBean.java b/live/src/main/java/com/yunbao/live/bean/LiveReceiveGiftBean.java index c876c30c4..975bcdce3 100644 --- a/live/src/main/java/com/yunbao/live/bean/LiveReceiveGiftBean.java +++ b/live/src/main/java/com/yunbao/live/bean/LiveReceiveGiftBean.java @@ -57,7 +57,7 @@ public class LiveReceiveGiftBean extends BaseModel { private boolean isBlindBox = false; private String namingLiveuid; private String namingUid; - private String naming_user_id; + private String namingUserId; private String namingLiveName; private String namingUserName; private String namingLiveAvatar; @@ -90,12 +90,12 @@ public class LiveReceiveGiftBean extends BaseModel { return this; } - public String getNaming_user_id() { - return naming_user_id; + public String getNamingUserId() { + return namingUserId; } - public void setNaming_user_id(String naming_user_id) { - this.naming_user_id = naming_user_id; + public void setNamingUserId(String namingUserId) { + this.namingUserId = namingUserId; } public String getMsg() { diff --git a/live/src/main/java/com/yunbao/live/socket/SocketSwClient.java b/live/src/main/java/com/yunbao/live/socket/SocketSwClient.java index 113e2b776..5da4fae24 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketSwClient.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketSwClient.java @@ -1150,6 +1150,7 @@ public class SocketSwClient { receiveGiftBean.setNamingLiveName(map.getString("naming_live_name")); receiveGiftBean.setNamingUid(map.getString("naming_uid")); receiveGiftBean.setNamingLiveuid(map.getString("naming_liveuid")); + receiveGiftBean.setNamingUserId(map.getString("naming_user_id")); receiveGiftBean.setUser_naming_status(map.getInteger("user_naming_status")); receiveGiftBean.setmLiveUId(mLiveUid); receiveGiftBean.setmTypeBuyGuard(false); diff --git a/live/src/main/java/com/yunbao/live/views/FrameGiftViewHolder.java b/live/src/main/java/com/yunbao/live/views/FrameGiftViewHolder.java index ba5a970dc..4afa6e496 100644 --- a/live/src/main/java/com/yunbao/live/views/FrameGiftViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/FrameGiftViewHolder.java @@ -126,7 +126,7 @@ public class FrameGiftViewHolder extends RecyclerView.ViewHolder { } else { mLoadingLayout.setVisibility(GiftCacheUtil.checkGiftIsDownload(model.getId()) ? View.GONE : View.VISIBLE); } - if(model.isChecked()&& !StringUtil.isEmpty(model.getNamingLiveName())){ + if(model.isChecked()&& !StringUtil.isEmpty(model.getNamingUserName())){ namingLayout.setVisibility(View.VISIBLE); }else{ namingLayout.setVisibility(View.GONE); diff --git a/live/src/main/java/com/yunbao/live/views/LiveGiftViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveGiftViewHolder.java index 80260d17d..0c1328abe 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveGiftViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveGiftViewHolder.java @@ -180,7 +180,7 @@ public class LiveGiftViewHolder extends AbsViewHolder { if (mGiftCount != null && mGiftCount.getVisibility() == View.VISIBLE) { mGiftCount.setVisibility(View.INVISIBLE); } - if(bean.getUid().equals(bean.getNaming_user_id())){ + if(bean.getUid().equals(bean.getNamingUserId())){ if (mStar != null && mStar.getVisibility() != View.VISIBLE) { mStar.setVisibility(View.VISIBLE); } @@ -203,7 +203,7 @@ public class LiveGiftViewHolder extends AbsViewHolder { } mLastGiftKey = bean.getKey(); // if (bean.getUid().equals(bean.getNaming_user_id())) { - if (bean.getUid().equals(bean.getNaming_user_id())) { + if (bean.getUid().equals(bean.getNamingUserId())) { SVGAVideoEntity drawable = null; if(WordUtil.isNewZh()&&LiveRoomViewHolder.drawableTitleCn!=null){ drawable = LiveRoomViewHolder.drawableTitleCn; diff --git a/main/src/main/java/com/yunbao/main/activity/EntryActivity.java b/main/src/main/java/com/yunbao/main/activity/EntryActivity.java index 24c1a7060..12e3a93b9 100644 --- a/main/src/main/java/com/yunbao/main/activity/EntryActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/EntryActivity.java @@ -1,7 +1,10 @@ package com.yunbao.main.activity; +import static com.lzy.okgo.utils.HttpUtils.runOnUiThread; import static com.yunbao.common.CommonAppContext.home_zdy_img_cn; import static com.yunbao.common.CommonAppContext.home_zdy_img_us; +import static com.yunbao.live.presenter.LiveLinkMicPresenter.mContext; +import static com.yunbao.live.views.LivePushSwViewHolder.btn_close; import android.annotation.SuppressLint; import android.app.Activity; @@ -17,12 +20,17 @@ import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.Environment; +import android.os.Handler; import android.provider.Settings; import android.util.Base64; import android.util.Log; import android.view.View; import android.view.Window; import android.view.WindowManager; +import android.webkit.JavascriptInterface; +import android.webkit.WebSettings; +import android.webkit.WebView; +import android.webkit.WebViewClient; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; @@ -127,6 +135,9 @@ public class EntryActivity extends AppCompatActivity { GoogleUtils googleUtils; + private WebView webview; + private WebSettings webSettings; + @Subscribe(threadMode = ThreadMode.MAIN) public void close(String str) { if ("close_login".equals(str)) { @@ -214,6 +225,8 @@ public class EntryActivity extends AppCompatActivity { btn_tip1.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG); btn_tip1.getPaint().setAntiAlias(true); + webview = (WebView) findViewById(R.id.webview); + initView(); btn_tip1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -269,24 +282,7 @@ public class EntryActivity extends AppCompatActivity { if (isBtnClick()) { return; } - timerOutBtn(view); - MainNetManager.get(EntryActivity.this).FaceBookUp(new com.yunbao.common.http.base.HttpCallback() { - @Override - public void onSuccess(FaceBookUpModel data) { - if (data.getType().equals("0")) { - LoginManager.getInstance().logInWithReadPermissions(EntryActivity.this, Arrays.asList("public_profile")); - } else { - WebViewActivity.forward(EntryActivity.this, data.getLink() + "?", false); - } - - } - - @Override - public void onError(String error) { - ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred"); - - } - }); + verfiy(1); } }); @@ -315,8 +311,7 @@ public class EntryActivity extends AppCompatActivity { if (isBtnClick()) { return; } - timerOutBtn(v); - startActivityForResult(googleUtils.getIntent(), 1002); + verfiy(2); } }); @@ -326,8 +321,7 @@ public class EntryActivity extends AppCompatActivity { if (isBtnClick()) { return; } - timerOutBtn(v); - tt_login_button.performClick(); + verfiy(3); } }); @@ -367,18 +361,7 @@ public class EntryActivity extends AppCompatActivity { if (isBtnClick()) { return; } - timerOutBtn(view); - try { - // App-to-app login - Intent loginIntent = LineLoginApi.getLoginIntent(view.getContext(), "1656399535", new LineAuthenticationParams.Builder().scopes(Arrays.asList(Scope.PROFILE)) - // .nonce("") // nonce can be used to improve security - .build()); - startActivityForResult(loginIntent, 1001); - } catch (Exception e) { - Log.e("ERROR", e.toString()); - ToastUtil.show(getResources().getString(R.string.user_login_outtime)); - } - + verfiy(4); } }); @@ -389,13 +372,93 @@ 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); } } }); } + private void verfiy(int loginType){ + this.loginType = loginType; + webview.setVisibility(View.VISIBLE); + } + + private int loginType; // 1:facebook 2:google 3:twitter 4:Line + + private void todo() { + timerOutBtn(); + if (loginType == 1) { + MainNetManager.get(EntryActivity.this).FaceBookUp(new com.yunbao.common.http.base.HttpCallback() { + @Override + public void onSuccess(FaceBookUpModel data) { + if (data.getType().equals("0")) { + LoginManager.getInstance().logInWithReadPermissions(EntryActivity.this, Arrays.asList("public_profile")); + } else { + WebViewActivity.forward(EntryActivity.this, data.getLink() + "?", false); + } + } + + @Override + public void onError(String error) { + ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred"); + } + }); + } else if (loginType == 2) { + startActivityForResult(googleUtils.getIntent(), 1002); + } else if (loginType == 3) { + tt_login_button.performClick(); + } else if (loginType == 4) { + try { + // App-to-app login + Intent loginIntent = LineLoginApi.getLoginIntent(findViewById(R.id.btn_line).getContext(), "1656399535", new LineAuthenticationParams.Builder().scopes(Arrays.asList(Scope.PROFILE)) + // .nonce("") // nonce can be used to improve security + .build()); + startActivityForResult(loginIntent, 1001); + } catch (Exception e) { + Log.e("ERROR", e.toString()); + ToastUtil.show(getResources().getString(R.string.user_login_outtime)); + } + } + } + + + public class JsBridge { + @JavascriptInterface + public void getData(final String Randstr, final String Ticket) { + runOnUiThread(new Runnable() { + @Override + public void run() { + webview.setVisibility(View.GONE); + //跳转 + todo(); + } + }); + } + } + + private void initView() { + webview = (WebView) findViewById(R.id.webview); + webSettings = webview.getSettings(); + webSettings.setUseWideViewPort(true); + webSettings.setLoadWithOverviewMode(true); +// 禁用缓存 + webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); + webview.setWebViewClient(new WebViewClient() { + @Override + public boolean shouldOverrideUrlLoading(WebView view, String url) { + view.loadUrl(url); + return true; + } + }); +// 开启js支持 + webSettings.setJavaScriptEnabled(true); + webview.addJavascriptInterface(new JsBridge(), "jsBridge"); +// 也可以加载本地html(webView.loadUrl("file:///android_asset/xxx.html")) + webview.loadUrl(CommonAppConfig.HOST + "/h5/live/TCaptcha.html" + "?isZh=" + (WordUtil.isNewZh() ? "1" : 0)); + } + + private void getUrl() { MainHttpUtil.getCustomerService(new HttpCallback() { @Override @@ -541,7 +604,7 @@ public class EntryActivity extends AppCompatActivity { Log.d("OpenInstall", "appData.getData()= " + appData.getData()); //获取自定义数据 if (appData.getData() != null && !appData.getData().equals("")) { - if (CommonAppConfig.IS_GOOGLE_PLAY == 1 || CommonAppConfig.IS_GOOGLE_PLAY == 2|| CommonAppConfig.IS_GOOGLE_PLAY == 3) { + if (CommonAppConfig.IS_GOOGLE_PLAY == 1 || CommonAppConfig.IS_GOOGLE_PLAY == 2 || CommonAppConfig.IS_GOOGLE_PLAY == 3) { } else { JSONObject data = JSON.parseObject(appData.getData()); @@ -577,7 +640,7 @@ public class EntryActivity extends AppCompatActivity { */ private void loginBuyThird(LoginData data) { mLoginType = data.getType(); - if (CommonAppConfig.IS_GOOGLE_PLAY == 1 || CommonAppConfig.IS_GOOGLE_PLAY == 2||CommonAppConfig.IS_GOOGLE_PLAY == 3) { + if (CommonAppConfig.IS_GOOGLE_PLAY == 1 || CommonAppConfig.IS_GOOGLE_PLAY == 2 || CommonAppConfig.IS_GOOGLE_PLAY == 3) { mPromoCode = ""; } MainHttpUtil.loginByThird(UserID, data.getOpenID(), mPromoCode, mUuidDevice, data.getNickName(), data.getAvatar(), data.getType(), new HttpCallback() { @@ -625,7 +688,7 @@ public class EntryActivity extends AppCompatActivity { public void callback(UserBean bean) { if (mFirstLogin) { - if (CommonAppConfig.IS_GOOGLE_PLAY == 1 || CommonAppConfig.IS_GOOGLE_PLAY == 2|| CommonAppConfig.IS_GOOGLE_PLAY == 3) { + if (CommonAppConfig.IS_GOOGLE_PLAY == 1 || CommonAppConfig.IS_GOOGLE_PLAY == 2 || CommonAppConfig.IS_GOOGLE_PLAY == 3) { EntryActivity.this.startActivity(new Intent(EntryActivity.this, OneLoginActivity.class)); } else { HttpClient.getInstance().post("Home.getRandJoinAnchor", "Home.getRandJoinAnchor").execute(new HttpCallback() { @@ -671,8 +734,8 @@ public class EntryActivity extends AppCompatActivity { } new LiveRoomCheckLivePresenter(activity, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() { @Override - public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) { - RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal),isSw); + public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk, boolean isSw) { + RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal), isSw); } @Override @@ -690,7 +753,7 @@ public class EntryActivity extends AppCompatActivity { }); } - private void timerOutBtn(View btn) { + private void timerOutBtn() { if (mBtnClick) { return; } diff --git a/main/src/main/res/layout/activity_entry.xml b/main/src/main/res/layout/activity_entry.xml index 5b74e59a5..a7f45aa2f 100644 --- a/main/src/main/res/layout/activity_entry.xml +++ b/main/src/main/res/layout/activity_entry.xml @@ -295,4 +295,12 @@ android:layout_marginTop="80dp" android:src="@mipmap/white_logo" /> + + + \ No newline at end of file