ozodrukh / CircularReveal

Lollipop ViewAnimationUtils.createCircularReveal for everyone 4.0+
MIT License
2.43k stars 391 forks source link

webview can't working correctly #75

Closed t2314862168 closed 7 years ago

t2314862168 commented 8 years ago

@ozodrukh when i use RevealFrameLayout contain WebView,and when web load url data show CircularReveal , it can't work correctly ,most of time can't see the CircularReveal ,can you help me ! my xml code is below :

<io.codetail.widget.RevealFrameLayout
        android:id="@+id/animator"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <WebView
            android:id="@+id/webview"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

        <com.wang.avi.AVLoadingIndicatorView
            android:id="@+id/avi"
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:layout_gravity="center"
            android:visibility="visible"
            app:indicator="BallSpinFadeLoader"
            app:indicator_color="@color/colorPrimary" />
    </io.codetail.widget.RevealFrameLayout>

and my activity code is:

private void initAnimData() {
        // get the center for the clipping circle
        cx = (mWebView.getLeft() + mWebView.getRight()) / 2;
        cy = (mWebView.getTop() + mWebView.getBottom()) / 2;
        // get the final radius for the clipping circle
        dx = Math.max(cx, mWebView.getWidth() - cx);
        dy = Math.max(cy, mWebView.getHeight() - cy);
        finalRadius = (float) Math.hypot(dx, dy);

        animator = ViewAnimationUtils.createCircularReveal(mWebView, cx, cy, 0, finalRadius);
        animator.setInterpolator(new AccelerateDecelerateInterpolator());
        animator.setDuration(1000);
    }

    private void startAnim() {
        if (hasRunAnim) {
            return;
        }
        animator.start();
        hasRunAnim = true;
    }

// used by  mWebView.setWebChromeClient(new MyWebViewClient());
 private class MyWebViewClient extends WebChromeClient {

        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            if (newProgress >= 30) {
                startAnim();
                if (newProgress >= 60) {
                    mAviView.setVisibility(View.INVISIBLE);
                }
            }
            super.onProgressChanged(view, newProgress);
        }

    }
ozodrukh commented 7 years ago

duplicate #51