Skip to content

Commit a1efeb5

Browse files
committed
Cleaned Reminder
1 parent e45eb7d commit a1efeb5

File tree

12 files changed

+739
-174
lines changed

12 files changed

+739
-174
lines changed

.idea/misc.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/github/meafs/recover/activites/ReminderActivity.java

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.github.meafs.recover.R;
2424
import com.github.meafs.recover.utils.AlarmBroadcast;
2525
import com.github.meafs.recover.utils.dbManager;
26+
import com.google.android.material.textfield.TextInputEditText;
2627

2728
import java.text.DateFormat;
2829
import java.text.ParseException;
@@ -32,8 +33,9 @@
3233
import java.util.Date;
3334

3435
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;
3739
String timeTonotify;
3840
private ArrayList<String> names = new ArrayList<>();
3941
private String patientName;
@@ -62,41 +64,31 @@ protected void onCreate(Bundle savedInstanceState) {
6264
patientName = (String) adapterView.getItemAtPosition(i);
6365
});
6466

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
7069
});
7170

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());
7873

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();
9086
} 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);
9688
}
97-
} else {
98-
Toast.makeText(getApplicationContext(), "Please select Patient", Toast.LENGTH_SHORT).show();
9989
}
90+
} else {
91+
Toast.makeText(getApplicationContext(), "Please select Patient", Toast.LENGTH_SHORT).show();
10092
}
10193
});
10294
}

app/src/main/java/com/github/meafs/recover/activites/ReminderListActvity.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,10 @@ protected void onCreate(Bundle savedInstanceState) {
4141
names = mBundle.getStringArrayList("namesList");
4242
}
4343

44-
mCreateRem.setOnClickListener(new View.OnClickListener() {
45-
@Override
46-
public void onClick(View view) {
47-
Intent intent = new Intent(getApplicationContext(), ReminderActivity.class);
48-
intent.putStringArrayListExtra("namesList", names);
49-
startActivity(intent);
50-
}
44+
mCreateRem.setOnClickListener(view -> {
45+
Intent intent = new Intent(getApplicationContext(), ReminderActivity.class);
46+
intent.putStringArrayListExtra("namesList", names);
47+
startActivity(intent);
5148
});
5249

5350
Cursor cursor = new dbManager(getApplicationContext()).readallreminders();

app/src/main/java/com/github/meafs/recover/adapters/ReminderAdapter.java

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -43,31 +43,28 @@ public void onBindViewHolder(@NonNull myviewholder holder, @SuppressLint("Recycl
4343
holder.mDate.setText(dataholder.get(position).getDate());
4444
holder.mTime.setText(dataholder.get(position).getTime());
4545
holder.mPatient.setText(dataholder.get(position).getPname());
46-
holder.reminder_rv_layout.setOnClickListener(new View.OnClickListener() {
47-
@Override
48-
public void onClick(View view) {
49-
AlertDialog.Builder adb = new AlertDialog.Builder(context);
50-
adb.setTitle("Delete?");
51-
adb.setMessage("Are you sure you want to delete " + position);
52-
final int positionToRemove = position;
53-
adb.setNegativeButton("Cancel", null);
54-
adb.setPositiveButton("Ok", new AlertDialog.OnClickListener() {
55-
public void onClick(DialogInterface dialog, int which) {
56-
String title = (String) ((TextView) view.findViewById(R.id.txtTitle)).getText();
57-
String date = (String) ((TextView) view.findViewById(R.id.txtDate)).getText();
58-
String time = (String) ((TextView) view.findViewById(R.id.txtTime)).getText();
59-
String pname = (String) ((TextView) view.findViewById(R.id.txtPname)).getText();
60-
61-
String result = new dbManager(context).deleteReminder(title, date, time, pname);
62-
Toast.makeText(context, result, Toast.LENGTH_SHORT).show();
63-
64-
dataholder.remove(position);
65-
notifyItemRemoved(position);
66-
notifyItemRangeChanged(position, getItemCount());
67-
}
68-
});
69-
adb.show();
70-
}
46+
holder.reminder_rv_layout.setOnClickListener(view -> {
47+
AlertDialog.Builder adb = new AlertDialog.Builder(context);
48+
adb.setTitle("Delete?");
49+
adb.setMessage("Are you sure you want to delete " + dataholder.get(position).getTitle() + " with " + dataholder.get(position).getPname());
50+
final int positionToRemove = position;
51+
adb.setNegativeButton("Cancel", null);
52+
adb.setPositiveButton("Ok", new AlertDialog.OnClickListener() {
53+
public void onClick(DialogInterface dialog, int which) {
54+
String title = (String) ((TextView) view.findViewById(R.id.txtTitle)).getText();
55+
String date = (String) ((TextView) view.findViewById(R.id.txtDate)).getText();
56+
String time = (String) ((TextView) view.findViewById(R.id.txtTime)).getText();
57+
String pname = (String) ((TextView) view.findViewById(R.id.txtPname)).getText();
58+
59+
String result = new dbManager(context).deleteReminder(title, date, time, pname);
60+
Toast.makeText(context, result, Toast.LENGTH_SHORT).show();
61+
62+
dataholder.remove(position);
63+
notifyItemRemoved(position);
64+
notifyItemRangeChanged(position, getItemCount());
65+
}
66+
});
67+
adb.show();
7168
});
7269
}
7370

0 commit comments

Comments
 (0)