调整webView
调整客服页面
This commit is contained in:
parent
d6e6164549
commit
16755a9c8c
@ -30,6 +30,7 @@ import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.interfaces.LifeCycleListener;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.ClickUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -381,5 +382,7 @@ public abstract class AbsActivity extends AppCompatActivity {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isKefu(String url){
|
||||
return url.startsWith("https://kefu.yaoulive.com");
|
||||
}
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ public class WebViewActivity extends AbsActivity {
|
||||
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
}
|
||||
mWebView.loadUrl(url);
|
||||
AndroidBug5497Workaround.assistActivity(this);
|
||||
AndroidBug5497Workaround.assistActivity(mWebView);
|
||||
|
||||
if (Constants.myIntoIndex == 2) {
|
||||
ft_title.setVisibility(View.GONE);
|
||||
|
@ -21,11 +21,14 @@ public class AndroidBug5497Workaround {
|
||||
public static void assistActivity(Activity activity) {
|
||||
new AndroidBug5497Workaround(activity);
|
||||
}
|
||||
public static void assistActivity(View webView) {
|
||||
new AndroidBug5497Workaround(webView);
|
||||
}
|
||||
|
||||
private View mChildOfContent;
|
||||
private int usableHeightPrevious;
|
||||
private int defHeight = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
private FrameLayout.LayoutParams frameLayoutParams;
|
||||
private ViewGroup.LayoutParams frameLayoutParams;
|
||||
|
||||
private AndroidBug5497Workaround(Activity activity) {
|
||||
FrameLayout content = (FrameLayout) activity.findViewById(android.R.id.content);
|
||||
@ -34,6 +37,7 @@ public class AndroidBug5497Workaround {
|
||||
public void onGlobalLayout() {
|
||||
possiblyResizeChildOfContent();
|
||||
int heightDiff = mChildOfContent.getRootView().getHeight() - mChildOfContent.getHeight();
|
||||
System.out.println("heightDiff = " + heightDiff);
|
||||
if (heightDiff < 100) {
|
||||
frameLayoutParams.height = defHeight;
|
||||
mChildOfContent.requestLayout();
|
||||
@ -41,7 +45,24 @@ public class AndroidBug5497Workaround {
|
||||
}
|
||||
});
|
||||
|
||||
frameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent.getLayoutParams();
|
||||
frameLayoutParams = (ViewGroup.LayoutParams) mChildOfContent.getLayoutParams();
|
||||
}
|
||||
|
||||
public AndroidBug5497Workaround(View content) {
|
||||
mChildOfContent = content;
|
||||
mChildOfContent.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
public void onGlobalLayout() {
|
||||
possiblyResizeChildOfContent();
|
||||
int heightDiff = mChildOfContent.getRootView().getHeight() - mChildOfContent.getHeight();
|
||||
System.out.println("heightDiff = " + heightDiff);
|
||||
if (heightDiff < 100) {
|
||||
frameLayoutParams.height = defHeight;
|
||||
mChildOfContent.requestLayout();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
frameLayoutParams = (ViewGroup.LayoutParams) mChildOfContent.getLayoutParams();
|
||||
}
|
||||
|
||||
private void possiblyResizeChildOfContent() {
|
||||
|
@ -77,11 +77,12 @@ public class CustomerServiceWebViewActivity extends AbsActivity {
|
||||
rootView = findViewById(R.id.webView_root);
|
||||
mWebView = findViewById(R.id.webView);
|
||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
params.topMargin = DpUtil.dp2px(1);
|
||||
/*params.topMargin = DpUtil.dp2px(1);
|
||||
if (getNavigationBarHeight(mContext) != 0) {
|
||||
params.bottomMargin = getNavigationBarHeight(mContext);
|
||||
}
|
||||
mWebView.setLayoutParams(params);
|
||||
}*/
|
||||
AndroidBug5497Workaround.assistActivity(rootView);
|
||||
//mWebView.setLayoutParams(params);
|
||||
mWebView.setOverScrollMode(View.OVER_SCROLL_NEVER);
|
||||
mWebView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
@ -178,7 +179,6 @@ public class CustomerServiceWebViewActivity extends AbsActivity {
|
||||
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
}
|
||||
mWebView.loadUrl(url);
|
||||
AndroidBug5497Workaround.assistActivity(this);
|
||||
}
|
||||
|
||||
private void openImageChooserActivity(ValueCallback<Uri> valueCallback) {
|
||||
@ -235,21 +235,27 @@ public class CustomerServiceWebViewActivity extends AbsActivity {
|
||||
}
|
||||
|
||||
protected boolean canGoBack() {
|
||||
// return mWebView != null && mWebView.canGoBack();
|
||||
ToastUtil.showDebug("2调用js userBackShowPraise");
|
||||
mWebView.loadUrl("javascript:userBackShowPraise()");
|
||||
if (!isKefu(mWebView.getUrl()==null?"":mWebView.getUrl())) {
|
||||
mWebView.loadUrl("javascript:userBackShowPraise()");
|
||||
return false;
|
||||
}
|
||||
// return mWebView != null && mWebView.canGoBack();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
// finish();
|
||||
ToastUtil.showDebug("调用js userBackShowPraise");
|
||||
if (!isKefu(mWebView.getUrl()==null?"":mWebView.getUrl())) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
mWebView.loadUrl("javascript:userBackShowPraise()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if(keyCode==KeyEvent.KEYCODE_ESCAPE || keyCode==KeyEvent.KEYCODE_BACK){
|
||||
if (keyCode == KeyEvent.KEYCODE_ESCAPE || keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
onBackPressed();
|
||||
return false;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
android:id="@+id/rootView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="68dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:orientation="vertical" />
|
||||
|
||||
<ProgressBar
|
||||
|
Loading…
Reference in New Issue
Block a user