summaryrefslogtreecommitdiffstats
path: root/sandbox/travelsample/scatours-android-ui/src/com/scatours/android/TripSearch.java
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/travelsample/scatours-android-ui/src/com/scatours/android/TripSearch.java')
-rw-r--r--sandbox/travelsample/scatours-android-ui/src/com/scatours/android/TripSearch.java106
1 files changed, 88 insertions, 18 deletions
diff --git a/sandbox/travelsample/scatours-android-ui/src/com/scatours/android/TripSearch.java b/sandbox/travelsample/scatours-android-ui/src/com/scatours/android/TripSearch.java
index 04c7c59c0c..b1191f0077 100644
--- a/sandbox/travelsample/scatours-android-ui/src/com/scatours/android/TripSearch.java
+++ b/sandbox/travelsample/scatours-android-ui/src/com/scatours/android/TripSearch.java
@@ -1,5 +1,9 @@
package com.scatours.android;
+import scatours.SCAToursSearch;
+import scatours.SCAToursSearchProxy;
+import scatours.common.TripItem;
+import scatours.common.TripLeg;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
@@ -7,11 +11,32 @@ import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
+import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.AdapterView.OnItemSelectedListener;
public class TripSearch extends Activity {
+
+ static final String[] AIRPORT_CODES = new String[] {
+ "LGW - London Gatwick Airport",
+ "FLR - Luigi Ridolfi Airport",
+ "SFO - San Francisco Airport",
+ "GRU - Sao Paulo Airport",
+ "GIG - Rio de Janeiro Airport"
+ };
+
+
+ private AutoCompleteTextView txtFromLocation,
+ txtToLocation,
+ txtDateStart,
+ txtDateEnd,
+ txtNumberOfPeople;
+ private Button btnSearch;
+
+
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -21,18 +46,51 @@ public class TripSearch extends Activity {
ArrayAdapter adapter = new ArrayAdapter(this,android.R.layout.simple_dropdown_item_1line, AIRPORT_CODES);
- AutoCompleteTextView textViewFrom = (AutoCompleteTextView) findViewById(R.id.edit_fromLocation);
+ txtFromLocation = (AutoCompleteTextView) findViewById(R.id.edit_fromLocation);
//ArrayAdapter adapterFrom = new ArrayAdapter(this,android.R.layout.simple_dropdown_item_1line, AIRPORT_CODES);
- textViewFrom.setAdapter(adapter);
+ txtFromLocation.setAdapter(adapter);
- AutoCompleteTextView textViewTo = (AutoCompleteTextView) findViewById(R.id.edit_toLocation);
+ txtToLocation = (AutoCompleteTextView) findViewById(R.id.edit_toLocation);
//ArrayAdapter adapterTo = new ArrayAdapter(this,android.R.layout.simple_dropdown_item_1line, AIRPORT_CODES);
- textViewTo.setAdapter(adapter);
+ txtToLocation.setAdapter(adapter);
+
+ txtDateStart = (AutoCompleteTextView) findViewById(R.id.edit_date_start);
+ txtDateEnd = (AutoCompleteTextView) findViewById(R.id.edit_date_end);
+ txtNumberOfPeople = (AutoCompleteTextView) findViewById(R.id.edit_NumberOfPeople);
+ btnSearch = (Button) this.findViewById(R.id.btnSearch);
+
+ doListen();
+ }
+
+ private void doListen() {
+
+ txtFromLocation.setOnItemClickListener(new OnItemClickListener() {
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ Log.i(getString(R.string.app_name),">>Item Clicked: " +AIRPORT_CODES[position]);
+ }
+
+ });
+
+ txtFromLocation.setOnItemSelectedListener(new OnItemSelectedListener() {
+
+ public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
+ Log.i(getString(R.string.app_name),">>Item Selected: " +AIRPORT_CODES[position]);
+ }
+
+ public void onNothingSelected(AdapterView<?> parent) {
+ Log.i(getString(R.string.app_name),">>Selection cleared");
+ }
+
+ });
- Button closeButton = (Button) this.findViewById(R.id.btnSearch);
- closeButton.setOnClickListener( new OnClickListener() {
+
+ //closeButton
+ btnSearch.setOnClickListener( new OnClickListener() {
public void onClick(View v) {
+
+ doTripSearch(v);
+ /*
//Search trips here
new AlertDialog.Builder(TripSearch.this)
.setTitle("SCATour")
@@ -44,23 +102,35 @@ public class TripSearch extends Activity {
}})
.setNegativeButton(R.string.alert_cancel, new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int which) {
-
+
}
})
- .show();
-
-
-
-
+ .show();*/
}
});
}
-
- static final String[] AIRPORT_CODES = new String[] {
- "LGW - London Gatwick Airport",
- "FLR - Luigi Ridolfi Airport",
- "SFO - San Francisco Airport"
- };
+
+
+ private void doTripSearch(View view) {
+ SCAToursSearch searchProxy = new SCAToursSearchProxy();
+ TripLeg tripLeg = new TripLeg();
+
+ Log.i(getString(R.string.app_name),"From : " + txtFromLocation.getText().toString() );
+ Log.i(getString(R.string.app_name),"To : " + txtToLocation.getText().toString() );
+ Log.i(getString(R.string.app_name),"Start Date : " + txtDateStart.getText().toString() );
+ Log.i(getString(R.string.app_name),"End Date : " + txtDateEnd.getText().toString() );
+ Log.i(getString(R.string.app_name),"NumberOfPeople : " + txtNumberOfPeople.getText().toString() );
+
+ tripLeg.setFromLocation("LGW");
+ tripLeg.setToLocation("FLR");
+ tripLeg.setFromDate("06/12/09");
+ tripLeg.setToDate("13/12/09");
+ tripLeg.setNoOfPeople("2");
+
+ TripItem[] tripsAvailable = searchProxy.search(tripLeg);
+
+ Log.i(getString(R.string.app_name),"Found " + tripsAvailable.length + " trips");
+ }
} \ No newline at end of file