@Synthetic void setFullscreen(boolean isFullscreen) { if (getView() == null) { return; } mFullscreen = isFullscreen; mControls.setVisibility(isFullscreen ? VISIBLE : View.GONE); AppUtils.toggleWebViewZoom(mWebView.getSettings(), isFullscreen); ViewGroup.LayoutParams params = mWebView.getLayoutParams(); if (isFullscreen) { mScrollView.removeView(mScrollViewContent); mWebView.scrollTo(mScrollView.getScrollX(), mScrollView.getScrollY()); mFullscreenView.addView(mScrollViewContent); params.height = ViewGroup.LayoutParams.MATCH_PARENT; } else { reset(); // We'll zoom out until it returns false, which means it has min zoom level. // It's quite dangerous piece of code - potentially could lead to infinite loop, // so let's add some reasonable limit just in case int i = 0; while (mWebView.zoomOut() && i < 30) { i++; } mFullscreenView.removeView(mScrollViewContent); mScrollView.addView(mScrollViewContent); mScrollView.post(() -> mScrollView.scrollTo(mWebView.getScrollX(), mWebView.getScrollY())); params.height = ViewGroup.LayoutParams.WRAP_CONTENT; } mWebView.setLayoutParams(params); }
@Override public void addView(View child, int index) { super.addView(child, index); findStickyViews(child); }
@Override public void addView(View child, int width, int height) { super.addView(child, width, height); findStickyViews(child); }
@Override public void addView(View child) { super.addView(child); findStickyViews(child); }
@Override public void addView(View child, int index, android.view.ViewGroup.LayoutParams params) { super.addView(child, index, params); findStickyViews(child); }
@Override public void addView(View child, android.view.ViewGroup.LayoutParams params) { super.addView(child, params); findStickyViews(child); }
@Override protected void initView() { view = mInflater.inflate(R.layout.panel_ns, null); mFrameLayout = view.findViewById(R.id.frameLayout); mNestedScrollView = view.findViewById(R.id.nestedScrollView); mRefreshLayout = view.findViewById(R.id.refreshLayout); mRefreshLayout.setHeaderHeight(100); mRefreshLayout.setFooterHeight(100); mRefreshLayout.setPrimaryColorsId(R.color.colorRefresh, R.color.colorWhite); contentView = mInflater.inflate(getContentViewId(), null); mNestedScrollView.addView(contentView); }
@Override public void showEssayContent(String contentHtml) { if (mWbParent.getChildCount() > 0) { mWbParent.removeViewAt(0); } mWebView = new WebView(this); mWebView.loadDataWithBaseURL(null, contentHtml, "text/html", "utf-8", null); FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); mWbParent.addView(mWebView, layoutParams); }
@Override public void setupDialog(final Dialog dialog, int style) { LinearLayout layout = new LinearLayout(getContext()); layout.setMinimumHeight(100); layout.setPadding(16, 16, 16, 16); layout.setOrientation(LinearLayout.VERTICAL); NestedScrollView scrollView = new NestedScrollView(getContext()); final String[] values = getInputValues(Objects.requireNonNull(getActivity()).getIntent()); for (int i = 0; i < values.length; ++i) { final int j = i; final TextView textView = new TextView(getContext()); textView.setText(values[j]); textView.setTextSize(20); textView.setPadding(56, 56, 56, 56); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { InputResult result = new InputResult(); result.text = values[j]; result.index = j; dialog.dismiss(); resultListener.onResult(result); } }); layout.addView(textView); } scrollView.addView(layout); dialog.setContentView(scrollView); hideKeyboard(); }