mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-26 12:03:28 +08:00
the plugins were executing on the UI thread. now on background thread. calls to loadUrl are now automatically on the ui thread
This commit is contained in:
parent
0c52ed44a0
commit
8ca1804de9
@ -280,9 +280,13 @@ public class DroidGap extends Activity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadUrl(String url)
|
public void loadUrl(final String url)
|
||||||
{
|
{
|
||||||
this.appView.loadUrl(url);
|
this.runOnUiThread(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
DroidGap.this.appView.loadUrl(url);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,12 +65,12 @@ public final class CommandManager {
|
|||||||
plugin.setView(this.app);
|
plugin.setView(this.app);
|
||||||
|
|
||||||
if (async) {
|
if (async) {
|
||||||
// Run this async on the UI thread so that JavaScript can continue on
|
// Run this on a different thread so that this one can return back to JS
|
||||||
app.post(new Runnable() {
|
Thread thread = new Thread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
// Call execute on the plugin so that it can do it's thing
|
// Call execute on the plugin so that it can do it's thing
|
||||||
CommandResult cr = plugin.execute(action, args);
|
CommandResult cr = plugin.execute(action, args);
|
||||||
// Check if the
|
// Check the status for 0 (success) or otherwise
|
||||||
if (cr.getStatus() == 0) {
|
if (cr.getStatus() == 0) {
|
||||||
app.loadUrl(cr.toSuccessCallbackString(callbackId));
|
app.loadUrl(cr.toSuccessCallbackString(callbackId));
|
||||||
} else {
|
} else {
|
||||||
@ -78,7 +78,7 @@ public final class CommandManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Return ""
|
thread.start();
|
||||||
return "";
|
return "";
|
||||||
} else {
|
} else {
|
||||||
// Call execute on the plugin so that it can do it's thing
|
// Call execute on the plugin so that it can do it's thing
|
||||||
|
Loading…
Reference in New Issue
Block a user