use of com.lingtuan.firefly.vo.UserInfoVo in project SmartMesh_Android by SmartMeshFoundation.
the class LoginUtil method registMethod.
/**
* registration verification
* @ param mPwd password
* @ param mAgainPwd secondary password
* @ param mName user name
*/
public void registMethod(String mPwd, String mAgainPwd, String mName, String locailid) {
// Authentication codes are consistent
if (!TextUtils.equals(mPwd, mAgainPwd)) {
MyToast.showToast(mContext, mContext.getString(R.string.account_pwd_again_warning));
return;
}
// Verify account password is in accordance with the specification
if (!LoginUtil.getInstance().registCheck(mName, mPwd)) {
return;
}
// Verify whether the user name already exists
ArrayList<UserInfoVo> infoList = JsonUtil.readLocalInfo(mContext);
for (int i = 0; i < infoList.size(); i++) {
if (TextUtils.equals(mName, infoList.get(i).getUsername())) {
MyToast.showToast(mContext, mContext.getString(R.string.notification_wallimp_repeat));
return;
}
}
LoadingDialog.show(mContext, "");
// Store the registration information Convenient synchronization
UserInfoVo userInfoVo = new UserInfoVo();
userInfoVo.setUsername(mName);
userInfoVo.setPassword(mPwd);
userInfoVo.setLocalId(locailid);
JsonUtil.writeLocalInfo(mContext, userInfoVo);
// Login XMPP
XmppUtils.loginXmppForNextApp(mContext);
// Enter the app
mContext.startActivity(new Intent(mContext, MainFragmentUI.class));
Utils.openNewActivityAnim(mContext, true);
LoadingDialog.close();
}
use of com.lingtuan.firefly.vo.UserInfoVo in project SmartMesh_Android by SmartMeshFoundation.
the class LoginUtil method register.
/**
* registered
* @ param uName user name
* @ param uPwd password
*/
public void register(final String uName, final String uPwd, final String mid, final String localid, final TextView uploadRegisterInfo) {
this.aeskey = Utils.makeRandomKey(16);
NetRequestImpl.getInstance().register(uName, uPwd, mid, localid, aeskey, new RequestListener() {
@Override
public void start() {
if (!TextUtils.isEmpty(mid)) {
LoadingDialog.show(mContext, "");
}
}
@Override
public void success(JSONObject response) {
String token = response.optString("token");
if (TextUtils.isEmpty(token)) {
return;
}
token = Aes.decode(aeskey, token);
try {
if (!TextUtils.isEmpty(mid)) {
LoadingDialog.close();
}
JSONObject info = new JSONObject();
info.put("username", uName);
info.put("password", uPwd);
if (!TextUtils.isEmpty(mid)) {
info.put("mid", mid);
}
info.put("localid", localid);
info.put("token", token);
MySharedPrefs.write(mContext, MySharedPrefs.FILE_USER, MySharedPrefs.KEY_LOGIN_USERINFO, info.toString());
UserInfoVo userInfoVo = new UserInfoVo();
userInfoVo.setUsername(uName);
userInfoVo.setPassword(uPwd);
if (!TextUtils.isEmpty(mid)) {
userInfoVo.setMid(mid);
}
userInfoVo.setLocalId(localid);
userInfoVo.setToken(token);
JsonUtil.updateLocalInfo(mContext, userInfoVo);
NextApplication.myInfo = new UserInfoVo().readMyUserInfo(mContext);
if (uploadRegisterInfo != null) {
uploadRegisterInfo.setVisibility(View.GONE);
}
// Login XMPP
XmppUtils.loginXmppForNextApp(mContext);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void error(int errorCode, String errorMsg) {
if (!TextUtils.isEmpty(mid)) {
LoadingDialog.close();
}
MyToast.showToast(mContext, errorMsg);
}
});
}
use of com.lingtuan.firefly.vo.UserInfoVo in project SmartMesh_Android by SmartMeshFoundation.
the class LoginUtil method login.
/**
* login authentication
* @ param uName user name
* @ param uPwd password
* @ param showDialog whether to display the dialog
*/
public void login(final String uName, final String uPwd, final boolean showDialog) {
this.aeskey = Utils.makeRandomKey(16);
NetRequestImpl.getInstance().login(uName, uPwd, aeskey, new RequestListener() {
@Override
public void start() {
if (showDialog) {
LoadingDialog.show(mContext, "");
}
}
@Override
public void success(JSONObject response) {
try {
JSONObject object = response.optJSONObject("data");
// Local encrypted token decrypted storage
String token = object.optString("token");
String mid = object.optString("mid");
if (TextUtils.isEmpty(token)) {
return;
}
token = Aes.decode(aeskey, token);
object.put("token", token);
object.put("mid", mid);
object.put("password", uPwd);
MySharedPrefs.write(mContext, MySharedPrefs.FILE_USER, MySharedPrefs.KEY_LOGIN_USERINFO, object.toString());
UserInfoVo userInfoVo = new UserInfoVo().parse(object);
JsonUtil.updateLocalInfo(mContext, userInfoVo);
NextApplication.myInfo = new UserInfoVo().readMyUserInfo(mContext);
XmppUtils.loginXmppForNextApp(mContext);
getUserInfo(showDialog, mid, uPwd, token);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void error(int errorCode, String errorMsg) {
if (showDialog) {
LoadingDialog.close();
MyToast.showToast(mContext, errorMsg);
}
}
});
}
use of com.lingtuan.firefly.vo.UserInfoVo in project SmartMesh_Android by SmartMeshFoundation.
the class ContactSearchNickUI method searchNick.
private synchronized void searchNick(final String text) {
friendList.clear();
NetRequestImpl.getInstance().friendSearch(text, new RequestListener() {
@Override
public void start() {
}
@Override
public void success(JSONObject response) {
String data = response.optString("data");
boolean flag = TextUtils.equals("[]", data);
JSONArray jsonArray = response.optJSONArray("data");
if (jsonArray != null && !flag) {
int count = jsonArray.length();
for (int i = 0; i < count; i++) {
UserInfoVo uInfo = new UserInfoVo().parse(jsonArray.optJSONObject(i));
if (uInfo != null) {
friendList.add(uInfo);
}
}
mAdapter.updateList(friendList);
checkListEmpty(false);
} else {
checkListEmpty(true);
}
swipeLayout.setRefreshing(false);
}
@Override
public void error(int errorCode, String errorMsg) {
swipeLayout.setRefreshing(false);
showToast(errorMsg);
checkListEmpty(true);
}
});
}
use of com.lingtuan.firefly.vo.UserInfoVo in project SmartMesh_Android by SmartMeshFoundation.
the class NextApplication method onCreate.
@Override
public void onCreate() {
super.onCreate();
/**
* Initialize the folder
*/
SDCardCtrl.initPath(this);
XmppUtils.isLogining = false;
mContext = this;
try {
myInfo = new UserInfoVo().readMyUserInfo(this);
Resources res = getResources();
Configuration config = new Configuration();
config.setToDefaults();
config.fontScale = 1;
res.updateConfiguration(config, res.getDisplayMetrics());
} catch (Exception e) {
e.printStackTrace();
}
NetRequestUtils.getInstance().getServerTime(this);
initImageLoaderConfig();
/**
*Initialize the expression
*/
SmileyParser.init(this);
mSmileyParser = SmileyParser.getInstance();
/**
*Initialization error log collection
*/
CrashHandler crashHandler = CrashHandler.getInstance();
crashHandler.init(getApplicationContext());
}
Aggregations