first time webview loads, thread called after x seconds, when clicking on url inside webview why thread not fired again. thread in pagestart loading once, needs fire everytime url clicked inside webview.
public class myappwebviewclient extends webviewclient { public myappwebviewclient() { timeout = true; } @override public void onpagestarted(webview view, string url, bitmap favicon) { super.onpagestarted(view, url, favicon); showprogressdialog(); new thread(new runnable() { @override public void run() { try { thread.sleep(constants.delaymilis); } catch (interruptedexception e) { e.printstacktrace(); } if(timeout) { // want systemutils.dismissprogressdialog(activity.getresources().getstring(r.string.app_name),activity.getresources().getstring(r.string.chargement_message_dialog)); } } }).start(); } @override public boolean shouldoverrideurlloading(webview view, string url) { super.shouldoverrideurlloading(view, url); webcontainer.loadurl(url); new thread(new runnable() { @override public void run() { try { thread.sleep(constants.delaymilis); } catch (interruptedexception e) { e.printstacktrace(); } if(timeout) { // want systemutils.dismissprogressdialog(activity.getresources().getstring(r.string.app_name),activity.getresources().getstring(r.string.chargement_message_dialog)); } } }).start(); return true; } @override public void onpagefinished(webview view, string url) { super.onpagefinished(view, url); timeout = false; cancelcurrentloading(); } @override public void onreceivederror(webview view, int errorcode, string description, string failingurl) { super.onreceivederror(view, errorcode, description, failingurl); log.e("error_loading_code: ", description); timeout = false; noconnection(); } } /* mehtod dismiss loading spinner */ public static void cancelcurrentloading() {
showwebview(); if (progressdialog.isshowing()) { progressdialog.dismiss(); } } /* method show , hide webview */ public static void showwebview(){ webcontainer.setvisibility(view.visible); } public static void hidewebview(){ webcontainer.setvisibility(view.gone); }
Comments
Post a Comment