forked from upstream-mirrors/OpenTracks
"I see dead threads".
Removing handler threads which were left to die, forever alone with nothing to execute.
This commit is contained in:
@@ -29,8 +29,6 @@ import android.app.ProgressDialog;
|
|||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.HandlerThread;
|
|
||||||
import android.os.PowerManager.WakeLock;
|
import android.os.PowerManager.WakeLock;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
@@ -91,12 +89,7 @@ public class ExportAllTracks {
|
|||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
HandlerThread handlerThread;
|
new Thread(runner, "SendToMyMaps").start();
|
||||||
Handler handler;
|
|
||||||
handlerThread = new HandlerThread("SendToMyMaps");
|
|
||||||
handlerThread.start();
|
|
||||||
handler = new Handler(handlerThread.getLooper());
|
|
||||||
handler.post(runner);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -117,7 +110,7 @@ public class ExportAllTracks {
|
|||||||
long recordingTrackId = -1;
|
long recordingTrackId = -1;
|
||||||
if (prefs != null) {
|
if (prefs != null) {
|
||||||
recordingTrackId =
|
recordingTrackId =
|
||||||
prefs.getLong(activity.getString(R.string.recording_track_key), -1);
|
prefs.getLong(activity.getString(R.string.recording_track_key), -1);
|
||||||
}
|
}
|
||||||
if (recordingTrackId != -1) {
|
if (recordingTrackId != -1) {
|
||||||
wakeLock = SystemUtils.acquireWakeLock(activity, wakeLock);
|
wakeLock = SystemUtils.acquireWakeLock(activity, wakeLock);
|
||||||
|
|||||||
@@ -25,8 +25,6 @@ import android.app.Activity;
|
|||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.HandlerThread;
|
|
||||||
import android.os.PowerManager.WakeLock;
|
import android.os.PowerManager.WakeLock;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
@@ -63,12 +61,8 @@ public class ImportAllTracks {
|
|||||||
Log.i(Constants.TAG, "ImportAllTracks: Starting");
|
Log.i(Constants.TAG, "ImportAllTracks: Starting");
|
||||||
fileUtils = new FileUtils();
|
fileUtils = new FileUtils();
|
||||||
gpxPath = fileUtils.buildExternalDirectoryPath("gpx");
|
gpxPath = fileUtils.buildExternalDirectoryPath("gpx");
|
||||||
HandlerThread handlerThread;
|
|
||||||
Handler handler;
|
new Thread(runner).start();
|
||||||
handlerThread = new HandlerThread("ImportAllTracks");
|
|
||||||
handlerThread.start();
|
|
||||||
handler = new Handler(handlerThread.getLooper());
|
|
||||||
handler.post(runner);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Runnable runner = new Runnable() {
|
private final Runnable runner = new Runnable() {
|
||||||
|
|||||||
@@ -32,8 +32,6 @@ import com.google.wireless.gdata.docs.XmlDocsGDataParserFactory;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.HandlerThread;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -55,8 +53,6 @@ public class SendToDocs {
|
|||||||
private final AuthManager docListAuth;
|
private final AuthManager docListAuth;
|
||||||
private final ProgressIndicator progressIndicator;
|
private final ProgressIndicator progressIndicator;
|
||||||
private final boolean metricUnits;
|
private final boolean metricUnits;
|
||||||
private final HandlerThread handlerThread;
|
|
||||||
private final Handler handler;
|
|
||||||
|
|
||||||
private boolean createdNewSpreadSheet = false;
|
private boolean createdNewSpreadSheet = false;
|
||||||
|
|
||||||
@@ -81,21 +77,17 @@ public class SendToDocs {
|
|||||||
} else {
|
} else {
|
||||||
metricUnits = true;
|
metricUnits = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
handlerThread = new HandlerThread("SendToGoogleDocs");
|
|
||||||
handlerThread.start();
|
|
||||||
handler = new Handler(handlerThread.getLooper());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendToDocs(final long trackId) {
|
public void sendToDocs(final long trackId) {
|
||||||
Log.d(Constants.TAG,
|
Log.d(Constants.TAG,
|
||||||
"Sending to Google Docs: trackId = " + trackId);
|
"Sending to Google Docs: trackId = " + trackId);
|
||||||
handler.post(new Runnable() {
|
new Thread("SendToGoogleDocs") {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
doUpload(trackId);
|
doUpload(trackId);
|
||||||
}
|
}
|
||||||
});
|
}.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doUpload(long trackId) {
|
private void doUpload(long trackId) {
|
||||||
|
|||||||
@@ -50,8 +50,6 @@ import android.content.Intent;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.HandlerThread;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -426,11 +424,7 @@ public class SendActivity extends Activity implements ProgressIndicator {
|
|||||||
final SendToMyMaps sender = new SendToMyMaps(this, sendToMyMapsMapId, lastAuth,
|
final SendToMyMaps sender = new SendToMyMaps(this, sendToMyMapsMapId, lastAuth,
|
||||||
sendTrackId, this /*progressIndicator*/, onCompletion);
|
sendTrackId, this /*progressIndicator*/, onCompletion);
|
||||||
|
|
||||||
// TODO: We're leaking this thread!
|
new Thread(sender, "SendToMyMaps").start();
|
||||||
HandlerThread handlerThread = new HandlerThread("SendToMyMaps");
|
|
||||||
handlerThread.start();
|
|
||||||
Handler handler = new Handler(handlerThread.getLooper());
|
|
||||||
handler.post(sender);
|
|
||||||
|
|
||||||
return SendState.NOT_READY;
|
return SendState.NOT_READY;
|
||||||
}
|
}
|
||||||
@@ -485,14 +479,11 @@ public class SendActivity extends Activity implements ProgressIndicator {
|
|||||||
executeStateMachine(SendState.SEND_TO_FUSION_TABLES_DONE);
|
executeStateMachine(SendState.SEND_TO_FUSION_TABLES_DONE);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
final SendToFusionTables sender = new SendToFusionTables(this, lastAuth,
|
final SendToFusionTables sender = new SendToFusionTables(this, lastAuth,
|
||||||
sendTrackId, this /*progressIndicator*/, onCompletion);
|
sendTrackId, this /*progressIndicator*/, onCompletion);
|
||||||
|
|
||||||
// TODO: We're leaking this thread!
|
new Thread(sender, "SendToFusionTables").start();
|
||||||
HandlerThread handlerThread = new HandlerThread("SendToFusionTables");
|
|
||||||
handlerThread.start();
|
|
||||||
Handler handler = new Handler(handlerThread.getLooper());
|
|
||||||
handler.post(sender);
|
|
||||||
|
|
||||||
return SendState.NOT_READY;
|
return SendState.NOT_READY;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user