summaryrefslogtreecommitdiff
path: root/same-android/src
diff options
context:
space:
mode:
Diffstat (limited to 'same-android/src')
-rw-r--r--same-android/src/main/java/com/orbekk/same/android/SameControllerActivity.java8
-rw-r--r--same-android/src/main/java/com/orbekk/same/android/SameService.java1
-rw-r--r--same-android/src/main/java/com/orbekk/same/android/widget/NetworkListAdapter.java51
3 files changed, 57 insertions, 3 deletions
diff --git a/same-android/src/main/java/com/orbekk/same/android/SameControllerActivity.java b/same-android/src/main/java/com/orbekk/same/android/SameControllerActivity.java
index a111bcc..8aacba5 100644
--- a/same-android/src/main/java/com/orbekk/same/android/SameControllerActivity.java
+++ b/same-android/src/main/java/com/orbekk/same/android/SameControllerActivity.java
@@ -20,12 +20,12 @@ import android.os.Messenger;
import android.os.RemoteException;
import android.view.View;
import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import com.orbekk.same.android.net.Broadcaster;
+import com.orbekk.same.android.widget.NetworkListAdapter;
public class SameControllerActivity extends Activity {
private Logger logger = LoggerFactory.getLogger(getClass());
@@ -71,9 +71,9 @@ public class SameControllerActivity extends Activity {
private void updateNetworkList() {
ListView list = (ListView)findViewById(R.id.network_list);
- list.setAdapter(new ArrayAdapter<String>(
+ list.setAdapter(new NetworkListAdapter(
SameControllerActivity.this,
- R.layout.list_text_item, networkNames));
+ R.layout.list_text_item, networkNames, networkUrls));
}
@@ -146,6 +146,8 @@ public class SameControllerActivity extends Activity {
ListView networkList = (ListView)findViewById(R.id.network_list);
networkList.setOnItemClickListener(networkListClickListener);
+
+ updateNetworkList();
}
@Override public void onResume() {
diff --git a/same-android/src/main/java/com/orbekk/same/android/SameService.java b/same-android/src/main/java/com/orbekk/same/android/SameService.java
index 0ebcbad..e526d51 100644
--- a/same-android/src/main/java/com/orbekk/same/android/SameService.java
+++ b/same-android/src/main/java/com/orbekk/same/android/SameService.java
@@ -1,6 +1,7 @@
package com.orbekk.same.android;
import java.util.ArrayList;
+import java.util.List;
import java.util.Properties;
import java.util.Vector;
diff --git a/same-android/src/main/java/com/orbekk/same/android/widget/NetworkListAdapter.java b/same-android/src/main/java/com/orbekk/same/android/widget/NetworkListAdapter.java
new file mode 100644
index 0000000..c058c56
--- /dev/null
+++ b/same-android/src/main/java/com/orbekk/same/android/widget/NetworkListAdapter.java
@@ -0,0 +1,51 @@
+package com.orbekk.same.android.widget;
+
+import java.util.List;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.TextView;
+import com.orbekk.same.android.R;
+
+/**
+ * This class extends ArrayAdapter incompletely.
+ *
+ * Only use as follows:
+ *
+ * list.setAdapter(new NetworkListAdapter(...));
+ */
+public class NetworkListAdapter extends ArrayAdapter<String> {
+ private List<String> networkNames;
+ private List<String> masterUrls;
+
+ public NetworkListAdapter(Context context, int resource_id,
+ List<String> networkNames, List<String> masterUrls) {
+ super(context, resource_id, networkNames);
+ this.networkNames = networkNames;
+ this.masterUrls = masterUrls;
+ }
+
+ public View getView(int position, View convertView, ViewGroup parent) {
+ if (convertView == null) {
+ LayoutInflater inflater = getLayoutInflater();
+ convertView = inflater.inflate(R.layout.network_list_item, null);
+ }
+ if (networkNames.get(position) != null) {
+ TextView nameText = (TextView)convertView.findViewById(
+ R.id.network_name_text);
+ TextView urlText = (TextView)convertView.findViewById(
+ R.id.master_url_text);
+ nameText.setText(networkNames.get(position));
+ urlText.setText(masterUrls.get(position));
+ }
+ return convertView;
+ }
+
+ private LayoutInflater getLayoutInflater() {
+ return (LayoutInflater)getContext().getSystemService(
+ Context.LAYOUT_INFLATER_SERVICE);
+ }
+}