ElectronicCardEditInfoActivity.java
11.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
package com.hjx.personalcenter.activity;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.FragmentActivity;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.bigkoo.pickerview.TimePickerView;
import com.hjx.personalcenter.R;
import com.hjx.personalcenter.customdialog.CitysListDialog;
import com.hjx.personalcenter.customdialog.CountryDialog;
import com.hjx.personalcenter.customdialog.ProvinceListDialog;
import com.hjx.personalcenter.db.Content;
import com.hjx.personalcenter.db.SaveParam;
import com.hjx.personalcenter.http.HttpCode;
import com.hjx.personalcenter.http.HttpManager;
import com.hjx.personalcenter.interfaces.DialogCallBack;
import com.hjx.personalcenter.model.CityInfo;
import com.hjx.personalcenter.model.CountyInfo;
import com.hjx.personalcenter.model.PesonalInfo;
import com.hjx.personalcenter.model.ProvinceInfo;
import com.hjx.personalcenter.util.AlertUtils;
import com.hjx.personalcenter.util.BrithdayStar;
import com.hjx.personalcenter.util.GetDate;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
/**
* 填写保卡信息 熊巍
* Created by h on 2017/8/11.
*/
public class ElectronicCardEditInfoActivity extends FragmentActivity implements View.OnClickListener
, DialogCallBack.ProvincesCallBack
, DialogCallBack.CitysCallBack, DialogCallBack.CountryCallBack {
private LinearLayout lineL_buy_time;
private TextView adress_shop, adress_custem;
private EditText username, store, detalAdress, telphone,et_salesperson_phone;
private TimePickerView pvTime;
private Button btn_change_info,cancel_btn,go_btn;
private ImageView iv_card_back, shop_adress, custom_adress;
private Dialog salesDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_electroniccard_info);
SysApplication.getInstance().addActivity(this);
initView();
initData();
initLister();
}
private void initView() {
lineL_buy_time = (LinearLayout) findViewById(R.id.lineL_buy_time);
// tv_buy_time = (TextView) findViewById(R.id.tv_buy_time);
adress_shop = (TextView) findViewById(R.id.tv_edit_adress_shop);
adress_custem = (TextView) findViewById(R.id.tv_edit_adress_custem);
username = (EditText) findViewById(R.id.et_edit_username);
store = (EditText) findViewById(R.id.et_edit_store);
detalAdress = (EditText) findViewById(R.id.et_edit_adress_detail);
telphone = (EditText) findViewById(R.id.et_edit_telphone);
btn_change_info = (Button) findViewById(R.id.btn_change_info);
iv_card_back = (ImageView) findViewById(R.id.iv_card_back);
shop_adress = (ImageView) findViewById(R.id.shopdizhi);
custom_adress = (ImageView) findViewById(R.id.cunstomdizhi);
et_salesperson_phone = (EditText) findViewById(R.id.et_salesperson_phone);
}
private void initData() {
GetDate date = new GetDate();
// tv_buy_time.setText(date.getYMD().toString());
String userID = SaveParam.getInstance().getLoginParam(this, "userId");
long id = Long.parseLong(userID);
//获取个人信息
HttpManager.getInstance().getpresonalinfo(this, id, 1, handler);
}
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case HttpCode.GETINFO:
PesonalInfo.DataBean cardinfoBean = (PesonalInfo.DataBean) msg.obj;
username.setText(cardinfoBean.getRealName());
adress_custem.setText(cardinfoBean.getRegion().getRegionName());
detalAdress.setText(cardinfoBean.getAddress());
break;
case HttpCode.SUCHCARDINFO:
Intent intent = new Intent();
intent.putExtra(SaveParam.CARDPHONE,getIntent().getStringExtra(SaveParam.CARDPHONE));
intent.putExtra(SaveParam.SALES_ID,msg.obj.toString());
intent.putExtra(SaveParam.SALES_PHONE,et_salesperson_phone.getText().toString().trim());
intent.setClass(ElectronicCardEditInfoActivity.this, ElectronicCardInfoOKActivity.class);
startActivity(intent);
overridePendingTransition(R.anim.rightin, R.anim.rightout);
break;
case HttpCode.NO_SALES_MAN:
showSwitchDialog();
break;
}
}
};
private void initLister() {
adress_shop.setOnClickListener(this);
adress_custem.setOnClickListener(this);
btn_change_info.setOnClickListener(this);
iv_card_back.setOnClickListener(this);
shop_adress.setOnClickListener(this);
custom_adress.setOnClickListener(this);
}
private void showSwitchDialog() {
//自定义部分
LayoutInflater mInflater = LayoutInflater.from(this);
View dialogView = mInflater.inflate(R.layout.sales_dialog_layout,
null);
salesDialog = new Dialog(this, R.style.CustomHintDialog);
cancel_btn = (Button) dialogView.findViewById(R.id.cancel_btn);
go_btn = (Button) dialogView.findViewById(R.id.go_btn);
salesDialog.addContentView(dialogView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
salesDialog.setCanceledOnTouchOutside(true);
salesDialog.show();
cancel_btn.setOnClickListener(this);
go_btn.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_change_info:
String info1 = username.getText().toString().trim();
String info2 = adress_custem.getText().toString().trim();
String info3 = detalAdress.getText().toString().trim();
// String info4 =tv_buy_time.getText().toString().trim();
String info5 = adress_shop.getText().toString().trim();
String info6 = store.getText().toString().trim();
String info7 = telphone.getText().toString().trim();
String info8 = et_salesperson_phone.getText().toString().trim();
if (TextUtils.isEmpty(info1) || TextUtils.isEmpty(info2) || TextUtils.isEmpty(info3)
|| TextUtils.isEmpty(info5) || TextUtils.isEmpty(info6)
|| TextUtils.isEmpty(info7)) {
AlertUtils.showToast(ElectronicCardEditInfoActivity.this, "所有内容不能为空。");
return;
} else if(!TextUtils.isEmpty(info8) ){
HttpManager.getInstance().checkSalesmanPhone(this,info8,handler);
savedata();
} else{
savedata();
Intent intent = new Intent();
intent.putExtra(SaveParam.CARDPHONE,getIntent().getStringExtra(SaveParam.CARDPHONE));
intent.setClass(ElectronicCardEditInfoActivity.this, ElectronicCardInfoOKActivity.class);
startActivity(intent);
overridePendingTransition(R.anim.rightin, R.anim.rightout);
}
break;
case R.id.tv_edit_adress_shop:
case R.id.shopdizhi:
Content.adressflag = 1;
ProvinceListDialog.getInstance((DialogCallBack.ProvincesCallBack) this).show(getSupportFragmentManager(), "ProvinceListDialog");
break;
case R.id.tv_edit_adress_custem:
case R.id.cunstomdizhi:
Content.adressflag = 2;
ProvinceListDialog.getInstance((DialogCallBack.ProvincesCallBack) this).show(getSupportFragmentManager(), "ProvinceListDialog");
break;
case R.id.iv_card_back:
finish();
break;
case R.id.cancel_btn:
salesDialog.cancel();
break;
case R.id.go_btn:
salesDialog.cancel();
Intent intent = new Intent();
intent.putExtra(SaveParam.CARDPHONE,getIntent().getStringExtra(SaveParam.CARDPHONE));
intent.setClass(ElectronicCardEditInfoActivity.this, ElectronicCardInfoOKActivity.class);
startActivity(intent);
overridePendingTransition(R.anim.rightin, R.anim.rightout);
break;
}
}
//保存数据
private void savedata() {
SaveParam.getInstance().saveCustomizeParam(this, SaveParam.CUNSTEMNAME, username.getText().toString().trim());
SaveParam.getInstance().saveCustomizeParam(this, SaveParam.ADRESSCUNSTEM, adress_custem.getText().toString().trim() + detalAdress.getText().toString().trim());
// SaveParam.getInstance().saveCustomizeParam(this,SaveParam.SHOPTIME, tv_buy_time.getText().toString().trim());
SaveParam.getInstance().saveCustomizeParam(this, SaveParam.SHOPADRESS, adress_shop.getText().toString().trim() + store.getText().toString().trim());
SaveParam.getInstance().saveCustomizeParam(this, SaveParam.SHOPTLEPHONE, telphone.getText().toString().trim());
SaveParam.getInstance().saveCustomizeParam(this, SaveParam.SALES_PHONE, et_salesperson_phone.getText().toString().trim());
}
@Override
public void province1OnItemClick(ArrayList<CityInfo.CitiesBean> data, int position, int type) {
String regionName = data.get(position).getRegionName();
String provice = SaveParam.getInstance().getLoginParam(this, "sheng");
SaveParam.getInstance().saveLoginParam(this, "shi", regionName);
CountryDialog.getInstance((DialogCallBack.CountryCallBack) this).show(getSupportFragmentManager(), "CountryDialog");
if (Content.adressflag == 1) {
adress_shop.setText("");
adress_shop.setText(provice + regionName);
} else {
adress_custem.setText("");
adress_custem.setText(provice + regionName);
}
}
@Override
public void province2OnItemClick(ArrayList<CountyInfo.CountiesBean> data, int position, int type) {
String regionName = data.get(position).getRegionName();
int regionId = data.get(position).getRegionId();
String provices = SaveParam.getInstance().getLoginParam(this, "sheng");
String citys = SaveParam.getInstance().getLoginParam(this, "shi");
if (Content.adressflag == 1) {
adress_shop.setText("");
adress_shop.setText(provices + citys + regionName);
} else {
adress_custem.setText("");
adress_custem.setText(provices + citys + regionName);
}
}
@Override
public void provinceOnItemClick(ArrayList<ProvinceInfo.ProvincesBean> data, int position, int type) {
String regionName = data.get(position).getRegionName();
SaveParam.getInstance().saveLoginParam(this, "sheng", regionName);
CitysListDialog.getInstance((DialogCallBack.CitysCallBack) this).show(getSupportFragmentManager(), "CitysListDialog");
// adress_custem.setText("");
// adress_custem.setText(regionName);
}
}