Skip to content

Commit

Permalink
add ByWebView get()
Browse files Browse the repository at this point in the history
  • Loading branch information
youlookwhat committed Oct 28, 2021
1 parent d300f1c commit 81b67c3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
19 changes: 11 additions & 8 deletions ByWebView/src/main/java/me/jingbin/web/ByWebView.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import android.os.Build;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -325,7 +324,6 @@ public void setFixScreenLandscape(boolean fixScreenLandscape) {

public static class Builder {
private Activity mActivity;
private Fragment mFragment;
// 默认使用进度条
private boolean mUseWebProgress = true;
// 进度条 开始颜色
Expand All @@ -351,11 +349,6 @@ public Builder(Activity activity) {
this.mActivity = activity;
}

public Builder(Activity activity, Fragment fragment) {
this.mActivity = activity;
this.mFragment = fragment;
}

/**
* WebView容器
*/
Expand Down Expand Up @@ -477,8 +470,18 @@ public Builder setOnByWebClientCallback(OnByWebClientCallback onByWebClientCallb
return this;
}

/**
* 直接获取ByWebView,避免一定要调用loadUrl()才能获取ByWebView的情况
*/
public ByWebView get() {
return new ByWebView(this);
}

/**
* loadUrl()并获取ByWebView
*/
public ByWebView loadUrl(String url) {
ByWebView byWebView = new ByWebView(this);
ByWebView byWebView = get();
byWebView.loadUrl(url);
return byWebView;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ private void getDataFromBrowser(Intent intent) {
String text = "Scheme: " + scheme + "\n" + "host: " + host + "\n" + "path: " + path;
Log.e("data", text);
String url = scheme + "://" + host + path;
webView.loadUrl(url);
byWebView.loadUrl(url);
} catch (Exception e) {
e.printStackTrace();
}
Expand Down

0 comments on commit 81b67c3

Please sign in to comment.