Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android: No multiple webviews #3

Open
litiobat opened this issue Aug 3, 2015 · 3 comments
Open

Android: No multiple webviews #3

litiobat opened this issue Aug 3, 2015 · 3 comments

Comments

@litiobat
Copy link

litiobat commented Aug 3, 2015

Hi!
In iOS I can create and destroy multiple webviews without problem. But in Android, I can create multiple webviews but only destroy the latest. What I need to change to create/destroy multiple webviews in Android?
Thank you for your plugin!

@arturokunder
Copy link
Contributor

@litiobat
You are right, there is a bug when you try to show 3 or more webviews on android.
The problem originates in this line:

private static Dialog webViewDialog;

private static Dialog webViewDialog;

The created webview gets stored at this variable. We needed to make a static variable so it should be available to all instances of the class (so you could close the new webview from the parent webview).
What you would have to make is change the variable for an arraylist (or similar). and then update the hide ans show method.

@litiobat
Copy link
Author

litiobat commented Aug 3, 2015

Hi!
Thank you for guide me to find the solution. (¿hablas español? he visto tus comentarios en el java) I've changed code and now it's working multiple webviews. Here's the changes (sorry, first time in github, maybe here is not the site, I don't know the rules...).
Hugs!

---LINE 40 changed to:
private static ArrayList webViewDialog = new ArrayList();

---FROM LINE 172:
webViewDialog.add(new Dialog(activity, android.R.style.Theme_NoTitleBar));
int indiceArray = webViewDialog.size();
indiceArray-=1;
webViewDialog.get(indiceArray).getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog;
webViewDialog.get(indiceArray).requestWindowFeature(Window.FEATURE_NO_TITLE);
webViewDialog.get(indiceArray).setCancelable(true);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(webViewDialog.get(indiceArray).getWindow().getAttributes());
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
lp.height = WindowManager.LayoutParams.MATCH_PARENT;
webViewDialog.get(indiceArray).setContentView(root);
webViewDialog.get(indiceArray).show();
webViewDialog.get(indiceArray).getWindow().setAttributes(lp);

---FROM LINE 208:
int indiceArray = webViewDialog.size() -1;
if(webViewDialog.get(indiceArray) != null && webViewDialog.get(indiceArray).isShowing()) {
webViewDialog.get(indiceArray).dismiss();
webViewDialog.remove(indiceArray);
webView.destroy();
}

@arturokunder
Copy link
Contributor

@litiobat hablo español ;)
La solución para android es justamente como dices.
Para subir el cambio, la forma de trabajar es que tu hagas un fork del repositorio, realices todos los cambios y despues hagas un pull request de los cambios.
Esto nos da la ventaja de que se pueden probar los cambios, github nos muestra el detalle de los cambios y mientras no se haga el merge, tu puedes ocupar tu repositorio como fuente del plugin.
Avísame si necesitas ayuda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants