diff options
Diffstat (limited to '')
6 files changed, 61 insertions, 97 deletions
diff --git a/branches/sca-java-1.x/samples/store-android/AndroidManifest.xml b/branches/sca-java-1.x/samples/store-android/AndroidManifest.xml index 4a26dd27c6..b89d86270a 100644 --- a/branches/sca-java-1.x/samples/store-android/AndroidManifest.xml +++ b/branches/sca-java-1.x/samples/store-android/AndroidManifest.xml @@ -4,7 +4,7 @@ android:versionCode="1" android:versionName="1.0.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> - <activity android:name=".catalog" + <activity android:name=".store" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> diff --git a/branches/sca-java-1.x/samples/store-android/res/layout/main.xml b/branches/sca-java-1.x/samples/store-android/res/layout/main.xml index 3a5f117d3c..f7494f5a3a 100644 --- a/branches/sca-java-1.x/samples/store-android/res/layout/main.xml +++ b/branches/sca-java-1.x/samples/store-android/res/layout/main.xml @@ -1,12 +1,47 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" +<TabHost xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@android:id/tabhost" android:layout_width="fill_parent" - android:layout_height="fill_parent" - > -<TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:text="@string/hello" - /> -</LinearLayout> + android:layout_height="fill_parent"> + <LinearLayout + android:orientation="vertical" + android:layout_width="fill_parent" + android:layout_height="fill_parent"> + <TabWidget + android:id="@android:id/tabs" + android:layout_width="fill_parent" + android:layout_height="wrap_content" /> + <FrameLayout + android:id="@android:id/tabcontent" + android:layout_width="fill_parent" + android:layout_height="fill_parent"> + + + <ListView android:id="@+id/ListView01" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + /> + + <LinearLayout + android:id="@+id/tab02" + android:orientation="vertical" + android:layout_width="fill_parent" + android:layout_height="fill_parent"> + + <ListView android:id="@+id/ListView02" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + /> + + <TextView + android:id="@+id/txtTotal" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + /> + + </LinearLayout> + </FrameLayout> + </LinearLayout> + +</TabHost> + diff --git a/branches/sca-java-1.x/samples/store-android/src/services/CatalogProxy.java b/branches/sca-java-1.x/samples/store-android/src/services/CatalogProxy.java index 3ce9459844..b83be4f42a 100644 --- a/branches/sca-java-1.x/samples/store-android/src/services/CatalogProxy.java +++ b/branches/sca-java-1.x/samples/store-android/src/services/CatalogProxy.java @@ -10,7 +10,7 @@ import org.json.JSONObject; import services.json.rpc.JSONRpc; public class CatalogProxy implements Catalog { - private static final String jsonRPCServiceURI = "http://192.168.1.104:8080/Catalog"; + private static final String jsonRPCServiceURI = "http://192.168.1.102:8080/Catalog"; private static final String jsonRPCRequest = "{\"id\": 3, \"method\": \"Service.get\", \"params\": []}"; private List<Item> catalog = new ArrayList<Item>(); diff --git a/branches/sca-java-1.x/samples/store-android/src/services/ShoppingCartProxy.java b/branches/sca-java-1.x/samples/store-android/src/services/ShoppingCartProxy.java index 872db654a4..a451f00060 100644 --- a/branches/sca-java-1.x/samples/store-android/src/services/ShoppingCartProxy.java +++ b/branches/sca-java-1.x/samples/store-android/src/services/ShoppingCartProxy.java @@ -3,10 +3,12 @@ package services; import org.json.JSONException; import org.json.JSONObject; +import android.util.Log; + import services.json.rpc.JSONRpc; public class ShoppingCartProxy { - private static final String jsonRPCTotalServiceURI = "http://192.168.1.104:8080/ShoppingCart/Total"; + private static final String jsonRPCTotalServiceURI = "http://192.168.1.102:8080/ShoppingCart/Total"; private static final String jsonRPCTotalRequest = "{\"id\": 4, \"method\": \"Service.getTotal\", \"params\": []}"; public Item[] getItems() { @@ -28,15 +30,18 @@ public class ShoppingCartProxy { public String getTotal() { String total = ""; JSONObject json = null; + Log.e("TUSC", "getting total"); try { json = JSONRpc.invoke(jsonRPCTotalServiceURI, jsonRPCTotalRequest); + Log.e("TUSC", "Request OK"); if(json != null) { - total = json.getString("result"); + total = json.getString("result"); + Log.e("TUSC", "Total: "+total); } } catch (JSONException e) { - e.printStackTrace(); + Log.e("TUSC",e.getMessage()); } return total; diff --git a/branches/sca-java-1.x/samples/store-android/src/store/android/R.java b/branches/sca-java-1.x/samples/store-android/src/store/android/R.java index 74dae5d7e4..cb6917a2c4 100644 --- a/branches/sca-java-1.x/samples/store-android/src/store/android/R.java +++ b/branches/sca-java-1.x/samples/store-android/src/store/android/R.java @@ -13,6 +13,12 @@ public final class R { public static final class drawable { public static final int icon=0x7f020000; } + public static final class id { + public static final int ListView01=0x7f050000; + public static final int ListView02=0x7f050002; + public static final int tab02=0x7f050001; + public static final int txtTotal=0x7f050003; + } public static final class layout { public static final int main=0x7f030000; } diff --git a/branches/sca-java-1.x/samples/store-android/src/store/android/catalog.java b/branches/sca-java-1.x/samples/store-android/src/store/android/catalog.java index e21196b3ed..e69de29bb2 100644 --- a/branches/sca-java-1.x/samples/store-android/src/store/android/catalog.java +++ b/branches/sca-java-1.x/samples/store-android/src/store/android/catalog.java @@ -1,82 +0,0 @@ -package store.android; - -import java.util.ArrayList; -import java.util.List; - -import services.Catalog; -import services.CatalogProxy; -import services.Item; -import services.ShoppingCartProxy; -import android.app.ListActivity; -import android.os.Bundle; -import android.util.SparseBooleanArray; -import android.view.View; -import android.widget.ArrayAdapter; -import android.widget.Button; -import android.widget.ListView; - -public class catalog extends ListActivity { - private Catalog catalogProxy = new CatalogProxy(); - private ShoppingCartProxy shoppingCartProxy = new ShoppingCartProxy(); - - private String[] getCatalogItems() { - List<String> catalog = new ArrayList<String>(); - - for(Item item : catalogProxy.get()) { - catalog.add(item.getName() + " - " + item.getPrice()); - } - - String[] catalogArray = new String[catalog.size()]; - catalog.toArray(catalogArray); - - return catalogArray; - } - - /** Called when the activity is first created. */ - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - - setListAdapter(new ArrayAdapter<String>(this, - android.R.layout.simple_list_item_multiple_choice, this.getCatalogItems())); - - Button addToCart = (Button) findViewById(1); - /* - addToCart.setOnClickListener(new View.OnClickListener() { - public void onCLick(View v) { - this. - } - }); - */ - - - final ListView listView = getListView(); - - listView.setItemsCanFocus(false); - listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); - } - - @Override - protected void onListItemClick(ListView l, View v, int position, long id) { - super.onListItemClick(l, v, position, id); - - String item = this.getCatalogItems()[position]; - System.out.println("Item clicked : " + item); - - System.out.println("Selected items:"); - SparseBooleanArray checkedItems = l.getCheckedItemPositions(); - for(int i = 0; i < checkedItems.size(); i++) { - if(checkedItems.valueAt(i) == true) { - System.out.println(">>>" + this.getCatalogItems()[checkedItems.keyAt(i)]); - } - } - System.out.println("Total: " + shoppingCartProxy.getTotal()); - - //l.getCheckedItemPosition(); - //Intent webIntent = new Intent("android.intent.action.VIEW", Uri.parse("http://192.168.1.104:8080/ShoppingCart/Cart")); - //startActivity(webIntent); - } - - -}
\ No newline at end of file |