Browse files

Display list of songs on main view

  • Loading branch information...
1 parent c462563 commit 4e044755babb7cf64f31ccf6079f7ac4a3b76aab @awinograd committed Jun 21, 2012
View
BIN bin/classes/com/winograd/mp3remote/BluetoothChat$1.class
Binary file not shown.
View
BIN bin/classes/com/winograd/mp3remote/BluetoothChat$10.class
Binary file not shown.
View
BIN bin/classes/com/winograd/mp3remote/BluetoothChat$2.class
Binary file not shown.
View
BIN bin/classes/com/winograd/mp3remote/BluetoothChat$3.class
Binary file not shown.
View
BIN bin/classes/com/winograd/mp3remote/BluetoothChat$4.class
Binary file not shown.
View
BIN bin/classes/com/winograd/mp3remote/BluetoothChat$5.class
Binary file not shown.
View
BIN bin/classes/com/winograd/mp3remote/BluetoothChat$6.class
Binary file not shown.
View
BIN bin/classes/com/winograd/mp3remote/BluetoothChat$7.class
Binary file not shown.
View
BIN bin/classes/com/winograd/mp3remote/BluetoothChat$8.class
Binary file not shown.
View
BIN bin/classes/com/winograd/mp3remote/BluetoothChat$9.class
Binary file not shown.
View
BIN bin/classes/com/winograd/mp3remote/BluetoothChat.class
Binary file not shown.
View
BIN bin/classes/com/winograd/mp3remote/Command.class
Binary file not shown.
View
BIN bin/classes/com/winograd/mp3remote/CommandArgs.class
Binary file not shown.
View
BIN bin/classes/com/winograd/mp3remote/R$id.class
Binary file not shown.
View
BIN bin/classes/com/winograd/mp3remote/R$layout.class
Binary file not shown.
View
BIN bin/classes/com/winograd/mp3remote/R$menu.class
Binary file not shown.
View
BIN bin/classes/com/winograd/mp3remote/R$string.class
Binary file not shown.
View
BIN bin/classes/com/winograd/mp3remote/Song.class
Binary file not shown.
View
8 gen/com/winograd/mp3remote/R.java
@@ -15,22 +15,25 @@
}
public static final class id {
public static final int albumTitle=0x7f06000e;
+ public static final int artist=0x7f060017;
public static final int artistTextView=0x7f06000f;
public static final int button_scan=0x7f060006;
public static final int connectButton=0x7f060007;
- public static final int debug=0x7f060016;
+ public static final int debug=0x7f060019;
public static final int in=0x7f060014;
+ public static final int library=0x7f060015;
public static final int new_devices=0x7f060005;
public static final int nextButton=0x7f06000c;
public static final int paired_devices=0x7f060003;
public static final int pauseButton=0x7f06000b;
public static final int playButton=0x7f06000a;
public static final int playerLayout=0x7f060008;
public static final int prevButton=0x7f060009;
- public static final int scan=0x7f060015;
+ public static final int scan=0x7f060018;
public static final int seekSlider=0x7f060013;
public static final int textView1=0x7f060010;
public static final int textView2=0x7f060012;
+ public static final int title=0x7f060016;
public static final int title_left_text=0x7f060000;
public static final int title_new_devices=0x7f060004;
public static final int title_paired_devices=0x7f060002;
@@ -44,6 +47,7 @@
public static final int device_name=0x7f030002;
public static final int main=0x7f030003;
public static final int message=0x7f030004;
+ public static final int song_list_item=0x7f030005;
}
public static final class menu {
public static final int option_menu=0x7f050000;
View
12 res/layout/main.xml
@@ -130,10 +130,20 @@
<ListView
android:id="@+id/in"
android:layout_width="match_parent"
- android:layout_height="200dp"
+ android:layout_height="102dp"
android:stackFromBottom="true"
android:transcriptMode="alwaysScroll" >
</ListView>
+
+ <ListView
+ android:id="@+id/library"
+ android:layout_width="wrap_content"
+ android:layout_height="204dp"
+ android:layout_gravity="fill" >
+ <!-- Preview: listitem=@android:layout/simple_list_item_1 -->
+
+ </ListView>
+
</LinearLayout>
</LinearLayout>
View
21 res/layout/song_list_item.xml
@@ -0,0 +1,21 @@
+<?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/title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Medium Text"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <TextView
+ android:id="@+id/artist"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Medium Text"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+</LinearLayout>
View
57 src/com/winograd/mp3remote/BluetoothChat.java
@@ -16,6 +16,8 @@
package com.winograd.mp3remote;
+import java.util.ArrayList;
+
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
@@ -32,12 +34,15 @@
import android.view.Window;
import android.view.View.OnClickListener;
import android.view.inputmethod.EditorInfo;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.SeekBar;
+import android.widget.SimpleCursorAdapter;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
import android.widget.Toast;
@@ -92,6 +97,10 @@
private TextView artistTextView = null;
private TextView albumTextView = null;
+ private ArrayList<Song> songs = new ArrayList<Song>();
+ private ArrayAdapter<Song> mAdapter;
+ private ListView library;
+
Gson gson = null;
String mReceived = "";
@@ -202,6 +211,42 @@ public void onStopTrackingTouch(SeekBar seekBar) {
artistTextView = (TextView) findViewById(R.id.artistTextView);
albumTextView = (TextView) findViewById(R.id.albumTitle);
+ //String[] from = new String[] { ReviewsDB.KEY_TITLE, ReviewsDB.KEY_CATEGORY, ReviewsDB.KEY_RATING };
+ //int[] to = new int[] { R.id.nameText, R.id.categoryText, R.id.ratingBar };
+ Song s = new Song();
+ s.title = "Title";
+ s.album = "Album";
+ s.artist = "Artist";
+ songs.add(s);
+ ArrayList<String> data = new ArrayList<String>();
+ data.add("The Prolific Oven");
+ data.add("Fraiche Yogurt");
+ data.add("Patxis Pizza");
+ data.add("Jing Jing");
+ data.add("St. Michael's Alley");
+ mAdapter = new ArrayAdapter<Song>(
+ this,
+ android.R.layout.simple_list_item_1,
+ songs
+ );
+ mAdapter.notifyDataSetChanged();
+ //mCursorAdapter = new SimpleCursorAdapter(this, R.layout.row3, cursor, from, to);
+
+
+ library = (ListView)findViewById(R.id.library);
+ library.setAdapter(mAdapter);
+
+ library.setOnItemClickListener(new OnItemClickListener(){
+ public void onItemClick(AdapterView<?> av, View view, int pos,
+ long arg3) {
+ ListView lv = (ListView)av;
+ Song s = (Song)lv.getAdapter().getItem(pos);
+ sendMessage("SONG,"+s.songNumber);
+ }
+ });
+
+
+
gson = new Gson();
updateInterfaceState();
}
@@ -365,7 +410,19 @@ private void handleCommand(String commandJSON){
break;
case MESSAGE:
//shown in catch all case
+ case LIBRARY:
+ songs = cmd.songs;
+ mAdapter = new ArrayAdapter(
+ this,
+ android.R.layout.simple_list_item_1,
+ songs);
+ mAdapter.notifyDataSetChanged();
+ library.setAdapter(mAdapter);
+ mConversationArrayAdapter.add("numSongs : " + cmd.songs.size());
+ mConversationArrayAdapter.add("first : " + songs.get(0).title);
+ break;
default:
+ mConversationArrayAdapter.add("UErr: "+ cmd.command.toString());
Toast.makeText(this, "Unknown Error", Toast.LENGTH_SHORT).show();
break;
}
View
3 src/com/winograd/mp3remote/Command.java
@@ -8,5 +8,6 @@
PREV_TRACK,
VOLUME,
SEEK,
- MESSAGE
+ MESSAGE,
+ LIBRARY
}
View
3 src/com/winograd/mp3remote/CommandArgs.java
@@ -1,5 +1,7 @@
package com.winograd.mp3remote;
+import java.util.ArrayList;
+
public class CommandArgs {
public String command;
public String state;
@@ -11,4 +13,5 @@
public String artist;
public String album;
public String message;
+ public ArrayList<Song> songs;
}
View
19 src/com/winograd/mp3remote/Song.java
@@ -0,0 +1,19 @@
+package com.winograd.mp3remote;
+
+public class Song {
+ public String title;
+ public String artist;
+ public String album;
+ public String filename;
+ public int songNumber;
+
+ public String toString(){
+ String toReturn = title;
+
+ if(artist != null){
+ toReturn += " by " + artist;
+ }
+
+ return toReturn;
+ }
+}

0 comments on commit 4e04475

Please sign in to comment.