Skip to content

Commit c674db9

Browse files
authored
Merge pull request #93 from jmsherrier/yitian
Temp check style fix
2 parents f81e161 + ddc19cb commit c674db9

8 files changed

Lines changed: 67 additions & 23 deletions

File tree

Project/Sprint0.5-main/app/src/main/java/com/example/sprintproject/adapter/BudgetAdapter.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import android.view.LayoutInflater;
55
import android.view.View;
66
import android.view.ViewGroup;
7-
import android.widget.ImageView;
87
import android.widget.TextView;
98

109
import androidx.annotation.NonNull;

Project/Sprint0.5-main/app/src/main/java/com/example/sprintproject/adapter/CircleAdapter.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
import java.util.HashMap;
1616
import java.util.List;
17-
import java.util.Locale;
1817
import java.util.Map;
1918

2019
/**
Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,43 @@
11
package com.example.sprintproject.model;
22

3+
/**
4+
* Represents a budget threshold notification, including the budget info,
5+
* the threshold percentage, and the current spending progress.
6+
*/
37
public class ThresholdNotification {
4-
public final String id;
5-
public final String budgetId;
6-
public final String budgetTitle;
7-
public final int thresholdPercent;
8-
public final double progress;
8+
private final String id;
9+
private final String budgetId;
10+
private final String budgetTitle;
11+
private final int thresholdPercent;
12+
private final double progress;
913

10-
public ThresholdNotification(String budgetId, String budgetTitle, int thresholdPercent, double progress) {
14+
public ThresholdNotification(
15+
String budgetId, String budgetTitle,
16+
int thresholdPercent, double progress) {
1117
this.budgetId = budgetId;
1218
this.budgetTitle = budgetTitle;
1319
this.thresholdPercent = thresholdPercent;
1420
this.progress = progress;
1521
this.id = budgetId + "_" + thresholdPercent;
1622
}
23+
24+
public String getId() {
25+
return id;
26+
}
27+
28+
public String getBudgetId() {
29+
return budgetId;
30+
}
31+
32+
public String getBudgetTitle() {
33+
return budgetTitle;
34+
}
35+
36+
public int getThresholdPercent() {
37+
return thresholdPercent;
38+
}
39+
40+
public double getProgress() {
41+
return progress;
42+
}
1743
}

Project/Sprint0.5-main/app/src/main/java/com/example/sprintproject/repository/SavingsCircleRepository.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.google.firebase.firestore.ListenerRegistration;
1313
import com.google.firebase.firestore.Query;
1414
import com.google.firebase.firestore.QueryDocumentSnapshot;
15+
import com.google.firebase.firestore.QuerySnapshot;
1516

1617

1718
import java.util.ArrayList;
@@ -132,7 +133,7 @@ public void loadUserCircles(String userId, RepositoryCallback<List<SavingsCircle
132133
e -> callback.onError("Error loading circles: " + e.getMessage()));
133134
}
134135

135-
private List<String> extractCircleIds(com.google.firebase.firestore.QuerySnapshot querySnapshot) {
136+
private List<String> extractCircleIds(QuerySnapshot querySnapshot) {
136137
List<String> circleIds = new ArrayList<>();
137138
for (QueryDocumentSnapshot circleDoc : querySnapshot) {
138139
circleIds.add(circleDoc.getId());
@@ -146,13 +147,16 @@ private void checkMembershipAndLoadCircles(String userId, List<String> circleIds
146147
final int[] completed = {0};
147148

148149
for (String circleId : circleIds) {
149-
checkMembershipForCircle(userId, circleId, userCircles, completed, circleIds.size(), callback);
150+
checkMembershipForCircle(
151+
userId, circleId, userCircles,
152+
completed, circleIds.size(), callback);
150153
}
151154
}
152155

153156
private void checkMembershipForCircle(String userId, String circleId,
154157
List<SavingsCircle> userCircles, int[] completed,
155-
int totalCircles, RepositoryCallback<List<SavingsCircle>> callback) {
158+
int totalCircles,
159+
RepositoryCallback<List<SavingsCircle>> callback) {
156160
db.collection(COLLECTION_SAVINGS_CIRCLES)
157161
.document(circleId)
158162
.collection(COLLECTION_MEMBERS)
@@ -167,7 +171,7 @@ private void checkMembershipForCircle(String userId, String circleId,
167171
})
168172
.addOnFailureListener(e ->
169173
incrementCompleted(completed, totalCircles, userCircles, callback)
170-
);
174+
);
171175
}
172176

173177
private void loadCircleForUser(String circleId, List<SavingsCircle> userCircles,
@@ -413,7 +417,7 @@ private void processInvitationAcceptance(String invitationId,
413417
)
414418
.addOnFailureListener(e ->
415419
callback.onError("Error updating invitation: " + e.getMessage())
416-
);
420+
);
417421
}
418422

