diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-06-02 06:58:36 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-06-02 06:58:36 +0000 |
commit | 93af1c6a6cc481b6204cd4d12e3d99ed7d419130 (patch) | |
tree | f4df00941ceca898cd048607383faac9457675b1 /sandbox/travelsample/scatours-android-ui/src | |
parent | 27dec0710cc7da2d2eda9b49178ca1334fc756d5 (diff) |
Adding new activity to display results
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@780958 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
3 files changed, 112 insertions, 2 deletions
diff --git a/sandbox/travelsample/scatours-android-ui/src/scatours/SCAToursSearchProxy.java b/sandbox/travelsample/scatours-android-ui/src/scatours/SCAToursSearchProxy.java index d43d5f7029..cfd6b98bcf 100644 --- a/sandbox/travelsample/scatours-android-ui/src/scatours/SCAToursSearchProxy.java +++ b/sandbox/travelsample/scatours-android-ui/src/scatours/SCAToursSearchProxy.java @@ -55,12 +55,13 @@ public class SCAToursSearchProxy implements SCAToursSearch { for(int i = 0; i < result.length(); i++) { TripItem item = new TripItem(); + item.setType(result.getJSONObject(i).getString("type")); item.setName(result.getJSONObject(i).getString("name")); item.setDescription(result.getJSONObject(i).getString("description")); item.setLocation(result.getJSONObject(i).getString("location")); item.setFromDate(result.getJSONObject(i).getString("fromDate")); item.setToDate(result.getJSONObject(i).getString("toDate")); - item.setPrice(result.getJSONObject(i).getLong("price")); + item.setPrice(result.getJSONObject(i).getDouble("price")); item.setCurrency(result.getJSONObject(i).getString("currency")); tripCatalog.add(item); diff --git a/sandbox/travelsample/scatours-android-ui/src/scatours/android/TripSearch.java b/sandbox/travelsample/scatours-android-ui/src/scatours/android/TripSearch.java index e2eb98625b..b64c14a583 100644 --- a/sandbox/travelsample/scatours-android-ui/src/scatours/android/TripSearch.java +++ b/sandbox/travelsample/scatours-android-ui/src/scatours/android/TripSearch.java @@ -5,6 +5,9 @@ import scatours.SCAToursSearchProxy; import scatours.common.TripItem; import scatours.common.TripLeg; import android.app.Activity; +import android.app.AlertDialog; +import android.content.DialogInterface; +import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.View; @@ -127,8 +130,57 @@ public class TripSearch extends Activity { tripLeg.setNoOfPeople("2"); TripItem[] tripsAvailable = searchProxy.search(tripLeg); - Log.i(getString(R.string.app_name),"Found " + tripsAvailable.length + " trips"); + + Log.i(getString(R.string.app_name),"Calling Results view..."); + + displayTripSearchResults(tripsAvailable); + + /* + try { + Intent resultView = new Intent(this, TripSearchResults.class); + resultView.putExtra("results", tripsAvailable); + startActivity(resultView); + } catch(Exception e) { + Log.e(getString(R.string.app_name), e.getMessage()); + } + */ + + //TripSearchResults searchResults = new TripSearchResults(tripsAvailable); + //searchResults.setContentView(R.layout.search_results); + + Log.i(getString(R.string.app_name),"Called..."); + + } + + private void displayTripSearchResults(TripItem[] tripsAvailable) { + + String result = ""; + for(TripItem item : tripsAvailable) { + Log.i(getString(R.string.app_name), "Item type:" + item.getType()); + if (item.getType().equals(TripItem.TRIP)) { + result += item.getDescription() + " (" + item.getCurrency() + " " + item.getPrice() + ")\n"; + } + } + + + //Search trips here + new AlertDialog.Builder(TripSearch.this) + .setTitle("SCATour") + .setMessage("Found:\n" + result) + .setIcon(R.drawable.icon) + .setCancelable(false) + .setPositiveButton(R.string.alert_yes, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int whichButton) { + + }}) + .setNegativeButton(R.string.alert_cancel, new DialogInterface.OnClickListener(){ + public void onClick(DialogInterface dialog, int which) { + + } + }) + .show(); + } }
\ No newline at end of file diff --git a/sandbox/travelsample/scatours-android-ui/src/scatours/android/TripSearchResults.java b/sandbox/travelsample/scatours-android-ui/src/scatours/android/TripSearchResults.java new file mode 100644 index 0000000000..002ef8def1 --- /dev/null +++ b/sandbox/travelsample/scatours-android-ui/src/scatours/android/TripSearchResults.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package scatours.android; + +import scatours.common.TripItem; +import android.app.Activity; +import android.os.Bundle; +import android.util.Log; +import android.widget.ArrayAdapter; +import android.widget.ListView; + +public class TripSearchResults extends Activity { + private TripItem[] results; + + private ListView listResults; + + public TripSearchResults( ) { + super(); + } + + public void setResults(TripItem[] results) { + Log.i(getString(R.string.app_name),"Setting results : " + results.length); + this.results = results; + } + + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.search_results); + + Log.i(getString(R.string.app_name),"Displaying " + results.length + " trips"); + + listResults = (ListView) findViewById(R.id.listPackages); + //listResults.setAdapter(new ArrayAdapter<TripItem>(this, R.id.listPackages, results)); + + + } + +} |