Added:
/trunk/src/android/res/layout/track_list_item.xml
Modified:
/trunk/src/android/res/layout/category_list.xml
/trunk/src/android/res/layout/category_list_item.xml
/trunk/src/android/src/org/musikcube/CategoryList.java
/trunk/src/android/src/org/musikcube/TrackList.java
/trunk/src/android/src/org/musikcube/core/Library.java
/trunk/src/android/src/org/musikcube/core/Player.java
=======================================
--- /dev/null
+++ /trunk/src/android/res/layout/track_list_item.xml Sun Aug 9 15:24:12
2009
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
android:orientation="horizontal">
+
+<TextView android:id="@+id/track"
+ android:layout_width="24sp"
+ android:layout_height="wrap_content" android:textSize="24sp"
android:fadingEdge="horizontal" android:maxLines="1"
android:fadingEdgeLength="10sp" android:text="1."/>
+<LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
android:orientation="vertical">
+ <TextView android:id="@+id/title"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:textSize="24sp"
android:fadingEdge="horizontal" android:maxLines="1"
android:fadingEdgeLength="10sp" android:text="Track"/>
+ <TextView android:id="@+id/artist"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
android:fadingEdge="horizontal" android:maxLines="1"
android:fadingEdgeLength="10sp" android:text="Track"
android:textColor="#999999" android:textSize="16sp"/>
+ </LinearLayout>
+
+ </LinearLayout>
=======================================
--- /trunk/src/android/res/layout/category_list.xml Sun Jul 5 14:53:29 2009
+++ /trunk/src/android/res/layout/category_list.xml Sun Aug 9 15:24:12 2009
@@ -15,5 +15,5 @@
<TextView android:id="@id/android:empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
- android:text="Loading...."/>
- </LinearLayout>
+ android:text=""/>
+</LinearLayout>
=======================================
--- /trunk/src/android/res/layout/category_list_item.xml Wed Jul 29
15:56:39 2009
+++ /trunk/src/android/res/layout/category_list_item.xml Sun Aug 9
15:24:12 2009
@@ -1,19 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
+ android:orientation="horizontal"
android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:paddingLeft="8dp"
- android:paddingRight="8dp">
-
- <ListView android:id="@id/android:list"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:layout_weight="1"
- android:drawSelectorOnTop="false"/>
-
- <TextView android:id="@id/android:empty"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:text="Loading...."/>
+ android:layout_height="fill_parent">
+
+ <TextView android:id="@+id/text"
+ android:layout_width="0dip"
+ android:layout_weight="1.0"
+ android:layout_height="wrap_content" android:textSize="24sp"
android:fadingEdge="horizontal" android:maxLines="1"
android:fadingEdgeLength="10sp"/>
+
</LinearLayout>
=======================================
--- /trunk/src/android/src/org/musikcube/CategoryList.java Sun Aug 9
13:57:19 2009
+++ /trunk/src/android/src/org/musikcube/CategoryList.java Sun Aug 9
15:24:12 2009
@@ -10,10 +10,12 @@
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 @@
private ArrayList<String> selectedCategory;
private ArrayList<Integer> selectedCategoryIds;
+ private ProgressDialog loadingDialog;
// Need handler for callbacks to the UI thread
final Handler callbackHandler = new Handler();
@@ -50,10 +53,12 @@
public class ResultAdapter extends BaseAdapter{
protected ListQuery query;
- protected Context context;
-
- public ResultAdapter(Context context){
+ protected ListActivity context;
+ private LayoutInflater inflator;
+
+ public ResultAdapter(ListActivity context){
this.context = context;
+ this.inflator = context.getLayoutInflater();
}
public int getCount() {
@@ -69,20 +74,17 @@
}
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));
-
- }
- return item;
+ view = inflator.inflate(R.layout.category_list_item, null);
+ }
+
+ ((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 @@
}
- /**
- * 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 @@
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 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();
}
=======================================
--- /trunk/src/android/src/org/musikcube/TrackList.java Thu Aug 6 15:24:39
2009
+++ /trunk/src/android/src/org/musikcube/TrackList.java Sun Aug 9 15:24:12
2009
@@ -18,6 +18,7 @@
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 @@
* @author doy
*
*/
+
public class TrackList extends ListActivity implements
OnQueryResultListener {
+
private ListQuery query = new ListQuery();
public java.util.ArrayList<Integer> trackList = new
java.util.ArrayList<Integer>();
public java.util.TreeMap<Integer, Track> trackCache = new
java.util.TreeMap<Integer,Track>();
@@ -48,13 +51,21 @@
}
};
+ static class TrackViewHolder{
+ TextView track;
+ TextView title;
+ TextView artist;
+ }
+
public class ResultAdapter extends BaseAdapter{
protected TrackList trackList;
- protected Context context;
-
- public ResultAdapter(Context context){
+ protected ListActivity context;
+ private LayoutInflater inflator;
+
+ public ResultAdapter(ListActivity context){
this.context = context;
+ this.inflator = context.getLayoutInflater();
}
public int getCount() {
@@ -69,20 +80,54 @@
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));
-
- }
- return item;
+ 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();
+ }
+
+ 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 @@
}
- /**
- * Convenience method to set the title of a CategoryItemView
- */
public void SetTitles(Track track) {
if(track!=null){
String text = "";
@@ -121,14 +163,14 @@
}
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();
=======================================
--- /trunk/src/android/src/org/musikcube/core/Library.java Wed Aug 5
16:16:30 2009
+++ /trunk/src/android/src/org/musikcube/core/Library.java Sun Aug 9
15:24:12 2009
@@ -10,10 +10,8 @@
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 void WaitForAuthroization(){
- Log.v("Library::WaitForAuthroization","start");
+// Log.v("Library::WaitForAuthroization","start");
synchronized (notifier) {
if(this.authorization.equals("")){
try {
@@ -190,7 +188,7 @@
}
}
}
- Log.v("Library::WaitForAuthroization","end");
+// Log.v("Library::WaitForAuthroization","end");
}
public void run(){
@@ -224,11 +222,11 @@
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 @@
//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 @@
}
}*/
- 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 @@
}
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 @@
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 @@
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());
}
}
=======================================
--- /trunk/src/android/src/org/musikcube/core/Player.java Sun Aug 9
13:57:19 2009
+++ /trunk/src/android/src/org/musikcube/core/Player.java Sun Aug 9
15:24:12 2009
@@ -31,17 +31,6 @@
}
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<Integer> playlist,int position){