|
|
|
@ -9,7 +9,6 @@ import android.os.Looper;
|
|
|
|
|
import android.os.Message;
|
|
|
|
|
import android.text.Editable;
|
|
|
|
|
import android.text.TextWatcher;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.widget.ImageView;
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
import android.widget.Toast;
|
|
|
|
@ -81,7 +80,9 @@ public class ModifyUserInfo extends AppCompatActivity {
|
|
|
|
|
}else{
|
|
|
|
|
tiNewMsg.setText("");
|
|
|
|
|
}
|
|
|
|
|
if(tiNewMsg.getText() != null){
|
|
|
|
|
tiNewMsg.setSelection(tiNewMsg.getText().length());
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ModelFieldConstants.COLLEGE_NAME : {
|
|
|
|
@ -92,7 +93,9 @@ public class ModifyUserInfo extends AppCompatActivity {
|
|
|
|
|
}else{
|
|
|
|
|
tiNewMsg.setText("");
|
|
|
|
|
}
|
|
|
|
|
if(tiNewMsg.getText() != null){
|
|
|
|
|
tiNewMsg.setSelection(tiNewMsg.getText().length());
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ModelFieldConstants.REAL_NAME : {
|
|
|
|
@ -103,7 +106,9 @@ public class ModifyUserInfo extends AppCompatActivity {
|
|
|
|
|
}else{
|
|
|
|
|
tiNewMsg.setText("");
|
|
|
|
|
}
|
|
|
|
|
if(tiNewMsg.getText() != null){
|
|
|
|
|
tiNewMsg.setSelection(tiNewMsg.getText().length());
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ModelFieldConstants.ID_NUMBER : {
|
|
|
|
@ -118,7 +123,9 @@ public class ModifyUserInfo extends AppCompatActivity {
|
|
|
|
|
}else{
|
|
|
|
|
tiNewMsg.setText("");
|
|
|
|
|
}
|
|
|
|
|
if(tiNewMsg.getText() != null){
|
|
|
|
|
tiNewMsg.setSelection(tiNewMsg.getText().length());
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ModelFieldConstants.GENDER : {
|
|
|
|
@ -138,36 +145,24 @@ public class ModifyUserInfo extends AppCompatActivity {
|
|
|
|
|
tiNewMsg.setKeyListener(null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tiNewMsg.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
tiNewMsg.setOnClickListener(v -> {
|
|
|
|
|
System.out.println("choose gender............");
|
|
|
|
|
String[] singleItems = {"男", "女"};
|
|
|
|
|
int checkedItem = "男".equals(tiNewMsg.getText().toString()) ? 0 : 1;
|
|
|
|
|
int checkedItem = 0;
|
|
|
|
|
if(tiNewMsg.getText() != null){
|
|
|
|
|
checkedItem = "男".equals(tiNewMsg.getText().toString()) ? 0 : 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(ModifyUserInfo.this)
|
|
|
|
|
.setTitle("请选择性别")
|
|
|
|
|
.setNeutralButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
.setNeutralButton(getString(R.string.cancel), (dialog, which) -> {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
tiNewMsg.setText(singleItems[bundle.getInt("checkedItem")]);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.setSingleChoiceItems(singleItems, checkedItem, new DialogInterface.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
bundle.putInt("checkedItem", which);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
.setPositiveButton(getString(R.string.ok), (dialog, which) ->
|
|
|
|
|
tiNewMsg.setText(singleItems[bundle.getInt("checkedItem")]))
|
|
|
|
|
.setSingleChoiceItems(singleItems, checkedItem, (dialog, which) ->
|
|
|
|
|
bundle.putInt("checkedItem", which));
|
|
|
|
|
materialAlertDialogBuilder.show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
@ -179,7 +174,9 @@ public class ModifyUserInfo extends AppCompatActivity {
|
|
|
|
|
}else{
|
|
|
|
|
tiNewMsg.setText("");
|
|
|
|
|
}
|
|
|
|
|
if (tiNewMsg.getText() != null){
|
|
|
|
|
tiNewMsg.setSelection(tiNewMsg.getText().length());
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ModelFieldConstants.PHONE : {
|
|
|
|
@ -190,11 +187,14 @@ public class ModifyUserInfo extends AppCompatActivity {
|
|
|
|
|
}else{
|
|
|
|
|
tiNewMsg.setText("");
|
|
|
|
|
}
|
|
|
|
|
if(tiNewMsg.getText() != null){
|
|
|
|
|
tiNewMsg.setSelection(tiNewMsg.getText().length());
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:{
|
|
|
|
|
tiNewMsg.setText("error.....");
|
|
|
|
|
String errorText = "error.....";
|
|
|
|
|
tiNewMsg.setText(errorText);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -204,12 +204,7 @@ public class ModifyUserInfo extends AppCompatActivity {
|
|
|
|
|
*/
|
|
|
|
|
private void setListener(){
|
|
|
|
|
//返回上一个活动,也就是个人信息部分
|
|
|
|
|
abIvTitle.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
finish();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
abIvTitle.setOnClickListener(v -> finish());
|
|
|
|
|
tiNewMsg.addTextChangedListener(new TextWatcher() {
|
|
|
|
|
@Override
|
|
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
|
|
@ -224,12 +219,7 @@ public class ModifyUserInfo extends AppCompatActivity {
|
|
|
|
|
abBtSave.setBackgroundResource(R.drawable.selector_bottom_modify_info_save_2);
|
|
|
|
|
abBtSave.setTextColor(Color.WHITE);
|
|
|
|
|
//为按钮添加点击事件
|
|
|
|
|
abBtSave.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
dialog();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
abBtSave.setOnClickListener(v -> dialog());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -244,6 +234,7 @@ public class ModifyUserInfo extends AppCompatActivity {
|
|
|
|
|
*/
|
|
|
|
|
private void dialog(){
|
|
|
|
|
|
|
|
|
|
//添加取消
|
|
|
|
|
AlertDialog alertDialog2 = new AlertDialog.Builder(this)
|
|
|
|
|
.setMessage("请确认是否进行" + abTvTitle.getText())
|
|
|
|
|
.setPositiveButton("确定", new DialogInterface.OnClickListener() {//添加"Yes"按钮
|
|
|
|
@ -259,10 +250,7 @@ public class ModifyUserInfo extends AppCompatActivity {
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.setNegativeButton("取消", new DialogInterface.OnClickListener() {//添加取消
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(DialogInterface dialogInterface, int i) {
|
|
|
|
|
}
|
|
|
|
|
.setNegativeButton("取消", (dialogInterface, i) -> {
|
|
|
|
|
})
|
|
|
|
|
.create();
|
|
|
|
|
alertDialog2.show();
|
|
|
|
@ -272,9 +260,7 @@ public class ModifyUserInfo extends AppCompatActivity {
|
|
|
|
|
* 更新信息网络请求
|
|
|
|
|
*/
|
|
|
|
|
private void modifyInfo(){
|
|
|
|
|
new Thread(new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
new Thread(() -> {
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
boolean isLegalInput = false;
|
|
|
|
|
try {
|
|
|
|
@ -320,7 +306,7 @@ public class ModifyUserInfo extends AppCompatActivity {
|
|
|
|
|
try {
|
|
|
|
|
String msg = Objects.requireNonNull(tiNewMsg.getText()).toString();
|
|
|
|
|
//判断输入电话号码是否能解析为long型,能解析的话说明输入没有非法字符
|
|
|
|
|
Long msgLong = Long.parseLong(msg);
|
|
|
|
|
// Long msgLong = Long.parseLong(msg);
|
|
|
|
|
jsonObject.put(modifyField, msg);
|
|
|
|
|
bundle.putString(modifyField, msg);
|
|
|
|
|
isLegalInput = true;
|
|
|
|
@ -375,7 +361,7 @@ public class ModifyUserInfo extends AppCompatActivity {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
System.out.println( "jsonObject : " + jsonObject.toString() + "..............................");
|
|
|
|
|
System.out.println( "jsonObject : " + jsonObject + "..............................");
|
|
|
|
|
String json = jsonObject.toString();
|
|
|
|
|
String url = UrlConstants.USER_UPDATE;
|
|
|
|
|
|
|
|
|
@ -396,7 +382,6 @@ public class ModifyUserInfo extends AppCompatActivity {
|
|
|
|
|
}
|
|
|
|
|
}.postConnect(url, json);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}).start();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|