package mozilla.org.webmaker.client;

import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.DecelerateInterpolator;

import org.xwalk.core.XWalkResourceClient;
import org.xwalk.core.XWalkView;

public class WebClient extends XWalkResourceClient {

    /**
     * Default {@link org.xwalk.core.XWalkResourceClient} constructor method.
     */
    public WebClient(XWalkView view) {
        super(view);
    }

    /**
     * A graphical animation played when a {@link org.xwalk.core.XWalkView} is being displayed visually.
     */
    private void animate(XWalkView view) {
        Animation fadeIn = new AlphaAnimation(0, 1);
        fadeIn.setInterpolator(new DecelerateInterpolator());
        fadeIn.setDuration(1000);
        view.startAnimation(fadeIn);
    }

    /**
     * Determines whether the host application is given the chance to take control when a new URL
     * is about to be loaded in the current {@link org.xwalk.core.XWalkView}.
     */
    @Override
    public boolean shouldOverrideUrlLoading(XWalkView view, String url) {
        view.setVisibility(View.GONE);
        return false;
    }

    /**
     * Notify the client that the {@link org.xwalk.core.XWalkView} completes to load
     * the resource specified by the given URL.
     */
    @Override
    public void onLoadFinished(XWalkView view, String url) {
        animate(view);
        view.setVisibility(View.VISIBLE);
        super.onLoadFinished(view, url);
    }

    /**
     * Notify the client the progress info of loading a specific URL.
     */
    @Override
    public void onProgressChanged(XWalkView view, int progressInPercent) {
        if (progressInPercent != 0) {
            animate(view);
            view.setVisibility(View.VISIBLE);
        } else {
            view.setVisibility(View.GONE);
        }
        super.onProgressChanged(view, progressInPercent);
    }
}

@@ -801,10 +801,9 @@
 ion(
-10
+5
 00);
@@ -1534,428 +1534,7 @@
    %7D
-%0A%0A    /**%0A     * Notify the client the progress info of loading a specific URL.%0A     */%0A    @Override%0A    public void onProgressChanged(XWalkView view, int progressInPercent) %7B%0A        if (progressInPercent != 0) %7B%0A            animate(view);%0A            view.setVisibility(View.VISIBLE);%0A        %7D else %7B%0A            view.setVisibility(View.GONE);%0A        %7D%0A        super.onProgressChanged(view, progressInPercent);%0A    %7D
 %0A%7D%0A

Improve animation / transition on loading of webviews