Merge pull request #653 from afischerdev/engine-mode
App: some error handling
This commit is contained in:
commit
6b659def02
2 changed files with 44 additions and 30 deletions
|
@ -96,11 +96,13 @@ public class BRouterService extends Service {
|
||||||
if (errMsg != null) {
|
if (errMsg != null) {
|
||||||
return errMsg;
|
return errMsg;
|
||||||
}
|
}
|
||||||
|
// profile is already done
|
||||||
|
params.remove("profile");
|
||||||
|
|
||||||
boolean canCompress = "true".equals(params.getString("acceptCompressedResult"));
|
boolean canCompress = "true".equals(params.getString("acceptCompressedResult"));
|
||||||
try {
|
try {
|
||||||
String gpxMessage = worker.getTrackFromParams(params);
|
String gpxMessage = worker.getTrackFromParams(params);
|
||||||
if (canCompress) {
|
if (canCompress && (gpxMessage.startsWith("<") || gpxMessage.startsWith("{"))) {
|
||||||
try {
|
try {
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
baos.write("z64".getBytes(Charset.forName("UTF-8"))); // marker prefix
|
baos.write("z64".getBytes(Charset.forName("UTF-8"))); // marker prefix
|
||||||
|
|
|
@ -10,6 +10,7 @@ import android.os.Bundle;
|
||||||
import android.window.OnBackInvokedCallback;
|
import android.window.OnBackInvokedCallback;
|
||||||
import android.window.OnBackInvokedDispatcher;
|
import android.window.OnBackInvokedDispatcher;
|
||||||
|
|
||||||
|
import androidx.activity.OnBackPressedCallback;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
@ -168,6 +169,22 @@ public class RoutingParameterDialog extends AppCompatActivity {
|
||||||
new OnBackInvokedCallback() {
|
new OnBackInvokedCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onBackInvoked() {
|
public void onBackInvoked() {
|
||||||
|
handleBackPressed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
OnBackPressedCallback callback = new OnBackPressedCallback(true) {
|
||||||
|
@Override
|
||||||
|
public void handleOnBackPressed() {
|
||||||
|
handleBackPressed();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
getOnBackPressedDispatcher().addCallback(this, callback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleBackPressed() {
|
||||||
StringBuilder sb = null;
|
StringBuilder sb = null;
|
||||||
if (sharedValues != null) {
|
if (sharedValues != null) {
|
||||||
// fill preference with used params
|
// fill preference with used params
|
||||||
|
@ -195,12 +212,7 @@ public class RoutingParameterDialog extends AppCompatActivity {
|
||||||
|
|
||||||
setResult(Activity.RESULT_OK, i);
|
setResult(Activity.RESULT_OK, i);
|
||||||
finish();
|
finish();
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue