Run gif during webview load

Asked

Viewed 67 times

1

Good evening, I’m willing to put a gif that will appear until the page on webview be fully loaded... gif already have, put a Compile and took the code from github, my problem is that I am not able to run gif before the web view. My plan is this, I want the gif to keep loading until the webview page is completed 100%.

But I’m not getting it, somebody help me?

code:

private WebView web;
    private ImageView gif;

    private String [] permissoesNecessarias = new String[]{
            Manifest.permission.SEND_SMS,
            Manifest.permission.INTERNET
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_web_mega_sena);

        PermissionAction.validaPermissoes(1, this, permissoesNecessarias);

        web = (WebView) findViewById(R.id.web_resultados);
        gif = (ImageView) findViewById(R.id.imageView4);

        web.setWebChromeClient(new WebChromeClient(){
            public void onProgressChanged(WebView view, int progress){

                if(progress == 100){
                    web.getSettings().setJavaScriptEnabled(true);
                    web.loadUrl("http://loterias.caixa.gov.br/wps/portal/loterias/landing/megasena#resultados");
                    Glide.with(getApplicationContext()).load(R.drawable.gif_loading).asGif().into(gif);
                }else{

                }
            }
        });

        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

Detail: after the webview loaded, the gif appears together...

1 answer

1


I think you just put the following code before Else:

 gif.setVisibility(View.GONE);

This will make the gif disappear when you reach that line

Browser other questions tagged

You are not signed in. Login or sign up in order to post.