added show cancelled optional
This commit is contained in:
parent
7d3ef3bf92
commit
36ff2f2e60
3 changed files with 35 additions and 2 deletions
|
@ -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> booking = (List<Booking>)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> booking = (List<Booking>)dbhelper.findNonCancelledBookings(username);
|
||||
Booking[] bookings = new Booking[booking.size()];
|
||||
bookings = booking.toArray(bookings);
|
||||
mAdapter = new MyAdapter(bookings, Bookings.this);
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,11 +12,20 @@
|
|||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:background="@drawable/background"
|
||||
tools:context=".Bookings">
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Show cancelled bookings"
|
||||
android:id="@+id/Switch"
|
||||
android:checked="true"
|
||||
android:theme="@style/Switch"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:textColor="@color/colorWhite"/>
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/Bookings"
|
||||
android:scrollbars="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="500dp"/>
|
||||
android:layout_height="450dp"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -13,10 +13,11 @@
|
|||
<item name="android:textColor">@color/colorBlack</item>
|
||||
</style>
|
||||
|
||||
<style name="RatingBar" parent="Theme.AppCompat">
|
||||
<style name="Switch" parent="Theme.AppCompat">
|
||||
<item name="colorControlNormal">@color/colorWhite</item>
|
||||
<item name="colorControlActivated">@color/colorWhite</item>
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue