-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNewUserRailway.java
More file actions
204 lines (173 loc) · 8.64 KB
/
NewUserRailway.java
File metadata and controls
204 lines (173 loc) · 8.64 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
package com.example.vmac.WatBot;
import android.support.design.widget.TextInputLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
public class NewUserRailway extends AppCompatActivity {
private Toolbar toolbar;
public EditText email,password,fullname,rollno,age,gender,contact,address,source,destination;
public String semail,spassword,sname,srollno,sage,sgender,scontact,saddress,ssource,sdestination,ssemester,syear,sclass;
private TextInputLayout temail,tpassword,tname, troll, tuserage,tsex,tcontactno,tadd,tsrc,tdestn;
private Button btnSignUp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_user_railway);
Spinner yearSpinner = (Spinner) findViewById(R.id.yearSpinner);
Spinner semSpinner = (Spinner) findViewById(R.id.semSpinner);
Spinner classSpinner = (Spinner) findViewById(R.id.classSpinner);
btnSignUp = (Button)findViewById(R.id.btn_signup);
/*ArrayAdapter<String> yearAdapter = new ArrayAdapter<String>(NewUserRailway.this, android.R.layout.simple_list_item_1,
getResources().getStringArray(R.array.year));
yearAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
yearSpinner.setAdapter(yearAdapter);
ArrayAdapter<String> semAdapter = new ArrayAdapter<String>(NewUserRailway.this, android.R.layout.simple_list_item_1,
getResources().getStringArray(R.array.semester));
semAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
semSpinner.setAdapter(semAdapter);
ArrayAdapter<String> classAdapter = new ArrayAdapter<String>(NewUserRailway.this, android.R.layout.simple_list_item_1,
getResources().getStringArray(R.array.travelClass));
classAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
classSpinner.setAdapter(classAdapter);*/
final String[] semester = new String[]{"I", "II", "III", "IV", "V", "VI", "VII", "VIII"};
ArrayAdapter<String> semAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, semester);
semSpinner.setAdapter(semAdapter);
semSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
ssemester = parent.getItemAtPosition(position).toString();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
// TODO Auto-generated method stub
btnSignUp.setEnabled(false);
Toast.makeText(NewUserRailway.this, "Select Semester", Toast.LENGTH_SHORT).show();
return;
}
});
final String[] year = new String[]{"1", "2", "3", "4"};
ArrayAdapter<String> yearAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, year);
yearSpinner.setAdapter(yearAdapter);
yearSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
syear = parent.getItemAtPosition(position).toString();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
// TODO Auto-generated method stub
btnSignUp.setEnabled(false);
Toast.makeText(NewUserRailway.this, "Select Year", Toast.LENGTH_SHORT).show();
return;
}
});
final String[] travelClass = new String[]{"I", "II"};
ArrayAdapter<String> classAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, travelClass);
classSpinner.setAdapter(classAdapter);
classSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
sclass = parent.getItemAtPosition(position).toString();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
// TODO Auto-generated method stub
btnSignUp.setEnabled(false);
Toast.makeText(NewUserRailway.this, "Select Travelling Class", Toast.LENGTH_SHORT).show();
return;
}
});
temail = (TextInputLayout)findViewById(R.id.mail);
tpassword = (TextInputLayout)findViewById(R.id.pass);
tname = (TextInputLayout) findViewById(R.id.name);
troll = (TextInputLayout) findViewById(R.id.roll);
tuserage = (TextInputLayout) findViewById(R.id.userage);
tsex = (TextInputLayout) findViewById(R.id.sex);
tcontactno = (TextInputLayout) findViewById(R.id.contactno);
tadd = (TextInputLayout) findViewById(R.id.add);
tsrc = (TextInputLayout) findViewById(R.id.src);
tdestn = (TextInputLayout) findViewById(R.id.destn);
email = (EditText)findViewById(R.id.email);
password = (EditText)findViewById(R.id.password);
fullname = (EditText)findViewById(R.id.fullname);
rollno = (EditText)findViewById(R.id.rollno);
age = (EditText)findViewById(R.id.age);
gender = (EditText)findViewById(R.id.gender);
contact = (EditText)findViewById(R.id.contact);
address = (EditText)findViewById(R.id.address);
source = (EditText)findViewById(R.id.source);
destination = (EditText)findViewById(R.id.destination);
}
public void signupClicked(View view){
if (email.getText().toString().isEmpty()) {
temail.setError("Enter your Email ID!");
email.requestFocus();
return;
}
else if (password.getText().toString().isEmpty()) {
tpassword.setError("Enter Password!");
password.requestFocus();
return;
}
else if (fullname.getText().toString().isEmpty()) {
tname.setError("Enter your name!");
fullname.requestFocus();
return;
}
else if (rollno.getText().toString().isEmpty()) {
troll.setError("Enter your roll no!");
rollno.requestFocus();
return;
}
else if (age.getText().toString().isEmpty()) {
tuserage.setError("Enter your age!");
age.requestFocus();
return;
}
else if (gender.getText().toString().isEmpty()) {
tsex.setError("Enter your gender!");
gender.requestFocus();
return;
}
else if (contact.getText().toString().isEmpty()) {
tcontactno.setError("Enter your contact no!");
contact.requestFocus();
return;
}
else if (address.getText().toString().isEmpty()) {
tadd.setError("Enter your address!");
address.requestFocus();
return;
}
else if (source.getText().toString().isEmpty()) {
tsrc.setError("Enter source!");
source.requestFocus();
return;
}
else if (destination.getText().toString().isEmpty()) {
tdestn.setError("Enter destination!");
destination.requestFocus();
return;
}
semail = email.getText().toString();
spassword = password.getText().toString();
sname = fullname.getText().toString();
srollno = rollno.getText().toString();
sage = age.getText().toString();
sgender = gender.getText().toString();
scontact = contact.getText().toString();
saddress = address.getText().toString();
ssource = source.getText().toString();
sdestination = destination.getText().toString();
String type = "new_user";
BackgroundWorker backgroundWorker = new BackgroundWorker(this);
backgroundWorker.execute(type,sname,srollno,sage,sgender,scontact,saddress,ssource,sdestination,syear,ssemester,sclass,semail,spassword);
}
}