diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Bookings.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Bookings.java index 033e8b4..5c79c9d 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Bookings.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Bookings.java @@ -9,9 +9,11 @@ import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; +import android.support.v7.widget.SwitchCompat; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.CompoundButton; import android.widget.EditText; import android.widget.RadioButton; import android.widget.RadioGroup; @@ -54,6 +56,27 @@ public class Bookings extends AppCompatActivity { mAdapter = new MyAdapter(bookings, this); mRecyclerView.setAdapter(mAdapter); + SwitchCompat toggle = findViewById(R.id.Switch); + toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + if (isChecked) { + List booking = (List)dbhelper.findBookings(username); + Booking[] bookings = new Booking[booking.size()]; + bookings = booking.toArray(bookings); + mAdapter = new MyAdapter(bookings, Bookings.this); + mRecyclerView.setAdapter(mAdapter); + mAdapter.notifyDataSetChanged(); + } else { + List booking = (List)dbhelper.findNonCancelledBookings(username); + Booking[] bookings = new Booking[booking.size()]; + bookings = booking.toArray(bookings); + mAdapter = new MyAdapter(bookings, Bookings.this); + mRecyclerView.setAdapter(mAdapter); + mAdapter.notifyDataSetChanged(); + } + } + }); + } /** diff --git a/OlympusServices/app/src/main/res/layout/activity_bookings.xml b/OlympusServices/app/src/main/res/layout/activity_bookings.xml index eb704f7..334eb60 100644 --- a/OlympusServices/app/src/main/res/layout/activity_bookings.xml +++ b/OlympusServices/app/src/main/res/layout/activity_bookings.xml @@ -12,11 +12,20 @@ android:paddingTop="@dimen/activity_vertical_margin" android:background="@drawable/background" tools:context=".Bookings"> + + android:layout_height="450dp"/> \ No newline at end of file diff --git a/OlympusServices/app/src/main/res/values/styles.xml b/OlympusServices/app/src/main/res/values/styles.xml index 4b78444..be9729a 100644 --- a/OlympusServices/app/src/main/res/values/styles.xml +++ b/OlympusServices/app/src/main/res/values/styles.xml @@ -13,10 +13,11 @@ @color/colorBlack - +