changed handle back pressed logic
This commit is contained in:
parent
9ef31e6d2c
commit
ec3461d8a2
1 changed files with 41 additions and 29 deletions
|
@ -10,6 +10,7 @@ import android.os.Bundle;
|
|||
import android.window.OnBackInvokedCallback;
|
||||
import android.window.OnBackInvokedDispatcher;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
@ -168,6 +169,22 @@ public class RoutingParameterDialog extends AppCompatActivity {
|
|||
new OnBackInvokedCallback() {
|
||||
@Override
|
||||
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;
|
||||
if (sharedValues != null) {
|
||||
// fill preference with used params
|
||||
|
@ -195,12 +212,7 @@ public class RoutingParameterDialog extends AppCompatActivity {
|
|||
|
||||
setResult(Activity.RESULT_OK, i);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue