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