Commit 91ba879e by amateur

1

1 parent 9f336e39
...@@ -60,20 +60,29 @@ public class ModulesFragmentMgr implements FragmentManager.OnBackStackChangedLis ...@@ -60,20 +60,29 @@ public class ModulesFragmentMgr implements FragmentManager.OnBackStackChangedLis
} }
public void showModule(ModulesEnum module) { public void showModule(ModulesEnum module) {
if (!module.fmtKey.equals(this.currentModule.fmtKey)) { if (module == this.currentModule) {
return ;
}
WebViewFragment fragment = this.findFragment(module); WebViewFragment fragment = this.findFragment(module);
if (!module.fmtKey.equals(this.currentModule.fmtKey)) {
FragmentTransaction transaction = this.manager.beginTransaction(); FragmentTransaction transaction = this.manager.beginTransaction();
transaction.hide(this.getCurrentFragment()); transaction.hide(this.getCurrentFragment());
transaction.addToBackStack("").show(fragment).commit(); transaction.addToBackStack("").show(fragment).commit();
} else {
IWebview webview = fragment.getWebview();
if (null != webview) {
webview.loadUrl(module.webUrl);
}
} }
this.setCurrentModule(module); this.setCurrentModule(module);
} }
public void showModule(MenuBean bean) { public void showModule(MenuBean bean) {
ModulesEnum module = ModulesEnum.findModule(bean.getModuleName()); ModulesEnum module = ModulesEnum.findModule(bean.getModuleName());
Fragment fragment = this.findFragment(module); WebViewFragment fragment = this.findFragment(module);
if (!TextUtils.isEmpty(bean.getUrl())) { if (!TextUtils.isEmpty(bean.getUrl())) {
((IWebview) fragment).loadUrl(bean.getUrl()); IWebview webview = fragment.getWebview();
webview.loadUrl(bean.getUrl());
} }
if (!module.fmtKey.equals(this.currentModule.fmtKey)) { if (!module.fmtKey.equals(this.currentModule.fmtKey)) {
FragmentTransaction transaction = this.manager.beginTransaction(); FragmentTransaction transaction = this.manager.beginTransaction();
......
package com.polysoft.nafmii.webview; package com.polysoft.nafmii.webview;
import android.text.TextUtils;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import com.polysoft.nafmii.activity.HomeActivity; import com.polysoft.nafmii.activity.HomeActivity;
...@@ -22,6 +24,7 @@ public class WebviewHandler implements IWebview{ ...@@ -22,6 +24,7 @@ public class WebviewHandler implements IWebview{
this.java2js = new JavaToJsinterface(webView); this.java2js = new JavaToJsinterface(webView);
this.js2java = new JsToJavaInterface(this, fragment, this.java2js); this.js2java = new JsToJavaInterface(this, fragment, this.java2js);
webView.addJavascriptInterface(this.js2java, "$NativeApi"); webView.addJavascriptInterface(this.js2java, "$NativeApi");
// webView.getSettings().setTextZoom(120);
} }
public void setButtomMenu(MenuBean bean) { public void setButtomMenu(MenuBean bean) {
...@@ -43,6 +46,9 @@ public class WebviewHandler implements IWebview{ ...@@ -43,6 +46,9 @@ public class WebviewHandler implements IWebview{
@Override @Override
public void loadUrl(String url) { public void loadUrl(String url) {
if (TextUtils.isEmpty(url) || url.equals(this.getUrl())) {
return;
}
this.webView.loadUrl(url); this.webView.loadUrl(url);
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!