20
20
import android .widget .RadioGroup ;
21
21
import android .widget .RelativeLayout ;
22
22
import android .widget .TextView ;
23
+ import android .widget .Toast ;
23
24
24
25
import java .text .SimpleDateFormat ;
25
26
import java .util .Calendar ;
@@ -107,12 +108,7 @@ public void onClick(View v) {
107
108
@ Override
108
109
public void onClick (View v ) {
109
110
retrieveData ();
110
- if (checkInput (VALID_STRING_PATTERN , sFame )
111
- && checkInput (VALID_STRING_PATTERN , sLame )
112
- && checkInput (VALID_EMAIL_PATTERN , sEmail )
113
- && checkInput (VALID_ADDRESS_PATTERN , sAddress )
114
- && isAdult ) {
115
- setOverlay ();
111
+ if (checkInput (VALID_STRING_PATTERN , sFame ) && checkInput (VALID_STRING_PATTERN , sLame ) && checkInput (VALID_EMAIL_PATTERN , sEmail ) && checkInput (VALID_ADDRESS_PATTERN , sAddress ) && isAdult ) {
116
112
newFragment = new RegFragment ();// Create fragment and give it an argument specifying the article it should show
117
113
Bundle args = new Bundle ();
118
114
args .putInt (RegFragment .ARG_POSITION , position );
@@ -128,16 +124,13 @@ && checkInput(VALID_ADDRESS_PATTERN, sAddress)
128
124
transaction .replace (R .id .your_placeholder , newFragment );// Replace whatever is in the fragment_container view with this fragment,
129
125
transaction .addToBackStack (null );
130
126
transaction .commit ();
131
- Log .i ("Notification" , "Attention: You can now proceed" );
132
-
127
+ Toast .makeText (getApplicationContext (), "Information correct, welcome" , Toast .LENGTH_SHORT ).show ();
133
128
} else {
134
- Log . i ( "Notification" , "Warning: Information provided is not correct" );
129
+ Toast . makeText ( getApplicationContext () , "Warning: Information provided is not correct" , Toast . LENGTH_SHORT ). show ( );
135
130
}
136
131
}
137
132
});
138
133
}
139
-
140
-
141
134
public void initialiseVars () {
142
135
fname = findViewById (R .id .fname );
143
136
lname = findViewById (R .id .lname );
@@ -147,15 +140,6 @@ public void initialiseVars() {
147
140
signup = findViewById (R .id .submit );
148
141
genderRG = findViewById (R .id .genderRG );
149
142
}
150
-
151
- public void setOverlay () {
152
-
153
- linearlayout .getBackground ().setAlpha (150 );
154
- linearlayout .getForeground ().setAlpha (255 );
155
-
156
- }
157
-
158
-
159
143
public void retrieveData () {
160
144
sFame = fname .getText ().toString ();
161
145
sLame = lname .getText ().toString ();
@@ -168,33 +152,25 @@ private void updateLabel() { // Formatting the given date to UK format
168
152
SimpleDateFormat sdf = new SimpleDateFormat (myFormat , Locale .UK );
169
153
dob .setText (sdf .format (myCalendar .getTime ()));
170
154
sDob = dob .getText ().toString ();
171
-
172
155
}
173
-
174
156
public void hideKeyboard (View view ) {
175
157
InputMethodManager inputMethodManager =(InputMethodManager ) getSystemService (Activity .INPUT_METHOD_SERVICE );
176
158
inputMethodManager .hideSoftInputFromWindow (view .getWindowToken (), 0 );
177
159
}
178
-
179
160
public static boolean checkInput (Pattern PATTERN , String str ) {// This will check for either password or email, depending on the Pattern
180
161
Matcher matcher = PATTERN .matcher (str );
181
162
if (str == null ) {
182
163
return false ;
183
164
} else return matcher .find ();
184
165
}
185
-
186
166
private int getAge (int year , int month , int day ){
187
167
Calendar dob = Calendar .getInstance ();
188
168
Calendar today = Calendar .getInstance ();
189
-
190
169
dob .set (year , month , day );
191
-
192
170
int age = today .get (Calendar .YEAR ) - dob .get (Calendar .YEAR );
193
-
194
171
if (today .get (Calendar .DAY_OF_YEAR ) < dob .get (Calendar .DAY_OF_YEAR )){
195
172
age --;
196
173
}
197
-
198
174
return age ;
199
175
}
200
176
}
0 commit comments