mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-20 23:56:20 +08:00
Refactor backHistory() code so calling navigator.app.backHistory() has consistent behavior with backbutton.
This commit is contained in:
parent
827af8a920
commit
2a866e2a7c
@ -577,13 +577,27 @@ public class DroidGap extends PhonegapActivity {
|
||||
|
||||
/**
|
||||
* Go to previous page in history. (We manage our own history)
|
||||
*
|
||||
* @return true if we went back, false if we are already at top
|
||||
*/
|
||||
public void backHistory() {
|
||||
if (this.urls.size() > 1) {
|
||||
this.urls.pop(); // Pop current url
|
||||
String url = this.urls.pop(); // Pop prev url that we want to load
|
||||
this.loadUrl(url);
|
||||
public boolean backHistory() {
|
||||
|
||||
// Check webview first to see if there is a history
|
||||
// This is needed to support curPage#diffLink, since they are added to appView's history, but not our history url array (JQMobile behavior)
|
||||
if (this.appView.canGoBack()) {
|
||||
this.appView.goBack();
|
||||
return true;
|
||||
}
|
||||
|
||||
// If our managed history has prev url
|
||||
if (this.urls.size() > 1) {
|
||||
this.urls.pop(); // Pop current url
|
||||
String url = this.urls.pop(); // Pop prev url that we want to load, since it will be added back by loadUrl()
|
||||
this.loadUrl(url);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1466,12 +1480,7 @@ public class DroidGap extends PhonegapActivity {
|
||||
else {
|
||||
|
||||
// Go to previous page in webview if it is possible to go back
|
||||
if (this.appView.canGoBack()) {
|
||||
this.appView.goBack(); // This is needed to support curPage#diffLink, since they are added to appView's history, but not our history url array (JQMobile behavior)
|
||||
return true;
|
||||
}
|
||||
else if (this.urls.size() > 1) {
|
||||
this.backHistory();
|
||||
if (this.backHistory()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user