mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2024-12-25 16:23:54 +01:00
canGoBack doesn't work consistently when using loadDataWithBaseURL. Update old logic to allow depth > 1.
https://stackoverflow.com/questions/2686933/android-webview-can-render-html-going-forward-but-not-backward https://stackoverflow.com/questions/14948652/webview-cangoback-not-working-when-using-loaddatawithbaseurl/15074071#15074071
This commit is contained in:
parent
fd13603be6
commit
921665167f
@ -36,6 +36,7 @@ public class AboutActivity extends AppCompatActivity {
|
||||
private WebView webView;
|
||||
private LinearLayout webViewContainer;
|
||||
private Subscription subscription;
|
||||
private int depth = 0;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -56,6 +57,7 @@ public class AboutActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
depth++;
|
||||
if (!url.startsWith("http")) {
|
||||
url = url.replace("file:///android_asset/", "");
|
||||
loadAsset(url);
|
||||
@ -100,6 +102,10 @@ public class AboutActivity extends AppCompatActivity {
|
||||
"</head><body><p>" + webViewData + "</p></body></html>";
|
||||
webViewData = webViewData.replace("\n", "<br/>");
|
||||
}
|
||||
else
|
||||
{
|
||||
depth = 0;
|
||||
}
|
||||
webViewData = String.format(webViewData, colorString);
|
||||
subscriber.onSuccess(webViewData);
|
||||
} catch (IOException e) {
|
||||
@ -120,8 +126,9 @@ public class AboutActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (webView.canGoBack()) {
|
||||
if (depth != 0) {
|
||||
webView.goBack();
|
||||
depth--;
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user