mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-27 06:17:27 +00:00
TRACKING APP: fix performance issue that would stall ui when too many fixes are sent simultaneously
This commit is contained in:
1 parent
36e5493c0a
commit
c5e2c08efa
7 files changed
+52
-31
No files matched your search
@@ -1,4 +1,12 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
+1
-2
@@ -165,14 +165,13 @@ public class TrackingService extends Service implements ConnectionCallbacks,
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
|
||||
reportGPSQualityBearingAndSpeed(location.getAccuracy(), location.getBearing(), location.getSpeed());
|
||||
|
||||
DatabaseHelper.getInstance().insertGPSFix(this, location.getLatitude(),
|
||||
location.getLongitude(), location.getSpeed(),
|
||||
location.getBearing(), location.getProvider(),
|
||||
location.getTime(), eventRowId);
|
||||
|
||||
|
||||
ensureTransmittingServiceIsRunning();
|
||||
}
|
||||
|
||||
|
||||
+18
-5
@@ -15,6 +15,7 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
@@ -151,7 +152,6 @@ public class TransmittingService extends Service {
|
||||
|
||||
lastTransmissionFailed = false;
|
||||
lastTransmissionTimestamp = System.nanoTime();
|
||||
|
||||
reportApiConnectivity(APIConnectivity.reachableTransmissionSuccess);
|
||||
}
|
||||
|
||||
@@ -170,7 +170,6 @@ public class TransmittingService extends Service {
|
||||
} else {
|
||||
reportApiConnectivity(APIConnectivity.notReachable);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -320,7 +319,7 @@ public class TransmittingService extends Service {
|
||||
if (host != null) {
|
||||
if (currentlySending == true)
|
||||
{
|
||||
ExLog.w(this, TAG, "Warning, can't send fixes, currentlySending flag is set!");
|
||||
ExLog.i(this, TAG, "Can't send fixes, currentlySending flag is set!");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -333,6 +332,7 @@ public class TransmittingService extends Service {
|
||||
+ prefs.getServerGpsFixesPostPath()), requestObject.toString(), this);
|
||||
|
||||
|
||||
ExLog.i(this, TAG, "transmitting..");
|
||||
NetworkHelper.getInstance(this).executeHttpJsonRequestAsnchronously(
|
||||
request,
|
||||
new FixSubmitListener(ids.toArray(idsArr)),
|
||||
@@ -454,8 +454,20 @@ public class TransmittingService extends Service {
|
||||
|
||||
@Override
|
||||
public void performAction(JSONObject response) {
|
||||
deleteSynced(ids);
|
||||
markSuccessfulTransmission();
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
deleteSynced(ids);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
super.onPostExecute(result);
|
||||
markSuccessfulTransmission();
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -531,6 +543,7 @@ public class TransmittingService extends Service {
|
||||
|
||||
public class TransmittingBinder extends Binder {
|
||||
public TransmittingService getService() {
|
||||
ExLog.i(TransmittingService.this, TAG, "get Service..");
|
||||
return TransmittingService.this;
|
||||
}
|
||||
}
|
||||
|
||||
+11
-14
@@ -232,22 +232,19 @@ public class TrackingFragment extends BaseFragment {
|
||||
}
|
||||
|
||||
public void setUnsentGPSFixesCount(final int count) {
|
||||
if (isAdded()) {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
TextView unsentGpsFixesTextView = (TextView) getActivity()
|
||||
.findViewById(R.id.tracking_unsent_fixes);
|
||||
if (count == 0)
|
||||
{
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (isAdded()) {
|
||||
TextView unsentGpsFixesTextView = (TextView) getActivity().findViewById(
|
||||
R.id.tracking_unsent_fixes);
|
||||
if (count == 0) {
|
||||
unsentGpsFixesTextView.setText(getString(R.string.none));
|
||||
}
|
||||
else
|
||||
{
|
||||
unsentGpsFixesTextView.setText(String.valueOf(count));
|
||||
} else {
|
||||
unsentGpsFixesTextView.setText(String.valueOf(count));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+10
-7
@@ -11,8 +11,10 @@ import android.content.Context;
|
||||
import android.content.OperationApplicationException;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Looper;
|
||||
import android.os.RemoteException;
|
||||
import android.provider.BaseColumns;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.sap.sailing.android.shared.logging.ExLog;
|
||||
import com.sap.sailing.android.tracking.app.BuildConfig;
|
||||
@@ -143,14 +145,15 @@ public class DatabaseHelper {
|
||||
public int deleteGpsFixes(Context context, String[] fixIdStrings)
|
||||
{
|
||||
int numDeleted = 0;
|
||||
for (String idStr: fixIdStrings)
|
||||
{
|
||||
ContentValues updateValues = new ContentValues();
|
||||
updateValues.put(SensorGps.GPS_SYNCED, 1);
|
||||
Uri uri = ContentUris.withAppendedId(SensorGps.CONTENT_URI, Long.parseLong(idStr));
|
||||
numDeleted = context.getContentResolver().delete(uri, null, null);
|
||||
}
|
||||
|
||||
String idsJoined = TextUtils.join(", ", fixIdStrings);
|
||||
|
||||
ContentValues updateValues = new ContentValues();
|
||||
updateValues.put(SensorGps.GPS_SYNCED, 1);
|
||||
|
||||
numDeleted = context.getContentResolver().delete(SensorGps.CONTENT_URI,
|
||||
String.format("%s in (%s)", SensorGps._ID, idsJoined), null);
|
||||
|
||||
return numDeleted;
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -25,8 +25,9 @@ public class NetworkHelper {
|
||||
if (mInstance == null)
|
||||
{
|
||||
mInstance = new NetworkHelper();
|
||||
mContext = context;
|
||||
mContext = context.getApplicationContext();
|
||||
}
|
||||
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
@@ -38,7 +39,7 @@ public class NetworkHelper {
|
||||
NetworkHelperSuccessListener successListener, NetworkHelperFailureListener failureListener) {
|
||||
|
||||
NetworkRequestTask task = new NetworkRequestTask(successListener, failureListener);
|
||||
task.execute(request);
|
||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, request);
|
||||
}
|
||||
|
||||
private class NetworkRequestTask extends AsyncTask<HttpRequest, Void, Void>
|
||||
@@ -65,7 +66,7 @@ public class NetworkHelper {
|
||||
String responseStr = readStream(stream);
|
||||
|
||||
response = null;
|
||||
|
||||
|
||||
if (responseStr.length() > 0) {
|
||||
response = new JSONObject(responseStr);
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in new issue
Block a user