更新FacebookSDK版本

修复Facebook登录成功后无反应问题
第三方登录新增三秒内不允许重复点击功能
This commit is contained in:
zlzw 2022-10-06 14:08:12 +08:00
parent 5c349902dd
commit 92e435f6b6
2 changed files with 76 additions and 10 deletions

View File

@ -163,8 +163,8 @@ dependencies {
api 'cn.rongcloud.sdk:im_kit:5.2.5' // UI api 'cn.rongcloud.sdk:im_kit:5.2.5' // UI
// //
api 'cn.rongcloud.sdk:sight:5.2.5' api 'cn.rongcloud.sdk:sight:5.2.5'
api 'com.facebook.android:facebook-android-sdk:11.3.0' api 'com.facebook.android:facebook-android-sdk:15.0.1'
implementation 'com.facebook.android:facebook-android-sdk:[8,9)' implementation 'com.facebook.android:facebook-android-sdk:15.0.1'
api('com.twitter.sdk.android:twitter-core:3.1.1@aar') { api('com.twitter.sdk.android:twitter-core:3.1.1@aar') {
transitive = true transitive = true

View File

@ -29,6 +29,7 @@ import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.VideoView; import android.widget.VideoView;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import com.adjust.sdk.Adjust; import com.adjust.sdk.Adjust;
@ -43,6 +44,7 @@ import com.facebook.CallbackManager;
import com.facebook.FacebookCallback; import com.facebook.FacebookCallback;
import com.facebook.FacebookException; import com.facebook.FacebookException;
import com.facebook.Profile; import com.facebook.Profile;
import com.facebook.ProfileTracker;
import com.facebook.login.LoginManager; import com.facebook.login.LoginManager;
import com.facebook.login.LoginResult; import com.facebook.login.LoginResult;
import com.fm.openinstall.OpenInstall; import com.fm.openinstall.OpenInstall;
@ -101,6 +103,8 @@ import org.greenrobot.eventbus.ThreadMode;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.Arrays; 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 GoogleSignInClient mGoogleSignInClient;
private LinearLayout lt_btn_twitter, lt_btn_facebook, lt_customer; private LinearLayout lt_btn_twitter, lt_btn_facebook, lt_customer;
private String kefuUrl = ""; private String kefuUrl = "";
private boolean mBtnClick = false;
@Subscribe(threadMode = ThreadMode.MAIN) @Subscribe(threadMode = ThreadMode.MAIN)
public void close(String str) { public void close(String str) {
@ -266,6 +271,10 @@ public class EntryActivity extends AppCompatActivity {
lt_btn_facebook.setOnClickListener(new View.OnClickListener() { lt_btn_facebook.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (isBtnClick()) {
return;
}
timerOutBtn(view);
AdjustEvent adjustEvent = new AdjustEvent("umk7ri"); AdjustEvent adjustEvent = new AdjustEvent("umk7ri");
Adjust.trackEvent(adjustEvent); Adjust.trackEvent(adjustEvent);
CommonHttpUtil.setAdvertisingChannels("umk7ri", new HttpCallback() { 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) // MainNetManager.get(EntryActivity.this)
// .FaceBookUp(new com.yunbao.common.http.base.HttpCallback<FaceBookUpModel>() { // .FaceBookUp(new com.yunbao.common.http.base.HttpCallback<FaceBookUpModel>() {
// @Override // @Override
@ -340,6 +349,10 @@ public class EntryActivity extends AppCompatActivity {
btn_google.setOnClickListener(new View.OnClickListener() { btn_google.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (isBtnClick()) {
return;
}
timerOutBtn(v);
AdjustEvent adjustEvent = new AdjustEvent("iqd6b7"); AdjustEvent adjustEvent = new AdjustEvent("iqd6b7");
Adjust.trackEvent(adjustEvent); Adjust.trackEvent(adjustEvent);
CommonHttpUtil.setAdvertisingChannels("iqd6b7", new HttpCallback() { CommonHttpUtil.setAdvertisingChannels("iqd6b7", new HttpCallback() {
@ -359,6 +372,10 @@ public class EntryActivity extends AppCompatActivity {
lt_btn_twitter.setOnClickListener(new View.OnClickListener() { lt_btn_twitter.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (isBtnClick()) {
return;
}
timerOutBtn(v);
AdjustEvent adjustEvent = new AdjustEvent("le2qca"); AdjustEvent adjustEvent = new AdjustEvent("le2qca");
Adjust.trackEvent(adjustEvent); Adjust.trackEvent(adjustEvent);
CommonHttpUtil.setAdvertisingChannels("le2qca", new HttpCallback() { CommonHttpUtil.setAdvertisingChannels("le2qca", new HttpCallback() {
@ -407,6 +424,10 @@ public class EntryActivity extends AppCompatActivity {
findViewById(R.id.btn_line).setOnClickListener(new View.OnClickListener() { findViewById(R.id.btn_line).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (isBtnClick()) {
return;
}
timerOutBtn(view);
try { try {
AdjustEvent adjustEvent = new AdjustEvent("gev462"); AdjustEvent adjustEvent = new AdjustEvent("gev462");
Adjust.trackEvent(adjustEvent); Adjust.trackEvent(adjustEvent);
@ -571,7 +592,34 @@ public class EntryActivity extends AppCompatActivity {
private void updateUI() { private void updateUI() {
boolean enableButtons = AccessToken.getCurrentAccessToken() != null; boolean enableButtons = AccessToken.getCurrentAccessToken() != null;
Profile profile = Profile.getCurrentProfile(); Profile profile = Profile.getCurrentProfile();
if (enableButtons && profile != null) { 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(); LoginData data = new LoginData();
data.setAvatar(profile.getProfilePictureUri(150, 150).toString()); data.setAvatar(profile.getProfilePictureUri(150, 150).toString());
data.setNickName(profile.getName()); data.setNickName(profile.getName());
@ -579,7 +627,6 @@ public class EntryActivity extends AppCompatActivity {
data.setType("facebook"); data.setType("facebook");
loginBuyThird(data); loginBuyThird(data);
} }
}
//从网页获取推广码 //从网页获取推广码
private void getPromoCode() { private void getPromoCode() {
@ -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;
}
} }