2025 lines
108 KiB
Java
2025 lines
108 KiB
Java
package com.diyidan.game.api;
|
|
|
|
import android.app.Activity;
|
|
import android.app.ProgressDialog;
|
|
import android.content.BroadcastReceiver;
|
|
import android.content.ComponentName;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.content.IntentFilter;
|
|
import android.content.ServiceConnection;
|
|
import android.graphics.Bitmap;
|
|
import android.os.Handler;
|
|
import android.os.IBinder;
|
|
import android.os.Looper;
|
|
import android.os.RemoteException;
|
|
import android.text.TextUtils;
|
|
import android.view.View;
|
|
import com.alipay.sdk.cons.a;
|
|
import com.diyidan.aidl.IGameCallback;
|
|
import com.diyidan.aidl.IGameMethod;
|
|
import com.diyidan.game.activity.DydPaymentActivity;
|
|
import com.diyidan.game.activity.WebViewActivity;
|
|
import com.diyidan.game.callback.AuthSuccessListener;
|
|
import com.diyidan.game.callback.OnAccountUpgradeListener;
|
|
import com.diyidan.game.callback.OnCheckLoginCompletedListener;
|
|
import com.diyidan.game.callback.OnLoginFinishedListener;
|
|
import com.diyidan.game.callback.OnLogoutFinishedListener;
|
|
import com.diyidan.game.callback.OnPayFinishedListener;
|
|
import com.diyidan.game.common.Constants;
|
|
import com.diyidan.game.common.DydPreferenceManager;
|
|
import com.diyidan.game.dialog.AccountDetectDialog;
|
|
import com.diyidan.game.dialog.AuthenticationDialog;
|
|
import com.diyidan.game.dialog.ConfirmDialog;
|
|
import com.diyidan.game.dialog.LoginDialog;
|
|
import com.diyidan.game.dialog.LoginFailTipDialog;
|
|
import com.diyidan.game.dialog.NoticeTouristDialog;
|
|
import com.diyidan.game.dialog.PersonalCenterDialog;
|
|
import com.diyidan.game.dialog.PrivacyDialog;
|
|
import com.diyidan.game.dialog.QuitGameDialog;
|
|
import com.diyidan.game.dialog.RegisterDialog;
|
|
import com.diyidan.game.dialog.SimpleInputDialog;
|
|
import com.diyidan.game.dialog.TouristCenterDialog;
|
|
import com.diyidan.game.dialog.UpgradeAccountDialog;
|
|
import com.diyidan.game.dialog.ViewFriendsDialog;
|
|
import com.diyidan.game.dialog.WelcomeBackDialog;
|
|
import com.diyidan.game.dialog.requestTipsDialog;
|
|
import com.diyidan.game.entity.DydPlayer;
|
|
import com.diyidan.game.entity.constant.AccountUpgradeFinishType;
|
|
import com.diyidan.game.entity.constant.LoginFinishType;
|
|
import com.diyidan.game.entity.constant.LogoutFinishType;
|
|
import com.diyidan.game.entity.constant.UserLoginStatus;
|
|
import com.diyidan.game.entity.impl.DydPlayerModel;
|
|
import com.diyidan.game.entity.impl.PayResultModel;
|
|
import com.diyidan.game.network.GameInfoNetwork2;
|
|
import com.diyidan.game.network.INetworkHandler;
|
|
import com.diyidan.game.network.SmsNetwork2;
|
|
import com.diyidan.game.network.UserNetwork2;
|
|
import com.diyidan.game.network.model.JsonData;
|
|
import com.diyidan.game.network.model.ListJsonDataModel;
|
|
import com.diyidan.game.network.util.DydStringRequest;
|
|
import com.diyidan.game.network.util.VolleySingleton;
|
|
import com.diyidan.game.util.Utils;
|
|
import com.diyidan.game.widget.DydToast;
|
|
import com.diyidan.game.widget.FloatView;
|
|
|
|
public class DydGameApi {
|
|
public static final String LOGIN_TYPE_QQ = "QQ";
|
|
public static final String LOGIN_TYPE_WEIBO = "WEIBO";
|
|
public static final String LOGIN_TYPE_WEIXIN = "WEIXIN";
|
|
private static final int REQUEST_CHANGE_BIND_PHONE = 10134;
|
|
private static final int REQUEST_CODE_DYD_BIND = 10132;
|
|
private static final int REQUEST_CODE_DYD_BIND_PHONE = 10133;
|
|
private static final int REQUEST_CODE_DYD_LOGIN = 10131;
|
|
private static final String TAG = "DydGameApi";
|
|
public static AuthSuccessListener authSuccessListener = null;
|
|
public static String birthday = "";
|
|
public static boolean isReady = false;
|
|
private String PWD;
|
|
private final int WELCOME_BACK_INTERVAL;
|
|
private Context appContext;
|
|
private ServiceConnection conn;
|
|
private IGameCallback gameCallback;
|
|
private IGameMethod gameMethod;
|
|
private OnAccountUpgradeListener mAccountUpgradeFinishedListener;
|
|
private long mAppKey;
|
|
private OnCheckLoginCompletedListener mCheckLoginCompletedListener;
|
|
private final Object mCheckLoginLock;
|
|
private UserLoginStatus mCheckLoginStatus;
|
|
private Context mContext;
|
|
private DydPlayerModel mCurrentPlayer;
|
|
private DialogUtil mDialogUtil;
|
|
private Runnable mDydWelcomBackRunnable;
|
|
private ExitCallback mExitGameCallback;
|
|
private FloatView mFloatView;
|
|
private String mGameName;
|
|
private final Object mGenTokenLock;
|
|
private String mGeneratedTokenLock;
|
|
private Handler mHandler;
|
|
private boolean mIsAidlEverStarted;
|
|
private boolean mIsAidlSucceeded;
|
|
private boolean mIsEnteredGame;
|
|
private boolean mIsFloatViewAllowVisible;
|
|
private boolean mIsLogEnabled;
|
|
private boolean mIsUserLoggedIn;
|
|
private OnLoginFinishedListener mLoginFinishedListener;
|
|
private OnLogoutFinishedListener mLogoutFinishedListener;
|
|
private NetworkCallbackImpl mNetworkCallbackImpl;
|
|
private OnPayFinishedListener mPayFinishedListener;
|
|
private String mSecretKey;
|
|
private final Object mVerifyLock;
|
|
private UserLoginStatus mVerifyTokenStatus;
|
|
|
|
public interface ExitCallback {
|
|
void onGameExit();
|
|
|
|
void onRoleExit();
|
|
}
|
|
|
|
public void onBackPressed(Activity activity) {
|
|
}
|
|
|
|
public void onNewIntent(Activity activity, Intent intent) {
|
|
}
|
|
|
|
public void onPause(Activity activity) {
|
|
}
|
|
|
|
public void onResume(Activity activity) {
|
|
}
|
|
|
|
public void onStop(Activity activity) {
|
|
}
|
|
|
|
private DydGameApi(Context context, long j, String str) {
|
|
this.mIsUserLoggedIn = false;
|
|
this.mIsLogEnabled = false;
|
|
this.gameCallback = new DydGameCallback();
|
|
this.conn = new DydServiceConnection();
|
|
this.mIsAidlSucceeded = false;
|
|
this.mIsAidlEverStarted = false;
|
|
this.mIsFloatViewAllowVisible = false;
|
|
this.mIsEnteredGame = false;
|
|
this.mNetworkCallbackImpl = new NetworkCallbackImpl();
|
|
this.mCheckLoginStatus = UserLoginStatus.UNKNOWN;
|
|
this.mVerifyTokenStatus = UserLoginStatus.UNKNOWN;
|
|
this.mGeneratedTokenLock = null;
|
|
this.mCheckLoginLock = new Object();
|
|
this.mGenTokenLock = new Object();
|
|
this.mVerifyLock = new Object();
|
|
this.WELCOME_BACK_INTERVAL = 3000;
|
|
this.PWD = "";
|
|
init(context, j, str);
|
|
}
|
|
|
|
public DydGameApi() {
|
|
this.mIsUserLoggedIn = false;
|
|
this.mIsLogEnabled = false;
|
|
this.gameCallback = new DydGameCallback();
|
|
this.conn = new DydServiceConnection();
|
|
this.mIsAidlSucceeded = false;
|
|
this.mIsAidlEverStarted = false;
|
|
this.mIsFloatViewAllowVisible = false;
|
|
this.mIsEnteredGame = false;
|
|
this.mNetworkCallbackImpl = new NetworkCallbackImpl();
|
|
this.mCheckLoginStatus = UserLoginStatus.UNKNOWN;
|
|
this.mVerifyTokenStatus = UserLoginStatus.UNKNOWN;
|
|
this.mGeneratedTokenLock = null;
|
|
this.mCheckLoginLock = new Object();
|
|
this.mGenTokenLock = new Object();
|
|
this.mVerifyLock = new Object();
|
|
this.WELCOME_BACK_INTERVAL = 3000;
|
|
this.PWD = "";
|
|
}
|
|
|
|
private void init(Context context, long j, String str) {
|
|
this.appContext = context.getApplicationContext();
|
|
this.mAppKey = j;
|
|
this.mSecretKey = str;
|
|
DydStringRequest.setAuthInfo(Utils.getDeviceId(context), j, str);
|
|
}
|
|
|
|
private void startAidlConnection() {
|
|
this.mIsAidlEverStarted = true;
|
|
Intent intent = new Intent(Constants.DYD_AIDL_SERVICE_ACTION_NAME);
|
|
intent.setPackage(Constants.DYD_PACKAGE_NAME);
|
|
boolean zBindService = this.appContext.bindService(intent, this.conn, 1);
|
|
this.mIsAidlSucceeded = zBindService;
|
|
if (zBindService) {
|
|
return;
|
|
}
|
|
if (DydPreferenceManager.getInstance(this.mContext).getPreferencesBoolean("isAgreePrivacy", false)) {
|
|
if (this.mDialogUtil.getLoginDialog() != null) {
|
|
this.mDialogUtil.getLoginDialog().showDialog();
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
this.mDialogUtil.getPrivacyDialog(new PrivacyDialog.OnDialogListener() { // from class: com.diyidan.game.api.DydGameApi.1
|
|
@Override // com.diyidan.game.dialog.PrivacyDialog.OnDialogListener
|
|
public void onAgree(PrivacyDialog privacyDialog) {
|
|
privacyDialog.dismissDialog();
|
|
DydGameApi.this.mDialogUtil.getLoginDialog().showDialog();
|
|
DydPreferenceManager.getInstance(DydGameApi.this.mContext).savePreferencesBoolean("isAgreePrivacy", true);
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.PrivacyDialog.OnDialogListener
|
|
public void onCancel(PrivacyDialog privacyDialog) {
|
|
privacyDialog.dismissDialog();
|
|
}
|
|
}).showDialog();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void stopAidlConnection() {
|
|
if (this.mIsAidlEverStarted) {
|
|
try {
|
|
IGameMethod iGameMethod = this.gameMethod;
|
|
if (iGameMethod != null) {
|
|
iGameMethod.unregisterCallback(this.gameCallback);
|
|
}
|
|
} catch (RemoteException e) {
|
|
if (this.mIsLogEnabled) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
this.appContext.unbindService(this.conn);
|
|
this.mIsAidlEverStarted = false;
|
|
this.mIsAidlSucceeded = false;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void clearExistedData() {
|
|
this.mCurrentPlayer = null;
|
|
DydPreferenceManager.getInstance(this.appContext).clearUserPreference();
|
|
VolleySingleton.getInstance(this.appContext).removeAllCookies();
|
|
}
|
|
|
|
private Handler getHandler() {
|
|
if (this.mHandler == null) {
|
|
this.mHandler = new Handler(Looper.getMainLooper());
|
|
}
|
|
return this.mHandler;
|
|
}
|
|
|
|
private Runnable getWelcomeBackWaitRunnable() {
|
|
if (this.mDydWelcomBackRunnable == null) {
|
|
this.mDydWelcomBackRunnable = new Runnable() { // from class: com.diyidan.game.api.DydGameApi.2
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
DydGameApi.this.mIsUserLoggedIn = true;
|
|
LoginFinishType loginFinishType = DydGameApi.this.mCurrentPlayer.isUserVisitor() ? LoginFinishType.VISITOR_LOGIN : LoginFinishType.NORMAL_LOGIN;
|
|
if (DydGameApi.this.mNetworkCallbackImpl != null) {
|
|
DydGameApi.this.mNetworkCallbackImpl.handleLoginFinishedCallback(loginFinishType, DydGameApi.this.mCurrentPlayer);
|
|
}
|
|
}
|
|
};
|
|
}
|
|
return this.mDydWelcomBackRunnable;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void prepareWelcomeBackWaitLogic() {
|
|
getHandler().postDelayed(getWelcomeBackWaitRunnable(), 3000L);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void cancelWelcomeBackRunnable() {
|
|
getHandler().removeCallbacks(getWelcomeBackWaitRunnable());
|
|
this.mDydWelcomBackRunnable = null;
|
|
this.mIsUserLoggedIn = false;
|
|
}
|
|
|
|
public Context getAppContext() {
|
|
return this.appContext;
|
|
}
|
|
|
|
public DydPlayer getCurrentPlayerInfo() {
|
|
return this.mCurrentPlayer;
|
|
}
|
|
|
|
public boolean isUserLoggedIn() {
|
|
DydPlayerModel dydPlayerModel = this.mCurrentPlayer;
|
|
if (dydPlayerModel == null || dydPlayerModel.isUserInfoEmpty()) {
|
|
clearExistedData();
|
|
return false;
|
|
}
|
|
if (this.mIsUserLoggedIn) {
|
|
return true;
|
|
}
|
|
this.mNetworkCallbackImpl.checkLogin(this.appContext, this.mCurrentPlayer.getToken());
|
|
synchronized (this.mCheckLoginLock) {
|
|
try {
|
|
this.mCheckLoginLock.wait();
|
|
} catch (InterruptedException e) {
|
|
if (this.mIsLogEnabled) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
return this.mCheckLoginStatus == UserLoginStatus.ALREADY_LOGIN;
|
|
}
|
|
|
|
public void isUserLoggedIn(OnCheckLoginCompletedListener onCheckLoginCompletedListener) {
|
|
DydPlayerModel dydPlayerModel = this.mCurrentPlayer;
|
|
if (dydPlayerModel == null || dydPlayerModel.isUserInfoEmpty()) {
|
|
clearExistedData();
|
|
if (onCheckLoginCompletedListener != null) {
|
|
onCheckLoginCompletedListener.onCheckLoginCompleted(false);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
this.mCheckLoginCompletedListener = onCheckLoginCompletedListener;
|
|
this.mNetworkCallbackImpl.checkLogin(this.appContext, this.mCurrentPlayer.getToken());
|
|
}
|
|
|
|
public void login(OnLoginFinishedListener onLoginFinishedListener) {
|
|
this.mLoginFinishedListener = onLoginFinishedListener;
|
|
LoginFailTipDialog.onLoginFinishedListener = onLoginFinishedListener;
|
|
DydPlayerModel userInfo = DydPreferenceManager.getInstance(this.appContext).getUserInfo();
|
|
String userMobile = DydPreferenceManager.getInstance(this.appContext).getUserMobile();
|
|
if (userInfo == null) {
|
|
startAidlConnection();
|
|
return;
|
|
}
|
|
if (Utils.isNull(userInfo.getToken())) {
|
|
if (Utils.isNull(userMobile)) {
|
|
startAidlConnection();
|
|
return;
|
|
} else {
|
|
if (this.mDialogUtil.getLoginDialog() != null) {
|
|
this.mDialogUtil.getLoginDialog().setMobile(userMobile).showDialog();
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
if (userInfo.isUserVisitor()) {
|
|
if (this.mDialogUtil.getNoticeVisitorDialog() != null) {
|
|
this.mDialogUtil.getNoticeVisitorDialog().isCancelable(false).setTouristName(userInfo.getNickName()).showDialog();
|
|
}
|
|
} else if (userInfo.isUserInfoEmpty()) {
|
|
VolleySingleton.getInstance(this.appContext).removeAllCookies();
|
|
startAidlConnection();
|
|
} else {
|
|
if (this.mDialogUtil.getProgressDialog() != null) {
|
|
this.mDialogUtil.getProgressDialog().show();
|
|
}
|
|
this.mNetworkCallbackImpl.loginByDydPermanentToken(this.appContext, userInfo.getToken());
|
|
}
|
|
}
|
|
|
|
public void logout(OnLogoutFinishedListener onLogoutFinishedListener) {
|
|
DydPlayerModel dydPlayerModel = this.mCurrentPlayer;
|
|
if (dydPlayerModel == null || dydPlayerModel.isUserInfoEmpty()) {
|
|
clearExistedData();
|
|
updateFloatViewVisibility(null);
|
|
if (onLogoutFinishedListener != null) {
|
|
onLogoutFinishedListener.onLogoutFinished(LogoutFinishType.LOGOUT_SUCCESS);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
this.mLogoutFinishedListener = onLogoutFinishedListener;
|
|
this.mNetworkCallbackImpl.logout(this.appContext);
|
|
}
|
|
|
|
public void addAccountUpgradeListener(OnAccountUpgradeListener onAccountUpgradeListener) {
|
|
this.mAccountUpgradeFinishedListener = onAccountUpgradeListener;
|
|
}
|
|
|
|
public void removeAccountUpgradeListener(OnAccountUpgradeListener onAccountUpgradeListener) {
|
|
if (this.mAccountUpgradeFinishedListener == onAccountUpgradeListener) {
|
|
this.mAccountUpgradeFinishedListener = null;
|
|
}
|
|
}
|
|
|
|
public void addExitGameListener(ExitCallback exitCallback) {
|
|
this.mExitGameCallback = exitCallback;
|
|
}
|
|
|
|
public void removeExitGameListener(ExitCallback exitCallback) {
|
|
if (this.mExitGameCallback == exitCallback) {
|
|
this.mExitGameCallback = null;
|
|
}
|
|
}
|
|
|
|
public void init(Activity activity, String str) {
|
|
this.mGameName = str;
|
|
this.mContext = activity;
|
|
}
|
|
|
|
public void onCreate(Activity activity) {
|
|
FloatView floatView = this.mFloatView;
|
|
if (floatView != null) {
|
|
floatView.removeView();
|
|
this.mFloatView = null;
|
|
}
|
|
if (this.mDialogUtil != null) {
|
|
this.mDialogUtil = null;
|
|
}
|
|
this.mDialogUtil = new DialogUtil(activity);
|
|
updateFloatViewVisibility(activity);
|
|
}
|
|
|
|
public void onRestart(Activity activity) {
|
|
FloatView floatView;
|
|
if (activity == null || (floatView = this.mFloatView) == null || floatView.getContext() != activity) {
|
|
FloatView floatView2 = this.mFloatView;
|
|
if (floatView2 != null) {
|
|
floatView2.removeView();
|
|
this.mFloatView = null;
|
|
}
|
|
if (this.mDialogUtil != null) {
|
|
this.mDialogUtil = null;
|
|
}
|
|
this.mDialogUtil = new DialogUtil(activity);
|
|
updateFloatViewVisibility(activity);
|
|
}
|
|
}
|
|
|
|
public void onDestroy(Activity activity) {
|
|
if (this.mDialogUtil.mProgressDialog != null && this.mDialogUtil.mProgressDialog.isShowing()) {
|
|
this.mDialogUtil.mProgressDialog.dismiss();
|
|
}
|
|
if (this.mDialogUtil.personalCenterDialog != null && this.mDialogUtil.personalCenterDialog.isShowing()) {
|
|
this.mDialogUtil.personalCenterDialog.dismissDialog();
|
|
}
|
|
this.mDialogUtil.mProgressDialog = null;
|
|
this.mDialogUtil.personalCenterDialog = null;
|
|
}
|
|
|
|
public void onActivityResult(Activity activity, int i, int i2, Intent intent) {
|
|
if (i2 == -1) {
|
|
if (i == REQUEST_CODE_DYD_LOGIN) {
|
|
if (intent == null) {
|
|
DydToast.toastShort(getAppContext(), "第三方登录失败~");
|
|
return;
|
|
}
|
|
String stringExtra = intent.getStringExtra("token");
|
|
if (Utils.isNull(stringExtra)) {
|
|
DydToast.toastShort(getAppContext(), "签名校验失败~");
|
|
return;
|
|
}
|
|
this.mNetworkCallbackImpl.thirdPartyLoginByDydToken(activity, stringExtra);
|
|
if (this.mDialogUtil.getProgressDialog() != null) {
|
|
this.mDialogUtil.getProgressDialog().show();
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
if (i == REQUEST_CODE_DYD_BIND) {
|
|
if (intent == null) {
|
|
DydToast.toastShort(getAppContext(), "绑定第三方帐号失败~");
|
|
return;
|
|
}
|
|
String stringExtra2 = intent.getStringExtra("token");
|
|
if (Utils.isNull(stringExtra2)) {
|
|
DydToast.toastShort(getAppContext(), "签名校验失败~");
|
|
return;
|
|
}
|
|
this.mNetworkCallbackImpl.bindThirdParty(getAppContext(), stringExtra2);
|
|
if (this.mDialogUtil.getProgressDialog() != null) {
|
|
this.mDialogUtil.getProgressDialog().show();
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
if (i != REQUEST_CODE_DYD_BIND_PHONE) {
|
|
if (i == REQUEST_CHANGE_BIND_PHONE) {
|
|
if (intent == null) {
|
|
DydToast.toastShort(getAppContext(), "更换手机号失败~");
|
|
return;
|
|
} else {
|
|
if (!Utils.isNull(intent.getStringExtra("errorMsg"))) {
|
|
if ("different_account".equals(intent.getStringExtra("errorMsg"))) {
|
|
DydToast.toastLong(getAppContext(), "当前帐户与第一弹登录用户不一致,请在第一弹中切换帐号后重试~");
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
DydToast.toastLong(getAppContext(), "换绑成功,下次登陆后生效哦~");
|
|
return;
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
if (intent == null) {
|
|
DydToast.toastShort(getAppContext(), "绑定手机号失败~");
|
|
return;
|
|
}
|
|
DydPlayerModel dydPlayerModel = this.mCurrentPlayer;
|
|
if (dydPlayerModel == null) {
|
|
return;
|
|
}
|
|
String token = dydPlayerModel.getToken();
|
|
this.mCurrentPlayer.setAccount(intent.getStringExtra("userAccount"));
|
|
this.mCurrentPlayer.setUserType(intent.getIntExtra("userType", -1));
|
|
this.mNetworkCallbackImpl.loginByDydToken(getAppContext(), token);
|
|
if (this.mDialogUtil.getProgressDialog() != null) {
|
|
this.mDialogUtil.getProgressDialog().show();
|
|
}
|
|
}
|
|
}
|
|
|
|
public void setLogEnabled(boolean z) {
|
|
this.mIsLogEnabled = z;
|
|
}
|
|
|
|
public void pay(final Activity activity, final String str, final String str2, final long j, final long j2, final long j3, final String str3, final OnPayFinishedListener onPayFinishedListener) {
|
|
if (activity == null || j3 < 0) {
|
|
return;
|
|
}
|
|
if (this.mCurrentPlayer.isUserVisitor()) {
|
|
DialogUtil dialogUtil = this.mDialogUtil;
|
|
Context context = this.mContext;
|
|
dialogUtil.getRequestTipsDialog(context.getString(Utils.getStringlId(context, "visitor_paytip"))).showDialog();
|
|
return;
|
|
}
|
|
if (TextUtils.isEmpty(birthday)) {
|
|
UpgradeAccountDialog upgradeAccountDialog = new UpgradeAccountDialog(this.mContext, true);
|
|
upgradeAccountDialog.show();
|
|
upgradeAccountDialog.setCallback(new AuthenticationDialog.Callback() { // from class: com.diyidan.game.api.DydGameApi.3
|
|
@Override // com.diyidan.game.dialog.AuthenticationDialog.Callback
|
|
public void onReload() {
|
|
DydGameApi.this.mNetworkCallbackImpl.loginByDydPermanentToken(DydGameApi.this.appContext, DydGameApi.this.mCurrentPlayer.getToken());
|
|
}
|
|
});
|
|
upgradeAccountDialog.setListen(new UpgradeAccountDialog.upgradeListen() { // from class: com.diyidan.game.api.DydGameApi.4
|
|
@Override // com.diyidan.game.dialog.UpgradeAccountDialog.upgradeListen
|
|
public void dismissOnclick() {
|
|
DydGameApiBroadcastReceiver dydGameApiBroadcastReceiver = new DydGameApiBroadcastReceiver();
|
|
dydGameApiBroadcastReceiver.setCurrentActivity(activity);
|
|
IntentFilter intentFilter = new IntentFilter();
|
|
intentFilter.addAction(Constants.ACTION_RECEIVER_PAYMENT_CALLBACK);
|
|
activity.registerReceiver(dydGameApiBroadcastReceiver, intentFilter);
|
|
DydGameApi.this.mPayFinishedListener = onPayFinishedListener;
|
|
Intent intent = new Intent(activity, (Class<?>) DydPaymentActivity.class);
|
|
intent.putExtra("gameName", "" + DydGameApi.this.mGameName);
|
|
intent.putExtra("tradeNo", "" + str);
|
|
intent.putExtra("itemName", "" + str2);
|
|
intent.putExtra("itemCount", j2);
|
|
intent.putExtra("itemPriceInCent", j);
|
|
intent.putExtra("totalMoneyInCent", j3);
|
|
intent.putExtra("discountInfo", str3);
|
|
}
|
|
});
|
|
return;
|
|
}
|
|
DydGameApiBroadcastReceiver dydGameApiBroadcastReceiver = new DydGameApiBroadcastReceiver();
|
|
dydGameApiBroadcastReceiver.setCurrentActivity(activity);
|
|
IntentFilter intentFilter = new IntentFilter();
|
|
intentFilter.addAction(Constants.ACTION_RECEIVER_PAYMENT_CALLBACK);
|
|
activity.registerReceiver(dydGameApiBroadcastReceiver, intentFilter);
|
|
this.mPayFinishedListener = onPayFinishedListener;
|
|
Intent intent = new Intent(activity, (Class<?>) DydPaymentActivity.class);
|
|
intent.putExtra("gameName", "" + this.mGameName);
|
|
intent.putExtra("tradeNo", "" + str);
|
|
intent.putExtra("itemName", "" + str2);
|
|
intent.putExtra("itemCount", j2);
|
|
intent.putExtra("itemPriceInCent", j);
|
|
intent.putExtra("totalMoneyInCent", j3);
|
|
intent.putExtra("discountInfo", str3);
|
|
activity.startActivity(intent);
|
|
}
|
|
|
|
public void exit(Activity activity, ExitCallback exitCallback, boolean z) {
|
|
if (exitCallback == null) {
|
|
return;
|
|
}
|
|
if (z) {
|
|
exitCallback.onGameExit();
|
|
return;
|
|
}
|
|
clearExistedData();
|
|
this.mIsEnteredGame = false;
|
|
updateFloatViewVisibility(null);
|
|
exitCallback.onRoleExit();
|
|
}
|
|
|
|
public void postGameInfo(String str, String str2, String str3, long j, long j2, long j3, String str4, long j4, long j5, String str5) {
|
|
if ("enterServer".equals(str)) {
|
|
this.mIsEnteredGame = true;
|
|
this.mIsFloatViewAllowVisible = DydPreferenceManager.getInstance(this.appContext).isFloatViewVisible();
|
|
updateFloatViewVisibility(null);
|
|
}
|
|
this.mNetworkCallbackImpl.postPlayerActivityToServer(this.appContext, str, str2, str3, j, j2, j3, str4, j4, j5, str5);
|
|
}
|
|
|
|
public void postGameBattleInfo(String str, long j, String str2, String str3, String str4, String str5, String str6, boolean z, long j2, String str7) {
|
|
this.mNetworkCallbackImpl.postGameBattleInfo(this.appContext, str, j, str2, str3, str4, str5, str6, z, j2, str7);
|
|
}
|
|
|
|
public String getToken(long j) {
|
|
this.mNetworkCallbackImpl.generateToken(this.appContext, j);
|
|
synchronized (this.mGenTokenLock) {
|
|
try {
|
|
this.mGenTokenLock.wait();
|
|
} catch (InterruptedException e) {
|
|
if (this.mIsLogEnabled) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
return this.mGeneratedTokenLock;
|
|
}
|
|
|
|
public boolean verifyToken(String str, String str2) {
|
|
DydPlayerModel dydPlayerModel = this.mCurrentPlayer;
|
|
if (dydPlayerModel == null || dydPlayerModel.isUserInfoEmpty() || str2 == null) {
|
|
clearExistedData();
|
|
return false;
|
|
}
|
|
this.mNetworkCallbackImpl.verifyToken(this.appContext, str2);
|
|
synchronized (this.mVerifyLock) {
|
|
try {
|
|
this.mVerifyLock.wait();
|
|
} catch (InterruptedException e) {
|
|
if (this.mIsLogEnabled) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
return this.mVerifyTokenStatus == UserLoginStatus.ALREADY_LOGIN;
|
|
}
|
|
|
|
public void startPersonalCenter() {
|
|
if (this.mCurrentPlayer.isUserVisitor()) {
|
|
TouristCenterDialog visitorCenterDialog = this.mDialogUtil.getVisitorCenterDialog();
|
|
if (visitorCenterDialog != null) {
|
|
visitorCenterDialog.setUserInfo(this.mCurrentPlayer).showDialog();
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
PersonalCenterDialog personalCenterDialog = this.mDialogUtil.getPersonalCenterDialog();
|
|
if (personalCenterDialog != null) {
|
|
personalCenterDialog.setUserInfo(this.mCurrentPlayer).setUserAbleToModifyPassword(!this.mCurrentPlayer.isUserVisitor()).showDialog();
|
|
}
|
|
}
|
|
|
|
public static class Builder {
|
|
private long appKey;
|
|
private Context context;
|
|
private DydGameApi dydGameApi;
|
|
private Bitmap iconBitmap;
|
|
private String secretKey;
|
|
|
|
public interface InitListener {
|
|
void initComplete(DydGameApi dydGameApi);
|
|
|
|
void initError(String str);
|
|
}
|
|
|
|
public Builder(Context context, long j, String str) {
|
|
this.context = context;
|
|
this.appKey = j;
|
|
this.secretKey = str;
|
|
}
|
|
|
|
public Builder setIconBitmap(Bitmap bitmap) {
|
|
this.iconBitmap = bitmap;
|
|
return this;
|
|
}
|
|
|
|
public DydGameApi create() throws IllegalArgumentException {
|
|
if (this.appKey <= 0) {
|
|
throw new IllegalArgumentException("appKey not correct: " + this.appKey);
|
|
}
|
|
if (Utils.isNull(this.secretKey)) {
|
|
throw new IllegalArgumentException("secretKey not correct: " + this.secretKey);
|
|
}
|
|
DydGameApi.isReady = true;
|
|
DydGameApi dydGameApi = new DydGameApi(this.context, this.appKey, this.secretKey);
|
|
this.dydGameApi = dydGameApi;
|
|
LoginFailTipDialog.dydGameApi = dydGameApi;
|
|
return this.dydGameApi;
|
|
}
|
|
|
|
public void create(final InitListener initListener) throws IllegalArgumentException {
|
|
if (this.appKey <= 0) {
|
|
throw new IllegalArgumentException("appKey not correct: " + this.appKey);
|
|
}
|
|
if (Utils.isNull(this.secretKey)) {
|
|
throw new IllegalArgumentException("secretKey not correct: " + this.secretKey);
|
|
}
|
|
DydGameApi.isReady = true;
|
|
this.dydGameApi = new DydGameApi(this.context, this.appKey, this.secretKey);
|
|
new Handler().post(new Runnable() { // from class: com.diyidan.game.api.DydGameApi.Builder.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
InitListener initListener2 = initListener;
|
|
if (initListener2 != null) {
|
|
initListener2.initComplete(Builder.this.dydGameApi);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
private class DydGameCallback extends IGameCallback.Stub {
|
|
private DydGameCallback() {
|
|
}
|
|
|
|
@Override // com.diyidan.aidl.IGameCallback
|
|
public void onLocalDydAccountVerified(final String str, final String str2, final String str3, final String str4, final int i) throws RemoteException {
|
|
new Handler(Looper.getMainLooper()).post(new Runnable() { // from class: com.diyidan.game.api.DydGameApi.DydGameCallback.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
if (DydPreferenceManager.getInstance(DydGameApi.this.mContext).getPreferencesBoolean("isAgreePrivacy", false)) {
|
|
DydGameCallback.this.toLoginDialog(str, str2, str3, str4, i);
|
|
} else {
|
|
DydGameApi.this.mDialogUtil.getPrivacyDialog(new PrivacyDialog.OnDialogListener() { // from class: com.diyidan.game.api.DydGameApi.DydGameCallback.1.1
|
|
@Override // com.diyidan.game.dialog.PrivacyDialog.OnDialogListener
|
|
public void onAgree(PrivacyDialog privacyDialog) {
|
|
privacyDialog.dismissDialog();
|
|
DydGameCallback.this.toLoginDialog(str, str2, str3, str4, i);
|
|
DydPreferenceManager.getInstance(DydGameApi.this.mContext).savePreferencesBoolean("isAgreePrivacy", true);
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.PrivacyDialog.OnDialogListener
|
|
public void onCancel(PrivacyDialog privacyDialog) {
|
|
privacyDialog.dismissDialog();
|
|
}
|
|
}).showDialog();
|
|
}
|
|
}
|
|
});
|
|
DydGameApi.this.stopAidlConnection();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void toLoginDialog(String str, String str2, String str3, String str4, int i) {
|
|
if (!Utils.isNullExists(str, str4)) {
|
|
DydGameApi.this.mCurrentPlayer = new DydPlayerModel(str, str2, str3, str4, i);
|
|
if (DydGameApi.this.mDialogUtil.getCheckAccountDialog(DydGameApi.this.mCurrentPlayer) != null) {
|
|
DydGameApi.this.mDialogUtil.getCheckAccountDialog(DydGameApi.this.mCurrentPlayer).showDialog();
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
if (DydGameApi.this.mDialogUtil.getLoginDialog() != null) {
|
|
DydGameApi.this.mDialogUtil.getLoginDialog().showDialog();
|
|
}
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void startBindPhone(Context context, int i, String str, String str2, String str3) {
|
|
if (Utils.isDydAppInstalled(getAppContext())) {
|
|
try {
|
|
if (!Utils.isNull(str3)) {
|
|
DydToast.toastLong(getAppContext(), str3);
|
|
}
|
|
Intent intent = new Intent();
|
|
intent.putExtra("phoneNum", str);
|
|
intent.putExtra("nickName", str2);
|
|
intent.setClassName(Constants.DYD_PACKAGE_NAME, Constants.DYD_BIND_PHONE_ACTIVITY);
|
|
((Activity) context).startActivityForResult(intent, i);
|
|
return;
|
|
} catch (Exception unused) {
|
|
DydToast.toastShort(getAppContext(), context.getString(Utils.getStringlId(context, "upgrade_dyd_app_toast")));
|
|
jumpToDydDownloadPage(context);
|
|
return;
|
|
}
|
|
}
|
|
DydToast.toastShort(getAppContext(), context.getString(Utils.getStringlId(context, "install_dyd_app_toast")));
|
|
jumpToDydDownloadPage(context);
|
|
}
|
|
|
|
private class DydServiceConnection implements ServiceConnection {
|
|
@Override // android.content.ServiceConnection
|
|
public void onServiceDisconnected(ComponentName componentName) {
|
|
}
|
|
|
|
private DydServiceConnection() {
|
|
}
|
|
|
|
@Override // android.content.ServiceConnection
|
|
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
|
|
DydGameApi.this.gameMethod = IGameMethod.Stub.asInterface(iBinder);
|
|
try {
|
|
DydGameApi.this.gameMethod.registerCallback(DydGameApi.this.gameCallback);
|
|
DydGameApi.this.gameMethod.detectLocalDydAccount("" + DydGameApi.this.mAppKey, DydGameApi.this.mSecretKey);
|
|
} catch (RemoteException e) {
|
|
if (DydGameApi.this.mIsLogEnabled) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private class DydGameApiBroadcastReceiver extends BroadcastReceiver {
|
|
private Activity activity;
|
|
|
|
private DydGameApiBroadcastReceiver() {
|
|
}
|
|
|
|
public void setCurrentActivity(Activity activity) {
|
|
this.activity = activity;
|
|
}
|
|
|
|
public void releaseActivity() {
|
|
this.activity = null;
|
|
}
|
|
|
|
@Override // android.content.BroadcastReceiver
|
|
public void onReceive(Context context, Intent intent) {
|
|
PayResultModel payResultModel;
|
|
if (Constants.ACTION_RECEIVER_PAYMENT_CALLBACK.equals(intent.getAction())) {
|
|
this.activity.sendBroadcast(new Intent(Constants.ACTION_RECEIVER_FINISH_PAYMENT_PAGE));
|
|
try {
|
|
payResultModel = (PayResultModel) intent.getSerializableExtra("payResult");
|
|
} catch (Exception e) {
|
|
if (DydGameApi.this.mIsLogEnabled) {
|
|
e.printStackTrace();
|
|
}
|
|
payResultModel = null;
|
|
}
|
|
if (DydGameApi.this.mPayFinishedListener != null && payResultModel != null) {
|
|
if (Utils.isNull(payResultModel.getUserId()) && DydGameApi.this.mCurrentPlayer != null) {
|
|
payResultModel.setUserId(DydGameApi.this.mCurrentPlayer.getUserId());
|
|
payResultModel.setNickName(DydGameApi.this.mCurrentPlayer.getNickName());
|
|
}
|
|
if (payResultModel.getIsSuccess()) {
|
|
DydGameApi.this.mPayFinishedListener.onPaySuccess(payResultModel);
|
|
} else {
|
|
DydGameApi.this.mPayFinishedListener.onPayFail(payResultModel);
|
|
}
|
|
}
|
|
this.activity.unregisterReceiver(this);
|
|
this.activity = null;
|
|
DydGameApi.this.mPayFinishedListener = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
public class NetworkCallbackImpl implements INetworkHandler {
|
|
private static final int REQUEST_BIND_BY_PHONE = 119;
|
|
private static final int REQUEST_BIND_THIRD_PARTY_BY_DYD_TOKEN = 118;
|
|
public static final int REQUEST_CHECK_USER_LOGIN = 116;
|
|
public static final int REQUEST_FORGET_PASS = 109;
|
|
public static final int REQUEST_GENERATE_TOKEN = 107;
|
|
public static final int REQUEST_LOGIN_BY_DYD_PERMANENT_TOKEN = 111;
|
|
public static final int REQUEST_LOGIN_BY_DYD_TOKEN = 101;
|
|
public static final int REQUEST_LOGIN_BY_PHONE = 102;
|
|
public static final int REQUEST_LOGOUT = 105;
|
|
private static final int REQUEST_POST_BATTLE_RECORD = 120;
|
|
private static final int REQUEST_POST_REAL_IDCARD = 121;
|
|
public static final int REQUEST_POST_ROLE_ACTIVITY = 115;
|
|
public static final int REQUEST_REGISTER_AS_VISITOR = 104;
|
|
public static final int REQUEST_REGISTER_BY_PHONE = 103;
|
|
public static final int REQUEST_SEND_SMS_FIND_PASSWORD = 113;
|
|
public static final int REQUEST_SEND_SMS_REGISTER = 108;
|
|
public static final int REQUEST_SEND_SMS_UPGRADE = 114;
|
|
public static final int REQUEST_SEND_SMS_input_dialog = 110;
|
|
private static final int REQUEST_THIRD_PARTY_LOGIN_BY_DYD_TOKEN = 117;
|
|
public static final int REQUEST_UPGRADE_BY_PHONE = 112;
|
|
public static final int REQUEST_VERIFY_TOKEN = 106;
|
|
|
|
public NetworkCallbackImpl() {
|
|
}
|
|
|
|
public void loginByDydToken(Context context, String str) {
|
|
new UserNetwork2(context, this, 101).loginByDydToken(str);
|
|
}
|
|
|
|
public void loginByDydPermanentToken(Context context, String str) {
|
|
new UserNetwork2(context, this, REQUEST_LOGIN_BY_DYD_PERMANENT_TOKEN).loginByDydPermanentToken(str);
|
|
}
|
|
|
|
public void loginByPhone(Context context, String str, String str2) {
|
|
DydPreferenceManager.getInstance(DydGameApi.this.appContext).saveUserMobile(str);
|
|
DydPreferenceManager.getInstance(DydGameApi.this.appContext).savePWD(str2);
|
|
new UserNetwork2(context, this, 102).loginByPhone(str, str2);
|
|
}
|
|
|
|
public void registerAsVisitor(Context context) {
|
|
new UserNetwork2(context, this, REQUEST_REGISTER_AS_VISITOR).registerAsVisitor(context);
|
|
}
|
|
|
|
public void registerByPhone(Context context, String str, String str2, String str3, String str4, String str5) {
|
|
DydPreferenceManager.getInstance(DydGameApi.this.appContext).saveUserMobile(str2);
|
|
DydPreferenceManager.getInstance(DydGameApi.this.appContext).savePWD(str3);
|
|
new UserNetwork2(context, this, REQUEST_REGISTER_BY_PHONE).registerByPhone(str, str2, str3, str4, str5);
|
|
}
|
|
|
|
public void visitorUpgrade(Context context, String str, String str2, String str3) {
|
|
new UserNetwork2(context, this, REQUEST_UPGRADE_BY_PHONE).visitorUpgrade(str, str2, str3);
|
|
}
|
|
|
|
public void logout(Context context) {
|
|
new UserNetwork2(context, this, REQUEST_LOGOUT).logout();
|
|
}
|
|
|
|
public void sendSms(Context context, String str, int i) {
|
|
if (i == 113) {
|
|
new SmsNetwork2(context, this, i).sendSmsCheckCodeForForgetPassword(str);
|
|
} else {
|
|
new SmsNetwork2(context, this, i).sendSmsCheckCodeForRegister(str);
|
|
}
|
|
}
|
|
|
|
public void generateToken(Context context, long j) {
|
|
new UserNetwork2(context, this, REQUEST_GENERATE_TOKEN).generateToken(j);
|
|
}
|
|
|
|
public void resetAccountPassword(Context context, String str, String str2, String str3) {
|
|
DydPreferenceManager.getInstance(DydGameApi.this.appContext).saveUserMobile(str);
|
|
DydPreferenceManager.getInstance(DydGameApi.this.appContext).savePWD(str2);
|
|
new UserNetwork2(context, this, REQUEST_FORGET_PASS).forgetPassword(str, str2, str3);
|
|
}
|
|
|
|
public void checkLogin(Context context, String str) {
|
|
new UserNetwork2(context, this, REQUEST_CHECK_USER_LOGIN).verifyToken(str);
|
|
}
|
|
|
|
public void verifyToken(Context context, String str) {
|
|
new UserNetwork2(context, this, REQUEST_VERIFY_TOKEN).verifyToken(str);
|
|
}
|
|
|
|
public void postPlayerActivityToServer(Context context, String str, String str2, String str3, long j, long j2, long j3, String str4, long j4, long j5, String str5) {
|
|
new GameInfoNetwork2(context, this, REQUEST_POST_ROLE_ACTIVITY).postPlayerActivityToServer(str, str2, str3, j, j2, j3, str4, j4, j5, str5);
|
|
}
|
|
|
|
public void postGameBattleInfo(Context context, String str, long j, String str2, String str3, String str4, String str5, String str6, boolean z, long j2, String str7) {
|
|
new GameInfoNetwork2(context, this, REQUEST_POST_BATTLE_RECORD).postGameBattleInfoToServer(str, j, str2, str3, str4, str5, str6, z, j2, str7);
|
|
}
|
|
|
|
@Override // com.diyidan.game.network.INetworkHandler
|
|
public void networkCallback(Object obj, int i, int i2) {
|
|
if (DydGameApi.this.mDialogUtil.mProgressDialog != null && DydGameApi.this.mDialogUtil.mProgressDialog.isShowing()) {
|
|
DydGameApi.this.mDialogUtil.mProgressDialog.dismiss();
|
|
}
|
|
JsonData jsonData = (JsonData) obj;
|
|
if (jsonData != null) {
|
|
if (jsonData.getCode() != 408) {
|
|
if (jsonData.getCode() != 501) {
|
|
if (jsonData.getCode() == 502) {
|
|
if (DydGameApi.this.mDialogUtil.loginDialog != null) {
|
|
DydGameApi.this.mDialogUtil.loginDialog.dismissDialog();
|
|
} else if (DydGameApi.this.mDialogUtil.noticeTouristDialog != null) {
|
|
DydGameApi.this.mDialogUtil.noticeTouristDialog.dismissDialog();
|
|
}
|
|
new requestTipsDialog(DydGameApi.this.mContext, DydGameApi.this.mContext.getString(Utils.getStringlId(DydGameApi.this.mContext, "rechargefail")), DydGameApi.this.mContext.getString(Utils.getStringlId(DydGameApi.this.mContext, "monthfial"))).show();
|
|
return;
|
|
}
|
|
} else {
|
|
if (DydGameApi.this.mDialogUtil.loginDialog != null) {
|
|
DydGameApi.this.mDialogUtil.loginDialog.dismissDialog();
|
|
} else if (DydGameApi.this.mDialogUtil.noticeTouristDialog != null) {
|
|
DydGameApi.this.mDialogUtil.noticeTouristDialog.dismissDialog();
|
|
}
|
|
new requestTipsDialog(DydGameApi.this.mContext, DydGameApi.this.mContext.getString(Utils.getStringlId(DydGameApi.this.mContext, "rechargefail")), DydGameApi.this.mContext.getString(Utils.getStringlId(DydGameApi.this.mContext, "dailyfail"))).show();
|
|
return;
|
|
}
|
|
} else {
|
|
if (DydGameApi.this.mDialogUtil.loginDialog != null) {
|
|
DydGameApi.this.mDialogUtil.loginDialog.dismissDialog();
|
|
} else if (DydGameApi.this.mDialogUtil.noticeTouristDialog != null) {
|
|
DydGameApi.this.mDialogUtil.noticeTouristDialog.dismissDialog();
|
|
}
|
|
if (DydGameApi.this.mDialogUtil.findPasswordDialog != null) {
|
|
DydGameApi.this.mDialogUtil.findPasswordDialog.dismissDialog();
|
|
}
|
|
new LoginFailTipDialog(DydGameApi.this.mContext).show();
|
|
return;
|
|
}
|
|
}
|
|
boolean zCheckNetworkResponse = checkNetworkResponse(obj, i, i2);
|
|
if (i2 == 105) {
|
|
DydGameApi.this.clearExistedData();
|
|
if (DydGameApi.this.mLogoutFinishedListener != null) {
|
|
DydGameApi.this.mLogoutFinishedListener.onLogoutFinished(LogoutFinishType.LOGOUT_SUCCESS);
|
|
DydGameApi.this.mLogoutFinishedListener = null;
|
|
}
|
|
if (DydGameApi.this.mExitGameCallback != null) {
|
|
DydGameApi.this.mExitGameCallback.onRoleExit();
|
|
DydGameApi.this.mIsEnteredGame = false;
|
|
}
|
|
DydGameApi.this.updateFloatViewVisibility(null);
|
|
DydGameApi.this.mIsUserLoggedIn = false;
|
|
return;
|
|
}
|
|
if (i2 == 116) {
|
|
if (i == 403 || obj == null || jsonData.getCode() != 200) {
|
|
DydGameApi.this.clearExistedData();
|
|
DydGameApi.this.mIsUserLoggedIn = false;
|
|
DydGameApi.this.mCheckLoginStatus = UserLoginStatus.NOT_LOGIN;
|
|
} else {
|
|
DydGameApi.this.mIsUserLoggedIn = true;
|
|
DydGameApi.this.mCheckLoginStatus = UserLoginStatus.ALREADY_LOGIN;
|
|
}
|
|
synchronized (DydGameApi.this.mCheckLoginLock) {
|
|
DydGameApi.this.mCheckLoginLock.notify();
|
|
}
|
|
if (DydGameApi.this.mCheckLoginCompletedListener != null) {
|
|
DydGameApi.this.mCheckLoginCompletedListener.onCheckLoginCompleted(DydGameApi.this.mIsUserLoggedIn);
|
|
}
|
|
DydGameApi.this.mCheckLoginCompletedListener = null;
|
|
return;
|
|
}
|
|
if (i2 == 106) {
|
|
if (i == 403 || obj == null || jsonData.getCode() != 200) {
|
|
DydGameApi.this.mVerifyTokenStatus = UserLoginStatus.NOT_LOGIN;
|
|
} else {
|
|
DydGameApi.this.mVerifyTokenStatus = UserLoginStatus.ALREADY_LOGIN;
|
|
}
|
|
synchronized (DydGameApi.this.mVerifyLock) {
|
|
DydGameApi.this.mVerifyLock.notify();
|
|
}
|
|
return;
|
|
}
|
|
if (i2 == 107) {
|
|
if (!zCheckNetworkResponse) {
|
|
DydGameApi.this.mGeneratedTokenLock = "";
|
|
}
|
|
if (jsonData != null && jsonData.getData() != null && !Utils.isListEmpty(((ListJsonDataModel) jsonData.getData()).getUserList())) {
|
|
DydGameApi.this.mGeneratedTokenLock = ((ListJsonDataModel) jsonData.getData()).getUserList().get(0).getToken();
|
|
}
|
|
if (DydGameApi.this.mGeneratedTokenLock == null) {
|
|
DydGameApi.this.mGeneratedTokenLock = "";
|
|
}
|
|
synchronized (DydGameApi.this.mGenTokenLock) {
|
|
DydGameApi.this.mGenTokenLock.notify();
|
|
}
|
|
}
|
|
if (zCheckNetworkResponse) {
|
|
if (i2 == 108) {
|
|
DydGameApi.this.mDialogUtil.registerDialog.startCount();
|
|
DydToast.toastShort(DydGameApi.this.appContext, "短信已发送");
|
|
return;
|
|
}
|
|
if (i2 == 113) {
|
|
DydGameApi.this.mDialogUtil.findPasswordDialog.startCount();
|
|
DydToast.toastShort(DydGameApi.this.appContext, "短信已发送");
|
|
return;
|
|
}
|
|
if (i2 == 114) {
|
|
DydGameApi.this.mDialogUtil.upgradeDialog.startCount();
|
|
DydToast.toastShort(DydGameApi.this.appContext, "短信已发送");
|
|
return;
|
|
}
|
|
if (i2 == 110) {
|
|
DydGameApi.this.mDialogUtil.inputPhoneDialog.dismissDialog();
|
|
DydGameApi.this.mDialogUtil.registerDialog.startCount().showDialog();
|
|
DydToast.toastShort(DydGameApi.this.appContext, "短信已发送");
|
|
return;
|
|
}
|
|
if (i2 == 115) {
|
|
if (DydGameApi.this.mIsLogEnabled) {
|
|
DydToast.toastShort(DydGameApi.this.appContext, "事件上传成功!");
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
if (i2 == REQUEST_POST_BATTLE_RECORD) {
|
|
if (DydGameApi.this.mIsLogEnabled) {
|
|
DydToast.toastShort(DydGameApi.this.appContext, "战斗记录上传成功!");
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
ListJsonDataModel listJsonDataModel = (ListJsonDataModel) jsonData.getData();
|
|
if (i2 == 102) {
|
|
if (!Utils.isListEmpty(listJsonDataModel.getUserList())) {
|
|
DydGameApi.this.mCurrentPlayer = listJsonDataModel.getUserList().get(0);
|
|
if (DydGameApi.this.mDialogUtil.getLoginDialog() != null) {
|
|
DydGameApi.this.mDialogUtil.getLoginDialog().dismissDialog();
|
|
}
|
|
DydGameApi.this.mIsUserLoggedIn = true;
|
|
DydPreferenceManager.getInstance(DydGameApi.this.appContext).saveUserInfo(DydGameApi.this.mCurrentPlayer);
|
|
handleLoginFinishedCallback(LoginFinishType.NORMAL_LOGIN, DydGameApi.this.mCurrentPlayer);
|
|
if (DydGameApi.this.mCurrentPlayer.getBirthday() == null) {
|
|
UpgradeAccountDialog upgradeAccountDialog = new UpgradeAccountDialog(DydGameApi.this.mContext);
|
|
upgradeAccountDialog.setCallback(new AuthenticationDialog.Callback() { // from class: com.diyidan.game.api.DydGameApi.NetworkCallbackImpl.1
|
|
@Override // com.diyidan.game.dialog.AuthenticationDialog.Callback
|
|
public void onReload() {
|
|
DydGameApi.this.mNetworkCallbackImpl.loginByDydPermanentToken(DydGameApi.this.appContext, DydGameApi.this.mCurrentPlayer.getToken());
|
|
}
|
|
});
|
|
upgradeAccountDialog.show();
|
|
}
|
|
}
|
|
} else if (i2 == 101) {
|
|
if (!Utils.isListEmpty(listJsonDataModel.getUserList())) {
|
|
DydGameApi.this.mCurrentPlayer = listJsonDataModel.getUserList().get(0);
|
|
DydGameApi.this.mDialogUtil.checkAccountDialog.dismissDialog();
|
|
DydGameApi.this.mIsUserLoggedIn = true;
|
|
DydPreferenceManager.getInstance(DydGameApi.this.appContext).saveUserInfo(DydGameApi.this.mCurrentPlayer);
|
|
handleLoginFinishedCallback(LoginFinishType.NORMAL_LOGIN, DydGameApi.this.mCurrentPlayer);
|
|
if (DydGameApi.this.mCurrentPlayer.getBirthday() == null) {
|
|
UpgradeAccountDialog upgradeAccountDialog2 = new UpgradeAccountDialog(DydGameApi.this.mContext);
|
|
upgradeAccountDialog2.setCallback(new AuthenticationDialog.Callback() { // from class: com.diyidan.game.api.DydGameApi.NetworkCallbackImpl.2
|
|
@Override // com.diyidan.game.dialog.AuthenticationDialog.Callback
|
|
public void onReload() {
|
|
DydGameApi.this.mNetworkCallbackImpl.loginByDydPermanentToken(DydGameApi.this.appContext, DydGameApi.this.mCurrentPlayer.getToken());
|
|
}
|
|
});
|
|
upgradeAccountDialog2.show();
|
|
}
|
|
}
|
|
} else if (i2 == 111) {
|
|
if (!Utils.isListEmpty(listJsonDataModel.getUserList())) {
|
|
DydGameApi.this.mCurrentPlayer = listJsonDataModel.getUserList().get(0);
|
|
DydPreferenceManager.getInstance(DydGameApi.this.appContext).saveUserInfo(DydGameApi.this.mCurrentPlayer);
|
|
if (DydGameApi.this.mDialogUtil.getWelcomeBackDialog() != null) {
|
|
DydGameApi.this.mDialogUtil.getWelcomeBackDialog().setUserInfo(DydGameApi.this.mCurrentPlayer.getAvatar(), DydGameApi.this.mCurrentPlayer.getNickName()).showDialog();
|
|
}
|
|
DydGameApi.this.prepareWelcomeBackWaitLogic();
|
|
if (DydGameApi.this.mCurrentPlayer.getBirthday() == null) {
|
|
UpgradeAccountDialog upgradeAccountDialog3 = new UpgradeAccountDialog(DydGameApi.this.mContext);
|
|
upgradeAccountDialog3.setCallback(new AuthenticationDialog.Callback() { // from class: com.diyidan.game.api.DydGameApi.NetworkCallbackImpl.3
|
|
@Override // com.diyidan.game.dialog.AuthenticationDialog.Callback
|
|
public void onReload() {
|
|
DydGameApi.this.mNetworkCallbackImpl.loginByDydPermanentToken(DydGameApi.this.appContext, DydGameApi.this.mCurrentPlayer.getToken());
|
|
}
|
|
});
|
|
upgradeAccountDialog3.show();
|
|
}
|
|
}
|
|
} else if (i2 == 109) {
|
|
if (!Utils.isListEmpty(listJsonDataModel.getUserList())) {
|
|
DydGameApi.this.mCurrentPlayer = listJsonDataModel.getUserList().get(0);
|
|
DydGameApi.this.mDialogUtil.findPasswordDialog.dismissDialog();
|
|
DydGameApi.this.mIsUserLoggedIn = true;
|
|
DydToast.toastShort(DydGameApi.this.appContext, "密码修改成功!");
|
|
DydPreferenceManager.getInstance(DydGameApi.this.appContext).saveUserInfo(DydGameApi.this.mCurrentPlayer);
|
|
handleLoginFinishedCallback(LoginFinishType.NORMAL_LOGIN, DydGameApi.this.mCurrentPlayer);
|
|
}
|
|
} else if (i2 == 104) {
|
|
if (!Utils.isListEmpty(listJsonDataModel.getUserList())) {
|
|
DydGameApi.this.mCurrentPlayer = listJsonDataModel.getUserList().get(0);
|
|
DydGameApi.this.mIsUserLoggedIn = true;
|
|
if (DydGameApi.this.mDialogUtil.loginDialog != null) {
|
|
DydGameApi.this.mDialogUtil.loginDialog.dismissDialog();
|
|
} else if (DydGameApi.this.mDialogUtil.noticeTouristDialog != null) {
|
|
DydGameApi.this.mDialogUtil.noticeTouristDialog.dismissDialog();
|
|
}
|
|
DydPreferenceManager.getInstance(DydGameApi.this.appContext).saveUserInfo(DydGameApi.this.mCurrentPlayer);
|
|
handleLoginFinishedCallback(LoginFinishType.VISITOR_LOGIN, DydGameApi.this.mCurrentPlayer);
|
|
}
|
|
} else if (i2 == 103) {
|
|
if (!Utils.isListEmpty(listJsonDataModel.getUserList())) {
|
|
DydGameApi.this.mCurrentPlayer = listJsonDataModel.getUserList().get(0);
|
|
DydGameApi.this.mDialogUtil.registerDialog.dismissDialog();
|
|
DydGameApi.this.mIsUserLoggedIn = true;
|
|
DydPreferenceManager.getInstance(DydGameApi.this.appContext).saveUserInfo(DydGameApi.this.mCurrentPlayer);
|
|
handleLoginFinishedCallback(LoginFinishType.NORMAL_LOGIN, DydGameApi.this.mCurrentPlayer);
|
|
UpgradeAccountDialog upgradeAccountDialog4 = new UpgradeAccountDialog(DydGameApi.this.mContext);
|
|
upgradeAccountDialog4.setCallback(new AuthenticationDialog.Callback() { // from class: com.diyidan.game.api.DydGameApi.NetworkCallbackImpl.4
|
|
@Override // com.diyidan.game.dialog.AuthenticationDialog.Callback
|
|
public void onReload() {
|
|
DydGameApi.this.mNetworkCallbackImpl.loginByDydPermanentToken(DydGameApi.this.appContext, DydGameApi.this.mCurrentPlayer.getToken());
|
|
}
|
|
});
|
|
upgradeAccountDialog4.show();
|
|
}
|
|
} else if (i2 == 112) {
|
|
if (!Utils.isListEmpty(listJsonDataModel.getUserList())) {
|
|
DydPlayerModel dydPlayerModel = DydGameApi.this.mCurrentPlayer;
|
|
DydGameApi.this.mCurrentPlayer = listJsonDataModel.getUserList().get(0);
|
|
DydGameApi.this.mDialogUtil.upgradeDialog.dismissDialog();
|
|
DydGameApi.this.mIsUserLoggedIn = true;
|
|
DydToast.toastShort(DydGameApi.this.appContext, "帐号升级成功!");
|
|
DydPreferenceManager.getInstance(DydGameApi.this.appContext).saveUserInfo(DydGameApi.this.mCurrentPlayer);
|
|
handleAccountUpgradeFinishedCallback(AccountUpgradeFinishType.SUCCESS, dydPlayerModel, DydGameApi.this.mCurrentPlayer);
|
|
handleLoginFinishedCallback(LoginFinishType.NORMAL_LOGIN, DydGameApi.this.mCurrentPlayer);
|
|
}
|
|
} else if (i2 == REQUEST_THIRD_PARTY_LOGIN_BY_DYD_TOKEN) {
|
|
if (!Utils.isListEmpty(listJsonDataModel.getUserList())) {
|
|
DydGameApi.this.mCurrentPlayer = listJsonDataModel.getUserList().get(0);
|
|
DydGameApi.this.mDialogUtil.loginDialog.dismissDialog();
|
|
DydGameApi.this.mIsUserLoggedIn = true;
|
|
DydPreferenceManager.getInstance(DydGameApi.this.appContext).saveUserInfo(DydGameApi.this.mCurrentPlayer);
|
|
handleLoginFinishedCallback(LoginFinishType.NORMAL_LOGIN, DydGameApi.this.mCurrentPlayer);
|
|
}
|
|
} else if (i2 == REQUEST_BIND_THIRD_PARTY_BY_DYD_TOKEN) {
|
|
if (!Utils.isListEmpty(listJsonDataModel.getUserList())) {
|
|
DydPlayerModel dydPlayerModel2 = DydGameApi.this.mCurrentPlayer;
|
|
DydGameApi.this.mCurrentPlayer = listJsonDataModel.getUserList().get(0);
|
|
DydGameApi.this.mDialogUtil.bindAccountDialog.dismissDialog();
|
|
DydGameApi.this.mIsUserLoggedIn = true;
|
|
DydToast.toastShort(DydGameApi.this.appContext, "绑定成功!");
|
|
DydPreferenceManager.getInstance(DydGameApi.this.appContext).saveUserInfo(DydGameApi.this.mCurrentPlayer);
|
|
handleAccountUpgradeFinishedCallback(AccountUpgradeFinishType.SUCCESS, dydPlayerModel2, DydGameApi.this.mCurrentPlayer);
|
|
handleLoginFinishedCallback(LoginFinishType.NORMAL_LOGIN, DydGameApi.this.mCurrentPlayer);
|
|
}
|
|
} else if (i2 == REQUEST_BIND_BY_PHONE && !Utils.isListEmpty(listJsonDataModel.getUserList())) {
|
|
DydPlayerModel dydPlayerModel3 = DydGameApi.this.mCurrentPlayer;
|
|
DydGameApi.this.mCurrentPlayer = listJsonDataModel.getUserList().get(0);
|
|
DydGameApi.this.mDialogUtil.bindAccountDialog.dismissDialog();
|
|
DydGameApi.this.mIsUserLoggedIn = true;
|
|
DydToast.toastShort(DydGameApi.this.appContext, "绑定手机成功!");
|
|
DydPreferenceManager.getInstance(DydGameApi.this.appContext).saveUserInfo(DydGameApi.this.mCurrentPlayer);
|
|
handleAccountUpgradeFinishedCallback(AccountUpgradeFinishType.SUCCESS, dydPlayerModel3, DydGameApi.this.mCurrentPlayer);
|
|
handleLoginFinishedCallback(LoginFinishType.NORMAL_LOGIN, DydGameApi.this.mCurrentPlayer);
|
|
}
|
|
DydGameApi.birthday = DydGameApi.this.mCurrentPlayer.getBirthday();
|
|
}
|
|
}
|
|
|
|
private boolean checkNetworkResponse(Object obj, int i, int i2) {
|
|
String str;
|
|
if (obj == null) {
|
|
return false;
|
|
}
|
|
JsonData jsonData = (JsonData) obj;
|
|
if (i == 403) {
|
|
DydToast.toastShort(DydGameApi.this.appContext, "当前帐号未登录");
|
|
return false;
|
|
}
|
|
if (i != 200) {
|
|
if (i == 409) {
|
|
str = "数据解析出了点问题";
|
|
} else {
|
|
str = i == 500 ? "服务器出了点问题,请稍后再试" : "网络状况不太好,请稍后再试";
|
|
}
|
|
DydToast.toastShort(DydGameApi.this.appContext, str);
|
|
return false;
|
|
}
|
|
if (jsonData.getCode() == 200) {
|
|
return true;
|
|
}
|
|
String message = jsonData.getMessage();
|
|
if (!Utils.isNull(message)) {
|
|
DydToast.toastShort(DydGameApi.this.appContext, message);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public boolean handleLoginFinishedCallback(final LoginFinishType loginFinishType, final DydPlayer dydPlayer) {
|
|
if (DydGameApi.this.mLoginFinishedListener == null) {
|
|
return false;
|
|
}
|
|
new Handler(Looper.getMainLooper()).post(new Runnable() { // from class: com.diyidan.game.api.DydGameApi.NetworkCallbackImpl.5
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
if (DydGameApi.this.mLoginFinishedListener != null) {
|
|
DydGameApi.this.mLoginFinishedListener.onLoginFinished(loginFinishType, dydPlayer);
|
|
}
|
|
DydGameApi.this.mLoginFinishedListener = null;
|
|
}
|
|
});
|
|
if (LoginFinishType.CANCEL == loginFinishType) {
|
|
return true;
|
|
}
|
|
DydGameApi.this.updateFloatViewVisibility(null);
|
|
return true;
|
|
}
|
|
|
|
public boolean handleAccountUpgradeFinishedCallback(final AccountUpgradeFinishType accountUpgradeFinishType, final DydPlayer dydPlayer, final DydPlayer dydPlayer2) {
|
|
if (DydGameApi.this.mAccountUpgradeFinishedListener == null) {
|
|
return false;
|
|
}
|
|
new Handler(Looper.getMainLooper()).post(new Runnable() { // from class: com.diyidan.game.api.DydGameApi.NetworkCallbackImpl.6
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
if (DydGameApi.this.mAccountUpgradeFinishedListener != null) {
|
|
DydGameApi.this.mAccountUpgradeFinishedListener.onUpgradeFinished(accountUpgradeFinishType, dydPlayer, dydPlayer2);
|
|
}
|
|
DydGameApi.this.mAccountUpgradeFinishedListener = null;
|
|
}
|
|
});
|
|
return true;
|
|
}
|
|
|
|
public void thirdPartyLoginByDydToken(Context context, String str) {
|
|
new UserNetwork2(context, this, REQUEST_THIRD_PARTY_LOGIN_BY_DYD_TOKEN).loginByDydToken(str);
|
|
}
|
|
|
|
public void bindThirdParty(Context context, String str) {
|
|
new UserNetwork2(context, this, REQUEST_BIND_THIRD_PARTY_BY_DYD_TOKEN).bindByDydToken(str);
|
|
}
|
|
|
|
public void bindByPhone(Context context, String str, String str2) {
|
|
new UserNetwork2(context, this, REQUEST_BIND_BY_PHONE).bindByPhone(str, str2);
|
|
}
|
|
}
|
|
|
|
private class DialogUtil {
|
|
private LoginDialog bindAccountDialog;
|
|
private AccountDetectDialog checkAccountDialog;
|
|
private Context context;
|
|
private RegisterDialog findPasswordDialog;
|
|
private SimpleInputDialog inputPhoneDialog;
|
|
private LoginDialog loginDialog;
|
|
private ProgressDialog mProgressDialog;
|
|
private NoticeTouristDialog noticeTouristDialog;
|
|
private PersonalCenterDialog personalCenterDialog;
|
|
private PrivacyDialog privacyDialog;
|
|
private RegisterDialog registerDialog;
|
|
private requestTipsDialog requestTipsDialog;
|
|
private RegisterDialog upgradeDialog;
|
|
private ViewFriendsDialog viewFriendsDialog;
|
|
private TouristCenterDialog visitorCenterDialog;
|
|
private WelcomeBackDialog welcomeBackDialog;
|
|
|
|
public DialogUtil(Activity activity) {
|
|
this.context = activity;
|
|
}
|
|
|
|
public PrivacyDialog getPrivacyDialog(PrivacyDialog.OnDialogListener onDialogListener) {
|
|
if (this.privacyDialog == null) {
|
|
this.privacyDialog = new PrivacyDialog(this.context).isCancelable(false);
|
|
}
|
|
return this.privacyDialog.setOnDialogListener(onDialogListener);
|
|
}
|
|
|
|
public ProgressDialog getProgressDialog() {
|
|
if (this.mProgressDialog == null) {
|
|
Context context = this.context;
|
|
ProgressDialog progressDialog = new ProgressDialog(context, Utils.getStyleId(context, "DydGameDialogTheme"));
|
|
this.mProgressDialog = progressDialog;
|
|
progressDialog.setMessage(this.context.getResources().getString(Utils.getStringlId(this.context, "entering_app_text")));
|
|
}
|
|
return this.mProgressDialog;
|
|
}
|
|
|
|
public LoginDialog getLoginDialog() {
|
|
if (this.loginDialog == null) {
|
|
this.loginDialog = LoginDialog.getDialog(this.context).isCancelable(false).setDialogListener(new LoginDialog.OnDialogListener() { // from class: com.diyidan.game.api.DydGameApi.DialogUtil.1
|
|
@Override // com.diyidan.game.dialog.LoginDialog.OnDialogListener
|
|
public void onLogin(String str, String str2) {
|
|
if (DialogUtil.this.getProgressDialog() != null) {
|
|
DialogUtil.this.getProgressDialog().show();
|
|
}
|
|
DydGameApi.this.PWD = str2;
|
|
DydGameApi.this.mNetworkCallbackImpl.loginByPhone(DialogUtil.this.context, str, str2);
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.LoginDialog.OnDialogListener
|
|
public void onRegister() {
|
|
DialogUtil.this.loginDialog.dismissDialog();
|
|
if (DialogUtil.this.getInputPhoneDialog() != null) {
|
|
DialogUtil.this.getInputPhoneDialog().showDialog();
|
|
}
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.LoginDialog.OnDialogListener
|
|
public void onTouristLogin() {
|
|
DydGameApi.this.mNetworkCallbackImpl.registerAsVisitor(DialogUtil.this.context);
|
|
if (DialogUtil.this.getProgressDialog() != null) {
|
|
DialogUtil.this.getProgressDialog().show();
|
|
}
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.LoginDialog.OnDialogListener
|
|
public void onFindPassWord() {
|
|
DialogUtil.this.loginDialog.dismissDialog();
|
|
if (DialogUtil.this.getFindPasswordDialog() != null) {
|
|
DialogUtil.this.getFindPasswordDialog().showDialog();
|
|
}
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.LoginDialog.OnDialogListener
|
|
public void onClose() {
|
|
if (DydGameApi.this.mLoginFinishedListener != null) {
|
|
DydGameApi.this.mLoginFinishedListener.onLoginFinished(LoginFinishType.CANCEL, null);
|
|
}
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.LoginDialog.OnDialogListener
|
|
public void onQQLogin() {
|
|
DydGameApi.this.startThirdPartyActivity(DialogUtil.this.context, DydGameApi.LOGIN_TYPE_QQ, DydGameApi.REQUEST_CODE_DYD_LOGIN);
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.LoginDialog.OnDialogListener
|
|
public void onWeixinLogin() {
|
|
DydGameApi.this.startThirdPartyActivity(DialogUtil.this.context, DydGameApi.LOGIN_TYPE_WEIXIN, DydGameApi.REQUEST_CODE_DYD_LOGIN);
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.LoginDialog.OnDialogListener
|
|
public void onWeiboLogin() {
|
|
DydGameApi.this.startThirdPartyActivity(DialogUtil.this.context, DydGameApi.LOGIN_TYPE_WEIBO, DydGameApi.REQUEST_CODE_DYD_LOGIN);
|
|
}
|
|
});
|
|
}
|
|
return this.loginDialog;
|
|
}
|
|
|
|
public AccountDetectDialog getCheckAccountDialog(DydPlayerModel dydPlayerModel) {
|
|
if (this.checkAccountDialog == null) {
|
|
this.checkAccountDialog = AccountDetectDialog.getDialog(this.context).setSubmitBtnText(this.context.getResources().getString(Utils.getStringlId(this.context, "authorize_login_text"))).isCancelable(false).setTitle(this.context.getResources().getString(Utils.getStringlId(this.context, "login_text"))).setMidCenterText(this.context.getResources().getString(Utils.getStringlId(this.context, "dyd_account_detected_text"))).setContentText("检测到第一弹通行证!是否登录?").setDialogListener(new AccountDetectDialog.OnDialogListener() { // from class: com.diyidan.game.api.DydGameApi.DialogUtil.2
|
|
@Override // com.diyidan.game.dialog.AccountDetectDialog.OnDialogListener
|
|
public void onSubmit() {
|
|
if (!DydGameApi.this.mCurrentPlayer.isNeedBindPhone()) {
|
|
if (!DydGameApi.this.mCurrentPlayer.isAVerifyUser()) {
|
|
DydToast.toastShort(DydGameApi.this.appContext, "账号未验证,请大大先去第一弹验证账号哦~");
|
|
return;
|
|
}
|
|
DydGameApi.this.mNetworkCallbackImpl.loginByDydToken(DialogUtil.this.context, DydGameApi.this.mCurrentPlayer.getToken());
|
|
if (DialogUtil.this.getProgressDialog() != null) {
|
|
DialogUtil.this.getProgressDialog().show();
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
DydGameApi.this.startBindPhone(DialogUtil.this.context, DydGameApi.REQUEST_CODE_DYD_BIND_PHONE, "", DydGameApi.this.mCurrentPlayer.getNickName(), "请设置手机号、登录密码~");
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.AccountDetectDialog.OnDialogListener
|
|
public void onOtherAction() {
|
|
DialogUtil.this.checkAccountDialog.dismissDialog();
|
|
if (DialogUtil.this.getLoginDialog() != null) {
|
|
DialogUtil.this.getLoginDialog().showDialog();
|
|
}
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.AccountDetectDialog.OnDialogListener
|
|
public void onClose() {
|
|
if (DydGameApi.this.mLoginFinishedListener != null) {
|
|
DydGameApi.this.mLoginFinishedListener.onLoginFinished(LoginFinishType.CANCEL, null);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
return this.checkAccountDialog;
|
|
}
|
|
|
|
public RegisterDialog getRegisterDialog() {
|
|
if (this.registerDialog == null) {
|
|
this.registerDialog = RegisterDialog.getDialog(this.context).isCancelable(false).setInputPhoneGone().setSummitText(this.context.getResources().getString(Utils.getStringlId(this.context, "register_text"))).setTitleText(this.context.getResources().getString(Utils.getStringlId(this.context, "register_account_text"))).setDialogListener(new RegisterDialog.OnDialogListener() { // from class: com.diyidan.game.api.DydGameApi.DialogUtil.3
|
|
@Override // com.diyidan.game.dialog.RegisterDialog.OnDialogListener
|
|
public void onClose() {
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.RegisterDialog.OnDialogListener
|
|
public void onSubmit() {
|
|
boolean isChecked = DialogUtil.this.registerDialog.getIsChecked();
|
|
String nickName = DialogUtil.this.registerDialog.getNickName();
|
|
String phoneNumber = DialogUtil.this.registerDialog.getPhoneNumber();
|
|
String password = DialogUtil.this.registerDialog.getPassword();
|
|
String codes = DialogUtil.this.registerDialog.getCodes();
|
|
if (Utils.isNull(codes)) {
|
|
DydToast.toastShort(DialogUtil.this.context, DialogUtil.this.context.getResources().getString(Utils.getStringlId(DialogUtil.this.context, "phone_codes_empty_text")));
|
|
return;
|
|
}
|
|
if (Utils.isNull(nickName)) {
|
|
DydToast.toastShort(DialogUtil.this.context, DialogUtil.this.context.getResources().getString(Utils.getStringlId(DialogUtil.this.context, "nick_name_empty_text")));
|
|
return;
|
|
}
|
|
if (Utils.isNull(password)) {
|
|
DydToast.toastShort(DialogUtil.this.context, DialogUtil.this.context.getResources().getString(Utils.getStringlId(DialogUtil.this.context, "password_empty_text")));
|
|
return;
|
|
}
|
|
if (password.length() < 6 || password.length() > 18) {
|
|
DydToast.toastShort(DialogUtil.this.context, DialogUtil.this.context.getResources().getString(Utils.getStringlId(DialogUtil.this.context, "password_length_illegal")));
|
|
} else {
|
|
if (isChecked) {
|
|
if (DydGameApi.this.mDialogUtil.getProgressDialog() != null) {
|
|
DydGameApi.this.mDialogUtil.getProgressDialog().show();
|
|
}
|
|
DydGameApi.this.mNetworkCallbackImpl.registerByPhone(DialogUtil.this.context, nickName, phoneNumber, password, codes, DydGameApi.this.mGameName);
|
|
return;
|
|
}
|
|
DydToast.toastShort(DialogUtil.this.context, DialogUtil.this.context.getResources().getString(Utils.getStringlId(DialogUtil.this.context, "agreement_not_check_text")));
|
|
}
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.RegisterDialog.OnDialogListener
|
|
public void onGetCodes() {
|
|
DydGameApi.this.mNetworkCallbackImpl.sendSms(DialogUtil.this.context, DialogUtil.this.registerDialog.getPhoneNumber(), NetworkCallbackImpl.REQUEST_SEND_SMS_REGISTER);
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.RegisterDialog.OnDialogListener
|
|
public void onBack() {
|
|
DialogUtil.this.registerDialog = null;
|
|
if (DialogUtil.this.getInputPhoneDialog() != null) {
|
|
DialogUtil.this.getInputPhoneDialog().showDialog();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
return this.registerDialog;
|
|
}
|
|
|
|
public SimpleInputDialog getInputPhoneDialog() {
|
|
if (this.inputPhoneDialog == null) {
|
|
this.inputPhoneDialog = SimpleInputDialog.getDialog(this.context).isCancelable(false).setSubmitText(this.context.getResources().getString(Utils.getStringlId(this.context, "get_verify_code"))).setTitle(this.context.getResources().getString(Utils.getStringlId(this.context, "account_register"))).setDialogListener(new SimpleInputDialog.OnDialogListener() { // from class: com.diyidan.game.api.DydGameApi.DialogUtil.4
|
|
@Override // com.diyidan.game.dialog.SimpleInputDialog.OnDialogListener
|
|
public void onSubmit(String str) {
|
|
if (Utils.isNull(str)) {
|
|
DydToast.toastShort(DialogUtil.this.context, DialogUtil.this.context.getResources().getString(Utils.getStringlId(DialogUtil.this.context, "phone_empty_text")));
|
|
} else {
|
|
if (!Utils.isMobileValid(str)) {
|
|
DydToast.toastShort(DialogUtil.this.context, DialogUtil.this.context.getResources().getString(Utils.getStringlId(DialogUtil.this.context, "phone_illegal_text")));
|
|
return;
|
|
}
|
|
if (DialogUtil.this.getRegisterDialog() != null) {
|
|
DialogUtil.this.getRegisterDialog().setPhoneNumber(str);
|
|
}
|
|
DydGameApi.this.mNetworkCallbackImpl.sendSms(DialogUtil.this.context, str, NetworkCallbackImpl.REQUEST_SEND_SMS_input_dialog);
|
|
}
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.SimpleInputDialog.OnDialogListener
|
|
public void onBack() {
|
|
DialogUtil.this.inputPhoneDialog = null;
|
|
if (DialogUtil.this.getLoginDialog() != null) {
|
|
DialogUtil.this.getLoginDialog().showDialog();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
return this.inputPhoneDialog;
|
|
}
|
|
|
|
public RegisterDialog getFindPasswordDialog() {
|
|
if (this.findPasswordDialog == null) {
|
|
this.findPasswordDialog = RegisterDialog.getDialog(this.context).isCancelable(false).setAgreementGone().setNoticeGone().setNickNameGone().setTitleText(this.context.getResources().getString(Utils.getStringlId(this.context, "find_password_text"))).setSummitText(this.context.getResources().getString(Utils.getStringlId(this.context, "ok"))).setDialogListener(new RegisterDialog.OnDialogListener() { // from class: com.diyidan.game.api.DydGameApi.DialogUtil.5
|
|
@Override // com.diyidan.game.dialog.RegisterDialog.OnDialogListener
|
|
public void onSubmit() {
|
|
String phoneNumber = DialogUtil.this.findPasswordDialog.getPhoneNumber();
|
|
String password = DialogUtil.this.findPasswordDialog.getPassword();
|
|
String codes = DialogUtil.this.findPasswordDialog.getCodes();
|
|
if (Utils.isNull(phoneNumber)) {
|
|
DydToast.toastShort(DialogUtil.this.context, DialogUtil.this.context.getResources().getString(Utils.getStringlId(DialogUtil.this.context, "phone_empty_text")));
|
|
return;
|
|
}
|
|
if (!Utils.isMobileValid(phoneNumber)) {
|
|
DydToast.toastShort(DialogUtil.this.context, DialogUtil.this.context.getResources().getString(Utils.getStringlId(DialogUtil.this.context, "phone_illegal_text")));
|
|
return;
|
|
}
|
|
if (Utils.isNull(codes)) {
|
|
DydToast.toastShort(DialogUtil.this.context, DialogUtil.this.context.getResources().getString(Utils.getStringlId(DialogUtil.this.context, "phone_codes_empty_text")));
|
|
return;
|
|
}
|
|
if (Utils.isNull(password)) {
|
|
DydToast.toastShort(DialogUtil.this.context, DialogUtil.this.context.getResources().getString(Utils.getStringlId(DialogUtil.this.context, "password_empty_text")));
|
|
return;
|
|
}
|
|
if (password.length() >= 6 && password.length() <= 18) {
|
|
if (DydGameApi.this.mDialogUtil.getProgressDialog() != null) {
|
|
DydGameApi.this.mDialogUtil.getProgressDialog().show();
|
|
}
|
|
DydGameApi.this.mNetworkCallbackImpl.resetAccountPassword(DialogUtil.this.context, phoneNumber, password, codes);
|
|
return;
|
|
}
|
|
DydToast.toastShort(DialogUtil.this.context, DialogUtil.this.context.getResources().getString(Utils.getStringlId(DialogUtil.this.context, "password_length_illegal")));
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.RegisterDialog.OnDialogListener
|
|
public void onGetCodes() {
|
|
String phoneNumber = DialogUtil.this.findPasswordDialog.getPhoneNumber();
|
|
if (Utils.isNull(phoneNumber)) {
|
|
DydToast.toastShort(DialogUtil.this.context, DialogUtil.this.context.getResources().getString(Utils.getStringlId(DialogUtil.this.context, "phone_empty_text")));
|
|
} else if (!Utils.isMobileValid(phoneNumber)) {
|
|
DydToast.toastShort(DialogUtil.this.context, DialogUtil.this.context.getResources().getString(Utils.getStringlId(DialogUtil.this.context, "phone_illegal_text")));
|
|
} else {
|
|
DydGameApi.this.mNetworkCallbackImpl.sendSms(DialogUtil.this.context, phoneNumber, NetworkCallbackImpl.REQUEST_SEND_SMS_FIND_PASSWORD);
|
|
}
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.RegisterDialog.OnDialogListener
|
|
public void onBack() {
|
|
DialogUtil.this.findPasswordDialog.dismissDialog();
|
|
DialogUtil.this.loginDialog.showDialog();
|
|
DialogUtil.this.findPasswordDialog = null;
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.RegisterDialog.OnDialogListener
|
|
public void onClose() {
|
|
DialogUtil.this.findPasswordDialog = null;
|
|
}
|
|
});
|
|
}
|
|
return this.findPasswordDialog;
|
|
}
|
|
|
|
public NoticeTouristDialog getNoticeVisitorDialog() {
|
|
if (this.noticeTouristDialog == null) {
|
|
this.noticeTouristDialog = NoticeTouristDialog.getDialog(this.context).setDialogListener(new NoticeTouristDialog.OnDialogListener() { // from class: com.diyidan.game.api.DydGameApi.DialogUtil.6
|
|
@Override // com.diyidan.game.dialog.NoticeTouristDialog.OnDialogListener
|
|
public void onUpgrade() {
|
|
DialogUtil.this.noticeTouristDialog.dismissDialog();
|
|
if (DialogUtil.this.getUpgradeDialog() != null) {
|
|
DialogUtil.this.getUpgradeDialog().showDialog();
|
|
}
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.NoticeTouristDialog.OnDialogListener
|
|
public void onLogin() {
|
|
if (DialogUtil.this.getProgressDialog() != null) {
|
|
DialogUtil.this.getProgressDialog().show();
|
|
}
|
|
DydGameApi.this.mNetworkCallbackImpl.registerAsVisitor(DialogUtil.this.context);
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.NoticeTouristDialog.OnDialogListener
|
|
public void onChange() {
|
|
DydGameApi.this.clearExistedData();
|
|
DialogUtil.this.noticeTouristDialog.dismissDialog();
|
|
if (DialogUtil.this.getLoginDialog() != null) {
|
|
DialogUtil.this.getLoginDialog().showDialog();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
return this.noticeTouristDialog;
|
|
}
|
|
|
|
public RegisterDialog getUpgradeDialog() {
|
|
if (this.upgradeDialog == null) {
|
|
this.upgradeDialog = RegisterDialog.getDialog(this.context).isCancelable(false).setNoticeGone().setNickNameGone().setTitleText(this.context.getResources().getString(Utils.getStringlId(this.context, "upgrade_account_text"))).setSummitText(this.context.getResources().getString(Utils.getStringlId(this.context, "ok"))).setDialogListener(new RegisterDialog.OnDialogListener() { // from class: com.diyidan.game.api.DydGameApi.DialogUtil.7
|
|
@Override // com.diyidan.game.dialog.RegisterDialog.OnDialogListener
|
|
public void onSubmit() {
|
|
String phoneNumber = DialogUtil.this.upgradeDialog.getPhoneNumber();
|
|
String password = DialogUtil.this.upgradeDialog.getPassword();
|
|
String codes = DialogUtil.this.upgradeDialog.getCodes();
|
|
boolean isChecked = DialogUtil.this.upgradeDialog.getIsChecked();
|
|
if (Utils.isNull(phoneNumber)) {
|
|
DydToast.toastShort(DialogUtil.this.context, DialogUtil.this.context.getResources().getString(Utils.getStringlId(DialogUtil.this.context, "phone_empty_text")));
|
|
return;
|
|
}
|
|
if (!Utils.isMobileValid(phoneNumber)) {
|
|
DydToast.toastShort(DialogUtil.this.context, DialogUtil.this.context.getResources().getString(Utils.getStringlId(DialogUtil.this.context, "phone_illegal_text")));
|
|
return;
|
|
}
|
|
if (Utils.isNull(codes)) {
|
|
DydToast.toastShort(DialogUtil.this.context, DialogUtil.this.context.getResources().getString(Utils.getStringlId(DialogUtil.this.context, "phone_codes_empty_text")));
|
|
return;
|
|
}
|
|
if (Utils.isNull(password)) {
|
|
DydToast.toastShort(DialogUtil.this.context, DialogUtil.this.context.getResources().getString(Utils.getStringlId(DialogUtil.this.context, "password_empty_text")));
|
|
return;
|
|
}
|
|
if (password.length() < 6 || password.length() > 18) {
|
|
DydToast.toastShort(DialogUtil.this.context, DialogUtil.this.context.getResources().getString(Utils.getStringlId(DialogUtil.this.context, "password_length_illegal")));
|
|
} else {
|
|
if (!isChecked) {
|
|
DydToast.toastShort(DialogUtil.this.context, DialogUtil.this.context.getResources().getString(Utils.getStringlId(DialogUtil.this.context, "agreement_not_check_text")));
|
|
return;
|
|
}
|
|
if (DialogUtil.this.getProgressDialog() != null) {
|
|
DialogUtil.this.getProgressDialog().show();
|
|
}
|
|
DydGameApi.this.mNetworkCallbackImpl.visitorUpgrade(DialogUtil.this.context, phoneNumber, password, codes);
|
|
}
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.RegisterDialog.OnDialogListener
|
|
public void onGetCodes() {
|
|
String phoneNumber = DialogUtil.this.upgradeDialog.getPhoneNumber();
|
|
if (Utils.isNull(phoneNumber)) {
|
|
DydToast.toastShort(DialogUtil.this.context, DialogUtil.this.context.getResources().getString(Utils.getStringlId(DialogUtil.this.context, "phone_empty_text")));
|
|
} else if (!Utils.isMobileValid(phoneNumber)) {
|
|
DydToast.toastShort(DialogUtil.this.context, DialogUtil.this.context.getResources().getString(Utils.getStringlId(DialogUtil.this.context, "phone_illegal_text")));
|
|
} else {
|
|
DydGameApi.this.mNetworkCallbackImpl.sendSms(DialogUtil.this.context, phoneNumber, NetworkCallbackImpl.REQUEST_SEND_SMS_UPGRADE);
|
|
}
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.RegisterDialog.OnDialogListener
|
|
public void onBack() {
|
|
DialogUtil.this.upgradeDialog = null;
|
|
if (DialogUtil.this.getNoticeVisitorDialog() != null) {
|
|
DialogUtil.this.getNoticeVisitorDialog().showDialog();
|
|
}
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.RegisterDialog.OnDialogListener
|
|
public void onClose() {
|
|
DialogUtil.this.upgradeDialog = null;
|
|
if (DydGameApi.this.mAccountUpgradeFinishedListener != null) {
|
|
DydGameApi.this.mAccountUpgradeFinishedListener.onUpgradeFinished(AccountUpgradeFinishType.CANCEL, null, null);
|
|
}
|
|
if (DydGameApi.this.mLoginFinishedListener != null) {
|
|
DydGameApi.this.mLoginFinishedListener.onLoginFinished(LoginFinishType.CANCEL, null);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
return this.upgradeDialog;
|
|
}
|
|
|
|
public WelcomeBackDialog getWelcomeBackDialog() {
|
|
if (this.welcomeBackDialog == null) {
|
|
this.welcomeBackDialog = WelcomeBackDialog.getDialog(this.context).setDialogListener(new WelcomeBackDialog.OnDialogListener() { // from class: com.diyidan.game.api.DydGameApi.DialogUtil.8
|
|
@Override // com.diyidan.game.dialog.WelcomeBackDialog.OnDialogListener
|
|
public void onDialogNormalFinish() {
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.WelcomeBackDialog.OnDialogListener
|
|
public void onSwitchAccount() {
|
|
DialogUtil.this.welcomeBackDialog.dismissDialog();
|
|
DydGameApi.this.cancelWelcomeBackRunnable();
|
|
DydGameApi.this.mNetworkCallbackImpl.logout(DialogUtil.this.context);
|
|
if (DialogUtil.this.getLoginDialog() != null) {
|
|
DialogUtil.this.getLoginDialog().showDialog();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
return this.welcomeBackDialog;
|
|
}
|
|
|
|
public PersonalCenterDialog getPersonalCenterDialog() {
|
|
if (this.personalCenterDialog == null) {
|
|
this.personalCenterDialog = PersonalCenterDialog.getDialog(this.context).isCancelable(false).setOnDialogListener(new PersonalCenterDialog.OnDialogListener() { // from class: com.diyidan.game.api.DydGameApi.DialogUtil.9
|
|
@Override // com.diyidan.game.dialog.PersonalCenterDialog.OnDialogListener
|
|
public void onModifyPassword() {
|
|
DialogUtil.this.personalCenterDialog.dismissDialog();
|
|
DialogUtil.this.getFindPasswordDialog().setTitleText("修改密码").isShowBack(false).isShowClose(true).showDialog();
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.PersonalCenterDialog.OnDialogListener
|
|
public void onViewFriends() {
|
|
DialogUtil.this.personalCenterDialog.dismissDialog();
|
|
if (DialogUtil.this.getViewFriendsDialog() != null) {
|
|
DialogUtil.this.getViewFriendsDialog().showDialog();
|
|
}
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.PersonalCenterDialog.OnDialogListener
|
|
public void onSwitchAccount() {
|
|
final ConfirmDialog confirmDialog = new ConfirmDialog((Activity) DialogUtil.this.context);
|
|
confirmDialog.show();
|
|
confirmDialog.setContent("确定要切换通行证吗?").setOKButtonClickListener("确定", new View.OnClickListener() { // from class: com.diyidan.game.api.DydGameApi.DialogUtil.9.2
|
|
@Override // android.view.View.OnClickListener
|
|
public void onClick(View view) {
|
|
confirmDialog.dismiss();
|
|
if (DialogUtil.this.personalCenterDialog != null) {
|
|
DialogUtil.this.personalCenterDialog.dismissDialog();
|
|
}
|
|
DialogUtil.this.personalCenterDialog = null;
|
|
DydGameApi.this.mIsUserLoggedIn = false;
|
|
if (DydGameApi.this.mNetworkCallbackImpl != null) {
|
|
DydGameApi.this.mNetworkCallbackImpl.logout(DialogUtil.this.context);
|
|
}
|
|
}
|
|
}).setCancelButtonClickListener("取消", new View.OnClickListener() { // from class: com.diyidan.game.api.DydGameApi.DialogUtil.9.1
|
|
@Override // android.view.View.OnClickListener
|
|
public void onClick(View view) {
|
|
confirmDialog.dismiss();
|
|
}
|
|
});
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.PersonalCenterDialog.OnDialogListener
|
|
public void onExitGame() {
|
|
new QuitGameDialog(DydGameApi.this.mContext).show();
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.PersonalCenterDialog.OnDialogListener
|
|
public void onChangeFloatViewVisibility(boolean z) {
|
|
if (!DydGameApi.this.mIsEnteredGame || !DydGameApi.this.mIsUserLoggedIn || z) {
|
|
DydPreferenceManager.getInstance(DydGameApi.this.appContext).saveFloatViewVisibility(z);
|
|
DydGameApi.this.mIsFloatViewAllowVisible = z;
|
|
DydGameApi.this.updateFloatViewVisibility(null);
|
|
} else {
|
|
final ConfirmDialog confirmDialog = new ConfirmDialog((Activity) DialogUtil.this.context);
|
|
confirmDialog.setCancelable(false);
|
|
confirmDialog.setCanceledOnTouchOutside(false);
|
|
confirmDialog.show();
|
|
confirmDialog.setContent("关闭后,悬浮球只能在登录页中重新设定显示。确认继续吗?").setOKButtonClickListener("确定", new View.OnClickListener() { // from class: com.diyidan.game.api.DydGameApi.DialogUtil.9.4
|
|
@Override // android.view.View.OnClickListener
|
|
public void onClick(View view) {
|
|
confirmDialog.dismiss();
|
|
DydPreferenceManager.getInstance(DydGameApi.this.appContext).saveFloatViewVisibility(false);
|
|
DydGameApi.this.mIsFloatViewAllowVisible = false;
|
|
DydGameApi.this.updateFloatViewVisibility(null);
|
|
}
|
|
}).setCancelButtonClickListener("取消", new View.OnClickListener() { // from class: com.diyidan.game.api.DydGameApi.DialogUtil.9.3
|
|
@Override // android.view.View.OnClickListener
|
|
public void onClick(View view) {
|
|
confirmDialog.dismiss();
|
|
DialogUtil.this.personalCenterDialog.setWiperSwitch(true);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.PersonalCenterDialog.OnDialogListener
|
|
public void onChangeBind() {
|
|
DydGameApi.this.startBindPhone(DialogUtil.this.context, DydGameApi.REQUEST_CHANGE_BIND_PHONE, DydGameApi.this.mCurrentPlayer.getAccount(), DydGameApi.this.mCurrentPlayer.getNickName(), "");
|
|
}
|
|
});
|
|
}
|
|
return this.personalCenterDialog;
|
|
}
|
|
|
|
public requestTipsDialog getRequestTipsDialog(String str) {
|
|
requestTipsDialog dialogListen = new requestTipsDialog(this.context, "", str).setDialogListen(new requestTipsDialog.OnDialogListen() { // from class: com.diyidan.game.api.DydGameApi.DialogUtil.10
|
|
@Override // com.diyidan.game.dialog.requestTipsDialog.OnDialogListen
|
|
public void BindPhone() {
|
|
DialogUtil.this.requestTipsDialog.dismiss();
|
|
if (DialogUtil.this.getBindAccountDialog() != null) {
|
|
DialogUtil.this.getBindAccountDialog().showDialog();
|
|
}
|
|
}
|
|
});
|
|
this.requestTipsDialog = dialogListen;
|
|
return dialogListen;
|
|
}
|
|
|
|
public TouristCenterDialog getVisitorCenterDialog() {
|
|
if (this.visitorCenterDialog == null) {
|
|
this.visitorCenterDialog = TouristCenterDialog.getDialog(this.context).isCancelable(false).setOnDialogListener(new TouristCenterDialog.OnDialogListener() { // from class: com.diyidan.game.api.DydGameApi.DialogUtil.11
|
|
@Override // com.diyidan.game.dialog.TouristCenterDialog.OnDialogListener
|
|
public void onBindPhone() {
|
|
DialogUtil.this.visitorCenterDialog.dismissDialog();
|
|
if (DialogUtil.this.getBindAccountDialog() != null) {
|
|
DialogUtil.this.getBindAccountDialog().showDialog();
|
|
}
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.TouristCenterDialog.OnDialogListener
|
|
public void onSwitchAccount() {
|
|
final ConfirmDialog confirmDialog = new ConfirmDialog((Activity) DialogUtil.this.context);
|
|
confirmDialog.show();
|
|
confirmDialog.setContent("确定要切换帐号吗?").setOKButtonClickListener("确定", new View.OnClickListener() { // from class: com.diyidan.game.api.DydGameApi.DialogUtil.11.2
|
|
@Override // android.view.View.OnClickListener
|
|
public void onClick(View view) {
|
|
confirmDialog.dismiss();
|
|
if (DialogUtil.this.visitorCenterDialog != null) {
|
|
DialogUtil.this.visitorCenterDialog.dismissDialog();
|
|
}
|
|
DialogUtil.this.visitorCenterDialog = null;
|
|
DydGameApi.this.mIsUserLoggedIn = false;
|
|
if (DydGameApi.this.mNetworkCallbackImpl != null) {
|
|
DydGameApi.this.mNetworkCallbackImpl.logout(DialogUtil.this.context);
|
|
}
|
|
}
|
|
}).setCancelButtonClickListener("取消", new View.OnClickListener() { // from class: com.diyidan.game.api.DydGameApi.DialogUtil.11.1
|
|
@Override // android.view.View.OnClickListener
|
|
public void onClick(View view) {
|
|
confirmDialog.dismiss();
|
|
}
|
|
});
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.TouristCenterDialog.OnDialogListener
|
|
public void onExitGame() {
|
|
new QuitGameDialog(DydGameApi.this.mContext).show();
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.TouristCenterDialog.OnDialogListener
|
|
public void onChangeFloatViewVisibility(boolean z) {
|
|
if (!DydGameApi.this.mIsEnteredGame || !DydGameApi.this.mIsUserLoggedIn || z) {
|
|
DydPreferenceManager.getInstance(DydGameApi.this.appContext).saveFloatViewVisibility(z);
|
|
DydGameApi.this.mIsFloatViewAllowVisible = z;
|
|
DydGameApi.this.updateFloatViewVisibility(null);
|
|
} else {
|
|
final ConfirmDialog confirmDialog = new ConfirmDialog((Activity) DialogUtil.this.context);
|
|
confirmDialog.setCancelable(false);
|
|
confirmDialog.setCanceledOnTouchOutside(false);
|
|
confirmDialog.show();
|
|
confirmDialog.setContent("关闭后,悬浮球只能在登录页中重新设定显示。确认继续吗?").setOKButtonClickListener("确定", new View.OnClickListener() { // from class: com.diyidan.game.api.DydGameApi.DialogUtil.11.4
|
|
@Override // android.view.View.OnClickListener
|
|
public void onClick(View view) {
|
|
confirmDialog.dismiss();
|
|
DydPreferenceManager.getInstance(DydGameApi.this.appContext).saveFloatViewVisibility(false);
|
|
DydGameApi.this.mIsFloatViewAllowVisible = false;
|
|
DydGameApi.this.updateFloatViewVisibility(null);
|
|
}
|
|
}).setCancelButtonClickListener("取消", new View.OnClickListener() { // from class: com.diyidan.game.api.DydGameApi.DialogUtil.11.3
|
|
@Override // android.view.View.OnClickListener
|
|
public void onClick(View view) {
|
|
confirmDialog.dismiss();
|
|
DialogUtil.this.visitorCenterDialog.setWiperSwitch(true);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
return this.visitorCenterDialog;
|
|
}
|
|
|
|
public ViewFriendsDialog getViewFriendsDialog() {
|
|
if (this.viewFriendsDialog == null) {
|
|
this.viewFriendsDialog = ViewFriendsDialog.getDialog(this.context).setOnDialogListener(new ViewFriendsDialog.OnDialogListener() { // from class: com.diyidan.game.api.DydGameApi.DialogUtil.12
|
|
@Override // com.diyidan.game.dialog.ViewFriendsDialog.OnDialogListener
|
|
public void onClose() {
|
|
DialogUtil.this.viewFriendsDialog.dismissDialog();
|
|
DialogUtil.this.viewFriendsDialog = null;
|
|
}
|
|
});
|
|
}
|
|
return this.viewFriendsDialog;
|
|
}
|
|
|
|
public LoginDialog getBindAccountDialog() {
|
|
if (this.bindAccountDialog == null) {
|
|
LoginDialog loginDialogIsCancelable = new LoginDialog(this.context, a.e).isCancelable(false);
|
|
Context context = this.context;
|
|
LoginDialog title = loginDialogIsCancelable.setTitle(context.getString(Utils.getStringlId(context, "bind_account_text")));
|
|
Context context2 = this.context;
|
|
this.bindAccountDialog = title.setLoginText(context2.getString(Utils.getStringlId(context2, "bind_option_text"))).setTouristLoginVisible(false).setDialogListener(new LoginDialog.OnDialogListener() { // from class: com.diyidan.game.api.DydGameApi.DialogUtil.13
|
|
@Override // com.diyidan.game.dialog.LoginDialog.OnDialogListener
|
|
public void onFindPassWord() {
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.LoginDialog.OnDialogListener
|
|
public void onTouristLogin() {
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.LoginDialog.OnDialogListener
|
|
public void onLogin(String str, String str2) {
|
|
if (DialogUtil.this.getProgressDialog() != null) {
|
|
DialogUtil.this.getProgressDialog().show();
|
|
}
|
|
DydGameApi.this.mNetworkCallbackImpl.bindByPhone(DydGameApi.this.appContext, str, str2);
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.LoginDialog.OnDialogListener
|
|
public void onRegister() {
|
|
DialogUtil.this.bindAccountDialog.dismissDialog();
|
|
DialogUtil.this.bindAccountDialog = null;
|
|
if (DialogUtil.this.getUpgradeDialog() != null) {
|
|
DialogUtil.this.getUpgradeDialog().isCancelable(false).isShowBack(false).isShowClose(true).showDialog();
|
|
}
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.LoginDialog.OnDialogListener
|
|
public void onClose() {
|
|
DialogUtil.this.bindAccountDialog = null;
|
|
if (DydGameApi.this.mLoginFinishedListener != null) {
|
|
DydGameApi.this.mLoginFinishedListener.onLoginFinished(LoginFinishType.CANCEL, null);
|
|
}
|
|
if (DydGameApi.this.mAccountUpgradeFinishedListener != null) {
|
|
DydGameApi.this.mAccountUpgradeFinishedListener.onUpgradeFinished(AccountUpgradeFinishType.CANCEL, null, null);
|
|
}
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.LoginDialog.OnDialogListener
|
|
public void onQQLogin() {
|
|
DydGameApi.this.startThirdPartyActivity(DialogUtil.this.context, DydGameApi.LOGIN_TYPE_QQ, DydGameApi.REQUEST_CODE_DYD_BIND);
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.LoginDialog.OnDialogListener
|
|
public void onWeixinLogin() {
|
|
DydGameApi.this.startThirdPartyActivity(DialogUtil.this.context, DydGameApi.LOGIN_TYPE_WEIXIN, DydGameApi.REQUEST_CODE_DYD_BIND);
|
|
}
|
|
|
|
@Override // com.diyidan.game.dialog.LoginDialog.OnDialogListener
|
|
public void onWeiboLogin() {
|
|
DydGameApi.this.startThirdPartyActivity(DialogUtil.this.context, DydGameApi.LOGIN_TYPE_WEIBO, DydGameApi.REQUEST_CODE_DYD_BIND);
|
|
}
|
|
});
|
|
}
|
|
return this.bindAccountDialog;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void updateFloatViewVisibility(Activity activity) {
|
|
if (this.mFloatView == null && activity == null) {
|
|
return;
|
|
}
|
|
if (activity != null) {
|
|
this.mFloatView = new FloatView(activity);
|
|
}
|
|
if (isFloatViewOkayToShow()) {
|
|
this.mFloatView.setOnFloatViewClickListener(new OnFloatViewClick());
|
|
this.mFloatView.setVisibility(0);
|
|
} else {
|
|
this.mFloatView.setVisibility(8);
|
|
}
|
|
}
|
|
|
|
private boolean isFloatViewOkayToShow() {
|
|
if (this.mCurrentPlayer == null || !this.mIsUserLoggedIn) {
|
|
return false;
|
|
}
|
|
if (this.mIsEnteredGame) {
|
|
return this.mIsFloatViewAllowVisible;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void startThirdPartyActivity(Context context, String str, int i) {
|
|
if (Utils.isDydAppInstalled(getAppContext())) {
|
|
try {
|
|
Intent intent = new Intent();
|
|
intent.putExtra("login_type", str);
|
|
intent.putExtra("appKey", "" + this.mAppKey);
|
|
intent.putExtra("secretKey", this.mSecretKey);
|
|
intent.putExtra("packageName", this.appContext.getPackageName());
|
|
intent.setClassName(Constants.DYD_PACKAGE_NAME, Constants.DYD_OAUTH_LOGIN_PAGE_FULL_NAME);
|
|
((Activity) context).startActivityForResult(intent, i);
|
|
return;
|
|
} catch (Exception unused) {
|
|
DydToast.toastShort(getAppContext(), context.getString(Utils.getStringlId(context, "upgrade_dyd_app_toast")));
|
|
jumpToDydDownloadPage(context);
|
|
return;
|
|
}
|
|
}
|
|
DydToast.toastShort(getAppContext(), context.getString(Utils.getStringlId(context, "install_dyd_app_toast")));
|
|
jumpToDydDownloadPage(context);
|
|
}
|
|
|
|
public void setAuthSuccessListener(AuthSuccessListener authSuccessListener2) {
|
|
authSuccessListener = authSuccessListener2;
|
|
}
|
|
|
|
private void jumpToDydDownloadPage(Context context) {
|
|
if (context == null) {
|
|
return;
|
|
}
|
|
Intent intent = new Intent(context, (Class<?>) WebViewActivity.class);
|
|
intent.putExtra("url", Constants.URL_DYD_DOWNLOAD_PAGE);
|
|
context.startActivity(intent);
|
|
}
|
|
|
|
private class OnFloatViewClick implements FloatView.OnFloatViewClickListener {
|
|
private OnFloatViewClick() {
|
|
}
|
|
|
|
@Override // com.diyidan.game.widget.FloatView.OnFloatViewClickListener
|
|
public void onFloatViewClick() {
|
|
if (!DydGameApi.this.mIsUserLoggedIn || DydGameApi.this.mCurrentPlayer == null) {
|
|
if (DydGameApi.this.appContext != null) {
|
|
DydToast.toastShort(DydGameApi.this.appContext, DydGameApi.this.appContext.getString(Utils.getStringlId(DydGameApi.this.appContext, "login_first_toast")));
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
DydGameApi.this.startPersonalCenter();
|
|
}
|
|
}
|
|
} |