mirror of
https://github.com/clangen/musikcube.git
synced 2024-10-02 04:52:32 +00:00
Modified CategoryViews and TrackList views to use inflator.
This commit is contained in:
parent
32baa51f0d
commit
4bc6365178
@ -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>
|
@ -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">
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<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...."/>
|
||||
<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>
|
20
src/android/res/layout/track_list_item.xml
Normal file
20
src/android/res/layout/track_list_item.xml
Normal file
@ -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>
|
@ -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<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 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();
|
||||
}
|
||||
|
||||
|
@ -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<Integer> trackList = new java.util.ArrayList<Integer>();
|
||||
public java.util.TreeMap<Integer, Track> trackCache = new java.util.TreeMap<Integer,Track>();
|
||||
@ -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();
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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<Integer> playlist,int position){
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user