Skip to content

Commit 185a657

Browse files
Smart Alarm
1 parent d4e57b2 commit 185a657

21 files changed

+81
-177
lines changed
53.4 KB
Loading

app/src/main/java/it/ezzie/smartalarm/AlarmAdapter.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class AlarmAdapter extends RecyclerView.Adapter<AlarmAdapter.AlarmViewHol
2424
private Calendar calendar = Calendar.getInstance();
2525
private AlarmClickListener listener;
2626
private AlarmDAO alarmDAO = AppDatabase.appDatabase.alarmDAO();
27+
private AlarmEntity alarm1;
2728
public AlarmAdapter(Context context , List<AlarmEntity> alarmList, AlarmClickListener listener){
2829
this.context = context;
2930
this.alarmList = alarmList;
@@ -72,9 +73,11 @@ public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
7273
holder.binding.alarmHour.setText(formattedHour);
7374
holder.binding.alarmMinute.setText(formattedMinute);
7475
holder.binding.alarmSwitch.setChecked(true);
75-
if(formattedUnit.equals("PM")){
76+
AlarmEntity alarm1 = new AlarmEntity(formattedHour,formattedMinute,formattedUnit,true);
77+
alarmDAO.createAlarm(alarm1);
78+
if(formattedUnit.equalsIgnoreCase("PM")){
7679
holder.binding.imageView.setImageResource(R.drawable.ic_moon);
77-
}else if(formattedUnit.equals("AM")){
80+
}else if(formattedUnit.equalsIgnoreCase("AM")){
7881
holder.binding.imageView.setImageResource(R.drawable.ic_sun);
7982
}
8083
}
@@ -88,10 +91,10 @@ public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
8891
holder.binding.alarmMinute.setText(String.format("%02d",resultMinute));
8992
holder.binding.alarmSwitch.setChecked(alarm.isAlarmOn());
9093
holder.binding.alarmUnit.setText(alarm.getAlarmUnit().toUpperCase());
91-
if(alarm.getAlarmUnit().equals("PM")){
94+
if(alarm.getAlarmUnit().equalsIgnoreCase("PM")){
9295
holder.binding.imageView.setImageResource(R.drawable.ic_moon);
9396
}
94-
else if(alarm.getAlarmUnit().equals("AM")){
97+
else if(alarm.getAlarmUnit().equalsIgnoreCase("AM")){
9598
holder.binding.imageView.setImageResource(R.drawable.ic_sun);
9699
}
97100
var alarms = alarmList.get(position);

app/src/main/java/it/ezzie/smartalarm/MainActivity.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ private void initUI(){
6767
}
6868
private void initListener(){
6969
binding.floatingBtn.setOnClickListener(v -> {
70-
refreshView();
7170
Intent intent = new Intent(this, EditAlarm.class);
7271
startActivityForResult(intent,CREATE_REQUEST_CODE);
7372
});
Lines changed: 70 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -1,170 +1,74 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<vector xmlns:android="http://schemas.android.com/apk/res/android"
3-
android:width="108dp"
2+
<vector
43
android:height="108dp"
4+
android:width="108dp"
5+
android:viewportHeight="108"
56
android:viewportWidth="108"
6-
android:viewportHeight="108">
7-
<path
8-
android:fillColor="#3DDC84"
9-
android:pathData="M0,0h108v108h-108z" />
10-
<path
11-
android:fillColor="#00000000"
12-
android:pathData="M9,0L9,108"
13-
android:strokeWidth="0.8"
14-
android:strokeColor="#33FFFFFF" />
15-
<path
16-
android:fillColor="#00000000"
17-
android:pathData="M19,0L19,108"
18-
android:strokeWidth="0.8"
19-
android:strokeColor="#33FFFFFF" />
20-
<path
21-
android:fillColor="#00000000"
22-
android:pathData="M29,0L29,108"
23-
android:strokeWidth="0.8"
24-
android:strokeColor="#33FFFFFF" />
25-
<path
26-
android:fillColor="#00000000"
27-
android:pathData="M39,0L39,108"
28-
android:strokeWidth="0.8"
29-
android:strokeColor="#33FFFFFF" />
30-
<path
31-
android:fillColor="#00000000"
32-
android:pathData="M49,0L49,108"
33-
android:strokeWidth="0.8"
34-
android:strokeColor="#33FFFFFF" />
35-
<path
36-
android:fillColor="#00000000"
37-
android:pathData="M59,0L59,108"
38-
android:strokeWidth="0.8"
39-
android:strokeColor="#33FFFFFF" />
40-
<path
41-
android:fillColor="#00000000"
42-
android:pathData="M69,0L69,108"
43-
android:strokeWidth="0.8"
44-
android:strokeColor="#33FFFFFF" />
45-
<path
46-
android:fillColor="#00000000"
47-
android:pathData="M79,0L79,108"
48-
android:strokeWidth="0.8"
49-
android:strokeColor="#33FFFFFF" />
50-
<path
51-
android:fillColor="#00000000"
52-
android:pathData="M89,0L89,108"
53-
android:strokeWidth="0.8"
54-
android:strokeColor="#33FFFFFF" />
55-
<path
56-
android:fillColor="#00000000"
57-
android:pathData="M99,0L99,108"
58-
android:strokeWidth="0.8"
59-
android:strokeColor="#33FFFFFF" />
60-
<path
61-
android:fillColor="#00000000"
62-
android:pathData="M0,9L108,9"
63-
android:strokeWidth="0.8"
64-
android:strokeColor="#33FFFFFF" />
65-
<path
66-
android:fillColor="#00000000"
67-
android:pathData="M0,19L108,19"
68-
android:strokeWidth="0.8"
69-
android:strokeColor="#33FFFFFF" />
70-
<path
71-
android:fillColor="#00000000"
72-
android:pathData="M0,29L108,29"
73-
android:strokeWidth="0.8"
74-
android:strokeColor="#33FFFFFF" />
75-
<path
76-
android:fillColor="#00000000"
77-
android:pathData="M0,39L108,39"
78-
android:strokeWidth="0.8"
79-
android:strokeColor="#33FFFFFF" />
80-
<path
81-
android:fillColor="#00000000"
82-
android:pathData="M0,49L108,49"
83-
android:strokeWidth="0.8"
84-
android:strokeColor="#33FFFFFF" />
85-
<path
86-
android:fillColor="#00000000"
87-
android:pathData="M0,59L108,59"
88-
android:strokeWidth="0.8"
89-
android:strokeColor="#33FFFFFF" />
90-
<path
91-
android:fillColor="#00000000"
92-
android:pathData="M0,69L108,69"
93-
android:strokeWidth="0.8"
94-
android:strokeColor="#33FFFFFF" />
95-
<path
96-
android:fillColor="#00000000"
97-
android:pathData="M0,79L108,79"
98-
android:strokeWidth="0.8"
99-
android:strokeColor="#33FFFFFF" />
100-
<path
101-
android:fillColor="#00000000"
102-
android:pathData="M0,89L108,89"
103-
android:strokeWidth="0.8"
104-
android:strokeColor="#33FFFFFF" />
105-
<path
106-
android:fillColor="#00000000"
107-
android:pathData="M0,99L108,99"
108-
android:strokeWidth="0.8"
109-
android:strokeColor="#33FFFFFF" />
110-
<path
111-
android:fillColor="#00000000"
112-
android:pathData="M19,29L89,29"
113-
android:strokeWidth="0.8"
114-
android:strokeColor="#33FFFFFF" />
115-
<path
116-
android:fillColor="#00000000"
117-
android:pathData="M19,39L89,39"
118-
android:strokeWidth="0.8"
119-
android:strokeColor="#33FFFFFF" />
120-
<path
121-
android:fillColor="#00000000"
122-
android:pathData="M19,49L89,49"
123-
android:strokeWidth="0.8"
124-
android:strokeColor="#33FFFFFF" />
125-
<path
126-
android:fillColor="#00000000"
127-
android:pathData="M19,59L89,59"
128-
android:strokeWidth="0.8"
129-
android:strokeColor="#33FFFFFF" />
130-
<path
131-
android:fillColor="#00000000"
132-
android:pathData="M19,69L89,69"
133-
android:strokeWidth="0.8"
134-
android:strokeColor="#33FFFFFF" />
135-
<path
136-
android:fillColor="#00000000"
137-
android:pathData="M19,79L89,79"
138-
android:strokeWidth="0.8"
139-
android:strokeColor="#33FFFFFF" />
140-
<path
141-
android:fillColor="#00000000"
142-
android:pathData="M29,19L29,89"
143-
android:strokeWidth="0.8"
144-
android:strokeColor="#33FFFFFF" />
145-
<path
146-
android:fillColor="#00000000"
147-
android:pathData="M39,19L39,89"
148-
android:strokeWidth="0.8"
149-
android:strokeColor="#33FFFFFF" />
150-
<path
151-
android:fillColor="#00000000"
152-
android:pathData="M49,19L49,89"
153-
android:strokeWidth="0.8"
154-
android:strokeColor="#33FFFFFF" />
155-
<path
156-
android:fillColor="#00000000"
157-
android:pathData="M59,19L59,89"
158-
android:strokeWidth="0.8"
159-
android:strokeColor="#33FFFFFF" />
160-
<path
161-
android:fillColor="#00000000"
162-
android:pathData="M69,19L69,89"
163-
android:strokeWidth="0.8"
164-
android:strokeColor="#33FFFFFF" />
165-
<path
166-
android:fillColor="#00000000"
167-
android:pathData="M79,19L79,89"
168-
android:strokeWidth="0.8"
169-
android:strokeColor="#33FFFFFF" />
7+
xmlns:android="http://schemas.android.com/apk/res/android">
8+
<path android:fillColor="#3DDC84"
9+
android:pathData="M0,0h108v108h-108z"/>
10+
<path android:fillColor="#00000000" android:pathData="M9,0L9,108"
11+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
12+
<path android:fillColor="#00000000" android:pathData="M19,0L19,108"
13+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
14+
<path android:fillColor="#00000000" android:pathData="M29,0L29,108"
15+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
16+
<path android:fillColor="#00000000" android:pathData="M39,0L39,108"
17+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
18+
<path android:fillColor="#00000000" android:pathData="M49,0L49,108"
19+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
20+
<path android:fillColor="#00000000" android:pathData="M59,0L59,108"
21+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
22+
<path android:fillColor="#00000000" android:pathData="M69,0L69,108"
23+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
24+
<path android:fillColor="#00000000" android:pathData="M79,0L79,108"
25+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
26+
<path android:fillColor="#00000000" android:pathData="M89,0L89,108"
27+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
28+
<path android:fillColor="#00000000" android:pathData="M99,0L99,108"
29+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
30+
<path android:fillColor="#00000000" android:pathData="M0,9L108,9"
31+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
32+
<path android:fillColor="#00000000" android:pathData="M0,19L108,19"
33+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
34+
<path android:fillColor="#00000000" android:pathData="M0,29L108,29"
35+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
36+
<path android:fillColor="#00000000" android:pathData="M0,39L108,39"
37+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
38+
<path android:fillColor="#00000000" android:pathData="M0,49L108,49"
39+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
40+
<path android:fillColor="#00000000" android:pathData="M0,59L108,59"
41+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
42+
<path android:fillColor="#00000000" android:pathData="M0,69L108,69"
43+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
44+
<path android:fillColor="#00000000" android:pathData="M0,79L108,79"
45+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
46+
<path android:fillColor="#00000000" android:pathData="M0,89L108,89"
47+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
48+
<path android:fillColor="#00000000" android:pathData="M0,99L108,99"
49+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
50+
<path android:fillColor="#00000000" android:pathData="M19,29L89,29"
51+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
52+
<path android:fillColor="#00000000" android:pathData="M19,39L89,39"
53+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
54+
<path android:fillColor="#00000000" android:pathData="M19,49L89,49"
55+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
56+
<path android:fillColor="#00000000" android:pathData="M19,59L89,59"
57+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
58+
<path android:fillColor="#00000000" android:pathData="M19,69L89,69"
59+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
60+
<path android:fillColor="#00000000" android:pathData="M19,79L89,79"
61+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
62+
<path android:fillColor="#00000000" android:pathData="M29,19L29,89"
63+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
64+
<path android:fillColor="#00000000" android:pathData="M39,19L39,89"
65+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
66+
<path android:fillColor="#00000000" android:pathData="M49,19L49,89"
67+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
68+
<path android:fillColor="#00000000" android:pathData="M59,19L59,89"
69+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
70+
<path android:fillColor="#00000000" android:pathData="M69,19L69,89"
71+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
72+
<path android:fillColor="#00000000" android:pathData="M79,19L79,89"
73+
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
17074
</vector>
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
3-
<background android:drawable="@drawable/ic_launcher_background" />
4-
<foreground android:drawable="@drawable/ic_launcher_foreground" />
5-
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
3+
<background android:drawable="@drawable/ic_launcher_background"/>
4+
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
65
</adaptive-icon>
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
3-
<background android:drawable="@drawable/ic_launcher_background" />
4-
<foreground android:drawable="@drawable/ic_launcher_foreground" />
5-
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
3+
<background android:drawable="@drawable/ic_launcher_background"/>
4+
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
65
</adaptive-icon>
-262 Bytes
Loading
2.85 KB
Loading
-610 Bytes
Loading
-228 Bytes
Loading

0 commit comments

Comments
 (0)