-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmployeeActivity.java
More file actions
98 lines (85 loc) · 3.81 KB
/
EmployeeActivity.java
File metadata and controls
98 lines (85 loc) · 3.81 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
package com.example.healthcareapp;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RadioGroup;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
public class EmployeeActivity extends AppCompatActivity {
private static final int REQUEST_IMAGE_CAPTURE =1;
ImageView imageView;
@Override
protected void onCreate( Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_employee);
}
public void btnSave(View view) {
EditText company = findViewById(R.id.companyName);
EditText name = findViewById(R.id.employeeName);
EditText email = findViewById(R.id.emailName);
EditText phone = findViewById(R.id.phoneNumber);
EditText visit = findViewById(R.id.visitPlace);
EditText temperature = findViewById(R.id.temperatureFarenheit);
RadioGroup symptoms = findViewById(R.id.symptomsRadio);
RadioGroup absence = findViewById(R.id.absenceRadio);
RadioGroup overseas = findViewById(R.id.overseasRadio);
RadioGroup contact = findViewById(R.id.contactRadio);
RadioGroup containment = findViewById(R.id.containmentRadio);
imageView=findViewById(R.id.Image);
//used to check if a field added by user is empty
// if (TextUtils.isEmpty(company.getText()))
//with RadioGroup buttons we use getCheckedRadioButtonId() function
if (TextUtils.isEmpty(company.getText())){
company.setError("Company Name is required");
}
if (TextUtils.isEmpty(name.getText())){
name.setError("Name is required");
}
if (TextUtils.isEmpty(email.getText())){
email.setError("e-mail id is required");
}
if(TextUtils.isEmpty(phone.getText())){
phone.setError("Phone Number is required");
}
if (TextUtils.isEmpty(temperature.getText())){
temperature.setError("Body Temperature is required.");
}
if (symptoms.getCheckedRadioButtonId()==-1){
Toast.makeText(this,"Please fill in all the yes/no questions",Toast.LENGTH_SHORT).show();
}
if (absence.getCheckedRadioButtonId()==-1){
Toast.makeText(this,"Please fill in all the yes/no questions",Toast.LENGTH_SHORT).show();
}
if (overseas.getCheckedRadioButtonId()==-1){
Toast.makeText(this,"Please fill in all the yes/no questions",Toast.LENGTH_SHORT).show();
}
if (contact.getCheckedRadioButtonId()==-1){
Toast.makeText(this,"Please fill in all the yes/no questions",Toast.LENGTH_SHORT).show();
}
if (containment.getCheckedRadioButtonId()==-1){
Toast.makeText(this,"Please fill in all the yes/no questions",Toast.LENGTH_SHORT).show();
}
}
private void selectImage() {
Intent takeImageIntent = ImagePicker.getPickImageIntent(this);
if (takeImageIntent.resolveActivity(this.getPackageManager()) != null) {
startActivityForResult(takeImageIntent, REQUEST_IMAGE_CAPTURE);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Bitmap bitmap = ImagePicker.getBitmapFromResult(this, resultCode, data);
if (null != bitmap && resultCode == RESULT_OK) {
imageView=findViewById(R.id.Image);
imageView.setImageBitmap(bitmap);
}
}
public void btnAddImage(View view) {
selectImage();
}
}