-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Krithic Kumar
committed
Sep 20, 2020
1 parent
7189548
commit cedf2a3
Showing
8 changed files
with
181 additions
and
21 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
app/src/main/java/com/attendancemanager/TimeTableAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.attendancemanager; | ||
|
||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.TextView; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
import java.util.List; | ||
import java.util.Locale; | ||
|
||
public class TimeTableAdapter extends RecyclerView.Adapter<TimeTableAdapter.TimeTableViewHolder> { | ||
|
||
private List<Subject> mSubjectList; | ||
|
||
public TimeTableAdapter(List<Subject> mSubjectList) { | ||
this.mSubjectList = mSubjectList; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public TimeTableViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | ||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.time_table_row, parent, false); | ||
return new TimeTableViewHolder(view); | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(@NonNull TimeTableViewHolder holder, int position) { | ||
|
||
Subject subject = mSubjectList.get(position); | ||
int percentage = subject.getTotalClasses() == 0 ? 0 : Math.round(((float) subject.getAttendedClasses() | ||
/ (float) subject.getTotalClasses()) * 100); | ||
|
||
holder.mPosition.setText(String.valueOf(position + 1)); | ||
holder.mSubjectName.setText(subject.getSubjectName()); | ||
holder.mAttendancePercentage.setText(String.format(Locale.US, "%d%%", percentage)); | ||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return mSubjectList.size(); | ||
} | ||
|
||
public static class TimeTableViewHolder extends RecyclerView.ViewHolder { | ||
|
||
private TextView mPosition; | ||
private TextView mSubjectName; | ||
private TextView mAttendancePercentage; | ||
|
||
public TimeTableViewHolder(@NonNull View itemView) { | ||
super(itemView); | ||
|
||
mPosition = itemView.findViewById(R.id.subject_position); | ||
mSubjectName = itemView.findViewById(R.id.time_table_subject_name); | ||
mAttendancePercentage = itemView.findViewById(R.id.time_table_attendance_percentage); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<TextView | ||
<androidx.recyclerview.widget.RecyclerView | ||
android:id="@+id/time_table_recycler_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:gravity="center" | ||
android:text="Hello" /> | ||
tools:listitem="@layout/time_table_row" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<androidx.cardview.widget.CardView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="16dp" | ||
android:layout_marginTop="16dp" | ||
android:layout_marginEnd="16dp" | ||
android:layout_marginBottom="8dp" | ||
app:cardCornerRadius="16dp"> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<TextView | ||
android:id="@+id/subject_position" | ||
android:layout_width="30dp" | ||
android:layout_height="30dp" | ||
android:layout_marginStart="16sp" | ||
android:layout_marginTop="16dp" | ||
android:layout_marginBottom="16dp" | ||
android:background="@drawable/circle_button_bg" | ||
android:backgroundTint="@color/colorPinkPrimaryDark" | ||
android:fontFamily="@font/rubik" | ||
android:gravity="center" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
tools:text="1" /> | ||
|
||
<TextView | ||
android:id="@+id/time_table_subject_name" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="16dp" | ||
android:layout_marginTop="16dp" | ||
android:layout_marginBottom="16dp" | ||
android:fontFamily="@font/raleway_semibold" | ||
android:textSize="24sp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintStart_toEndOf="@id/subject_position" | ||
app:layout_constraintTop_toTopOf="parent" | ||
tools:text="English" /> | ||
|
||
<TextView | ||
android:id="@+id/time_table_attendance_percentage" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="16dp" | ||
android:layout_marginEnd="16dp" | ||
android:layout_marginBottom="16dp" | ||
android:fontFamily="@font/raleway_semibold" | ||
android:textSize="20sp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
tools:text="75%" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
|
||
</androidx.cardview.widget.CardView> | ||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters