Bugfixing

This commit is contained in:
Daniel Önnerby 2009-09-08 05:06:38 +00:00
parent e2c1bb0195
commit e19beb75fb
3 changed files with 30 additions and 16 deletions

View File

@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.musikcube"
android:versionName="1.0.5" android:versionCode="5">
<application android:icon="@drawable/icon" android:label="@string/app_name" android:name="App" android:debuggable="false">
<application android:icon="@drawable/icon" android:label="@string/app_name" android:name="App" android:debuggable="true">
<activity android:name=".main"
android:label="@string/app_name" android:launchMode="singleTask" android:screenOrientation="portrait">
<intent-filter>

View File

@ -78,10 +78,12 @@ public class Service extends android.app.Service {
// TODO Auto-generated method stub
super.onStart(intent, startId);
boolean stopWorkout = false;
String action = intent.getStringExtra("org.musikcube.Service.action");
if(action==null){
this.library.Startup(this);
return;
}
if(action.equals("playlist")){

View File

@ -10,6 +10,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log;
import doep.xml.*;
import org.musikcube.core.IQuery;
@ -30,7 +31,7 @@ public final class Library implements Runnable{
private Thread thread;
private boolean running = false;
private boolean restart = false;
private boolean exit = false;
private boolean exit = true;
private Socket socket;
private Context context;
@ -78,7 +79,7 @@ public final class Library implements Runnable{
private final void SetStatus(int status){
synchronized(this.status){
//Log.v("mC2::Lib","STATUS "+this.status);
Log.v("mC2::Lib","STATUS "+this.status);
this.status = status;
if(this.statusListener!=null){
this.statusListener.OnLibraryStatusChange(status);
@ -128,18 +129,23 @@ public final class Library implements Runnable{
public final void Startup(Context context){
this.context = context;
// Startup thread when the application sends the context for the first time
this.thread = new Thread(this);
this.running = true;
this.thread.start();
synchronized(this.notifier){
if(this.exit){
this.exit = false;
this.context = context;
// Startup thread when the application sends the context for the first time
this.thread = new Thread(this);
this.running = true;
this.thread.start();
}
}
}
public final void Restart(){
synchronized(this.notifier){
this.running = false;
this.restart = true;
if(this.socket!=null){
try {
this.socket.shutdownInput();
@ -200,7 +206,7 @@ public final class Library implements Runnable{
this.SetStatus(STATUS_SHUTDOWN);
while(true){
//Log.v("mC2::Lib","1");
Log.v("mC2::Lib","1");
this.running = true;
// First try to connect
@ -310,7 +316,7 @@ public final class Library implements Runnable{
}
//Log.v("mC2::Lib","4");
Log.v("mC2::Lib","4");
synchronized (notifier) {
if(!this.restart){
@ -323,10 +329,10 @@ public final class Library implements Runnable{
}
this.restart = false;
//Log.v("mC2::Lib","5");
Log.v("mC2::Lib","5");
if(this.exit){
//Log.v("mC2::Lib","EXIT");
Log.v("mC2::Lib","EXIT");
Intent intent = new Intent(this.context, org.musikcube.Service.class);
intent.putExtra("org.musikcube.Service.action", "shutdown");
this.context.startService(intent);
@ -334,7 +340,7 @@ public final class Library implements Runnable{
}
this.restart = false;
// this.running = true;
//Log.v("mC2::Lib","6");
Log.v("mC2::Lib","6");
}
}
@ -378,7 +384,7 @@ public final class Library implements Runnable{
}
}
//Log.v("Library::WriteThread","wait over");
Log.v("Library::WriteThread","wait over");
}else{
// Get the first query
query = this.sendQueryQueue.removeFirst();
@ -423,7 +429,7 @@ public final class Library implements Runnable{
//Log.e("Library::WriteThread","E "+x.getMessage());
}
//Log.v("Library::WriteThread","Ended");
Log.v("Library::WriteThread","Ended");
}
public final void Exit(){
@ -451,6 +457,12 @@ public final class Library implements Runnable{
}
}
public final boolean Exited(){
synchronized(this.notifier){
return this.exit;
}
}
public final void AddQuery(IQuery query){
synchronized(this.sendQueryQueue){
this.sendQueryQueue.addLast(query);