From 92e435f6b6193a6dc8fa5cf7373c0aa21e71767a Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Thu, 6 Oct 2022 14:08:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0FacebookSDK=E7=89=88=E6=9C=AC?= =?UTF-8?q?=20=E4=BF=AE=E5=A4=8DFacebook=E7=99=BB=E5=BD=95=E6=88=90?= =?UTF-8?q?=E5=8A=9F=E5=90=8E=E6=97=A0=E5=8F=8D=E5=BA=94=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20=E7=AC=AC=E4=B8=89=E6=96=B9=E7=99=BB=E5=BD=95=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E4=B8=89=E7=A7=92=E5=86=85=E4=B8=8D=E5=85=81=E8=AE=B8?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E7=82=B9=E5=87=BB=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/build.gradle | 4 +- .../yunbao/main/activity/EntryActivity.java | 82 +++++++++++++++++-- 2 files changed, 76 insertions(+), 10 deletions(-) diff --git a/common/build.gradle b/common/build.gradle index ebeb7bafd..fd0dd39a6 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -163,8 +163,8 @@ dependencies { api 'cn.rongcloud.sdk:im_kit:5.2.5' // 即时通讯 UI 基础组件 //融云小视频模块 api 'cn.rongcloud.sdk:sight:5.2.5' - api 'com.facebook.android:facebook-android-sdk:11.3.0' - implementation 'com.facebook.android:facebook-android-sdk:[8,9)' + api 'com.facebook.android:facebook-android-sdk:15.0.1' + implementation 'com.facebook.android:facebook-android-sdk:15.0.1' api('com.twitter.sdk.android:twitter-core:3.1.1@aar') { transitive = true 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 ae6a9b35b..90048e41a 100644 --- a/main/src/main/java/com/yunbao/main/activity/EntryActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/EntryActivity.java @@ -29,6 +29,7 @@ import android.widget.LinearLayout; import android.widget.TextView; import android.widget.VideoView; +import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import com.adjust.sdk.Adjust; @@ -43,6 +44,7 @@ import com.facebook.CallbackManager; import com.facebook.FacebookCallback; import com.facebook.FacebookException; import com.facebook.Profile; +import com.facebook.ProfileTracker; import com.facebook.login.LoginManager; import com.facebook.login.LoginResult; import com.fm.openinstall.OpenInstall; @@ -101,6 +103,8 @@ import org.greenrobot.eventbus.ThreadMode; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Arrays; +import java.util.Timer; +import java.util.TimerTask; /** @@ -124,6 +128,7 @@ public class EntryActivity extends AppCompatActivity { private GoogleSignInClient mGoogleSignInClient; private LinearLayout lt_btn_twitter, lt_btn_facebook, lt_customer; private String kefuUrl = ""; + private boolean mBtnClick = false; @Subscribe(threadMode = ThreadMode.MAIN) public void close(String str) { @@ -266,6 +271,10 @@ public class EntryActivity extends AppCompatActivity { lt_btn_facebook.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { + if (isBtnClick()) { + return; + } + timerOutBtn(view); AdjustEvent adjustEvent = new AdjustEvent("umk7ri"); Adjust.trackEvent(adjustEvent); CommonHttpUtil.setAdvertisingChannels("umk7ri", new HttpCallback() { @@ -295,7 +304,7 @@ public class EntryActivity extends AppCompatActivity { } }); - LoginManager.getInstance().logInWithReadPermissions(EntryActivity.this, Arrays.asList("public_profile")); + // LoginManager.getInstance().logInWithReadPermissions(EntryActivity.this, Arrays.asList("public_profile")); // MainNetManager.get(EntryActivity.this) // .FaceBookUp(new com.yunbao.common.http.base.HttpCallback() { // @Override @@ -340,6 +349,10 @@ public class EntryActivity extends AppCompatActivity { btn_google.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + if (isBtnClick()) { + return; + } + timerOutBtn(v); AdjustEvent adjustEvent = new AdjustEvent("iqd6b7"); Adjust.trackEvent(adjustEvent); CommonHttpUtil.setAdvertisingChannels("iqd6b7", new HttpCallback() { @@ -359,6 +372,10 @@ public class EntryActivity extends AppCompatActivity { lt_btn_twitter.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + if (isBtnClick()) { + return; + } + timerOutBtn(v); AdjustEvent adjustEvent = new AdjustEvent("le2qca"); Adjust.trackEvent(adjustEvent); CommonHttpUtil.setAdvertisingChannels("le2qca", new HttpCallback() { @@ -407,6 +424,10 @@ public class EntryActivity extends AppCompatActivity { findViewById(R.id.btn_line).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { + if (isBtnClick()) { + return; + } + timerOutBtn(view); try { AdjustEvent adjustEvent = new AdjustEvent("gev462"); Adjust.trackEvent(adjustEvent); @@ -571,16 +592,42 @@ public class EntryActivity extends AppCompatActivity { private void updateUI() { boolean enableButtons = AccessToken.getCurrentAccessToken() != null; Profile profile = Profile.getCurrentProfile(); - if (enableButtons && profile != null) { - LoginData data = new LoginData(); - data.setAvatar(profile.getProfilePictureUri(150, 150).toString()); - data.setNickName(profile.getName()); - data.setOpenID(AccessToken.getCurrentAccessToken().getUserId()); - data.setType("facebook"); - loginBuyThird(data); + if (profile == null) { + ProfileTracker tracker = new ProfileTracker() { + + @Override + protected void onCurrentProfileChanged(@Nullable Profile pf, @Nullable Profile profile1) { + if(!enableButtons){ + stopTracking(); + return; + } + if(pf!=null){ + loginFaceBookUpdateUI(pf); + }else if(profile1!=null){ + loginFaceBookUpdateUI(profile1); + }else{ + ToastUtil.show(getResources().getString(R.string.user_login_outtime)); + } + stopTracking(); + } + }; + tracker.startTracking(); + } else { + if (enableButtons) { + loginFaceBookUpdateUI(profile); + } } } + private void loginFaceBookUpdateUI(Profile profile) { + LoginData data = new LoginData(); + data.setAvatar(profile.getProfilePictureUri(150, 150).toString()); + data.setNickName(profile.getName()); + data.setOpenID(AccessToken.getCurrentAccessToken().getUserId()); + data.setType("facebook"); + loginBuyThird(data); + } + //从网页获取推广码 private void getPromoCode() { OpenInstall.getInstall(new AppInstallAdapter() { @@ -827,5 +874,24 @@ public class EntryActivity extends AppCompatActivity { }); } + private void timerOutBtn(View btn) { + if(mBtnClick){ + return; + } + new Timer().schedule(new TimerTask() { + @Override + public void run() { + mBtnClick = false; + } + }, 3000); + mBtnClick = true; + } + + private boolean isBtnClick() { + if (mBtnClick) { + ToastUtil.show("請稍後再試"); + } + return mBtnClick; + } }