当前位置: 首页 > 工具软件 > JFinal OA > 使用案例 >

android+oa框架,定制Android App的OA UI

薛元忠
2023-12-01

//OALoginActivity中的LoginTask

protected class LoginTask extends TaskWithDialog> {

private String loginId;

private String password;

private String sig;

private String nocToken;

private String cSessionId;

public LoginTask(Activity activity, String loginId, String password, String sig, String nocToken, String cSessionId) {

super(activity);

this.loginId = loginId;

this.password = password;

this.sig = sig;

this.nocToken = nocToken;

this.cSessionId = cSessionId;

}

protected Result asyncExecute(Void... params) {

Map loginRequest = new HashMap();

if (this.loginId != null) {

loginRequest.put("loginId", this.loginId);

}

if (this.password != null) {

try {

String rsaKey = RSAKey.getRsaPubkey();

if (TextUtils.isEmpty(rsaKey)) {

return null;

}

loginRequest.put("password", Rsa.encrypt(this.password, rsaKey));

} catch (Exception var4) {

return null;

}

}

LoginActivity.this.hideSoftInputForHw();

Result result;

if (!CommonUtils.isNetworkAvailable()) {

if (ConfigManager.getInstance().isSupportOfflineLogin()) {

return LoginActivity.this.tryOfflineLogin(this.loginId, this.password);

} else {

result = new Result();

result.code = 10014;

result.message = MessageUtils.getMessageContent(10014, new Object[0]);

return result;

}

} else {

if (this.sig != null) {

loginRequest.put("sig", this.sig);

}

if (!TextUtils.isEmpty(this.cSessionId)) {

loginRequest.put("csessionid", this.cSessionId);

}

if (!TextUtils.isEmpty(this.nocToken)) {

loginRequest.put("nctoken", this.nocToken);

}

result = OpenAccountUtils.toLoginResult(RpcUtils.pureInvokeWithRiskControlInfo("loginRequest", loginRequest, "login"));

return ConfigManager.getInstance().isSupportOfflineLogin() && result.code == 10019 ? LoginActivity.this.tryOfflineLogin(this.loginId, this.password) : result;

}

}

protected void doWhenException(Throwable t) {

this.executorService.postUITask(new Runnable() {

public void run() {

ToastUtils.toastSystemError(LoginTask.this.context);

}

});

}

protected void onPostExecute(Result result) {

this.dismissProgressDialog();

super.onPostExecute(result);

try {

if (result == null) {

if (ConfigManager.getInstance().isSupportOfflineLogin()) {

ToastUtils.toastNetworkError(this.context);

} else {

ToastUtils.toastSystemError(this.context);

}

} else {

android.net.Uri.Builder builder;

Intent h5Intent;

String accountName;

switch(result.code) {

case 1:

if (result.data != null && ((LoginResult)result.data).loginSuccessResult != null) {

SessionData sessionData = OpenAccountUtils.createSessionDataFromLoginSuccessResult(((LoginResult)result.data).loginSuccessResult);

if (sessionData.scenario == null) {

sessionData.scenario = 1;

}

LoginActivity.this.sessionManagerService.updateSession(sessionData);

accountName = ((LoginResult)result.data).userInputName;

if (TextUtils.isEmpty(accountName)) {

accountName = this.loginId;

}

if (ConfigManager.getInstance().isSupportOfflineLogin()) {

OpenAccountSDK.getSqliteUtil().saveToSqlite(this.loginId, this.password);

}

boolean isExist = LoginActivity.this.loginIdEdit.saveInputHistory(accountName);

if (AccountPasswordLoginFlow.showTipAlertAfterLogin && !isExist) {

String message = ResourceUtils.getString(LoginActivity.this.getApplicationContext(), "ali_sdk_openaccount_dynamic_text_alert_msg_after_login");

LoginActivity.this.showTipDialog(String.format(message, this.loginId));

} else {

LoginActivity.this.loginSuccess();

}

return;

}

break;

case 2:

SessionData sessionData1 = OpenAccountUtils.createSessionDataFromLoginSuccessResult(((LoginResult)result.data).loginSuccessResult);

if (sessionData1.scenario == null) {

sessionData1.scenario = 1;

}

LoginActivity.this.sessionManagerService.updateSession(sessionData1);

LoginActivity.this.loginSuccess();

break;

case 4037:

if (AccountPasswordLoginFlow.showAlertForPwdErrorToManyTimes) {

String postive = LoginActivity.this.getResources().getString(string.ali_sdk_openaccount_text_confirm);

accountName = LoginActivity.this.getResources().getString(string.ali_sdk_openaccount_text_reset_password);

final ToastUtils toastUtils = new ToastUtils();

android.content.DialogInterface.OnClickListener postiveListener = new android.content.DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog, int which) {

toastUtils.dismissAlertDialog(LoginActivity.this);

}

};

android.content.DialogInterface.OnClickListener negativeListener = new android.content.DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog, int which) {

LoginActivity.this.forgetPassword((View)null);

}

};

//重写toastUtils类的alert()方法

toastUtils.alert(LoginActivity.this, "", result.message, postive, postiveListener, accountName, negativeListener);

} else {

ToastUtils.toast(this.context, result.message, result.code);

}

break;

case 26053:

if (result.data != null && ((LoginResult)result.data).checkCodeResult != null && !TextUtils.isEmpty(((LoginResult)result.data).checkCodeResult.clientVerifyData)) {

builder = Uri.parse(((LoginResult)result.data).checkCodeResult.clientVerifyData).buildUpon();

builder.appendQueryParameter("callback", "https://www.alipay.com/webviewbridge");

h5Intent = new Intent(LoginActivity.this, LoginDoubleCheckWebActivity.class);

h5Intent.putExtra("url", builder.toString());

h5Intent.putExtra("title", result.message);

h5Intent.putExtra("callback", "https://www.alipay.com/webviewbridge");

LoginActivity.this.startActivityForResult(h5Intent, RequestCode.NO_CAPTCHA_REQUEST_CODE);

return;

}

break;

case 26152:

if (result.data != null && ((LoginResult)result.data).checkCodeResult != null && !TextUtils.isEmpty(((LoginResult)result.data).checkCodeResult.clientVerifyData)) {

builder = Uri.parse(((LoginResult)result.data).checkCodeResult.clientVerifyData).buildUpon();

builder.appendQueryParameter("callback", "https://www.alipay.com/webviewbridge");

h5Intent = new Intent(LoginActivity.this, LoginIVWebActivity.class);

h5Intent.putExtra("url", builder.toString());

h5Intent.putExtra("title", result.message);

h5Intent.putExtra("callback", "https://www.alipay.com/webviewbridge");

LoginActivity.this.startActivityForResult(h5Intent, RequestCode.RISK_IV_REQUEST_CODE);

}

break;

default:

if (TextUtils.equals(result.type, "CALLBACK") && LoginActivity.this.getLoginCallback() != null) {

LoginActivity.this.getLoginCallback().onFailure(result.code, result.message);

return;

}

LoginActivity.this.onPwdLoginFail(result.code, result.message);

}

}

} catch (Throwable var8) {

AliSDKLogger.e("oa", "after post execute error", var8);

ToastUtils.toastSystemError(this.context);

}

}

}

 类似资料: