summaryrefslogtreecommitdiff
path: root/same-android
diff options
context:
space:
mode:
Diffstat (limited to 'same-android')
-rw-r--r--same-android/res/layout/network_list_item.xml19
-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
4 files changed, 76 insertions, 3 deletions
diff --git a/same-android/res/layout/network_list_item.xml b/same-android/res/layout/network_list_item.xml
new file mode 100644
index 0000000..10219fb
--- /dev/null
+++ b/same-android/res/layout/network_list_item.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical" >
+
+ <TextView
+ android:id="@+id/network_name_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <TextView
+ android:id="@+id/master_url_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+
+</LinearLayout> \ No newline at end of file
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);
+ }
+}