-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSignUp.java
More file actions
103 lines (85 loc) · 4.38 KB
/
SignUp.java
File metadata and controls
103 lines (85 loc) · 4.38 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
package com.example.medicareapp;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.material.textfield.TextInputEditText;
import com.vishnusivadas.advanced_httpurlconnection.PutData;
public class SignUp extends AppCompatActivity {
TextInputEditText textInputEditTextFullname, textInputEditTextUsername, textInputEditTextPassword, textInputEditTextEmail;
Button buttonSignUp;
TextView textViewLogin;
ProgressBar progressBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_up);
textInputEditTextFullname = findViewById(R.id.fullname);
textInputEditTextUsername = findViewById(R.id.username);
textInputEditTextPassword = findViewById(R.id.password);
textInputEditTextEmail = findViewById(R.id.email);
buttonSignUp = findViewById(R.id.buttonSignUp);
textViewLogin = findViewById(R.id.loginText);
progressBar = findViewById(R.id.progress);
buttonSignUp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String fullname, username, password, email;
fullname = String.valueOf(textInputEditTextFullname.getText());
username = String.valueOf(textInputEditTextUsername.getText());
password = String.valueOf(textInputEditTextPassword.getText());
email = String.valueOf(textInputEditTextEmail.getText());
if(!fullname.equals("") && !username.equals("") && !password.equals("") && !email.equals("")) {
//Start ProgressBar first (Set visibility VISIBLE)
progressBar.setVisibility(view.VISIBLE);
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
@Override
public void run() {
//Starting to Write and Read data with URL
//Creating array for parameters
String[] field = new String[4];
field[0] = "fullname";
field[1] = "username";
field[2] = "password";
field[3] = "email";
//Creating array for data
String[] data = new String[4];
data[0] = "fullname";
data[1] = "username";
data[2] = "password";
data[3] = "email";
PutData putData = new PutData("http://192.168.1.100/MedicareApp/signup.php", "POST", field, data);
if (putData.startPut()) {
if (putData.onComplete()) {
progressBar.setVisibility(view.GONE);
String result = putData.getResult();
if(result.equals("Sign Up Successful")){
Toast.makeText(getApplicationContext(), result, Toast.LENGTH_SHORT).show();
Intent intent = new Intent(getApplicationContext(), Login.class);
startActivity(intent);
finish();
}
else{
Toast.makeText(getApplicationContext(), result, Toast.LENGTH_SHORT).show();
}
//End ProgressBar (Set visibility to GONE)
}
}
//End Write and Read data with URL
}
});
}
else{
Toast.makeText(getApplicationContext(),"All fields are required", Toast.LENGTH_SHORT).show();
}
}
});
}
}