Skip to content

Commit

Permalink
Updated Overall Attendance
Browse files Browse the repository at this point in the history
  • Loading branch information
ezhil56x committed Mar 31, 2024
1 parent 6329fee commit 4fb8eb0
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,7 @@ private void downloadAttendance() {
JSONArray attendanceArray = response.getJSONArray("attendance");
List<Attendance> attendance = new ArrayList<>();

float overallAttendance = 0;
int overallAttendance = 0;

int attendedClasses = 0;
int totalClasses = 0;
Expand All @@ -1320,6 +1320,7 @@ private void downloadAttendance() {
attendanceItem.total = this.getIntegerValue(attendanceObject, "total");

if (attendanceItem.attended != null && attendanceItem.total != null && attendanceItem.total != 0) {
attendanceItem.percentage = (int) Math.ceil((attendanceItem.attended * 100.0) / attendanceItem.total);
attendedClasses += attendanceItem.attended;
totalClasses += attendanceItem.total;
}
Expand All @@ -1328,7 +1329,7 @@ private void downloadAttendance() {
}

if (totalClasses != 0) {
overallAttendance = (attendedClasses * 100.0f) / totalClasses;
overallAttendance = (int) ((attendedClasses * 100) / totalClasses);
}

sharedPreferences.edit().putInt("overallAttendance", (int) overallAttendance).apply();
Expand Down

0 comments on commit 4fb8eb0

Please sign in to comment.