Skip to content

Commit

Permalink
make registration work
Browse files Browse the repository at this point in the history
  • Loading branch information
Crystalsage committed Apr 11, 2023
1 parent dd24c23 commit 38d7b0c
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ class RegistrationActivity: AppCompatActivity() {
etEmail = findViewById(R.id.edit_text_register_email)
etPassword = findViewById(R.id.edit_text_register_password)
etStudentId = findViewById(R.id.edit_text_register_student_id)
etEmail.setText("[email protected]")
etStudentId.setText("2018FHCO106")
etPassword.setText("root")

btnRegister = findViewById(R.id.button_register)
btnRegister.setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class ComplaintAdapter(private val complaintList : ArrayList<Complaint>): Recycl
val desc : TextView = itemView.findViewById(R.id.complaint_text)
val subject : TextView = itemView.findViewById(R.id.complaint_sub)
val replyBtn : Button = itemView.findViewById(R.id.reply_btn)
val btnDecline : Button = itemView.findViewById(R.id.dialog_decline_btn)
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,26 @@ class EventWrapper {
File.createTempFile("poster", posterExtension)
}

Log.d("UPDATE_FLOW_OLDEVENTREF", oldEventRef.toString())
Log.d("UPDATE_FLOW_NEWEVENTREF", newEventRef.toString())
Log.d("UPDATE_FLOW_TEMPFILE", localFile.absolutePath.toString())

oldEventRef.getFile(localFile).await()
newEventRef.putFile(Uri.fromFile(localFile)).await()
}

suspend fun registerStudent(eventObject: Event, studentId: String) {
if (eventObject.registrants == null) {
eventObject.registrants = mutableListOf(studentId)
} else {
eventObject.registrants!!.add(studentId)
}

Log.d("EVENT", eventObject.toString())

updateEvent(eventObject, eventObject)
}

suspend fun unregisterStudent(eventObject: Event, studentId: String) {
eventObject.registrants?.remove(studentId)
Log.d("EVENT", eventObject.toString())
updateEvent(eventObject, eventObject)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ class EventUpsertActivity: AppCompatActivity() {
title = etEventTitle.text.toString(),
venue = etEventVenue.text.toString(),
speaker = etEventSpeaker.text.toString(),
prerequisites = etEventPrerequisites.text.toString(),
uuid = Helpers.generateEventUuid(),
datetime = Helpers.generateUnixTimestampFromDate(
Helpers.eventUpsertDateTimeFormat.parse(etEventDateTime.text.toString())!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,10 @@ class EventViewActivity: AppCompatActivity() {
stateRegistered = false
}


if (!stateRegistered) {
// TODO: Insert attendee into the database
runBlocking { EventWrapper.unregisterStudent(eventObject, CsiAuthWrapper.getStudentId(applicationContext)) }
} else {
// TODO: Remove attendee from the database.
runBlocking { EventWrapper.registerStudent(eventObject, CsiAuthWrapper.getStudentId(applicationContext)) }
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
android:layout_marginHorizontal="20dp">

<com.google.android.material.button.MaterialButton
android:id="@+id/dialog_decline_btn"
android:id="@+id/button_dialog_decline_complaints"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@


<com.google.android.material.button.MaterialButton
android:id="@+id/dialog_decline_btn"
android:id="@+id/button_dialog_decline_complaints"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@


<com.google.android.material.button.MaterialButton
android:id="@+id/dialog_decline_btn"
android:id="@+id/button_dialog_decline_complaints"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
Expand Down

0 comments on commit 38d7b0c

Please sign in to comment.