diff --git a/src/android/res/layout/category_list.xml b/src/android/res/layout/category_list.xml
index 2a7fcee05..cef9bef61 100644
--- a/src/android/res/layout/category_list.xml
+++ b/src/android/res/layout/category_list.xml
@@ -15,5 +15,5 @@
-
\ No newline at end of file
+ android:text=""/>
+
\ No newline at end of file
diff --git a/src/android/res/layout/category_list_item.xml b/src/android/res/layout/category_list_item.xml
index 2a7fcee05..f158cf710 100644
--- a/src/android/res/layout/category_list_item.xml
+++ b/src/android/res/layout/category_list_item.xml
@@ -1,19 +1,12 @@
+ android:layout_height="fill_parent">
-
-
-
+
+
\ No newline at end of file
diff --git a/src/android/res/layout/track_list_item.xml b/src/android/res/layout/track_list_item.xml
new file mode 100644
index 000000000..83fe98cff
--- /dev/null
+++ b/src/android/res/layout/track_list_item.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/android/src/org/musikcube/CategoryList.java b/src/android/src/org/musikcube/CategoryList.java
index 74ac63277..8241925ad 100644
--- a/src/android/src/org/musikcube/CategoryList.java
+++ b/src/android/src/org/musikcube/CategoryList.java
@@ -10,10 +10,12 @@ import org.musikcube.core.ListQuery;
import org.musikcube.core.IQuery.OnQueryResultListener;
import android.app.ListActivity;
+import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
+import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
@@ -36,6 +38,7 @@ public class CategoryList extends ListActivity implements OnQueryResultListener
private ArrayList selectedCategory;
private ArrayList selectedCategoryIds;
+ private ProgressDialog loadingDialog;
// Need handler for callbacks to the UI thread
final Handler callbackHandler = new Handler();
@@ -50,10 +53,12 @@ public class CategoryList extends ListActivity implements OnQueryResultListener
public class ResultAdapter extends BaseAdapter{
protected ListQuery query;
- protected Context context;
+ protected ListActivity context;
+ private LayoutInflater inflator;
- public ResultAdapter(Context context){
+ public ResultAdapter(ListActivity context){
this.context = context;
+ this.inflator = context.getLayoutInflater();
}
public int getCount() {
@@ -69,20 +74,17 @@ public class CategoryList extends ListActivity implements OnQueryResultListener
}
public View getView(int position, View view, ViewGroup parent) {
- CategoryItemView item;
if(view==null){
- item = new CategoryItemView(this.context,this.query.resultsStrings.get(position));
- }else{
- item = (CategoryItemView)view;
- item.SetTitle(this.query.resultsStrings.get(position));
-
+ view = inflator.inflate(R.layout.category_list_item, null);
}
- return item;
+
+ ((TextView) view.findViewById(R.id.text)).setText(this.query.resultsStrings.get(position));
+ return view;
}
}
- private class CategoryItemView extends LinearLayout {
+/* private class CategoryItemView extends LinearLayout {
public CategoryItemView(Context context, String title) {
super(context);
this.setOrientation(VERTICAL);
@@ -95,16 +97,13 @@ public class CategoryList extends ListActivity implements OnQueryResultListener
}
- /**
- * Convenience method to set the title of a CategoryItemView
- */
public void SetTitle(String title) {
mTitle.setText(title);
}
private TextView mTitle;
}
-
+ */
private ResultAdapter listAdapter;
@Override
@@ -154,7 +153,8 @@ public class CategoryList extends ListActivity implements OnQueryResultListener
org.musikcube.core.Library library = org.musikcube.core.Library.GetInstance();
- library.AddQuery(this.query);
+ this.loadingDialog = ProgressDialog.show(this, "", "Loading "+this.category+"...", true);
+ library.AddQuery(this.query);
}else{
//Log.v("musikcube.CategoryList", "category=null");
@@ -167,6 +167,10 @@ public class CategoryList extends ListActivity implements OnQueryResultListener
public void OnResults(){
//Log.i("CategoryList::OnResults","In right thread "+this.query.resultsStrings.size());
+ if(this.loadingDialog!=null){
+ this.loadingDialog.dismiss();
+ this.loadingDialog = null;
+ }
this.listAdapter.notifyDataSetChanged();
}
diff --git a/src/android/src/org/musikcube/TrackList.java b/src/android/src/org/musikcube/TrackList.java
index 075a0ad48..c8bb05865 100644
--- a/src/android/src/org/musikcube/TrackList.java
+++ b/src/android/src/org/musikcube/TrackList.java
@@ -18,6 +18,7 @@ import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
+import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
@@ -29,8 +30,10 @@ import android.widget.TextView;
* @author doy
*
*/
+
public class TrackList extends ListActivity implements OnQueryResultListener {
+
private ListQuery query = new ListQuery();
public java.util.ArrayList trackList = new java.util.ArrayList();
public java.util.TreeMap trackCache = new java.util.TreeMap();
@@ -48,13 +51,21 @@ public class TrackList extends ListActivity implements OnQueryResultListener {
}
};
+ static class TrackViewHolder{
+ TextView track;
+ TextView title;
+ TextView artist;
+ }
+
public class ResultAdapter extends BaseAdapter{
protected TrackList trackList;
- protected Context context;
+ protected ListActivity context;
+ private LayoutInflater inflator;
- public ResultAdapter(Context context){
+ public ResultAdapter(ListActivity context){
this.context = context;
+ this.inflator = context.getLayoutInflater();
}
public int getCount() {
@@ -69,20 +80,54 @@ public class TrackList extends ListActivity implements OnQueryResultListener {
return this.trackList.trackList.get(position);
}
+
public View getView(int position, View view, ViewGroup parent) {
- TrackItemView item;
+ TrackViewHolder holder;
if(view==null){
- item = new TrackItemView(this.context,this.trackList.GetTrack(position));
- }else{
- item = (TrackItemView)view;
- item.SetTitles(this.trackList.GetTrack(position));
+ view = inflator.inflate(R.layout.track_list_item, null);
+ holder = new TrackViewHolder();
+ holder.title = (TextView) view.findViewById(R.id.title);
+ holder.track = (TextView) view.findViewById(R.id.track);
+ holder.artist = (TextView) view.findViewById(R.id.artist);
+ view.setTag(holder);
+ }else{
+ holder = (TrackViewHolder)view.getTag();
}
- return item;
+
+ Track track = this.trackList.GetTrack(position);
+ if(track==null){
+ holder.track.setText("");
+ holder.title.setText("....");
+ holder.artist.setText("");
+ return view;
+ }
+
+ String trackNumber = track.metadata.get("track");
+ String title = track.metadata.get("title");
+ String artist = track.metadata.get("visual_artist");
+ if(trackNumber!=null){
+ holder.track.setText(trackNumber);
+ }else{
+ holder.track.setText("");
+ }
+ if(title!=null){
+ holder.title.setText(title);
+ }else{
+ holder.title.setText("");
+ }
+ if(artist!=null){
+ holder.artist.setText(artist);
+ }else{
+ holder.artist.setText("");
+ }
+
+ return view;
+
}
}
-
+ /*
private class TrackItemView extends LinearLayout {
public TrackItemView(Context context, Track track) {
super(context);
@@ -96,9 +141,6 @@ public class TrackList extends ListActivity implements OnQueryResultListener {
}
- /**
- * Convenience method to set the title of a CategoryItemView
- */
public void SetTitles(Track track) {
if(track!=null){
String text = "";
@@ -121,14 +163,14 @@ public class TrackList extends ListActivity implements OnQueryResultListener {
}
private TextView mTitle;
- }
+ }*/
private ResultAdapter listAdapter;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
- Log.v("musikcube.TrackList", "start");
+ //Log.v("musikcube.TrackList", "start");
this.setContentView(R.layout.track_list);
Intent intent = this.getIntent();
diff --git a/src/android/src/org/musikcube/core/Library.java b/src/android/src/org/musikcube/core/Library.java
index 0cd71cc6a..12e23c62f 100644
--- a/src/android/src/org/musikcube/core/Library.java
+++ b/src/android/src/org/musikcube/core/Library.java
@@ -10,10 +10,8 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
-import android.util.*;
import doep.xml.*;
-import org.musikcube.R;
import org.musikcube.core.IQuery;
/**
@@ -181,7 +179,7 @@ public class Library implements Runnable{
}
public void WaitForAuthroization(){
- Log.v("Library::WaitForAuthroization","start");
+// Log.v("Library::WaitForAuthroization","start");
synchronized (notifier) {
if(this.authorization.equals("")){
try {
@@ -190,7 +188,7 @@ public class Library implements Runnable{
}
}
}
- Log.v("Library::WaitForAuthroization","end");
+// Log.v("Library::WaitForAuthroization","end");
}
public void run(){
@@ -224,11 +222,11 @@ public class Library implements Runnable{
authNode.End();
synchronized (notifier) {
- Log.v("Library::run","Authtag end");
+ //Log.v("Library::run","Authtag end");
this.authorization = authNode.content;
- Log.v("Library::run","Authorization="+this.authorization);
+ //Log.v("Library::run","Authorization="+this.authorization);
this.notifier.notifyAll();
- Log.v("Library::run","Authorization notify");
+ //Log.v("Library::run","Authorization notify");
}
}
}
@@ -272,10 +270,10 @@ public class Library implements Runnable{
//Log.v("Library::socket","NOT Waiting for query results");
}
catch(IOException x){
- Log.e("Library::socket","IOE "+x.getMessage());
+ //Log.e("Library::socket","IOE "+x.getMessage());
}
catch(Exception x){
- Log.e("Library::socket","E "+x.getMessage());
+ //Log.e("Library::socket","E "+x.getMessage());
}
synchronized (notifier) {
@@ -326,7 +324,7 @@ public class Library implements Runnable{
}
}*/
- Log.i("musikcube::LIB","exit? "+this.exit);
+ //Log.i("musikcube::LIB","exit? "+this.exit);
if(this.exit){
Intent intent = new Intent(this.context, org.musikcube.Service.class);
@@ -402,10 +400,10 @@ public class Library implements Runnable{
}
catch(IOException x){
- Log.e("Library::WriteThread","IOException error");
+ //Log.e("Library::WriteThread","IOException error");
}
catch(Exception x){
- Log.e("Library::WriteThread","E "+x.getMessage());
+ //Log.e("Library::WriteThread","E "+x.getMessage());
}
this.SetStatus(STATUS_SHUTDOWN);
@@ -414,7 +412,7 @@ public class Library implements Runnable{
try {
this.socket.close();
} catch (Exception x) {
- Log.e("Library::WriteThread","E "+x.getMessage());
+ //Log.e("Library::WriteThread","E "+x.getMessage());
}
//Log.v("Library::WriteThread","Ended");
@@ -435,13 +433,13 @@ public class Library implements Runnable{
this.socket.close();
}
catch(Exception x){
- Log.e("Library::Disconnect","Exception error "+x.getMessage());
+ //Log.e("Library::Disconnect","Exception error "+x.getMessage());
}
try{
this.thread.join();
}
catch(Exception x){
- Log.e("Library::Disconnect","Exception error "+x.getMessage());
+ //Log.e("Library::Disconnect","Exception error "+x.getMessage());
}
}
diff --git a/src/android/src/org/musikcube/core/Player.java b/src/android/src/org/musikcube/core/Player.java
index 2eab2b4dd..b081897e3 100644
--- a/src/android/src/org/musikcube/core/Player.java
+++ b/src/android/src/org/musikcube/core/Player.java
@@ -31,17 +31,6 @@ public class Player implements TrackPlayer.OnTrackStatusListener{
}
return Player.player;
}
-/*
- private synchronized void StartThread(){
- synchronized(lock){
- if(this.running==false){
- this.thread = new Thread(this);
- this.running = true;
- this.thread.start();
- }
- }
- }
- */
public void Play(java.util.ArrayList playlist,int position){