diff options
author | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-02-13 20:15:39 +0100 |
---|---|---|
committer | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-02-13 20:15:39 +0100 |
commit | 5bc18853d378e8d6c6f965a3e16f1c388cfb8210 (patch) | |
tree | 82cb2a9e8adcb331251bd81811cb068a317d07f3 | |
parent | 5190cf7a9b1db1ef0d7cac007ce73aff248203f0 (diff) |
Display discovered networks in user interface.
-rw-r--r-- | same-android/src/main/java/com/orbekk/SameControllerActivity.java | 15 | ||||
-rw-r--r-- | same-android/src/main/java/com/orbekk/SameService.java | 10 |
2 files changed, 9 insertions, 16 deletions
diff --git a/same-android/src/main/java/com/orbekk/SameControllerActivity.java b/same-android/src/main/java/com/orbekk/SameControllerActivity.java index a2d5688..4fb1424 100644 --- a/same-android/src/main/java/com/orbekk/SameControllerActivity.java +++ b/same-android/src/main/java/com/orbekk/SameControllerActivity.java @@ -49,8 +49,10 @@ public class SameControllerActivity extends Activity { if (SameService.AVAILABLE_NETWORKS_UPDATE.equals(intent.getAction())) { ArrayList<String> networkList = intent.getStringArrayListExtra( SameService.AVAILABLE_NETWORKS); - Toast.makeText(SameControllerActivity.this, networkList.toString(), - Toast.LENGTH_SHORT).show(); + ListView list = (ListView)findViewById(R.id.network_list); + list.setAdapter(new ArrayAdapter<String>( + SameControllerActivity.this, + R.layout.list_text_item, networkList)); } } }; @@ -89,15 +91,6 @@ public class SameControllerActivity extends Activity { public void searchNetworks(View unused) { logger.info("SearchNetworks()"); -// Toast.makeText(this, "Discovering networks", Toast.LENGTH_SHORT).show(); -// final String[] listItems = new String[]{"First item", "Second item"}; -// ListView list = (ListView)findViewById(R.id.network_list); -// list.setAdapter(new ArrayAdapter<String>(this, R.layout.list_text_item, -// listItems)); - -// Message message = Message.obtain(null, SameService.DISPLAY_MESSAGE, -// "Message from Activity!"); - Message searchMessage = Message.obtain(null, SameService.SEARCH_NETWORKS); try { sameService.send(searchMessage); diff --git a/same-android/src/main/java/com/orbekk/SameService.java b/same-android/src/main/java/com/orbekk/SameService.java index 305bf44..bc758ab 100644 --- a/same-android/src/main/java/com/orbekk/SameService.java +++ b/same-android/src/main/java/com/orbekk/SameService.java @@ -41,19 +41,19 @@ public class SameService extends Service { private SameController sameController = null; private Configuration configuration = null; - // A list with alternating network names and urls. - private ArrayList<String> availableNetworks = new ArrayList<String>(); + private ArrayList<String> networkNames = new ArrayList<String>(); + private ArrayList<String> networkUrls = new ArrayList<String>(); private NetworkNotificationListener networkListener = new NetworkNotificationListener() { @Override public void notifyNetwork(String networkName, String masterUrl) { logger.info("notifyNetwork({})", networkName); - availableNetworks.add(networkName); - availableNetworks.add(masterUrl); + networkNames.add(networkName); + networkUrls.add(masterUrl); Intent intent = new Intent(AVAILABLE_NETWORKS_UPDATE); intent.putStringArrayListExtra(AVAILABLE_NETWORKS, - availableNetworks); + networkNames); sendBroadcast(intent); } }; |