|
23 | 23 | import com.github.meafs.recover.R;
|
24 | 24 | import com.github.meafs.recover.utils.AlarmBroadcast;
|
25 | 25 | import com.github.meafs.recover.utils.dbManager;
|
| 26 | +import com.google.android.material.textfield.TextInputEditText; |
26 | 27 |
|
27 | 28 | import java.text.DateFormat;
|
28 | 29 | import java.text.ParseException;
|
|
32 | 33 | import java.util.Date;
|
33 | 34 |
|
34 | 35 | public class ReminderActivity extends AppCompatActivity {
|
35 |
| - Button mSubmitbtn, mDatebtn, mTimebtn, mPname; |
36 |
| - EditText mTitledit; |
| 36 | + Button mSubmitbtn, mPname; |
| 37 | + TextInputEditText mDatebtn, mTimebtn; |
| 38 | + TextInputEditText mTitledit; |
37 | 39 | String timeTonotify;
|
38 | 40 | private ArrayList<String> names = new ArrayList<>();
|
39 | 41 | private String patientName;
|
@@ -62,41 +64,31 @@ protected void onCreate(Bundle savedInstanceState) {
|
62 | 64 | patientName = (String) adapterView.getItemAtPosition(i);
|
63 | 65 | });
|
64 | 66 |
|
65 |
| - mTimebtn.setOnClickListener(new View.OnClickListener() { |
66 |
| - @Override |
67 |
| - public void onClick(View view) { |
68 |
| - selectTime(); //when we click on the choose time button it calls the select time method |
69 |
| - } |
| 67 | + mTimebtn.setOnClickListener(view -> { |
| 68 | + selectTime(); //when we click on the choose time button it calls the select time method |
70 | 69 | });
|
71 | 70 |
|
72 |
| - mDatebtn.setOnClickListener(new View.OnClickListener() { |
73 |
| - @Override |
74 |
| - public void onClick(View view) { |
75 |
| - selectDate(); |
76 |
| - } //when we click on the choose date button it calls the select date method |
77 |
| - }); |
| 71 | + //when we click on the choose date button it calls the select date method |
| 72 | + mDatebtn.setOnClickListener(view -> selectDate()); |
78 | 73 |
|
79 |
| - mSubmitbtn.setOnClickListener(new View.OnClickListener() { |
80 |
| - @Override |
81 |
| - public void onClick(View view) { |
82 |
| - String title = mTitledit.getText().toString().trim(); //access the data from the input field |
83 |
| - String date = mDatebtn.getText().toString().trim(); //access the date from the choose date button |
84 |
| - String time = mTimebtn.getText().toString().trim(); //access the time from the choose time button |
85 |
| - String pname = patientName; |
86 |
| - if (pname != null) { |
87 |
| - |
88 |
| - if (title.isEmpty()) { |
89 |
| - Toast.makeText(getApplicationContext(), "Please Enter text", Toast.LENGTH_SHORT).show(); //shows the toast if input field is empty |
| 74 | + mSubmitbtn.setOnClickListener(view -> { |
| 75 | + String title = mTitledit.getText().toString().trim(); //access the data from the input field |
| 76 | + String date = mDatebtn.getText().toString().trim(); //access the date from the choose date button |
| 77 | + String time = mTimebtn.getText().toString().trim(); //access the time from the choose time button |
| 78 | + String pname = patientName; |
| 79 | + if (pname != null) { |
| 80 | + |
| 81 | + if (title.isEmpty()) { |
| 82 | + Toast.makeText(getApplicationContext(), "Please Enter text", Toast.LENGTH_SHORT).show(); //shows the toast if input field is empty |
| 83 | + } else { |
| 84 | + if (time.equals("time") || date.equals("date")) { //shows toast if date and time are not selected |
| 85 | + Toast.makeText(getApplicationContext(), "Please select date and time", Toast.LENGTH_SHORT).show(); |
90 | 86 | } else {
|
91 |
| - if (time.equals("time") || date.equals("date")) { //shows toast if date and time are not selected |
92 |
| - Toast.makeText(getApplicationContext(), "Please select date and time", Toast.LENGTH_SHORT).show(); |
93 |
| - } else { |
94 |
| - processinsert(title, date, time, pname); |
95 |
| - } |
| 87 | + processinsert(title, date, time, pname); |
96 | 88 | }
|
97 |
| - } else { |
98 |
| - Toast.makeText(getApplicationContext(), "Please select Patient", Toast.LENGTH_SHORT).show(); |
99 | 89 | }
|
| 90 | + } else { |
| 91 | + Toast.makeText(getApplicationContext(), "Please select Patient", Toast.LENGTH_SHORT).show(); |
100 | 92 | }
|
101 | 93 | });
|
102 | 94 | }
|
|
0 commit comments