419423
private void loadCircleAndAddMember(String circleId, String userId,
@@ -474,7 +478,7 @@ public void declineInvitation(String invitationId,
474478
.addOnSuccessListener(aVoid -> callback.onSuccess(null))
475479
.addOnFailureListener(e -> callback.onError(
476480
"Error declining invitation: " + e.getMessage())
477-
);
481+
);
478482
})
479483
.addOnFailureListener(e -> callback.onError(
480484
"Error loading invitation: " + e.getMessage()));

Project/Sprint0.5-main/app/src/main/java/com/example/sprintproject/utils/NotificationQueue.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@ public NotificationQueue(OnShow onShow) {
1717
this.onShow = onShow;
1818
}
1919
public synchronized void enqueue(ThresholdNotification item) {
20-
if (item == null) return;
20+
if (item == null) {
21+
return;
22+
}
2123
queue.offer(item);
2224
run();
2325
}
2426

2527
private synchronized void run() {
26-
if (running) return;
28+
if (running) {
29+
return;
30+
}
2731
running = true;
2832
processNext();
2933
}

Project/Sprint0.5-main/app/src/main/java/com/example/sprintproject/view/ExpenseLogFragment.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ public View onCreateView(@NonNull LayoutInflater inflater,
6767
@Nullable Bundle savedInstanceState) {
6868
View view = inflater.inflate(R.layout.activity_expense_log, container, false);
6969

70-
TimeViewModel timeViewModel = new ViewModelProvider(requireActivity()).get(TimeViewModel.class);
70+
TimeViewModel timeViewModel =
71+
new ViewModelProvider(requireActivity()).get(TimeViewModel.class);
7172

7273
timeViewModel.getCurrentDate().observe(getViewLifecycleOwner(), date -> {
7374
SimpleDateFormat fmt =
@@ -368,11 +369,11 @@ public int compare(Expense e1, Expense e2) {
368369
})
369370
.addOnFailureListener(e ->
370371
Log.e("ExpenseLog", "Error creating seed expense 2", e)
371-
);
372+
);
372373
})
373374
.addOnFailureListener(e ->
374375
Log.e("ExpenseLog", "Error creating seed expense 1", e)
375-
);
376+
);
376377
}
377378

378379
private void updateUI() {

Project/Sprint0.5-main/app/src/main/java/com/example/sprintproject/view/SavingsCirclesFragment.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ private void observeData() {
128128
});
129129

130130
// Observe pending invitations
131-
viewModel.getPendingInvitations().observe(getViewLifecycleOwner(), this::updateInvitationsList);
131+
viewModel.getPendingInvitations().observe(
132+
getViewLifecycleOwner(), this::updateInvitationsList);
132133
}
133134

134135
private void updateInvitationsList(List<CircleInvitation> invitations) {

Project/Sprint0.5-main/app/src/main/java/com/example/sprintproject/viewmodel/DashboardViewModel.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,21 @@ private void addBudgetBarEntry(List<BarEntry> barEntries, List<String> labels,
178178
}
179179

180180
private static class BarChartData {
181-
final List<BarEntry> barEntries;
182-
final List<String> labels;
181+
private List<BarEntry> barEntries;
182+
private List<String> labels;
183183

184184
BarChartData(List<BarEntry> barEntries, List<String> labels) {
185185
this.barEntries = barEntries;
186186
this.labels = labels;
187187
}
188+
189+
public List<BarEntry> getBarEntries() {
190+
return barEntries;
191+
}
192+
193+
public List<String> getLabels() {
194+
return labels;
195+
}
188196
}
189197

190198
public void checkExpenseReminder() {
@@ -212,7 +220,9 @@ public void checkExpenseReminder() {
212220

213221
// prevent repeated pop-ups in the same day
214222
if (lastReminderShownDate != null) {
215-
long diffSinceReminder = (System.currentTimeMillis() - lastReminderShownDate.getTime()) / (1000L * 60 * 60 * 24);
223+
long diffSinceReminder =
224+
(System.currentTimeMillis() - lastReminderShownDate.getTime())
225+
/ (1000L * 60 * 60 * 24);
216226
if (diffSinceReminder < 1) {
217227
Log.d("REMINDER_DEBUG", "Reminder already shown today → skipping");
218228
return;

0 commit comments

Comments
 (0)