Permalink
Browse files

Option to cancel checkin, doesn't work yet

  • Loading branch information...
zman0900 committed Jun 3, 2012
1 parent a0bdd0c commit 338bb7e859892a71551d8bb3222cab4a5a1a0698
Showing with 50 additions and 17 deletions.
  1. +13 −3 res/layout/checkin.xml
  2. +3 −0 res/values/strings.xml
  3. +4 −0 src/com/cse694/User.java
  4. +30 −14 src/com/cse694/UserChecksIn.java
View
@@ -19,19 +19,29 @@
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
- android:id="@+id/checkingInAt"
+ android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/restaurantName"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <TextView
+ android:id="@+id/message"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_below="@+id/description"
+ android:layout_marginTop="10dp"
+ android:text="@string/checkinMessage"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
<RadioGroup
android:id="@+id/radioGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_below="@+id/checkingInAt" >
+ android:layout_below="@+id/message" >
<RadioButton
android:id="@+id/twoPeople"
@@ -65,7 +75,7 @@
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/radioGroup"
- android:text="Check In!" />
+ android:text="@string/acceptBtn" />
<Button
android:id="@+id/cancelButtonCHK"
View
@@ -22,5 +22,8 @@
<string name="seatNotify">This is a static string.</string>
<string name="acceptBtn">Accept Seat</string>
<string name="declineSeat">Decline Seat</string>
+ <string name="checkinMessage">Please let us know how many people are in your party:</string>
+ <string name="alreadyCheckedIn">You\'re already checked in at this location.</string>
+ <string name="cancelCheckinBtn">Cancel Checkin</string>
</resources>
View
@@ -129,6 +129,10 @@ public void run() {
return;
}
+
+ public void cancelCheckin() {
+ Log.d("buzzer","Checkin canceled");
+ }
public boolean accept_seat(Restaurant rest, boolean accept, Context context) {
boolean ans = true;
@@ -16,6 +16,7 @@
private PartySizes partySize = PartySizes.ONE_TWO; // default party size
private Restaurant restaurant;
+ private boolean checkedIn = false;
/** Called when the activity is first created. */
@Override
@@ -35,16 +36,25 @@ protected void onCreate(Bundle savedInstanceState) {
TextView restName = (TextView) findViewById(R.id.restaurantName);
restName.setText(restaurant.getName());
- TextView checkingIn = (TextView) findViewById(R.id.checkingInAt);
- checkingIn.setText(restaurant.getDescription()
- + "\n\nPlease let us know how many people are in your party:");
+ TextView description = (TextView) findViewById(R.id.description);
+ description.setText(restaurant.getDescription());
- View btnCancel = (Button) findViewById(R.id.cancelButtonCHK);
+ Button btnCancel = (Button) findViewById(R.id.cancelButtonCHK);
btnCancel.setOnClickListener(this);
- View btnRegister = (Button) findViewById(R.id.checkInButton);
+ Button btnRegister = (Button) findViewById(R.id.checkInButton);
btnRegister.setOnClickListener(this);
RadioGroup radio = (RadioGroup) findViewById(R.id.radioGroup);
radio.setOnCheckedChangeListener(this);
+
+ User user = User.getCurrentUser(this);
+ if (user.getCheckedInAtId() != null && user.getCheckedInAtId() == id) {
+ // User alread checked in here
+ checkedIn = true;
+ radio.setVisibility(View.GONE);
+ TextView message = (TextView) findViewById(R.id.message);
+ message.setText(R.string.alreadyCheckedIn);
+ btnRegister.setText(R.string.cancelCheckinBtn);
+ }
}
@Override
@@ -81,19 +91,25 @@ protected void onDestroy() {
public void onClick(View v) {
switch (v.getId()) {
case R.id.cancelButtonCHK:
- Log.i("Buzzer", "Canceled checkIn");
+ Log.d("buzzer", "Canceled checkIn screen");
finish();
break;
case R.id.checkInButton:
- Log.i("Buzzer", "Checked in");
User user = User.getCurrentUser(this);
- Toast.makeText(
- this,
- "Checking in " + partySize.getNum() + " guests at "
- + restaurant.getName() + "...", Toast.LENGTH_LONG)
- .show();
- user.checkIn(restaurant.getId(), partySize, this);
- finish();
+ if (checkedIn) {
+ Log.d("buzzer", "Canceling checkin");
+ user.cancelCheckin();
+ finish();
+ } else {
+ Log.d("buzzer", "Checking in");
+ Toast.makeText(
+ this,
+ "Checking in " + partySize.getNum() + " guests at "
+ + restaurant.getName() + "...",
+ Toast.LENGTH_LONG).show();
+ user.checkIn(restaurant.getId(), partySize, this);
+ finish();
+ }
}
}

0 comments on commit 338bb7e

Please sign in to comment.