Java Examples for android.webkit.DownloadListener

The following java examples will help you to understand the usage of android.webkit.DownloadListener. These source code samples are taken from different open source projects.

Example 1
Project: Android-Debug-Tools-master  File: WebViewActivity.java View source code
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    url = getIntent().getStringExtra("key");
    setContentView(R.layout.activity_webview);
    webView = (WebView) findViewById(R.id.webView1);
    this.webView = (WebView) findViewById(R.id.webView1);
    this.webView.setScrollBarStyle(0);
    this.webView.setDownloadListener(new DownloadListener() {

        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(url));
            startActivity(intent);
        }
    });
    this.webView.getSettings().setJavaScriptEnabled(true);
    this.listenClient = new Client(WebViewActivity.this);
    this.webView.setWebViewClient(this.listenClient);
    this.webView.addJavascriptInterface(this.listenClient, "Android");
    this.webView.setWebChromeClient(new WebChromeClient() {

        // 加载倒计时
        private CountDownTimer loadCDT = null;

        @Override
        public void onProgressChanged(final WebView view, int progress) {
        }
    });
    this.webView.loadUrl(url);
}
Example 2
Project: Devtf_APP-master  File: WebViewActivity.java View source code
private void loadWeb() {
    mVebView.loadUrl(url);
    mVebView.clearCache(true);
    WebSettings webSettings = mVebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setPluginState(PluginState.ON);
    webSettings.setJavaScriptEnabled(true);
    webSettings.setDomStorageEnabled(true);
    mVebView.setWebChromeClient(new WebChromeClient() {

        public void onProgressChanged(WebView view, int progress) {
        }

        @Override
        public void onReceivedTitle(WebView view, String title) {
            super.onReceivedTitle(view, title);
            getSupportActionBar().setTitle(title);
        }
    });
    mVebView.setWebViewClient(new WebViewClient() {

        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            super.onPageStarted(view, url, favicon);
            loadingIV.setVisibility(View.VISIBLE);
            if (null == ad)
                ad = (AnimationDrawable) loadingIV.getBackground();
            ad.start();
            setMenuEnable();
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            setMenuEnable();
            if (null != ad) {
                ad.stop();
            }
            loadingIV.setVisibility(View.GONE);
        }

        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            super.onReceivedError(view, errorCode, description, failingUrl);
        }
    });
    mVebView.setDownloadListener(new DownloadListener() {

        @Override
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
            Uri uri = Uri.parse(url);
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);
        }
    });
    mVebView.setOnScrollListener(new OnScrollListener() {

        @Override
        public void onScroll(int l, int t) {
        }
    });
}
Example 3
Project: GanHuoIO-master  File: WebViewUtil.java View source code
private static void settWebViewDownloadListener(final WebView webView) {
    webView.setDownloadListener(new DownloadListener() {

        @Override
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
            Uri uri = Uri.parse(url);
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            webView.getContext().startActivity(intent);
        }
    });
}
Example 4
Project: JwZhangJie-master  File: WebVideo.java View source code
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.webvideo);
    MyWebView = (WebView) findViewById(R.id.webvideo_webview);
    MyWebView.getSettings().setJavaScriptEnabled(true);
    MyWebView.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            super.onPageStarted(view, url, favicon);
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
        }
    });
    MyWebView.setWebChromeClient(new WebChromeClient() {

        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            super.onProgressChanged(view, newProgress);
        }
    });
    MyWebView.setDownloadListener(new DownloadListener() {

        @Override
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
            Uri uri = Uri.parse(url);
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);
        }
    });
    MyWebView.loadUrl("http://www.google.hk");
}
Example 5
Project: naruto-master  File: AboutActivity.java View source code
private void initWebview() {
    webView.getSettings().setJavaScriptEnabled(true);
    webView.setWebViewClient(new WebViewClient() {

        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }

        public void onPageFinished(WebView view, String url) {
            loadingview.loadingSuccess();
        }

        public void onFormResubmission(WebView view, Message dontResend, Message resend) {
            resend.sendToTarget();
        }
    });
    webView.setWebChromeClient(new WebChromeClient() {
    });
    webView.setDownloadListener(new DownloadListener() {

        @Override
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
        }
    });
}
Example 6
Project: AndroidExercise-master  File: MainActivity.java View source code
@SuppressLint("JavascriptInterface")
private void initWebView() {
    WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    webView.addJavascriptInterface(new WebHost(MainActivity.this), "js");
    webView.setWebChromeClient(new WebChromeClient() {

        @Override
        public void onReceivedTitle(WebView view, String title) {
            super.onReceivedTitle(view, title);
            tvTopTitle.setText(title);
        }
    });
    webView.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return super.shouldOverrideUrlLoading(view, url);
        }

        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            super.onReceivedError(view, errorCode, description, failingUrl);
            view.loadUrl("file:///android_asset/error.html");
        }
    });
    webView.setDownloadListener(new DownloadListener() {

        @Override
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
            Log.i(TAG, "downloadUrl--->" + url);
            if (url.endsWith(".apk")) {
                //开�线程下载
                //                    new HttpThread(url).start();
                //调用系统下载
                Uri uri = Uri.parse(url);
                Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                startActivity(intent);
            }
        }
    });
}
Example 7
Project: pa-updater-master  File: DownloadReq.java View source code
@SuppressLint("SetJavaScriptEnabled")
public void RequestROM() {
    Functions.createDirIfNotExists("pa_updater");
    webview.setVisibility(0);
    WebSettings settings = webview.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setLoadWithOverviewMode(true);
    settings.setUseWideViewPort(true);
    webview.setWebViewClient(new WebViewClient());
    webview.loadUrl(gooShortURL);
    timer.scheduleAtFixedRate(new TimerTask() {

        @Override
        public void run() {
            webview.loadUrl(gooShortURL);
            Functions.Notify(mActivity, "Failed! Retrying Request...");
        }
    }, 21000, 21000);
    webview.setDownloadListener(new DownloadListener() {

        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
            webview.setDownloadListener(null);
            timer.cancel();
            URL = url;
            processStopService();
            processStartService();
            finish();
        }
    });
}
Example 8
Project: shuba-master  File: BrowserActivity.java View source code
/**
     * �始化视图。
     */
private void initViews() {
    pbLoading = (ProgressBar) findViewById(R.id.pb_loading);
    webview = (WebView) findViewById(R.id.webview);
    webview.getSettings().setJavaScriptEnabled(true);
    webview.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
    webview.getSettings().setDomStorageEnabled(true);
    webview.getSettings().setUseWideViewPort(true);
    webview.getSettings().setLoadWithOverviewMode(true);
    webview.setDownloadListener(new DownloadListener() {

        @Override
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
            Uri uri = Uri.parse(url);
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);
        }
    });
    webview.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    });
    webview.setWebChromeClient(new WebChromeClient() {

        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            if (newProgress > 50) {
                pbLoading.setVisibility(View.GONE);
            }
            super.onProgressChanged(view, newProgress);
        }
    });
    webview.loadUrl(url);
}
Example 9
Project: AndroidGeek-master  File: BaseWebViewActivity.java View source code
@SuppressLint("SetJavaScriptEnabled")
protected void initWebViewSettings() {
    WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    // WebView中�有�以下载文件的链接,点击该链接�,应该开始执行下载的�作并�存文件到本地中。
    webView.setDownloadListener(new DownloadListener() {

        @Override
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
            Uri uri = Uri.parse(url);
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);
            if (webView.canGoBack())
                webView.goBack();
            else
                finish();
        }
    });
}
Example 10
Project: FastDev4Android-master  File: HTML5WebViewCustomAD.java View source code
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mWebView = new HTML5CustomWebView(this, HTML5WebViewCustomAD.this, title, ad_url);
    mWebView.setDownloadListener(new DownloadListener() {

        @Override
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
            Uri uri = Uri.parse(url);
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
        }
    });
    //准备javascript注入
    mWebView.addJavascriptInterface(new Js2JavaInterface(), "Js2JavaInterface");
    if (savedInstanceState != null) {
        mWebView.restoreState(savedInstanceState);
    } else {
        if (ad_url != null) {
            mWebView.loadUrl(ad_url);
        }
    }
    setContentView(mWebView.getLayout());
}
Example 11
Project: KingPlayer-master  File: WebActivity.java View source code
@SuppressLint("SetJavaScriptEnabled")
private void initView() {
    mTipTextView.setText(R.string.loading_web);
    showLoadingView();
    Intent intent = getIntent();
    String url = "http://3g.youku.com";
    if (intent != null) {
        url = intent.getStringExtra(OnlineFragment.URL);
    }
    mWebView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.setDownloadListener(new DownloadListener() {

        @Override
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
            Log.e(TAG, "onDownload Start :; url is :" + url + ":" + userAgent + "contentDi: " + contentDisposition + ":mine:" + mimetype + ":length::" + contentLength);
        }
    });
    mWebView.setWebViewClient(new WebViewClient() {

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            Log.d(TAG, "on page finished.");
            hideLoadingView();
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            Log.w(TAG, "page jump  should override url loading... url is : " + url);
            // view.loadUrl(url);
            return false;
        }
    });
    mWebView.setWebChromeClient(new WebChromeClient() {

        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            super.onProgressChanged(view, newProgress);
            if (newProgress == 100) {
                hideLoadingView();
            }
        /*else {
                    showLoadingView();
                }*/
        }
    });
    mWebView.setOnKeyListener(new OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView != null && mWebView.canGoBack()) {
                mWebView.goBack();
                return true;
            }
            return false;
        }
    });
    mWebView.loadUrl(url);
    mWebView.clearHistory();
}
Example 12
Project: progscrape-android-master  File: BrowserView.java View source code
private void setupBrowser() {
    WebSettings settings = browser.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setSupportZoom(true);
    settings.setDisplayZoomControls(false);
    settings.setBuiltInZoomControls(true);
    settings.setUseWideViewPort(true);
    browser.setWebChromeClient(new WebChromeClient() {

        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            if (newProgress == 0) {
                progress.setVisibility(View.VISIBLE);
                progress.setIndeterminate(true);
            } else if (newProgress == 100) {
                progress.setVisibility(View.GONE);
            } else {
                progress.setVisibility(View.VISIBLE);
                progress.setIndeterminate(false);
                progress.setProgress(newProgress);
            }
        }
    });
    browser.setWebViewClient(new WebViewClient());
    browser.setDownloadListener(new DownloadListener() {

        @Override
        public void onDownloadStart(final String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
            AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
            builder.setMessage("Unable to view " + mimetype + ". Download the file instead?").setPositiveButton("Yes", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    DownloadManager dm = (DownloadManager) getContext().getSystemService(Context.DOWNLOAD_SERVICE);
                    dm.enqueue(new DownloadManager.Request(Uri.parse(url)));
                    back();
                }
            }).setNegativeButton("No", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    back();
                }
            }).show();
        }
    });
}
Example 13
Project: appboy-android-sdk-master  File: AppboyWebViewActivity.java View source code
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_PROGRESS);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setWindowFlagsSafe();
    setContentView(R.layout.com_appboy_webview_activity);
    setProgressBarVisibility(true);
    WebView webView = (WebView) findViewById(R.id.com_appboy_webview_activity_webview);
    WebSettings webSettings = webView.getSettings();
    // JavaScript is enabled by default to support a larger number of web pages. If JavaScript support is not
    // necessary, then it should be disabled.
    webSettings.setJavaScriptEnabled(true);
    webSettings.setAllowFileAccess(false);
    // Plugin support is disabled by default. If plugins, such as flash, are required, change the PluginState.
    webSettings.setPluginState(WebSettings.PluginState.OFF);
    setZoomSafe(webSettings);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setDomStorageEnabled(true);
    // Instruct webview to be as large as its parent view.
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    webView.setLayoutParams(layoutParams);
    webView.setWebChromeClient(new WebChromeClient() {

        public void onProgressChanged(WebView view, int progress) {
            if (progress < 100) {
                setProgressBarVisibility(true);
            } else {
                setProgressBarVisibility(false);
            }
        }
    });
    webView.setDownloadListener(new DownloadListener() {

        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(url));
            startActivity(intent);
        }
    });
    webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
    setWebLayerTypeSafe(webView);
    webView.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            try {
                // for example, redirects to the play store via a "store://" Uri.
                if (!AppboyFileUtils.REMOTE_SCHEMES.contains(Uri.parse(url).getScheme())) {
                    IAction action = ActionFactory.createUriActionFromUrlString(url, getIntent().getExtras(), false, Channel.UNKNOWN);
                    // Instead of using AppboyNavigator, just open directly.
                    action.execute(view.getContext());
                    // Close the WebView if the action was executed successfully
                    finish();
                    return true;
                }
            } catch (Exception e) {
                AppboyLogger.i(TAG, String.format("Unexpected exception while processing url %s. " + "Passing url back to WebView.", url), e);
            }
            return super.shouldOverrideUrlLoading(view, url);
        }
    });
    Bundle extras = getIntent().getExtras();
    // Opens the URL passed as an intent extra (if one exists).
    if (extras != null && extras.containsKey(URL_EXTRA)) {
        String url = extras.getString(URL_EXTRA);
        webView.loadUrl(url);
    }
}
Example 14
Project: MvpApp-master  File: CustomWebView.java View source code
@SuppressLint("SetJavaScriptEnabled")
private void init(Context context) {
    // 顶部显示的进度�
    mProgressBar = new ProgressBar(context, null, android.R.attr.progressBarStyleHorizontal);
    mProgressBar.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 7, 0, 0));
    Drawable drawable = context.getResources().getDrawable(R.drawable.layer_web_progress_bar);
    mProgressBar.setProgressDrawable(drawable);
    addView(mProgressBar);
    WebSettings webSettings = this.getSettings();
    webSettings.setJavaScriptEnabled(true);
    // 是能放大缩�
    webSettings.setSupportZoom(true);
    webSettings.setUseWideViewPort(true);
    webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setBuiltInZoomControls(true);
    //éš?è—?
    webSettings.setDisplayZoomControls(false);
    webSettings.setDomStorageEnabled(true);
    webSettings.setSupportMultipleWindows(true);
    //webSettings.setUseWideViewPort(true);
    this.setWebViewClient(mWebViewClientBase);
    this.setWebChromeClient(mWebChromeClientBase);
    setDownloadListener(new DownloadListener());
    this.onResume();
}
Example 15
Project: UnivrApp-master  File: NonLeakingWebView.java View source code
private void init(final Context context) {
    setWebViewClient(new MyWebViewClient((Activity) context));
    getSettings().setAllowFileAccess(true);
    getSettings().setAppCacheEnabled(true);
    getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
    setDownloadListener(new DownloadListener() {

        @Override
        public void onDownloadStart(final String url, final String userAgent, final String contentDisposition, final String mimetype, final long contentLength) {
            UIUtils.safeOpenLink(context, new Intent(Intent.ACTION_VIEW, Uri.parse(url)).setType(mimetype));
        }
    });
}
Example 16
Project: wger-android-master  File: MainActivity.java View source code
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ActionBar actionBar = getActionBar();
    actionBar.hide();
    web = (WebView) findViewById(R.id.webview);
    web.setWebViewClient(new WgerWebViewClient());
    web.setDownloadListener(new DownloadListener() {

        /*
            * Special care for the application downloads
            * 
            * This is needed because they are only available to logged in users
            * and we have to send the authentication cookie and handle the rest
            */
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
            String fileName = URLUtil.guessFileName(url, contentDisposition, mimetype);
            String cookie = CookieManager.getInstance().getCookie(url);
            DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
            Request request = new Request(Uri.parse(url));
            request.setTitle(fileName);
            request.addRequestHeader("Cookie", cookie);
            dm.enqueue(request);
            // Open the download manager
            Intent downloadsIntent = new Intent();
            downloadsIntent.setAction(DownloadManager.ACTION_VIEW_DOWNLOADS);
            startActivity(downloadsIntent);
        }
    });
    WebSettings webSettings = web.getSettings();
    /*
         *  Change WebView UserAgent
         *  
         *  This is needed for example to hide the persona login button, which does
         *  not work when called from an app.
         */
    webSettings.setUserAgentString(webSettings.getUserAgentString() + " WgerAndroidWebApp");
    webSettings.setJavaScriptEnabled(true);
    // changes
    if (savedInstanceState == null) {
        web.loadUrl("https://wger.de/dashboard");
    }
}
Example 17
Project: android-signage-client-master  File: FullScreenWebViewActivity.java View source code
@SuppressLint({ "SetJavaScriptEnabled", "NewApi" })
@Override
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);
    intent = getIntent();
    activity = this;
    setContentView(R.layout.activity_fullscreen);
    webView = (WebView) findViewById(R.id.webView);
    webView.setWebChromeClient(new CustomWebChromeClient());
    webView.addJavascriptInterface(new HardwareInterface(this), "Android");
    webView.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            // handle redirects internally (stop launching the default browser)
            return false;
        }

        @Override
        public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
            // allow self-unsigned SSL certificates for dev 
            handler.proceed();
        }

        @Override
        public void onReceivedError(final WebView view, int errorCode, String description, String failingUrl) {
            // load a blank page and retry, rather heavy-handedly
            Log.w(TAG, String.format("%d: Could not load %s: %s", errorCode, failingUrl, description));
            view.loadData(getString(R.string.blank_page), "text/html", null);
            Toast.makeText(activity, "Network error", Toast.LENGTH_SHORT).show();
            final String retryUrl = failingUrl;
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    Toast.makeText(activity, "Retrying...", Toast.LENGTH_SHORT).show();
                    view.loadUrl(retryUrl);
                }
            }, 1000);
        //super.onReceivedError(view, errorCode, description, failingUrl);
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            // inject device information into the DOM
            webView.loadUrl(String.format("javascript:(function() {window.device = Object({'MACAddress':'%s', 'IPAddress':'%s'})})()", getMACAddress(null), getIPAddress(null, true)));
        }
    });
    webView.setDownloadListener(new DownloadListener() {

        // allow us to download stuff inside this webview for dev
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
        }
    });
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    // let us send back minimal info from JS
    webView.getSettings().setGeolocationEnabled(true);
    // start media automatically (if we can get it to work)
    webView.getSettings().setMediaPlaybackRequiresUserGesture(false);
    // use viewport meta tag if present
    webView.getSettings().setUseWideViewPort(true);
    webView.loadUrl(getString(R.string.initial_url));
    final View controlsView = findViewById(R.id.fullscreen_content_controls);
    // Set up an instance of SystemUiHider to control the system UI for
    // this activity.
    mSystemUiHider = SystemUiHider.getInstance(this, webView, HIDER_FLAGS);
    mSystemUiHider.setup();
    mSystemUiHider.setOnVisibilityChangeListener(new SystemUiHider.OnVisibilityChangeListener() {

        // Cached values.
        int mControlsHeight;

        int mShortAnimTime;

        @Override
        @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
        public void onVisibilityChange(boolean visible) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
                // screen.
                if (mControlsHeight == 0) {
                    mControlsHeight = controlsView.getHeight();
                }
                if (mShortAnimTime == 0) {
                    mShortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);
                }
                controlsView.animate().translationY(visible ? 0 : mControlsHeight).setDuration(mShortAnimTime);
            } else {
                // If the ViewPropertyAnimator APIs aren't
                // available, simply show or hide the in-layout UI
                // controls.
                controlsView.setVisibility(visible ? View.VISIBLE : View.GONE);
            }
            if (visible && AUTO_HIDE) {
                // Schedule a hide().
                delayedHide(AUTO_HIDE_DELAY_MILLIS);
            }
        }
    });
}
Example 18
Project: GigaGet-master  File: BrowserActivity.java View source code
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mInput = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    // Toolbar
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    // Custom view
    if (Build.VERSION.SDK_INT < 21) {
        ContextThemeWrapper wrap = new ContextThemeWrapper(this, R.style.Theme_AppCompat);
        LayoutInflater inflater = (LayoutInflater) wrap.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View custom = inflater.inflate(R.layout.browser_url, null);
        getSupportActionBar().setCustomView(custom);
    } else {
        getSupportActionBar().setCustomView(R.layout.browser_url);
    }
    // Initialize WebView
    mProgress = Utility.findViewById(this, R.id.progress);
    mUrl = Utility.findViewById(getSupportActionBar().getCustomView(), R.id.browser_url);
    mWeb = Utility.findViewById(this, R.id.web);
    mWeb.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            getSupportActionBar().setDisplayShowCustomEnabled(false);
            getSupportActionBar().setDisplayShowTitleEnabled(true);
            return true;
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            mProgress.setProgress(0);
        }

        @Override
        public void onPageStarted(WebView view, String url, Bitmap fav) {
            if (isVideo(url)) {
                // If viewing a video, start download immediately
                view.stopLoading();
                Intent i = new Intent();
                i.setAction(MainActivity.INTENT_DOWNLOAD);
                i.setDataAndType(Uri.parse(url), "application/octet-stream");
                startActivity(i);
                finish();
            }
        }
    });
    mWeb.setWebChromeClient(new WebChromeClient() {

        @Override
        public void onProgressChanged(WebView v, int progress) {
            mProgress.setProgress(progress);
        }

        @Override
        public void onReceivedTitle(WebView v, String title) {
            getSupportActionBar().setTitle(title);
        }
    });
    mWeb.getSettings().setJavaScriptEnabled(true);
    mWeb.setDownloadListener(new DownloadListener() {

        @Override
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimeType, long contentLength) {
            // Start MainActivity for downloading
            Intent i = new Intent();
            i.setAction(MainActivity.INTENT_DOWNLOAD);
            i.setDataAndType(Uri.parse(url), mimeType);
            startActivity(i);
            finish();
        }
    });
    mUrl.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent ev) {
            if (actionId == EditorInfo.IME_ACTION_GO) {
                String url = mUrl.getText().toString();
                if (!url.startsWith("http")) {
                    url = "http://" + url;
                }
                mWeb.loadUrl(url);
                switchCustom();
                return true;
            }
            return false;
        }
    });
    mWeb.addJavascriptInterface(new MyJavascriptInterface(), "HTMLOUT");
    mWeb.loadUrl("about:blank");
    switchCustom();
    mToolbar.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            switchCustom();
        }
    });
    // Parse Intent
    Intent i = getIntent();
    if (i.getAction().equals(Intent.ACTION_SEND)) {
        String data = i.getStringExtra(Intent.EXTRA_TEXT);
        mWeb.loadUrl(data);
        mUrl.setText(data);
    }
}
Example 19
Project: hplookball-master  File: HupuWebView.java View source code
private void initDownloadListener() {
    final Activity context = (Activity) getContext();
    setDownloadListener(new DownloadListener() {

        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
            //				HupuLog.d("load url =" + url + "  mimetype=" + mimetype);
            if (contentDisposition == null || !contentDisposition.regionMatches(true, 0, "attachment", 0, 10)) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setDataAndType(Uri.parse(url), mimetype);
                ResolveInfo info = context.getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
                if (info != null) {
                    ComponentName myName = context.getComponentName();
                    if (!myName.getPackageName().equals(info.activityInfo.packageName) || !myName.getClassName().equals(info.activityInfo.name)) {
                        try {
                            context.startActivity(intent);
                            return;
                        } catch (ActivityNotFoundException ex) {
                            Toast.makeText(context, "您没有安装�媒体播放器,请到应用市场安装播放器", Toast.LENGTH_SHORT);
                        }
                    }
                } else {
                    // 自定义下载
                    download(url, context);
                }
            }
        }
    });
// setOnLongClickListener(new LongClick());
}
Example 20
Project: mBrowser-master  File: MainActivity.java View source code
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    //---------------------views part-----------------------//
    myWebView = (WebView) findViewById(R.id.mWebView);
    videoFrame = (FrameLayout) findViewById(R.id.videoFrame);
    View prompt = getPrompt();
    uri = (TextView) prompt.findViewById(R.id.uri);
    loadImages = (CheckBox) prompt.findViewById(R.id.loadImages);
    loadScripts = (CheckBox) prompt.findViewById(R.id.loadScripts);
    //---------------------webview part-----------------------//
    mClient = new WebChromeClient() {

        @Override
        public void onShowCustomView(View view, CustomViewCallback callback) {
            myWebView.setVisibility(View.GONE);
            mCustomViewCallback = callback;
            mCustomView = view;
            videoFrame.addView(view);
            videoFrame.setVisibility(View.VISIBLE);
            videoFrame.bringToFront();
        }

        @Override
        public void onHideCustomView() {
            if (mCustomView != null) {
                videoFrame.setVisibility(View.GONE);
                videoFrame.removeAllViews();
                mCustomView = null;
                mCustomViewCallback.onCustomViewHidden();
                myWebView.setVisibility(View.VISIBLE);
            }
        }
    };
    myWebView.setWebViewClient(new WebViewClient() {

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            if (!url.equals("about:blank")) {
                View layout = getLayoutInflater().inflate(R.layout.toast, (ViewGroup) findViewById(R.id.toastWrapper));
                TextView text = (TextView) layout.findViewById(R.id.toastText);
                text.setText(url);
                Toast toast = new Toast(MainActivity.this);
                toast.setGravity(Gravity.TOP | Gravity.FILL_HORIZONTAL, 0, 0);
                toast.setDuration(Toast.LENGTH_SHORT);
                toast.setView(layout);
                toast.show();
            }
            super.onPageStarted(view, url, favicon);
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (url.startsWith("http://") || url.startsWith("https://")) {
                return false;
            } else {
                Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                startActivity(Intent.createChooser(i, getResources().getString(R.string.complete_action_using)));
                return true;
            }
        }
    });
    myWebView.setWebChromeClient(mClient);
    myWebView.setDownloadListener(new DownloadListener() {

        @Override
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimeType, long contentLength) {
            String fileName = URLUtil.guessFileName(url, contentDisposition, mimeType);
            Toast.makeText(MainActivity.this, "Downloading " + fileName, Toast.LENGTH_LONG).show();
            Request request = new DownloadManager.Request(Uri.parse(url));
            request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName);
            final DownloadManager dm = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
            dm.enqueue(request);
        }
    });
    //---------------------prompt part-----------------------//
    uri.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            boolean handled = false;
            if (actionId == EditorInfo.IME_ACTION_GO) {
                String uriValue = uri.getText().toString();
                if (uriValue.startsWith("http://") || uriValue.startsWith("https://")) {
                    loadUrl(uriValue);
                } else {
                    String host = Uri.parse("http://" + uriValue).getHost();
                    if (host == null || host.indexOf(".") == -1 || host.indexOf(".") == 0 || host.indexOf(".") == host.length() - 1) {
                        search(uriValue);
                    } else {
                        loadUrl("http://" + uriValue);
                    }
                }
                dialog.cancel();
                handled = true;
            }
            return handled;
        }
    });
    SharedPreferences settings = getSharedPreferences("config", 0);
    loadImages.setChecked(settings.getBoolean("loadImages", true));
    loadScripts.setChecked(settings.getBoolean("loadScripts", true));
    dialog = new AlertDialog.Builder(this).setView(prompt).create();
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    //----------------start action------------------------//
    Intent intent = getIntent();
    if (intent.getAction().equals(Intent.ACTION_VIEW)) {
        loadUrl(intent.getDataString());
    } else {
        dialog.show();
    }
}
Example 21
Project: vtu-life-android-master  File: WebFragment.java View source code
@SuppressLint({ "SetJavaScriptEnabled", "JavascriptInterface" })
private void initWebView() {
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.addJavascriptInterface(new JavaScriptInterface(), "HTMLOUT");
    mWebView.setWebChromeClient(new WebChromeClient() {

        public void onProgressChanged(WebView view, int progress) {
            loadingProgressBar.setProgress(progress);
        }
    });
    mWebView.setWebViewClient(new WebViewClient() {

        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            activity.showCrouton(description, Style.ALERT, false);
            showReload();
        }

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            isRefresh = false;
            isBackEnabled = mWebView.canGoBack();
            isForwardEnabled = mWebView.canGoForward();
            mActionBarStatus.subTitle = getString(R.string.loading);
            activity.reflectActionBarChange(mActionBarStatus, VTULifeMainActivity.ID_VTU_LIFE_WEB_FRAGMENT, true);
            showLoadingProgressBar();
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            currentUrl = url;
            mWebView.loadUrl("javascript:window.HTMLOUT.showHTML('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
            isRefresh = true;
            isBackEnabled = mWebView.canGoBack();
            isForwardEnabled = mWebView.canGoForward();
            mActionBarStatus.subTitle = null;
            activity.reflectActionBarChange(mActionBarStatus, VTULifeMainActivity.ID_VTU_LIFE_WEB_FRAGMENT, true);
            hideLodingProgressBar();
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (url.equals(SystemFeatureChecker.getAppPlayStoreURL()))
                activity.showRateApp();
            else if (url.contains("classresults.php"))
                activity.changeCurrentFragemnt(VTULifeMainActivity.ID_CLASS_RESULT_FRAGMENT);
            else if (url.contains("fastresults.php"))
                activity.changeCurrentFragemnt(VTULifeMainActivity.ID_FAST_RESULT_FRAGMENT);
            else if (url.contains("resource"))
                activity.changeCurrentFragemnt(VTULifeMainActivity.ID_DIRECTORY_LISTING_FRAGMENT);
            else if (url.contains("upload.html"))
                activity.changeCurrentFragemnt(VTULifeMainActivity.ID_UPLOAD_FILE_FRAGEMENT);
            else
                view.loadUrl(url);
            return true;
        }
    });
    mWebView.setDownloadListener(new DownloadListener() {

        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
            SystemFeatureChecker.downloadFile(activity, url, false);
            activity.showCrouton(R.string.downloading_started, Style.INFO, false);
        }
    });
}
Example 22
Project: Catroid-master  File: WebViewActivity.java View source code
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_webview);
    ActionBar actionBar = getActionBar();
    actionBar.hide();
    Intent intent = getIntent();
    url = intent.getStringExtra(INTENT_PARAMETER_URL);
    if (url == null) {
        url = Constants.BASE_URL_HTTPS;
    }
    callingActivity = intent.getStringExtra(CALLING_ACTIVITY);
    webView = (WebView) findViewById(R.id.webView);
    webView.setWebChromeClient(new WebChromeClient() {

        private ProgressDialog progressCircle;

        @Override
        public void onProgressChanged(WebView view, int progress) {
            if (progressCircle == null) {
                progressCircle = new ProgressDialog(view.getContext(), R.style.WebViewLoadingCircle);
                progressCircle.setCancelable(true);
                progressCircle.setProgressStyle(android.R.style.Widget_ProgressBar_Small);
                try {
                    progressCircle.show();
                } catch (Exception e) {
                    Log.e(TAG, "Exception while showing progress circle", e);
                }
            }
            if (progress == 100) {
                progressCircle.dismiss();
                progressCircle = null;
            }
        }
    });
    webView.setWebViewClient(new MyWebViewClient());
    webView.getSettings().setJavaScriptEnabled(true);
    String language = String.valueOf(Constants.CURRENT_CATROBAT_LANGUAGE_VERSION);
    String flavor = Constants.FLAVOR_DEFAULT;
    String version = Utils.getVersionName(getApplicationContext());
    String platform = Constants.PLATFORM_DEFAULT;
    webView.getSettings().setUserAgentString("Catrobat/" + language + " " + flavor + "/" + version + " Platform/" + platform);
    webView.loadUrl(url);
    webView.setDownloadListener(new DownloadListener() {

        @Override
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
            Log.d(WebViewActivity.class.getSimpleName(), "contentDisposition: " + contentDisposition + "   " + mimetype);
            if (getExtensionFromContentDisposition(contentDisposition).contains(Constants.CATROBAT_EXTENSION)) {
                DownloadUtil.getInstance().prepareDownloadAndStartIfPossible(WebViewActivity.this, url);
            } else if (url.contains(Constants.LIBRARY_BASE_URL)) {
                String name = getMediaNameFromUrl(url);
                String mediaType = getMediaTypeFromContentDisposition(contentDisposition);
                String fileName = name + getExtensionFromContentDisposition(contentDisposition);
                String tempPath = null;
                switch(mediaType) {
                    case Constants.MEDIA_TYPE_LOOK:
                        tempPath = Constants.TMP_LOOKS_PATH;
                        break;
                    case Constants.MEDIA_TYPE_SOUND:
                        tempPath = Constants.TMP_SOUNDS_PATH;
                }
                String filePath = Utils.buildPath(tempPath, fileName);
                resultIntent.putExtra(MEDIA_FILE_PATH, filePath);
                DownloadUtil.getInstance().prepareMediaDownloadAndStartIfPossible(WebViewActivity.this, url, mediaType, name, filePath, callingActivity);
            } else {
                DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
                request.setTitle(getString(R.string.notification_download_title_pending) + " " + DownloadUtil.getInstance().getProjectNameFromUrl(url));
                request.setDescription(getString(R.string.notification_download_pending));
                request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
                request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, DownloadUtil.getInstance().getProjectNameFromUrl(url) + ANDROID_APPLICATION_EXTENSION);
                request.setMimeType(mimetype);
                registerReceiver(onDownloadComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
                DownloadManager downloadManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
                downloadManager.enqueue(request);
            }
        }
    });
}
Example 23
Project: EmopAndroid-master  File: WebViewActivity.java View source code
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.web_view);
    this.web = (WebView) findViewById(R.id.web);
    this.processBar = (ProgressBar) findViewById(R.id.progressbar_loading);
    web.setVerticalScrollBarEnabled(false);
    web.setHorizontalScrollBarEnabled(false);
    //web.getSettings().s
    web.getSettings().setJavaScriptEnabled(true);
    web.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    web.setDownloadListener(new DownloadListener() {

        @Override
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
            Uri uri = Uri.parse(url);
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);
        }
    });
    CookieSyncManager.createInstance(this);
    //web.setWebViewClient(new TaokeWebViewClient());
    titleView = (TextView) findViewById(R.id.title);
    titleView.setLongClickable(true);
    titleView.setOnLongClickListener(new OnLongClickListener() {

        @Override
        public boolean onLongClick(View arg0) {
            if (curURL != null && curURL.length() > 1) {
                Uri uri = Uri.parse(curURL);
                Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                startActivity(intent);
            }
            return false;
        }
    });
}
Example 24
Project: Hybrid-Framework-master  File: RexxarWebViewCore.java View source code
protected DownloadListener getDownloadListener() {
    return new DownloadListener() {

        @Override
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimeType, long contentLength) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            Uri uri = Uri.parse(url);
            intent.setData(uri);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            try {
                getContext().startActivity(intent);
            } catch (ActivityNotFoundException e) {
                e.printStackTrace();
            }
        }
    };
}
Example 25
Project: RedReader-master  File: WebViewFragment.java View source code
@SuppressLint("NewApi")
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
    mActivity = (AppCompatActivity) getActivity();
    CookieSyncManager.createInstance(mActivity);
    outer = (FrameLayout) inflater.inflate(R.layout.web_view_fragment, null);
    final RedditPost src_post = getArguments().getParcelable("post");
    final RedditPreparedPost post;
    if (src_post != null) {
        final RedditParsedPost parsedPost = new RedditParsedPost(src_post, false);
        post = new RedditPreparedPost(mActivity, CacheManager.getInstance(mActivity), 0, parsedPost, -1, false, false);
    } else {
        post = null;
    }
    webView = (WebViewFixed) outer.findViewById(R.id.web_view_fragment_webviewfixed);
    final FrameLayout loadingViewFrame = (FrameLayout) outer.findViewById(R.id.web_view_fragment_loadingview_frame);
    /*handle download links show an alert box to load this outside the internal browser*/
    webView.setDownloadListener(new DownloadListener() {

        @Override
        public void onDownloadStart(final String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
            {
                new AlertDialog.Builder(mActivity).setTitle(R.string.download_link_title).setMessage(R.string.download_link_message).setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                        Intent i = new Intent(Intent.ACTION_VIEW);
                        i.setData(Uri.parse(url));
                        getContext().startActivity(i);
                        //get back from internal browser
                        mActivity.onBackPressed();
                    }
                }).setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                        //get back from internal browser
                        mActivity.onBackPressed();
                    }
                }).setIcon(android.R.drawable.ic_dialog_alert).show();
            }
        }
    });
    /*handle download links end*/
    progressView = new ProgressBar(mActivity, null, android.R.attr.progressBarStyleHorizontal);
    loadingViewFrame.addView(progressView);
    loadingViewFrame.setPadding(General.dpToPixels(mActivity, 10), 0, General.dpToPixels(mActivity, 10), 0);
    final WebSettings settings = webView.getSettings();
    settings.setBuiltInZoomControls(true);
    settings.setJavaScriptEnabled(true);
    settings.setJavaScriptCanOpenWindowsAutomatically(false);
    settings.setUseWideViewPort(true);
    settings.setLoadWithOverviewMode(true);
    settings.setDomStorageEnabled(true);
    if (AndroidApi.isHoneyCombOrLater()) {
        settings.setDisplayZoomControls(false);
    }
    // TODO handle long clicks
    webView.setWebChromeClient(new WebChromeClient() {

        @Override
        public void onProgressChanged(WebView view, final int newProgress) {
            super.onProgressChanged(view, newProgress);
            AndroidApi.UI_THREAD_HANDLER.post(new Runnable() {

                @Override
                public void run() {
                    progressView.setProgress(newProgress);
                    progressView.setVisibility(newProgress == 100 ? View.GONE : View.VISIBLE);
                }
            });
        }
    });
    if (mUrl != null) {
        webView.loadUrl(mUrl);
    } else {
        webView.loadDataWithBaseURL("https://reddit.com/", html, "text/html; charset=UTF-8", null, null);
    }
    webView.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(final WebView view, final String url) {
            if (url == null)
                return false;
            if (url.startsWith("data:")) {
                // Prevent imgur bug where we're directed to some random data URI
                return true;
            }
            // Go back if loading same page to prevent redirect loops.
            if (goingBack && currentUrl != null && url.equals(currentUrl)) {
                General.quickToast(mActivity, String.format(Locale.US, "Handling redirect loop (level %d)", -lastBackDepthAttempt), Toast.LENGTH_SHORT);
                lastBackDepthAttempt--;
                if (webView.canGoBackOrForward(lastBackDepthAttempt)) {
                    webView.goBackOrForward(lastBackDepthAttempt);
                } else {
                    mActivity.finish();
                }
            } else {
                if (RedditURLParser.parse(Uri.parse(url)) != null) {
                    LinkHandler.onLinkClicked(mActivity, url, false);
                } else {
                    webView.loadUrl(url);
                    currentUrl = url;
                }
            }
            return true;
        }

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            super.onPageStarted(view, url, favicon);
            if (mUrl != null && url != null) {
                final AppCompatActivity activity = mActivity;
                if (activity != null) {
                    activity.setTitle(url);
                }
            }
        }

        @Override
        public void onPageFinished(final WebView view, final String url) {
            super.onPageFinished(view, url);
            new Timer().schedule(new TimerTask() {

                @Override
                public void run() {
                    AndroidApi.UI_THREAD_HANDLER.post(new Runnable() {

                        @Override
                        public void run() {
                            if (currentUrl == null || url == null)
                                return;
                            if (!url.equals(view.getUrl()))
                                return;
                            if (goingBack && url.equals(currentUrl)) {
                                General.quickToast(mActivity, String.format(Locale.US, "Handling redirect loop (level %d)", -lastBackDepthAttempt));
                                lastBackDepthAttempt--;
                                if (webView.canGoBackOrForward(lastBackDepthAttempt)) {
                                    webView.goBackOrForward(lastBackDepthAttempt);
                                } else {
                                    mActivity.finish();
                                }
                            } else {
                                goingBack = false;
                            }
                        }
                    });
                }
            }, 1000);
        }

        @Override
        public void doUpdateVisitedHistory(WebView view, String url, boolean isReload) {
            super.doUpdateVisitedHistory(view, url, isReload);
        }
    });
    final FrameLayout outerFrame = new FrameLayout(mActivity);
    outerFrame.addView(outer);
    if (post != null) {
        final SideToolbarOverlay toolbarOverlay = new SideToolbarOverlay(mActivity);
        final BezelSwipeOverlay bezelOverlay = new BezelSwipeOverlay(mActivity, new BezelSwipeOverlay.BezelSwipeListener() {

            @Override
            public boolean onSwipe(@BezelSwipeOverlay.SwipeEdge int edge) {
                toolbarOverlay.setContents(post.generateToolbar(mActivity, false, toolbarOverlay));
                toolbarOverlay.show(edge == BezelSwipeOverlay.LEFT ? SideToolbarOverlay.SideToolbarPosition.LEFT : SideToolbarOverlay.SideToolbarPosition.RIGHT);
                return true;
            }

            @Override
            public boolean onTap() {
                if (toolbarOverlay.isShown()) {
                    toolbarOverlay.hide();
                    return true;
                }
                return false;
            }
        });
        outerFrame.addView(bezelOverlay);
        outerFrame.addView(toolbarOverlay);
        bezelOverlay.getLayoutParams().width = android.widget.FrameLayout.LayoutParams.MATCH_PARENT;
        bezelOverlay.getLayoutParams().height = android.widget.FrameLayout.LayoutParams.MATCH_PARENT;
        toolbarOverlay.getLayoutParams().width = android.widget.FrameLayout.LayoutParams.MATCH_PARENT;
        toolbarOverlay.getLayoutParams().height = android.widget.FrameLayout.LayoutParams.MATCH_PARENT;
    }
    return outerFrame;
}
Example 26
Project: rexxar-android-master  File: RexxarWebViewCore.java View source code
protected DownloadListener getDownloadListener() {
    return new DownloadListener() {

        @Override
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimeType, long contentLength) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            Uri uri = Uri.parse(url);
            intent.setData(uri);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            try {
                getContext().startActivity(intent);
            } catch (ActivityNotFoundException e) {
                e.printStackTrace();
            }
        }
    };
}
Example 27
Project: slide-master  File: PeekMediaView.java View source code
public void doLoadLink(String url) {
    client = new MyWebViewClient();
    web = true;
    webClient = new WebViewClient() {

        @Override
        public void onPageFinished(WebView view, String url) {
            website.loadUrl("javascript:(function() { document.getElementsByTagName('video')[0].play(); })()");
        }

        private Map<String, Boolean> loadedUrls = new HashMap<>();

        @Override
        public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
            boolean ad;
            if (!loadedUrls.containsKey(url)) {
                ad = AdBlocker.isAd(url, getContext());
                loadedUrls.put(url, ad);
            } else {
                ad = loadedUrls.get(url);
            }
            return ad && SettingValues.tabletUI ? AdBlocker.createEmptyResource() : super.shouldInterceptRequest(view, url);
        }
    };
    website.setVisibility(View.VISIBLE);
    website.setWebChromeClient(client);
    website.setWebViewClient(webClient);
    website.getSettings().setBuiltInZoomControls(true);
    website.getSettings().setDisplayZoomControls(false);
    website.getSettings().setJavaScriptEnabled(true);
    website.getSettings().setLoadWithOverviewMode(true);
    website.getSettings().setUseWideViewPort(true);
    website.setDownloadListener(new DownloadListener() {

        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
            //Downloads using download manager on default browser
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(url));
            getContext().startActivity(i);
        }
    });
    website.loadUrl(url);
}
Example 28
Project: android_packages_apps-master  File: Tab.java View source code
/**
     * Sets the WebView for this tab, correctly removing the old WebView from
     * the container view.
     */
void setWebView(WebView w) {
    if (mMainView == w) {
        return;
    }
    // Geolocation permission requests are void.
    if (mGeolocationPermissionsPrompt != null) {
        mGeolocationPermissionsPrompt.hide();
    }
    mWebViewController.onSetWebView(this, w);
    if (mMainView != null) {
        mMainView.setPictureListener(null);
        if (w != null) {
            syncCurrentState(w, null);
        } else {
            mCurrentState = new PageState(mContext, false);
        }
    }
    // set the new one
    mMainView = w;
    // attach the WebViewClient, WebChromeClient and DownloadListener
    if (mMainView != null) {
        mMainView.setWebViewClient(mWebViewClient);
        mMainView.setWebChromeClient(mWebChromeClient);
        // Attach DownloadManager so that downloads can start in an active
        // or a non-active window. This can happen when going to a site that
        // does a redirect after a period of time. The user could have
        // switched to another tab while waiting for the download to start.
        mMainView.setDownloadListener(mDownloadListener);
        mMainView.setWebBackForwardListClient(mWebBackForwardListClient);
        TabControl tc = mWebViewController.getTabControl();
        if (tc != null && tc.getOnThumbnailUpdatedListener() != null) {
            mMainView.setPictureListener(this);
        }
        if (mSavedState != null) {
            WebBackForwardList restoredState = mMainView.restoreState(mSavedState);
            if (restoredState == null || restoredState.getSize() == 0) {
                Log.w(LOGTAG, "Failed to restore WebView state!");
                loadUrl(mCurrentState.mOriginalUrl, null);
            }
            mSavedState = null;
        }
    }
}
Example 29
Project: browser.apk-master  File: PopularUrlsTest.java View source code
void setupBrowserInternal() {
    Tab tab = mController.getTabControl().getCurrentTab();
    WebView webView = tab.getWebView();
    webView.setWebChromeClient(new TestWebChromeClient(WebViewClassic.fromWebView(webView).getWebChromeClient()) {

        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            super.onProgressChanged(view, newProgress);
            if (newProgress >= 100) {
                if (!pageProgressFull) {
                    // void duplicate calls
                    pageProgressFull = true;
                    if (pageLoadFinishCalled) {
                        //reset latch and move forward only if both indicators are true
                        resetLatch();
                    }
                }
            }
        }

        /**
             * Dismisses and logs Javascript alerts.
             */
        @Override
        public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
            String logMsg = String.format("JS Alert '%s' received from %s", message, url);
            Log.w(TAG, logMsg);
            result.confirm();
            return true;
        }

        /**
             * Confirms and logs Javascript alerts.
             */
        @Override
        public boolean onJsConfirm(WebView view, String url, String message, JsResult result) {
            String logMsg = String.format("JS Confirmation '%s' received from %s", message, url);
            Log.w(TAG, logMsg);
            result.confirm();
            return true;
        }

        /**
             * Confirms and logs Javascript alerts, providing the default value.
             */
        @Override
        public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) {
            String logMsg = String.format("JS Prompt '%s' received from %s; " + "Giving default value '%s'", message, url, defaultValue);
            Log.w(TAG, logMsg);
            result.confirm(defaultValue);
            return true;
        }

        /*
             * Skip the unload confirmation
             */
        @Override
        public boolean onJsBeforeUnload(WebView view, String url, String message, JsResult result) {
            result.confirm();
            return true;
        }
    });
    webView.setWebViewClient(new TestWebViewClient(WebViewClassic.fromWebView(webView).getWebViewClient()) {

        /**
             * Bypasses and logs errors.
             */
        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            String message = String.format("Error '%s' (%d) loading url: %s", description, errorCode, failingUrl);
            Log.w(TAG, message);
        }

        /**
             * Ignores and logs SSL errors.
             */
        @Override
        public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
            Log.w(TAG, "SSL error: " + error);
            handler.proceed();
        }

        /**
             * Ignores and logs SSL client certificate requests.
             */
        @Override
        public void onReceivedClientCertRequest(WebView view, ClientCertRequestHandler handler, String host_and_port) {
            Log.w(TAG, "SSL client certificate request: " + host_and_port);
            handler.cancel();
        }

        /**
             * Ignores http auth with dummy username and password
             */
        @Override
        public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm) {
            handler.proceed("user", "passwd");
        }

        /* (non-Javadoc)
             * @see com.android.browser.TestWebViewClient#onPageFinished(android.webkit.WebView, java.lang.String)
             */
        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            if (!pageLoadFinishCalled) {
                pageLoadFinishCalled = true;
                if (pageProgressFull) {
                    //reset latch and move forward only if both indicators are true
                    resetLatch();
                }
            }
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (!(url.startsWith("http://") || url.startsWith("https://"))) {
                Log.v(TAG, String.format("suppressing non-http url scheme: %s", url));
                return true;
            }
            return super.shouldOverrideUrlLoading(view, url);
        }
    });
    webView.setDownloadListener(new DownloadListener() {

        @Override
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
            Log.v(TAG, String.format("Download request ignored: %s", url));
        }
    });
}
Example 30
Project: QEditor-master  File: MTubebook.java View source code
/**
     * Start the WebView
     */
public void startWV() {
    //执行�始化函数
    initWebView();
    MyBean bean = new MyBean(this);
    bean.setTitle("MILIB");
    wv.addJavascriptInterface(bean, "milib");
    wv.setOnTouchListener(this);
    wv.requestFocus();
    wv.setDownloadListener(new DownloadListener() {

        @SuppressWarnings("deprecation")
        @Override
        public void onDownloadStart(final String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
            //String dir = FileHelper.getTypeByMimeType(mimetype);
            String filename = FileHelper.getFileNameFromUrl(url);
            //Toast.makeText(getApplicationContext(), "Download(mimetype:"+mimetype+")(contentDisposition:"+contentDisposition+")(contentLength:"+contentLength+")(dir:"+dir+")(file:"+filename+"):"+url, Toast.LENGTH_LONG).show();
            //Log.d(TAG, "Download(mimetype:"+mimetype+")(contentDisposition:"+contentDisposition+")(contentLength:"+contentLength+")(dir:"+dir+")(file:"+filename+"):"+url);
            EditText termT = (EditText) findViewById(R.id.url_input);
            WebBackForwardList mWebBackForwardList = wv.copyBackForwardList();
            try {
                String historyUrl = mWebBackForwardList.getItemAtIndex(mWebBackForwardList.getCurrentIndex()).getUrl();
                termT.setText(historyUrl);
            } catch (Exception e) {
            }
            // Download confirm
            /*String root = NAction.getDefaultRoot(getApplicationContext());
    	        String rootDir;
    			try {
    				if (root.equals("")) {
    					rootDir = new File(FileHelper.getBasePath(CONF.BASE_PATH, CONF.DFROM_LOCAL),"").getAbsolutePath();
    				} else {
    					rootDir = root;
    				}

    				String ext = "."+FileHelper.getExt(FileHelper.getFileName(NUtil.getPathFromUrl(url)), "dat");
					*/
            String savePath = filename;
            WBase.setTxtDialogParam(0, R.string.download_as, savePath, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    AlertDialog ad = (AlertDialog) dialog;
                    EditText t = (EditText) ad.findViewById(R.id.editText_prompt);
                    String content = t.getText().toString();
                    String ext = FileHelper.getExt(content, "dat");
                    String title = content.substring(0, content.lastIndexOf("." + ext));
                    downloadReceiver(title, url, ext);
                }
            }, null);
            showDialog(_WBase.DIALOG_TEXT_ENTRY + dialogIndex);
            dialogIndex++;
        /*} catch (Exception e) {
    				
    			}*/
        }
    });
    //if (NUtil.netCheckin(getApplicationContext())) {
    //NAction.userProxy(getApplicationContext());
    //String lang = NUtil.getLang();
    //Log.d(TAG, "lang:"+lang);
    String mediaUrl = NAction.getMediaCenter(getApplicationContext());
    Intent i = getIntent();
    if (i.getData() != null) {
        mediaUrl = i.getDataString();
    } else {
        mediaUrl = "file:///android_asset/mbox/md3.html";
        String lang = NUtil.getLang();
        if (lang.equals("zh")) {
            mediaUrl = "file:///android_asset/mbox/md3_zh.html";
        }
    }
    /**
             * Convert the markdown to HTML for displaying in the WebView 
             */
    if (mediaUrl.endsWith(".md")) {
        try {
            String markupToTranslate = readFile(mediaUrl.substring(7));
            String htmlContent = new Markdown4jProcessor().process(markupToTranslate);
            wv.loadDataWithBaseURL("md://" + mediaUrl.substring(7), htmlContent, "text/html", "UTF-8", "");
        //wv.loadData(htmlContent, "text/html", "UTF-8");
        } catch (IOException e) {
            e.printStackTrace();
        }
    } else {
        EditText termT = (EditText) findViewById(R.id.url_input);
        termT.setText(mediaUrl);
        loadurl(wv, mediaUrl);
    }
/*} else {
    		
			String html5file = "file:///android_asset/mbox/md3.html";
    		String lang = NUtil.getLang();

			if (lang.equals("zh")) {
				html5file = "file:///android_asset/mbox/md3_zh.html";
			}
            Intent i = getIntent();
            if (i.getData() != null) {
            	html5file = i.getDataString();
            	Toast.makeText(getApplicationContext(), R.string.need_network, Toast.LENGTH_SHORT).show();
            } 
            
	    	EditText termT = (EditText)findViewById(R.id.url_input);    	
	    	termT.setText(html5file);

			loadurl(wv, html5file);
    	}*/
}
Example 31
Project: android-search-and-stories-master  File: WebFragment.java View source code
public void init() {
    keyboardService = new KeyboardService(getActivity());
    mainWebView = (DDGWebView) fragmentView.findViewById(R.id.fragmentMainWebView);
    mainWebView.setParentActivity(getActivity());
    mainWebView.getSettings().setJavaScriptEnabled(PreferencesManager.getEnableJavascript());
    Log.e("javascript_enabled", PreferencesManager.getEnableJavascript() + "");
    DDGWebView.recordCookies(PreferencesManager.getRecordCookies());
    DDGNetworkConstants.setWebView(mainWebView);
    // get default User-Agent string for reuse later
    mWebViewDefaultUA = mainWebView.getSettings().getUserAgentString();
    mainWebView.setWebViewClient(new DDGWebViewClient(getActivity(), this));
    View hideContent = getActivity().findViewById(R.id.main_container);
    ViewGroup showContent = (ViewGroup) getActivity().findViewById(R.id.fullscreen_video_container);
    mainWebView.setWebChromeClient(new DDGWebChromeClient(getActivity(), hideContent, showContent));
    contentDownloader = new ContentDownloader(getActivity());
    mainWebView.setDownloadListener(new DownloadListener() {

        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
            contentDownloader.downloadContent(url, mimetype);
        }
    });
    //https://code.google.com/p/android/issues/detail?id=80434
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB_MR2) {
        mainWebView.setOnLongClickListener(new View.OnLongClickListener() {

            @Override
            public boolean onLongClick(View v) {
                return true;
            }
        });
        mainWebView.setLongClickable(false);
    }
    webMenu = new MenuBuilder(getActivity());
    getActivity().getMenuInflater().inflate(R.menu.feed, webMenu);
    headerMenu = new MenuBuilder(getActivity());
    getActivity().getMenuInflater().inflate(R.menu.web_navigation, headerMenu);
    mainMenu = new MenuBuilder(getActivity());
    getActivity().getMenuInflater().inflate(R.menu.main, mainMenu);
    Bundle args = getArguments();
    if (args != null) {
        String url = null;
        if (args.containsKey(URL))
            url = args.getString(URL);
        SESSIONTYPE sessionType = SESSIONTYPE.SESSION_BROWSE;
        if (args.containsKey(SESSION_TYPE))
            sessionType = SESSIONTYPE.getByCode(args.getInt(SESSION_TYPE));
        if (url != null) {
            searchOrGoToUrl(url, sessionType);
        }
    }
}
Example 32
Project: Favorite-Android-Client-Example-master  File: document_read.java View source code
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
    HeaderListAdapter ca = (HeaderListAdapter) arg0.getAdapter();
    HeaderList ls = (HeaderList) ca.getItem(arg2);
    try {
        if (ls.getPath().endsWith("jpg")) {
            Intent intent = new Intent(document_read.this, GalleryView.class);
            intent.putExtra("path", String.valueOf(ls.getPath()));
            startActivity(intent);
        } else {
            webview = new WebView(ct);
            webview.setDownloadListener(new DownloadListener() {

                @Override
                public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
                    Global.toast(getString(R.string.start_downloading));
                    Filedw.startdownload(url, userAgent, contentDisposition, mimetype, contentLength);
                    webview.setDownloadListener(null);
                    webview = null;
                }
            });
            webview.loadUrl(ls.getPath());
        }
    } catch (Exception e) {
    }
}
Example 33
Project: Favorite-Android-Client-master  File: document_read.java View source code
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
    HeaderListAdapter ca = (HeaderListAdapter) arg0.getAdapter();
    HeaderList ls = (HeaderList) ca.getItem(arg2);
    try {
        if (ls.getPath().endsWith("jpg")) {
            Intent intent = new Intent(document_read.this, GalleryView.class);
            intent.putExtra("path", String.valueOf(ls.getPath()));
            startActivity(intent);
        } else {
            webview = new WebView(ct);
            webview.setDownloadListener(new DownloadListener() {

                @Override
                public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
                    Global.toast(getString(R.string.start_downloading));
                    Filedw.startdownload(url, userAgent, contentDisposition, mimetype, contentLength);
                    webview.setDownloadListener(null);
                    webview = null;
                }
            });
            webview.loadUrl(ls.getPath());
        }
    } catch (Exception e) {
    }
}
Example 34
Project: Orweb-master  File: Browser.java View source code
private void initUI() {
    // Grab UI elements
    mWebView = (BrowserWebView) findViewById(R.id.WebView);
    mWebView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (mWebView.getScrollY() > 10)
                Browser.this.getSupportActionBar().hide();
            else
                Browser.this.getSupportActionBar().show();
            return false;
        }
    });
    //mNoTorLayout = (LinearLayout) findViewById(R.id.NoTorLayout);
    //mStartTor = (Button) findViewById(R.id.StartTor);
    mCookieIcon = (LinearLayout) findViewById(R.id.CookieIcon);
    //mTorStatus = (TextView) findViewById(R.id.torStatus);
    mCookieIcon.setOnClickListener(this);
    // Misc
    mGenericFavicon = getResources().getDrawable(R.drawable.app_web_browser_sm);
    // Set up UI elements
    //mStartTor.setOnClickListener(this);
    mWebView.setWebViewClient(mWebViewClient);
    mWebView.setWebChromeClient(mWebViewChrome);
    mWebView.setDownloadListener(new DownloadListener() {

        @Override
        public void onDownloadStart(final String url, String userAgent, String contentDisposition, final String mimetype, long contentLength) {
            final AlertDialog.Builder downloadDialog = new AlertDialog.Builder(Browser.this);
            downloadDialog.setTitle(info.guardianproject.browser.R.string.title_download_manager);
            downloadDialog.setMessage(getString(info.guardianproject.browser.R.string.prompt_would_you_like_to_download_this_file_) + '\n' + mimetype + '\n' + url);
            downloadDialog.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialogInterface, int i) {
                    doProxiedDownload(url, mimetype);
                    dialogInterface.dismiss();
                }
            });
            downloadDialog.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialogInterface, int i) {
                }
            });
            downloadDialog.show();
        }
    });
    mWebView.clearFormData();
    mWebView.clearCache(true);
    mWebView.clearHistory();
}
Example 35
Project: Android-AdvancedWebView-master  File: AdvancedWebView.java View source code
@SuppressLint({ "SetJavaScriptEnabled" })
protected void init(Context context) {
    // in IDE's preview mode
    if (isInEditMode()) {
        // do not run the code from this method
        return;
    }
    if (context instanceof Activity) {
        mActivity = new WeakReference<Activity>((Activity) context);
    }
    mLanguageIso3 = getLanguageIso3();
    setFocusable(true);
    setFocusableInTouchMode(true);
    setSaveEnabled(true);
    final String filesDir = context.getFilesDir().getPath();
    final String databaseDir = filesDir.substring(0, filesDir.lastIndexOf("/")) + DATABASES_SUB_FOLDER;
    final WebSettings webSettings = getSettings();
    webSettings.setAllowFileAccess(false);
    setAllowAccessFromFileUrls(webSettings, false);
    webSettings.setBuiltInZoomControls(false);
    webSettings.setJavaScriptEnabled(true);
    webSettings.setDomStorageEnabled(true);
    if (Build.VERSION.SDK_INT < 18) {
        webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);
    }
    webSettings.setDatabaseEnabled(true);
    if (Build.VERSION.SDK_INT < 19) {
        webSettings.setDatabasePath(databaseDir);
    }
    setMixedContentAllowed(webSettings, true);
    setThirdPartyCookiesEnabled(true);
    super.setWebViewClient(new WebViewClient() {

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            if (!hasError()) {
                if (mListener != null) {
                    mListener.onPageStarted(url, favicon);
                }
            }
            if (mCustomWebViewClient != null) {
                mCustomWebViewClient.onPageStarted(view, url, favicon);
            }
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            if (!hasError()) {
                if (mListener != null) {
                    mListener.onPageFinished(url);
                }
            }
            if (mCustomWebViewClient != null) {
                mCustomWebViewClient.onPageFinished(view, url);
            }
        }

        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            setLastError();
            if (mListener != null) {
                mListener.onPageError(errorCode, description, failingUrl);
            }
            if (mCustomWebViewClient != null) {
                mCustomWebViewClient.onReceivedError(view, errorCode, description, failingUrl);
            }
        }

        @Override
        public boolean shouldOverrideUrlLoading(final WebView view, final String url) {
            // if the hostname may not be accessed
            if (!isHostnameAllowed(url)) {
                // if a listener is available
                if (mListener != null) {
                    // inform the listener about the request
                    mListener.onExternalPageRequest(url);
                }
                // cancel the original request
                return true;
            }
            // if there is a user-specified handler available
            if (mCustomWebViewClient != null) {
                // if the user-specified handler asks to override the request
                if (mCustomWebViewClient.shouldOverrideUrlLoading(view, url)) {
                    // cancel the original request
                    return true;
                }
            }
            // route the request through the custom URL loading method
            view.loadUrl(url);
            // cancel the original request
            return true;
        }

        @Override
        public void onLoadResource(WebView view, String url) {
            if (mCustomWebViewClient != null) {
                mCustomWebViewClient.onLoadResource(view, url);
            } else {
                super.onLoadResource(view, url);
            }
        }

        @SuppressLint("NewApi")
        @SuppressWarnings("all")
        public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
            if (Build.VERSION.SDK_INT >= 11) {
                if (mCustomWebViewClient != null) {
                    return mCustomWebViewClient.shouldInterceptRequest(view, url);
                } else {
                    return super.shouldInterceptRequest(view, url);
                }
            } else {
                return null;
            }
        }

        @SuppressLint("NewApi")
        @SuppressWarnings("all")
        public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
            if (Build.VERSION.SDK_INT >= 21) {
                if (mCustomWebViewClient != null) {
                    return mCustomWebViewClient.shouldInterceptRequest(view, request);
                } else {
                    return super.shouldInterceptRequest(view, request);
                }
            } else {
                return null;
            }
        }

        @Override
        public void onFormResubmission(WebView view, Message dontResend, Message resend) {
            if (mCustomWebViewClient != null) {
                mCustomWebViewClient.onFormResubmission(view, dontResend, resend);
            } else {
                super.onFormResubmission(view, dontResend, resend);
            }
        }

        @Override
        public void doUpdateVisitedHistory(WebView view, String url, boolean isReload) {
            if (mCustomWebViewClient != null) {
                mCustomWebViewClient.doUpdateVisitedHistory(view, url, isReload);
            } else {
                super.doUpdateVisitedHistory(view, url, isReload);
            }
        }

        @Override
        public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
            if (mCustomWebViewClient != null) {
                mCustomWebViewClient.onReceivedSslError(view, handler, error);
            } else {
                super.onReceivedSslError(view, handler, error);
            }
        }

        @SuppressLint("NewApi")
        @SuppressWarnings("all")
        public void onReceivedClientCertRequest(WebView view, ClientCertRequest request) {
            if (Build.VERSION.SDK_INT >= 21) {
                if (mCustomWebViewClient != null) {
                    mCustomWebViewClient.onReceivedClientCertRequest(view, request);
                } else {
                    super.onReceivedClientCertRequest(view, request);
                }
            }
        }

        @Override
        public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm) {
            if (mCustomWebViewClient != null) {
                mCustomWebViewClient.onReceivedHttpAuthRequest(view, handler, host, realm);
            } else {
                super.onReceivedHttpAuthRequest(view, handler, host, realm);
            }
        }

        @Override
        public boolean shouldOverrideKeyEvent(WebView view, KeyEvent event) {
            if (mCustomWebViewClient != null) {
                return mCustomWebViewClient.shouldOverrideKeyEvent(view, event);
            } else {
                return super.shouldOverrideKeyEvent(view, event);
            }
        }

        @Override
        public void onUnhandledKeyEvent(WebView view, KeyEvent event) {
            if (mCustomWebViewClient != null) {
                mCustomWebViewClient.onUnhandledKeyEvent(view, event);
            } else {
                super.onUnhandledKeyEvent(view, event);
            }
        }

        @SuppressLint("NewApi")
        @SuppressWarnings("all")
        public void onUnhandledInputEvent(WebView view, InputEvent event) {
            if (Build.VERSION.SDK_INT >= 21) {
                if (mCustomWebViewClient != null) {
                    mCustomWebViewClient.onUnhandledInputEvent(view, event);
                } else {
                    super.onUnhandledInputEvent(view, event);
                }
            }
        }

        @Override
        public void onScaleChanged(WebView view, float oldScale, float newScale) {
            if (mCustomWebViewClient != null) {
                mCustomWebViewClient.onScaleChanged(view, oldScale, newScale);
            } else {
                super.onScaleChanged(view, oldScale, newScale);
            }
        }

        @SuppressLint("NewApi")
        @SuppressWarnings("all")
        public void onReceivedLoginRequest(WebView view, String realm, String account, String args) {
            if (Build.VERSION.SDK_INT >= 12) {
                if (mCustomWebViewClient != null) {
                    mCustomWebViewClient.onReceivedLoginRequest(view, realm, account, args);
                } else {
                    super.onReceivedLoginRequest(view, realm, account, args);
                }
            }
        }
    });
    super.setWebChromeClient(new WebChromeClient() {

        // file upload callback (Android 2.2 (API level 8) -- Android 2.3 (API level 10)) (hidden method)
        @SuppressWarnings("unused")
        public void openFileChooser(ValueCallback<Uri> uploadMsg) {
            openFileChooser(uploadMsg, null);
        }

        // file upload callback (Android 3.0 (API level 11) -- Android 4.0 (API level 15)) (hidden method)
        public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {
            openFileChooser(uploadMsg, acceptType, null);
        }

        // file upload callback (Android 4.1 (API level 16) -- Android 4.3 (API level 18)) (hidden method)
        @SuppressWarnings("unused")
        public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
            openFileInput(uploadMsg, null, false);
        }

        // file upload callback (Android 5.0 (API level 21) -- current) (public method)
        @SuppressWarnings("all")
        public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) {
            if (Build.VERSION.SDK_INT >= 21) {
                final boolean allowMultiple = fileChooserParams.getMode() == FileChooserParams.MODE_OPEN_MULTIPLE;
                openFileInput(null, filePathCallback, allowMultiple);
                return true;
            } else {
                return false;
            }
        }

        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            if (mCustomWebChromeClient != null) {
                mCustomWebChromeClient.onProgressChanged(view, newProgress);
            } else {
                super.onProgressChanged(view, newProgress);
            }
        }

        @Override
        public void onReceivedTitle(WebView view, String title) {
            if (mCustomWebChromeClient != null) {
                mCustomWebChromeClient.onReceivedTitle(view, title);
            } else {
                super.onReceivedTitle(view, title);
            }
        }

        @Override
        public void onReceivedIcon(WebView view, Bitmap icon) {
            if (mCustomWebChromeClient != null) {
                mCustomWebChromeClient.onReceivedIcon(view, icon);
            } else {
                super.onReceivedIcon(view, icon);
            }
        }

        @Override
        public void onReceivedTouchIconUrl(WebView view, String url, boolean precomposed) {
            if (mCustomWebChromeClient != null) {
                mCustomWebChromeClient.onReceivedTouchIconUrl(view, url, precomposed);
            } else {
                super.onReceivedTouchIconUrl(view, url, precomposed);
            }
        }

        @Override
        public void onShowCustomView(View view, CustomViewCallback callback) {
            if (mCustomWebChromeClient != null) {
                mCustomWebChromeClient.onShowCustomView(view, callback);
            } else {
                super.onShowCustomView(view, callback);
            }
        }

        @SuppressLint("NewApi")
        @SuppressWarnings("all")
        public void onShowCustomView(View view, int requestedOrientation, CustomViewCallback callback) {
            if (Build.VERSION.SDK_INT >= 14) {
                if (mCustomWebChromeClient != null) {
                    mCustomWebChromeClient.onShowCustomView(view, requestedOrientation, callback);
                } else {
                    super.onShowCustomView(view, requestedOrientation, callback);
                }
            }
        }

        @Override
        public void onHideCustomView() {
            if (mCustomWebChromeClient != null) {
                mCustomWebChromeClient.onHideCustomView();
            } else {
                super.onHideCustomView();
            }
        }

        @Override
        public boolean onCreateWindow(WebView view, boolean isDialog, boolean isUserGesture, Message resultMsg) {
            if (mCustomWebChromeClient != null) {
                return mCustomWebChromeClient.onCreateWindow(view, isDialog, isUserGesture, resultMsg);
            } else {
                return super.onCreateWindow(view, isDialog, isUserGesture, resultMsg);
            }
        }

        @Override
        public void onRequestFocus(WebView view) {
            if (mCustomWebChromeClient != null) {
                mCustomWebChromeClient.onRequestFocus(view);
            } else {
                super.onRequestFocus(view);
            }
        }

        @Override
        public void onCloseWindow(WebView window) {
            if (mCustomWebChromeClient != null) {
                mCustomWebChromeClient.onCloseWindow(window);
            } else {
                super.onCloseWindow(window);
            }
        }

        @Override
        public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
            if (mCustomWebChromeClient != null) {
                return mCustomWebChromeClient.onJsAlert(view, url, message, result);
            } else {
                return super.onJsAlert(view, url, message, result);
            }
        }

        @Override
        public boolean onJsConfirm(WebView view, String url, String message, JsResult result) {
            if (mCustomWebChromeClient != null) {
                return mCustomWebChromeClient.onJsConfirm(view, url, message, result);
            } else {
                return super.onJsConfirm(view, url, message, result);
            }
        }

        @Override
        public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) {
            if (mCustomWebChromeClient != null) {
                return mCustomWebChromeClient.onJsPrompt(view, url, message, defaultValue, result);
            } else {
                return super.onJsPrompt(view, url, message, defaultValue, result);
            }
        }

        @Override
        public boolean onJsBeforeUnload(WebView view, String url, String message, JsResult result) {
            if (mCustomWebChromeClient != null) {
                return mCustomWebChromeClient.onJsBeforeUnload(view, url, message, result);
            } else {
                return super.onJsBeforeUnload(view, url, message, result);
            }
        }

        @Override
        public void onGeolocationPermissionsShowPrompt(String origin, Callback callback) {
            if (mGeolocationEnabled) {
                callback.invoke(origin, true, false);
            } else {
                if (mCustomWebChromeClient != null) {
                    mCustomWebChromeClient.onGeolocationPermissionsShowPrompt(origin, callback);
                } else {
                    super.onGeolocationPermissionsShowPrompt(origin, callback);
                }
            }
        }

        @Override
        public void onGeolocationPermissionsHidePrompt() {
            if (mCustomWebChromeClient != null) {
                mCustomWebChromeClient.onGeolocationPermissionsHidePrompt();
            } else {
                super.onGeolocationPermissionsHidePrompt();
            }
        }

        @SuppressLint("NewApi")
        @SuppressWarnings("all")
        public void onPermissionRequest(PermissionRequest request) {
            if (Build.VERSION.SDK_INT >= 21) {
                if (mCustomWebChromeClient != null) {
                    mCustomWebChromeClient.onPermissionRequest(request);
                } else {
                    super.onPermissionRequest(request);
                }
            }
        }

        @SuppressLint("NewApi")
        @SuppressWarnings("all")
        public void onPermissionRequestCanceled(PermissionRequest request) {
            if (Build.VERSION.SDK_INT >= 21) {
                if (mCustomWebChromeClient != null) {
                    mCustomWebChromeClient.onPermissionRequestCanceled(request);
                } else {
                    super.onPermissionRequestCanceled(request);
                }
            }
        }

        @Override
        public boolean onJsTimeout() {
            if (mCustomWebChromeClient != null) {
                return mCustomWebChromeClient.onJsTimeout();
            } else {
                return super.onJsTimeout();
            }
        }

        @Override
        public void onConsoleMessage(String message, int lineNumber, String sourceID) {
            if (mCustomWebChromeClient != null) {
                mCustomWebChromeClient.onConsoleMessage(message, lineNumber, sourceID);
            } else {
                super.onConsoleMessage(message, lineNumber, sourceID);
            }
        }

        @Override
        public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
            if (mCustomWebChromeClient != null) {
                return mCustomWebChromeClient.onConsoleMessage(consoleMessage);
            } else {
                return super.onConsoleMessage(consoleMessage);
            }
        }

        @Override
        public Bitmap getDefaultVideoPoster() {
            if (mCustomWebChromeClient != null) {
                return mCustomWebChromeClient.getDefaultVideoPoster();
            } else {
                return super.getDefaultVideoPoster();
            }
        }

        @Override
        public View getVideoLoadingProgressView() {
            if (mCustomWebChromeClient != null) {
                return mCustomWebChromeClient.getVideoLoadingProgressView();
            } else {
                return super.getVideoLoadingProgressView();
            }
        }

        @Override
        public void getVisitedHistory(ValueCallback<String[]> callback) {
            if (mCustomWebChromeClient != null) {
                mCustomWebChromeClient.getVisitedHistory(callback);
            } else {
                super.getVisitedHistory(callback);
            }
        }

        @Override
        public void onExceededDatabaseQuota(String url, String databaseIdentifier, long quota, long estimatedDatabaseSize, long totalQuota, QuotaUpdater quotaUpdater) {
            if (mCustomWebChromeClient != null) {
                mCustomWebChromeClient.onExceededDatabaseQuota(url, databaseIdentifier, quota, estimatedDatabaseSize, totalQuota, quotaUpdater);
            } else {
                super.onExceededDatabaseQuota(url, databaseIdentifier, quota, estimatedDatabaseSize, totalQuota, quotaUpdater);
            }
        }

        @Override
        public void onReachedMaxAppCacheSize(long requiredStorage, long quota, QuotaUpdater quotaUpdater) {
            if (mCustomWebChromeClient != null) {
                mCustomWebChromeClient.onReachedMaxAppCacheSize(requiredStorage, quota, quotaUpdater);
            } else {
                super.onReachedMaxAppCacheSize(requiredStorage, quota, quotaUpdater);
            }
        }
    });
    setDownloadListener(new DownloadListener() {

        @Override
        public void onDownloadStart(final String url, final String userAgent, final String contentDisposition, final String mimeType, final long contentLength) {
            final String suggestedFilename = URLUtil.guessFileName(url, contentDisposition, mimeType);
            if (mListener != null) {
                mListener.onDownloadRequested(url, suggestedFilename, mimeType, contentLength, contentDisposition, userAgent);
            }
        }
    });
}
Example 36
Project: gaeproxy-master  File: MainActivity.java View source code
/**
	 * Initialize a newly created WebView.
	 */
private void initializeCurrentWebView() {
    mCurrentWebView.setWebViewClient(new CustomWebViewClient(this));
    mCurrentWebView.setOnTouchListener(this);
    mCurrentWebView.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {

        @Override
        public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
            HitTestResult result = ((WebView) v).getHitTestResult();
            int resultType = result.getType();
            if ((resultType == HitTestResult.ANCHOR_TYPE) || (resultType == HitTestResult.IMAGE_ANCHOR_TYPE) || (resultType == HitTestResult.SRC_ANCHOR_TYPE) || (resultType == HitTestResult.SRC_IMAGE_ANCHOR_TYPE)) {
                Intent i = new Intent();
                i.putExtra(Constants.EXTRA_ID_URL, result.getExtra());
                MenuItem item = menu.add(0, CONTEXT_MENU_OPEN, 0, R.string.Main_MenuOpen);
                item.setIntent(i);
                item = menu.add(0, CONTEXT_MENU_OPEN_IN_NEW_TAB, 0, R.string.Main_MenuOpenNewTab);
                item.setIntent(i);
                item = menu.add(0, CONTEXT_MENU_COPY, 0, R.string.Main_MenuCopyLinkUrl);
                item.setIntent(i);
                item = menu.add(0, CONTEXT_MENU_DOWNLOAD, 0, R.string.Main_MenuDownload);
                item.setIntent(i);
                item = menu.add(0, CONTEXT_MENU_SHARE, 0, R.string.Main_MenuShareLinkUrl);
                item.setIntent(i);
                menu.setHeaderTitle(result.getExtra());
            } else if (resultType == HitTestResult.IMAGE_TYPE) {
                Intent i = new Intent();
                i.putExtra(Constants.EXTRA_ID_URL, result.getExtra());
                MenuItem item = menu.add(0, CONTEXT_MENU_OPEN, 0, R.string.Main_MenuViewImage);
                item.setIntent(i);
                item = menu.add(0, CONTEXT_MENU_COPY, 0, R.string.Main_MenuCopyImageUrl);
                item.setIntent(i);
                item = menu.add(0, CONTEXT_MENU_DOWNLOAD, 0, R.string.Main_MenuDownloadImage);
                item.setIntent(i);
                item = menu.add(0, CONTEXT_MENU_SHARE, 0, R.string.Main_MenuShareImageUrl);
                item.setIntent(i);
                menu.setHeaderTitle(result.getExtra());
            } else if (resultType == HitTestResult.EMAIL_TYPE) {
                Intent sendMail = new Intent(Intent.ACTION_VIEW, Uri.parse(WebView.SCHEME_MAILTO + result.getExtra()));
                MenuItem item = menu.add(0, CONTEXT_MENU_SEND_MAIL, 0, R.string.Main_MenuSendEmail);
                item.setIntent(sendMail);
                Intent i = new Intent();
                i.putExtra(Constants.EXTRA_ID_URL, result.getExtra());
                item = menu.add(0, CONTEXT_MENU_COPY, 0, R.string.Main_MenuCopyEmailUrl);
                item.setIntent(i);
                item = menu.add(0, CONTEXT_MENU_SHARE, 0, R.string.Main_MenuShareEmailUrl);
                item.setIntent(i);
                menu.setHeaderTitle(result.getExtra());
            }
        }
    });
    mCurrentWebView.setDownloadListener(new DownloadListener() {

        @Override
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
            doDownloadStart(url, userAgent, contentDisposition, mimetype, contentLength);
        }
    });
    final Activity activity = this;
    mCurrentWebView.setWebChromeClient(new WebChromeClient() {

        @Override
        public boolean onCreateWindow(WebView view, final boolean dialog, final boolean userGesture, final Message resultMsg) {
            WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
            addTab(false, mViewFlipper.getDisplayedChild());
            transport.setWebView(mCurrentWebView);
            resultMsg.sendToTarget();
            return false;
        }

        @Override
        public boolean onJsAlert(WebView view, String url, String message, final JsResult result) {
            new AlertDialog.Builder(activity).setTitle(R.string.Commons_JavaScriptDialog).setMessage(message).setPositiveButton(android.R.string.ok, new AlertDialog.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    result.confirm();
                }
            }).setCancelable(false).create().show();
            return true;
        }

        @Override
        public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) {
            new AlertDialog.Builder(MainActivity.this).setTitle(R.string.Commons_JavaScriptDialog).setMessage(message).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    result.confirm();
                }
            }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    result.cancel();
                }
            }).create().show();
            return true;
        }

        @Override
        public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, final JsPromptResult result) {
            final LayoutInflater factory = LayoutInflater.from(MainActivity.this);
            final View v = factory.inflate(R.layout.javascript_prompt_dialog, null);
            ((TextView) v.findViewById(R.id.JavaScriptPromptMessage)).setText(message);
            ((EditText) v.findViewById(R.id.JavaScriptPromptInput)).setText(defaultValue);
            new AlertDialog.Builder(MainActivity.this).setTitle(R.string.Commons_JavaScriptDialog).setView(v).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int whichButton) {
                    String value = ((EditText) v.findViewById(R.id.JavaScriptPromptInput)).getText().toString();
                    result.confirm(value);
                }
            }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int whichButton) {
                    result.cancel();
                }
            }).setOnCancelListener(new DialogInterface.OnCancelListener() {

                @Override
                public void onCancel(DialogInterface dialog) {
                    result.cancel();
                }
            }).show();
            return true;
        }

        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            ((CustomWebView) view).setProgress(newProgress);
            mProgressBar.setProgress(mCurrentWebView.getProgress());
        }

        @Override
        public void onReceivedIcon(WebView view, Bitmap icon) {
            new Thread(new FaviconUpdaterRunnable(MainActivity.this, view.getUrl(), view.getOriginalUrl(), icon)).start();
            updateFavIcon();
            super.onReceivedIcon(view, icon);
        }

        @Override
        public void onReceivedTitle(WebView view, String title) {
            setTitle(String.format(getResources().getString(R.string.ApplicationNameUrl), title));
            startHistoryUpdaterRunnable(title, mCurrentWebView.getUrl(), mCurrentWebView.getOriginalUrl());
            super.onReceivedTitle(view, title);
        }

        @SuppressWarnings("unused")
        public // Used to show a file chooser dialog.
        void openFileChooser(ValueCallback<Uri> uploadMsg) {
            mUploadMessage = uploadMsg;
            Intent i = new Intent(Intent.ACTION_GET_CONTENT);
            i.addCategory(Intent.CATEGORY_OPENABLE);
            i.setType("*/*");
            MainActivity.this.startActivityForResult(Intent.createChooser(i, MainActivity.this.getString(R.string.Main_FileChooserPrompt)), OPEN_FILE_CHOOSER_ACTIVITY);
        }
    });
}
Example 37
Project: ShadowsocksProxy-master  File: MainActivity.java View source code
/**
	 * Initialize a newly created WebView.
	 */
private void initializeCurrentWebView() {
    mCurrentWebView.setWebViewClient(new CustomWebViewClient(this));
    mCurrentWebView.setOnTouchListener(this);
    mCurrentWebView.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {

        @Override
        public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
            HitTestResult result = ((WebView) v).getHitTestResult();
            int resultType = result.getType();
            if ((resultType == HitTestResult.ANCHOR_TYPE) || (resultType == HitTestResult.IMAGE_ANCHOR_TYPE) || (resultType == HitTestResult.SRC_ANCHOR_TYPE) || (resultType == HitTestResult.SRC_IMAGE_ANCHOR_TYPE)) {
                Intent i = new Intent();
                i.putExtra(Constants.EXTRA_ID_URL, result.getExtra());
                MenuItem item = menu.add(0, CONTEXT_MENU_OPEN, 0, R.string.Main_MenuOpen);
                item.setIntent(i);
                item = menu.add(0, CONTEXT_MENU_OPEN_IN_NEW_TAB, 0, R.string.Main_MenuOpenNewTab);
                item.setIntent(i);
                item = menu.add(0, CONTEXT_MENU_COPY, 0, R.string.Main_MenuCopyLinkUrl);
                item.setIntent(i);
                item = menu.add(0, CONTEXT_MENU_DOWNLOAD, 0, R.string.Main_MenuDownload);
                item.setIntent(i);
                item = menu.add(0, CONTEXT_MENU_SHARE, 0, R.string.Main_MenuShareLinkUrl);
                item.setIntent(i);
                menu.setHeaderTitle(result.getExtra());
            } else if (resultType == HitTestResult.IMAGE_TYPE) {
                Intent i = new Intent();
                i.putExtra(Constants.EXTRA_ID_URL, result.getExtra());
                MenuItem item = menu.add(0, CONTEXT_MENU_OPEN, 0, R.string.Main_MenuViewImage);
                item.setIntent(i);
                item = menu.add(0, CONTEXT_MENU_COPY, 0, R.string.Main_MenuCopyImageUrl);
                item.setIntent(i);
                item = menu.add(0, CONTEXT_MENU_DOWNLOAD, 0, R.string.Main_MenuDownloadImage);
                item.setIntent(i);
                item = menu.add(0, CONTEXT_MENU_SHARE, 0, R.string.Main_MenuShareImageUrl);
                item.setIntent(i);
                menu.setHeaderTitle(result.getExtra());
            } else if (resultType == HitTestResult.EMAIL_TYPE) {
                Intent sendMail = new Intent(Intent.ACTION_VIEW, Uri.parse(WebView.SCHEME_MAILTO + result.getExtra()));
                MenuItem item = menu.add(0, CONTEXT_MENU_SEND_MAIL, 0, R.string.Main_MenuSendEmail);
                item.setIntent(sendMail);
                Intent i = new Intent();
                i.putExtra(Constants.EXTRA_ID_URL, result.getExtra());
                item = menu.add(0, CONTEXT_MENU_COPY, 0, R.string.Main_MenuCopyEmailUrl);
                item.setIntent(i);
                item = menu.add(0, CONTEXT_MENU_SHARE, 0, R.string.Main_MenuShareEmailUrl);
                item.setIntent(i);
                menu.setHeaderTitle(result.getExtra());
            }
        }
    });
    mCurrentWebView.setDownloadListener(new DownloadListener() {

        @Override
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
            doDownloadStart(url, userAgent, contentDisposition, mimetype, contentLength);
        }
    });
    final Activity activity = this;
    mCurrentWebView.setWebChromeClient(new WebChromeClient() {

        @Override
        public boolean onCreateWindow(WebView view, final boolean dialog, final boolean userGesture, final Message resultMsg) {
            WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
            addTab(false, mViewFlipper.getDisplayedChild());
            transport.setWebView(mCurrentWebView);
            resultMsg.sendToTarget();
            return false;
        }

        @Override
        public boolean onJsAlert(WebView view, String url, String message, final JsResult result) {
            new AlertDialog.Builder(activity).setTitle(R.string.Commons_JavaScriptDialog).setMessage(message).setPositiveButton(android.R.string.ok, new AlertDialog.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    result.confirm();
                }
            }).setCancelable(false).create().show();
            return true;
        }

        @Override
        public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) {
            new AlertDialog.Builder(MainActivity.this).setTitle(R.string.Commons_JavaScriptDialog).setMessage(message).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    result.confirm();
                }
            }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    result.cancel();
                }
            }).create().show();
            return true;
        }

        @Override
        public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, final JsPromptResult result) {
            final LayoutInflater factory = LayoutInflater.from(MainActivity.this);
            final View v = factory.inflate(R.layout.javascript_prompt_dialog, null);
            ((TextView) v.findViewById(R.id.JavaScriptPromptMessage)).setText(message);
            ((EditText) v.findViewById(R.id.JavaScriptPromptInput)).setText(defaultValue);
            new AlertDialog.Builder(MainActivity.this).setTitle(R.string.Commons_JavaScriptDialog).setView(v).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int whichButton) {
                    String value = ((EditText) v.findViewById(R.id.JavaScriptPromptInput)).getText().toString();
                    result.confirm(value);
                }
            }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int whichButton) {
                    result.cancel();
                }
            }).setOnCancelListener(new DialogInterface.OnCancelListener() {

                @Override
                public void onCancel(DialogInterface dialog) {
                    result.cancel();
                }
            }).show();
            return true;
        }

        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            ((CustomWebView) view).setProgress(newProgress);
            mProgressBar.setProgress(mCurrentWebView.getProgress());
        }

        @Override
        public void onReceivedIcon(WebView view, Bitmap icon) {
            new Thread(new FaviconUpdaterRunnable(MainActivity.this, view.getUrl(), view.getOriginalUrl(), icon)).start();
            updateFavIcon();
            super.onReceivedIcon(view, icon);
        }

        @Override
        public void onReceivedTitle(WebView view, String title) {
            setTitle(String.format(getResources().getString(R.string.ApplicationNameUrl), title));
            startHistoryUpdaterRunnable(title, mCurrentWebView.getUrl(), mCurrentWebView.getOriginalUrl());
            super.onReceivedTitle(view, title);
        }

        @SuppressWarnings("unused")
        public // Used to show a file chooser dialog.
        void openFileChooser(ValueCallback<Uri> uploadMsg) {
            mUploadMessage = uploadMsg;
            Intent i = new Intent(Intent.ACTION_GET_CONTENT);
            i.addCategory(Intent.CATEGORY_OPENABLE);
            i.setType("*/*");
            MainActivity.this.startActivityForResult(Intent.createChooser(i, MainActivity.this.getString(R.string.Main_FileChooserPrompt)), OPEN_FILE_CHOOSER_ACTIVITY);
        }
    });
}
Example 38
Project: zircobrowser_android-master  File: MainActivity.java View source code
/**
     * Initialize a newly created WebView.
     */
private void initializeCurrentWebView() {
    mCurrentWebView.setWebViewClient(new CustomWebViewClient(this));
    mCurrentWebView.setOnTouchListener(this);
    mCurrentWebView.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {

        @Override
        public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
            HitTestResult result = ((WebView) v).getHitTestResult();
            int resultType = result.getType();
            if ((resultType == HitTestResult.ANCHOR_TYPE) || (resultType == HitTestResult.IMAGE_ANCHOR_TYPE) || (resultType == HitTestResult.SRC_ANCHOR_TYPE) || (resultType == HitTestResult.SRC_IMAGE_ANCHOR_TYPE)) {
                Intent i = new Intent();
                i.putExtra(Constants.EXTRA_ID_URL, result.getExtra());
                MenuItem item = menu.add(0, CONTEXT_MENU_OPEN, 0, R.string.Main_MenuOpen);
                item.setIntent(i);
                item = menu.add(0, CONTEXT_MENU_OPEN_IN_NEW_TAB, 0, R.string.Main_MenuOpenNewTab);
                item.setIntent(i);
                item = menu.add(0, CONTEXT_MENU_COPY, 0, R.string.Main_MenuCopyLinkUrl);
                item.setIntent(i);
                item = menu.add(0, CONTEXT_MENU_DOWNLOAD, 0, R.string.Main_MenuDownload);
                item.setIntent(i);
                item = menu.add(0, CONTEXT_MENU_SHARE, 0, R.string.Main_MenuShareLinkUrl);
                item.setIntent(i);
                menu.setHeaderTitle(result.getExtra());
            } else if (resultType == HitTestResult.IMAGE_TYPE) {
                Intent i = new Intent();
                i.putExtra(Constants.EXTRA_ID_URL, result.getExtra());
                MenuItem item = menu.add(0, CONTEXT_MENU_OPEN, 0, R.string.Main_MenuViewImage);
                item.setIntent(i);
                item = menu.add(0, CONTEXT_MENU_COPY, 0, R.string.Main_MenuCopyImageUrl);
                item.setIntent(i);
                item = menu.add(0, CONTEXT_MENU_DOWNLOAD, 0, R.string.Main_MenuDownloadImage);
                item.setIntent(i);
                item = menu.add(0, CONTEXT_MENU_SHARE, 0, R.string.Main_MenuShareImageUrl);
                item.setIntent(i);
                menu.setHeaderTitle(result.getExtra());
            } else if (resultType == HitTestResult.EMAIL_TYPE) {
                Intent sendMail = new Intent(Intent.ACTION_VIEW, Uri.parse(WebView.SCHEME_MAILTO + result.getExtra()));
                MenuItem item = menu.add(0, CONTEXT_MENU_SEND_MAIL, 0, R.string.Main_MenuSendEmail);
                item.setIntent(sendMail);
                Intent i = new Intent();
                i.putExtra(Constants.EXTRA_ID_URL, result.getExtra());
                item = menu.add(0, CONTEXT_MENU_COPY, 0, R.string.Main_MenuCopyEmailUrl);
                item.setIntent(i);
                item = menu.add(0, CONTEXT_MENU_SHARE, 0, R.string.Main_MenuShareEmailUrl);
                item.setIntent(i);
                menu.setHeaderTitle(result.getExtra());
            }
        }
    });
    mCurrentWebView.setDownloadListener(new DownloadListener() {

        @Override
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
            doDownloadStart(url, userAgent, contentDisposition, mimetype, contentLength);
        }
    });
    final Activity activity = this;
    mCurrentWebView.setWebChromeClient(new WebChromeClient() {

        @SuppressWarnings("unused")
        public // Used to show a file chooser dialog.
        void openFileChooser(ValueCallback<Uri> uploadMsg) {
            mUploadMessage = uploadMsg;
            Intent i = new Intent(Intent.ACTION_GET_CONTENT);
            i.addCategory(Intent.CATEGORY_OPENABLE);
            i.setType("*/*");
            MainActivity.this.startActivityForResult(Intent.createChooser(i, MainActivity.this.getString(R.string.Main_FileChooserPrompt)), OPEN_FILE_CHOOSER_ACTIVITY);
        }

        @SuppressWarnings("unused")
        public // Used to show a file chooser dialog.
        void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {
            mUploadMessage = uploadMsg;
            Intent i = new Intent(Intent.ACTION_GET_CONTENT);
            i.addCategory(Intent.CATEGORY_OPENABLE);
            i.setType("*/*");
            MainActivity.this.startActivityForResult(Intent.createChooser(i, MainActivity.this.getString(R.string.Main_FileChooserPrompt)), OPEN_FILE_CHOOSER_ACTIVITY);
        }

        @Override
        public Bitmap getDefaultVideoPoster() {
            if (mDefaultVideoPoster == null) {
                mDefaultVideoPoster = BitmapFactory.decodeResource(MainActivity.this.getResources(), R.drawable.default_video_poster);
            }
            return mDefaultVideoPoster;
        }

        @Override
        public View getVideoLoadingProgressView() {
            if (mVideoProgressView == null) {
                LayoutInflater inflater = LayoutInflater.from(MainActivity.this);
                mVideoProgressView = inflater.inflate(R.layout.video_loading_progress, null);
            }
            return mVideoProgressView;
        }

        public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback) {
            showCustomView(view, callback);
        }

        @Override
        public void onHideCustomView() {
            hideCustomView();
        }

        //			@Override
        //			public void onShowCustomView(View view, CustomViewCallback callback) {
        //				super.onShowCustomView(view, callback);
        //				
        //				if (view instanceof FrameLayout) {
        //					mCustomViewContainer = (FrameLayout) view;
        //		            mCustomViewCallback = callback;
        //		            
        //		            mContentView = (LinearLayout) findViewById(R.id.MainContainer);
        //		            
        //		            if (mCustomViewContainer.getFocusedChild() instanceof VideoView) {
        //		                mCustomVideoView = (VideoView) mCustomViewContainer.getFocusedChild();
        //		                // frame.removeView(video);
        //		                mContentView.setVisibility(View.GONE);
        //		                mCustomViewContainer.setVisibility(View.VISIBLE);
        //		                
        //		                setContentView(mCustomViewContainer);
        //		                //mCustomViewContainer.bringToFront();
        //
        //		                mCustomVideoView.setOnCompletionListener(new OnCompletionListener() {							
        //							@Override
        //							public void onCompletion(MediaPlayer mp) {
        //								mp.stop();
        //								onHideCustomView();
        //							}
        //						});
        //		                
        //		                mCustomVideoView.setOnErrorListener(new OnErrorListener() {						
        //							@Override
        //							public boolean onError(MediaPlayer mp, int what, int extra) {
        //								onHideCustomView();
        //								return true;
        //							}
        //						});
        //		                
        //		                mCustomVideoView.start();
        //		            }
        //
        //				}
        //			}
        //
        //			@Override
        //			public void onHideCustomView() {
        //				super.onHideCustomView();
        //				
        //				if (mCustomVideoView == null) {
        //					return;
        //				}
        //				
        //				mCustomVideoView.setVisibility(View.GONE);
        //				mCustomViewContainer.removeView(mCustomVideoView);
        //				mCustomVideoView = null;
        //				
        //				mCustomViewContainer.setVisibility(View.GONE);
        //		        mCustomViewCallback.onCustomViewHidden();
        //		        
        //		        mContentView.setVisibility(View.VISIBLE);
        //		        setContentView(mContentView);		        
        //			}
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            ((CustomWebView) view).setProgress(newProgress);
            mProgressBar.setProgress(mCurrentWebView.getProgress());
        }

        @Override
        public void onReceivedIcon(WebView view, Bitmap icon) {
            new Thread(new FaviconUpdaterRunnable(MainActivity.this, view.getUrl(), view.getOriginalUrl(), icon)).start();
            updateFavIcon();
            super.onReceivedIcon(view, icon);
        }

        @Override
        public boolean onCreateWindow(WebView view, final boolean dialog, final boolean userGesture, final Message resultMsg) {
            WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
            addTab(false, mViewFlipper.getDisplayedChild());
            transport.setWebView(mCurrentWebView);
            resultMsg.sendToTarget();
            return true;
        }

        @Override
        public void onReceivedTitle(WebView view, String title) {
            setTitle(String.format(getResources().getString(R.string.ApplicationNameUrl), title));
            startHistoryUpdaterRunnable(title, mCurrentWebView.getUrl(), mCurrentWebView.getOriginalUrl());
            super.onReceivedTitle(view, title);
        }

        @Override
        public boolean onJsAlert(WebView view, String url, String message, final JsResult result) {
            new AlertDialog.Builder(activity).setTitle(R.string.Commons_JavaScriptDialog).setMessage(message).setPositiveButton(android.R.string.ok, new AlertDialog.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    result.confirm();
                }
            }).setCancelable(false).create().show();
            return true;
        }

        @Override
        public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) {
            new AlertDialog.Builder(MainActivity.this).setTitle(R.string.Commons_JavaScriptDialog).setMessage(message).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    result.confirm();
                }
            }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    result.cancel();
                }
            }).create().show();
            return true;
        }

        @Override
        public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, final JsPromptResult result) {
            final LayoutInflater factory = LayoutInflater.from(MainActivity.this);
            final View v = factory.inflate(R.layout.javascript_prompt_dialog, null);
            ((TextView) v.findViewById(R.id.JavaScriptPromptMessage)).setText(message);
            ((EditText) v.findViewById(R.id.JavaScriptPromptInput)).setText(defaultValue);
            new AlertDialog.Builder(MainActivity.this).setTitle(R.string.Commons_JavaScriptDialog).setView(v).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int whichButton) {
                    String value = ((EditText) v.findViewById(R.id.JavaScriptPromptInput)).getText().toString();
                    result.confirm(value);
                }
            }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int whichButton) {
                    result.cancel();
                }
            }).setOnCancelListener(new DialogInterface.OnCancelListener() {

                public void onCancel(DialogInterface dialog) {
                    result.cancel();
                }
            }).show();
            return true;
        }
    });
}
Example 39
Project: anvil-master  File: DSL.java View source code
public boolean set(View v, String name, final Object arg, final Object old) {
    switch(name) {
        case "accessibilityDelegate":
            if (arg instanceof View.AccessibilityDelegate) {
                v.setAccessibilityDelegate((View.AccessibilityDelegate) arg);
                return true;
            }
            break;
        case "accessibilityLiveRegion":
            if (arg instanceof Integer) {
                v.setAccessibilityLiveRegion((int) arg);
                return true;
            }
            break;
        case "activated":
            if (arg instanceof Boolean) {
                v.setActivated((boolean) arg);
                return true;
            }
            break;
        case "activity":
            if (v instanceof FragmentBreadCrumbs && arg instanceof Activity) {
                ((FragmentBreadCrumbs) v).setActivity((Activity) arg);
                return true;
            }
            break;
        case "adapter":
            if (v instanceof AdapterView && arg instanceof Adapter) {
                ((AdapterView) v).setAdapter((Adapter) arg);
                return true;
            }
            if (v instanceof ExpandableListView && arg instanceof ExpandableListAdapter) {
                ((ExpandableListView) v).setAdapter((ExpandableListAdapter) arg);
                return true;
            }
            break;
        case "addStatesFromChildren":
            if (v instanceof ViewGroup && arg instanceof Boolean) {
                ((ViewGroup) v).setAddStatesFromChildren((boolean) arg);
                return true;
            }
            break;
        case "adjustViewBounds":
            if (v instanceof ImageView && arg instanceof Boolean) {
                ((ImageView) v).setAdjustViewBounds((boolean) arg);
                return true;
            }
            break;
        case "alignmentMode":
            if (v instanceof GridLayout && arg instanceof Integer) {
                ((GridLayout) v).setAlignmentMode((int) arg);
                return true;
            }
            break;
        case "allCaps":
            if (v instanceof TextView && arg instanceof Boolean) {
                ((TextView) v).setAllCaps((boolean) arg);
                return true;
            }
            break;
        case "alpha":
            if (arg instanceof Float) {
                v.setAlpha((float) arg);
                return true;
            }
            break;
        case "alwaysDrawnWithCacheEnabled":
            if (v instanceof ViewGroup && arg instanceof Boolean) {
                ((ViewGroup) v).setAlwaysDrawnWithCacheEnabled((boolean) arg);
                return true;
            }
            break;
        case "anchorView":
            if (v instanceof MediaController && arg instanceof View) {
                ((MediaController) v).setAnchorView((View) arg);
                return true;
            }
            break;
        case "animateFirstView":
            if (v instanceof AdapterViewAnimator && arg instanceof Boolean) {
                ((AdapterViewAnimator) v).setAnimateFirstView((boolean) arg);
                return true;
            }
            if (v instanceof ViewAnimator && arg instanceof Boolean) {
                ((ViewAnimator) v).setAnimateFirstView((boolean) arg);
                return true;
            }
            break;
        case "animation":
            if (arg instanceof Animation) {
                v.setAnimation((Animation) arg);
                return true;
            }
            break;
        case "animationCacheEnabled":
            if (v instanceof ViewGroup && arg instanceof Boolean) {
                ((ViewGroup) v).setAnimationCacheEnabled((boolean) arg);
                return true;
            }
            break;
        case "animationDuration":
            if (v instanceof Gallery && arg instanceof Integer) {
                ((Gallery) v).setAnimationDuration((int) arg);
                return true;
            }
            break;
        case "autoLinkMask":
            if (v instanceof TextView && arg instanceof Integer) {
                ((TextView) v).setAutoLinkMask((int) arg);
                return true;
            }
            break;
        case "autoStart":
            if (v instanceof AdapterViewFlipper && arg instanceof Boolean) {
                ((AdapterViewFlipper) v).setAutoStart((boolean) arg);
                return true;
            }
            if (v instanceof ViewFlipper && arg instanceof Boolean) {
                ((ViewFlipper) v).setAutoStart((boolean) arg);
                return true;
            }
            break;
        case "background":
            if (arg instanceof Drawable) {
                v.setBackground((Drawable) arg);
                return true;
            }
            break;
        case "backgroundColor":
            if (arg instanceof Integer) {
                v.setBackgroundColor((int) arg);
                return true;
            }
            break;
        case "backgroundResource":
            if (arg instanceof Integer) {
                v.setBackgroundResource((int) arg);
                return true;
            }
            break;
        case "backgroundTintList":
            if (arg instanceof ColorStateList) {
                v.setBackgroundTintList((ColorStateList) arg);
                return true;
            }
            break;
        case "backgroundTintMode":
            if (arg instanceof PorterDuff.Mode) {
                v.setBackgroundTintMode((PorterDuff.Mode) arg);
                return true;
            }
            break;
        case "base":
            if (v instanceof Chronometer && arg instanceof Long) {
                ((Chronometer) v).setBase((long) arg);
                return true;
            }
            break;
        case "baseline":
            if (v instanceof ImageView && arg instanceof Integer) {
                ((ImageView) v).setBaseline((int) arg);
                return true;
            }
            break;
        case "baselineAlignBottom":
            if (v instanceof ImageView && arg instanceof Boolean) {
                ((ImageView) v).setBaselineAlignBottom((boolean) arg);
                return true;
            }
            break;
        case "baselineAligned":
            if (v instanceof LinearLayout && arg instanceof Boolean) {
                ((LinearLayout) v).setBaselineAligned((boolean) arg);
                return true;
            }
            break;
        case "baselineAlignedChildIndex":
            if (v instanceof LinearLayout && arg instanceof Integer) {
                ((LinearLayout) v).setBaselineAlignedChildIndex((int) arg);
                return true;
            }
            break;
        case "bottom":
            if (arg instanceof Integer) {
                v.setBottom((int) arg);
                return true;
            }
            break;
        case "buttonDrawable":
            if (v instanceof CompoundButton && arg instanceof Drawable) {
                ((CompoundButton) v).setButtonDrawable((Drawable) arg);
                return true;
            }
            if (v instanceof CompoundButton && arg instanceof Integer) {
                ((CompoundButton) v).setButtonDrawable((int) arg);
                return true;
            }
            break;
        case "buttonTintList":
            if (v instanceof CompoundButton && arg instanceof ColorStateList) {
                ((CompoundButton) v).setButtonTintList((ColorStateList) arg);
                return true;
            }
            break;
        case "buttonTintMode":
            if (v instanceof CompoundButton && arg instanceof PorterDuff.Mode) {
                ((CompoundButton) v).setButtonTintMode((PorterDuff.Mode) arg);
                return true;
            }
            break;
        case "cacheColorHint":
            if (v instanceof AbsListView && arg instanceof Integer) {
                ((AbsListView) v).setCacheColorHint((int) arg);
                return true;
            }
            break;
        case "calendarViewShown":
            if (v instanceof DatePicker && arg instanceof Boolean) {
                ((DatePicker) v).setCalendarViewShown((boolean) arg);
                return true;
            }
            break;
        case "callback":
            if (v instanceof TvView && arg instanceof TvView.TvInputCallback) {
                ((TvView) v).setCallback((TvView.TvInputCallback) arg);
                return true;
            }
            break;
        case "callbackDuringFling":
            if (v instanceof Gallery && arg instanceof Boolean) {
                ((Gallery) v).setCallbackDuringFling((boolean) arg);
                return true;
            }
            break;
        case "cameraDistance":
            if (arg instanceof Float) {
                v.setCameraDistance((float) arg);
                return true;
            }
            break;
        case "captionEnabled":
            if (v instanceof TvView && arg instanceof Boolean) {
                ((TvView) v).setCaptionEnabled((boolean) arg);
                return true;
            }
            break;
        case "checkMarkDrawable":
            if (v instanceof CheckedTextView && arg instanceof Drawable) {
                ((CheckedTextView) v).setCheckMarkDrawable((Drawable) arg);
                return true;
            }
            if (v instanceof CheckedTextView && arg instanceof Integer) {
                ((CheckedTextView) v).setCheckMarkDrawable((int) arg);
                return true;
            }
            break;
        case "checkMarkTintList":
            if (v instanceof CheckedTextView && arg instanceof ColorStateList) {
                ((CheckedTextView) v).setCheckMarkTintList((ColorStateList) arg);
                return true;
            }
            break;
        case "checkMarkTintMode":
            if (v instanceof CheckedTextView && arg instanceof PorterDuff.Mode) {
                ((CheckedTextView) v).setCheckMarkTintMode((PorterDuff.Mode) arg);
                return true;
            }
            break;
        case "checked":
            if (v instanceof CheckedTextView && arg instanceof Boolean) {
                ((CheckedTextView) v).setChecked((boolean) arg);
                return true;
            }
            if (v instanceof CompoundButton && arg instanceof Boolean) {
                ((CompoundButton) v).setChecked((boolean) arg);
                return true;
            }
            break;
        case "childDivider":
            if (v instanceof ExpandableListView && arg instanceof Drawable) {
                ((ExpandableListView) v).setChildDivider((Drawable) arg);
                return true;
            }
            break;
        case "childIndicator":
            if (v instanceof ExpandableListView && arg instanceof Drawable) {
                ((ExpandableListView) v).setChildIndicator((Drawable) arg);
                return true;
            }
            break;
        case "choiceMode":
            if (v instanceof AbsListView && arg instanceof Integer) {
                ((AbsListView) v).setChoiceMode((int) arg);
                return true;
            }
            break;
        case "clickable":
            if (arg instanceof Boolean) {
                v.setClickable((boolean) arg);
                return true;
            }
            break;
        case "clipBounds":
            if (arg instanceof Rect) {
                v.setClipBounds((Rect) arg);
                return true;
            }
            break;
        case "clipChildren":
            if (v instanceof ViewGroup && arg instanceof Boolean) {
                ((ViewGroup) v).setClipChildren((boolean) arg);
                return true;
            }
            break;
        case "clipToOutline":
            if (arg instanceof Boolean) {
                v.setClipToOutline((boolean) arg);
                return true;
            }
            break;
        case "clipToPadding":
            if (v instanceof ViewGroup && arg instanceof Boolean) {
                ((ViewGroup) v).setClipToPadding((boolean) arg);
                return true;
            }
            break;
        case "colorFilter":
            if (v instanceof ImageView && arg instanceof ColorFilter) {
                ((ImageView) v).setColorFilter((ColorFilter) arg);
                return true;
            }
            if (v instanceof ImageView && arg instanceof Integer) {
                ((ImageView) v).setColorFilter((int) arg);
                return true;
            }
            break;
        case "columnCount":
            if (v instanceof GridLayout && arg instanceof Integer) {
                ((GridLayout) v).setColumnCount((int) arg);
                return true;
            }
            break;
        case "columnOrderPreserved":
            if (v instanceof GridLayout && arg instanceof Boolean) {
                ((GridLayout) v).setColumnOrderPreserved((boolean) arg);
                return true;
            }
            break;
        case "columnWidth":
            if (v instanceof GridView && arg instanceof Integer) {
                ((GridView) v).setColumnWidth((int) arg);
                return true;
            }
            break;
        case "completionHint":
            if (v instanceof AutoCompleteTextView && arg instanceof CharSequence) {
                ((AutoCompleteTextView) v).setCompletionHint((CharSequence) arg);
                return true;
            }
            break;
        case "compoundDrawablePadding":
            if (v instanceof TextView && arg instanceof Integer) {
                ((TextView) v).setCompoundDrawablePadding((int) arg);
                return true;
            }
            break;
        case "contentDescription":
            if (arg instanceof CharSequence) {
                v.setContentDescription((CharSequence) arg);
                return true;
            }
            break;
        case "cropToPadding":
            if (v instanceof ImageView && arg instanceof Boolean) {
                ((ImageView) v).setCropToPadding((boolean) arg);
                return true;
            }
            break;
        case "currentHour":
            if (v instanceof TimePicker && arg instanceof Integer) {
                ((TimePicker) v).setCurrentHour((Integer) arg);
                return true;
            }
            break;
        case "currentMinute":
            if (v instanceof TimePicker && arg instanceof Integer) {
                ((TimePicker) v).setCurrentMinute((Integer) arg);
                return true;
            }
            break;
        case "currentTab":
            if (v instanceof TabHost && arg instanceof Integer) {
                ((TabHost) v).setCurrentTab((int) arg);
                return true;
            }
            if (v instanceof TabWidget && arg instanceof Integer) {
                ((TabWidget) v).setCurrentTab((int) arg);
                return true;
            }
            break;
        case "currentTabByTag":
            if (v instanceof TabHost && arg instanceof String) {
                ((TabHost) v).setCurrentTabByTag((String) arg);
                return true;
            }
            break;
        case "currentText":
            if (v instanceof TextSwitcher && arg instanceof CharSequence) {
                ((TextSwitcher) v).setCurrentText((CharSequence) arg);
                return true;
            }
            break;
        case "cursorVisible":
            if (v instanceof TextView && arg instanceof Boolean) {
                ((TextView) v).setCursorVisible((boolean) arg);
                return true;
            }
            break;
        case "customSelectionActionModeCallback":
            if (v instanceof TextView && arg instanceof ActionMode.Callback) {
                ((TextView) v).setCustomSelectionActionModeCallback((ActionMode.Callback) arg);
                return true;
            }
            break;
        case "date":
            if (v instanceof CalendarView && arg instanceof Long) {
                ((CalendarView) v).setDate((long) arg);
                return true;
            }
            break;
        case "dateTextAppearance":
            if (v instanceof CalendarView && arg instanceof Integer) {
                ((CalendarView) v).setDateTextAppearance((int) arg);
                return true;
            }
            break;
        case "debugFlags":
            if (v instanceof GLSurfaceView && arg instanceof Integer) {
                ((GLSurfaceView) v).setDebugFlags((int) arg);
                return true;
            }
            break;
        case "descendantFocusability":
            if (v instanceof ViewGroup && arg instanceof Integer) {
                ((ViewGroup) v).setDescendantFocusability((int) arg);
                return true;
            }
            break;
        case "digitsWatcher":
            if (v instanceof DialerFilter && arg instanceof TextWatcher) {
                ((DialerFilter) v).setDigitsWatcher((TextWatcher) arg);
                return true;
            }
            break;
        case "displayedChild":
            if (v instanceof AdapterViewAnimator && arg instanceof Integer) {
                ((AdapterViewAnimator) v).setDisplayedChild((int) arg);
                return true;
            }
            if (v instanceof ViewAnimator && arg instanceof Integer) {
                ((ViewAnimator) v).setDisplayedChild((int) arg);
                return true;
            }
            break;
        case "displayedValues":
            if (v instanceof NumberPicker && arg instanceof String[]) {
                ((NumberPicker) v).setDisplayedValues((String[]) arg);
                return true;
            }
            break;
        case "divider":
            if (v instanceof ListView && arg instanceof Drawable) {
                ((ListView) v).setDivider((Drawable) arg);
                return true;
            }
            break;
        case "dividerDrawable":
            if (v instanceof LinearLayout && arg instanceof Drawable) {
                ((LinearLayout) v).setDividerDrawable((Drawable) arg);
                return true;
            }
            if (v instanceof TabWidget && arg instanceof Integer) {
                ((TabWidget) v).setDividerDrawable((int) arg);
                return true;
            }
            break;
        case "dividerHeight":
            if (v instanceof ListView && arg instanceof Integer) {
                ((ListView) v).setDividerHeight((int) arg);
                return true;
            }
            break;
        case "dividerPadding":
            if (v instanceof LinearLayout && arg instanceof Integer) {
                ((LinearLayout) v).setDividerPadding((int) arg);
                return true;
            }
            break;
        case "downloadListener":
            if (v instanceof WebView && arg instanceof DownloadListener) {
                ((WebView) v).setDownloadListener((DownloadListener) arg);
                return true;
            }
            break;
        case "drawSelectorOnTop":
            if (v instanceof AbsListView && arg instanceof Boolean) {
                ((AbsListView) v).setDrawSelectorOnTop((boolean) arg);
                return true;
            }
            break;
        case "drawingCacheBackgroundColor":
            if (arg instanceof Integer) {
                v.setDrawingCacheBackgroundColor((int) arg);
                return true;
            }
            break;
        case "drawingCacheEnabled":
            if (arg instanceof Boolean) {
                v.setDrawingCacheEnabled((boolean) arg);
                return true;
            }
            break;
        case "drawingCacheQuality":
            if (arg instanceof Integer) {
                v.setDrawingCacheQuality((int) arg);
                return true;
            }
            break;
        case "dropDownAnchor":
            if (v instanceof AutoCompleteTextView && arg instanceof Integer) {
                ((AutoCompleteTextView) v).setDropDownAnchor((int) arg);
                return true;
            }
            break;
        case "dropDownBackgroundDrawable":
            if (v instanceof AutoCompleteTextView && arg instanceof Drawable) {
                ((AutoCompleteTextView) v).setDropDownBackgroundDrawable((Drawable) arg);
                return true;
            }
            break;
        case "dropDownBackgroundResource":
            if (v instanceof AutoCompleteTextView && arg instanceof Integer) {
                ((AutoCompleteTextView) v).setDropDownBackgroundResource((int) arg);
                return true;
            }
            break;
        case "dropDownHeight":
            if (v instanceof AutoCompleteTextView && arg instanceof Integer) {
                ((AutoCompleteTextView) v).setDropDownHeight((int) arg);
                return true;
            }
            break;
        case "dropDownHorizontalOffset":
            if (v instanceof AutoCompleteTextView && arg instanceof Integer) {
                ((AutoCompleteTextView) v).setDropDownHorizontalOffset((int) arg);
                return true;
            }
            if (v instanceof Spinner && arg instanceof Integer) {
                ((Spinner) v).setDropDownHorizontalOffset((int) arg);
                return true;
            }
            break;
        case "dropDownVerticalOffset":
            if (v instanceof AutoCompleteTextView && arg instanceof Integer) {
                ((AutoCompleteTextView) v).setDropDownVerticalOffset((int) arg);
                return true;
            }
            if (v instanceof Spinner && arg instanceof Integer) {
                ((Spinner) v).setDropDownVerticalOffset((int) arg);
                return true;
            }
            break;
        case "dropDownWidth":
            if (v instanceof AutoCompleteTextView && arg instanceof Integer) {
                ((AutoCompleteTextView) v).setDropDownWidth((int) arg);
                return true;
            }
            if (v instanceof Spinner && arg instanceof Integer) {
                ((Spinner) v).setDropDownWidth((int) arg);
                return true;
            }
            break;
        case "duplicateParentStateEnabled":
            if (arg instanceof Boolean) {
                v.setDuplicateParentStateEnabled((boolean) arg);
                return true;
            }
            break;
        case "eGLConfigChooser":
            if (v instanceof GLSurfaceView && arg instanceof GLSurfaceView.EGLConfigChooser) {
                ((GLSurfaceView) v).setEGLConfigChooser((GLSurfaceView.EGLConfigChooser) arg);
                return true;
            }
            if (v instanceof GLSurfaceView && arg instanceof Boolean) {
                ((GLSurfaceView) v).setEGLConfigChooser((boolean) arg);
                return true;
            }
            break;
        case "eGLContextClientVersion":
            if (v instanceof GLSurfaceView && arg instanceof Integer) {
                ((GLSurfaceView) v).setEGLContextClientVersion((int) arg);
                return true;
            }
            break;
        case "eGLContextFactory":
            if (v instanceof GLSurfaceView && arg instanceof GLSurfaceView.EGLContextFactory) {
                ((GLSurfaceView) v).setEGLContextFactory((GLSurfaceView.EGLContextFactory) arg);
                return true;
            }
            break;
        case "eGLWindowSurfaceFactory":
            if (v instanceof GLSurfaceView && arg instanceof GLSurfaceView.EGLWindowSurfaceFactory) {
                ((GLSurfaceView) v).setEGLWindowSurfaceFactory((GLSurfaceView.EGLWindowSurfaceFactory) arg);
                return true;
            }
            break;
        case "editableFactory":
            if (v instanceof TextView && arg instanceof Editable.Factory) {
                ((TextView) v).setEditableFactory((Editable.Factory) arg);
                return true;
            }
            break;
        case "elegantTextHeight":
            if (v instanceof TextView && arg instanceof Boolean) {
                ((TextView) v).setElegantTextHeight((boolean) arg);
                return true;
            }
            break;
        case "elevation":
            if (arg instanceof Float) {
                v.setElevation((float) arg);
                return true;
            }
            break;
        case "ellipsize":
            if (v instanceof TextView && arg instanceof TextUtils.TruncateAt) {
                ((TextView) v).setEllipsize((TextUtils.TruncateAt) arg);
                return true;
            }
            break;
        case "emptyView":
            if (v instanceof AdapterView && arg instanceof View) {
                ((AdapterView) v).setEmptyView((View) arg);
                return true;
            }
            break;
        case "ems":
            if (v instanceof TextView && arg instanceof Integer) {
                ((TextView) v).setEms((int) arg);
                return true;
            }
            break;
        case "enabled":
            if (arg instanceof Boolean) {
                v.setEnabled((boolean) arg);
                return true;
            }
            break;
        case "error":
            if (v instanceof TextView && arg instanceof CharSequence) {
                ((TextView) v).setError((CharSequence) arg);
                return true;
            }
            break;
        case "eventsInterceptionEnabled":
            if (v instanceof GestureOverlayView && arg instanceof Boolean) {
                ((GestureOverlayView) v).setEventsInterceptionEnabled((boolean) arg);
                return true;
            }
            break;
        case "excludeMimes":
            if (v instanceof QuickContactBadge && arg instanceof String[]) {
                ((QuickContactBadge) v).setExcludeMimes((String[]) arg);
                return true;
            }
            break;
        case "extendedSettingsClickListener":
            if (v instanceof MediaRouteButton && arg instanceof View.OnClickListener) {
                ((MediaRouteButton) v).setExtendedSettingsClickListener((View.OnClickListener) arg);
                return true;
            }
            break;
        case "extractedText":
            if (v instanceof TextView && arg instanceof ExtractedText) {
                ((TextView) v).setExtractedText((ExtractedText) arg);
                return true;
            }
            break;
        case "factory":
            if (v instanceof ViewSwitcher && arg instanceof ViewSwitcher.ViewFactory) {
                ((ViewSwitcher) v).setFactory((ViewSwitcher.ViewFactory) arg);
                return true;
            }
            break;
        case "fadeEnabled":
            if (v instanceof GestureOverlayView && arg instanceof Boolean) {
                ((GestureOverlayView) v).setFadeEnabled((boolean) arg);
                return true;
            }
            break;
        case "fadeOffset":
            if (v instanceof GestureOverlayView && arg instanceof Long) {
                ((GestureOverlayView) v).setFadeOffset((long) arg);
                return true;
            }
            break;
        case "fadingEdgeLength":
            if (arg instanceof Integer) {
                v.setFadingEdgeLength((int) arg);
                return true;
            }
            break;
        case "fastScrollAlwaysVisible":
            if (v instanceof AbsListView && arg instanceof Boolean) {
                ((AbsListView) v).setFastScrollAlwaysVisible((boolean) arg);
                return true;
            }
            break;
        case "fastScrollEnabled":
            if (v instanceof AbsListView && arg instanceof Boolean) {
                ((AbsListView) v).setFastScrollEnabled((boolean) arg);
                return true;
            }
            break;
        case "fastScrollStyle":
            if (v instanceof AbsListView && arg instanceof Integer) {
                ((AbsListView) v).setFastScrollStyle((int) arg);
                return true;
            }
            break;
        case "fillViewport":
            if (v instanceof HorizontalScrollView && arg instanceof Boolean) {
                ((HorizontalScrollView) v).setFillViewport((boolean) arg);
                return true;
            }
            if (v instanceof ScrollView && arg instanceof Boolean) {
                ((ScrollView) v).setFillViewport((boolean) arg);
                return true;
            }
            break;
        case "filterText":
            if (v instanceof AbsListView && arg instanceof String) {
                ((AbsListView) v).setFilterText((String) arg);
                return true;
            }
            break;
        case "filterTouchesWhenObscured":
            if (arg instanceof Boolean) {
                v.setFilterTouchesWhenObscured((boolean) arg);
                return true;
            }
            break;
        case "filterWatcher":
            if (v instanceof DialerFilter && arg instanceof TextWatcher) {
                ((DialerFilter) v).setFilterWatcher((TextWatcher) arg);
                return true;
            }
            break;
        case "filters":
            if (v instanceof TextView && arg instanceof InputFilter[]) {
                ((TextView) v).setFilters((InputFilter[]) arg);
                return true;
            }
            break;
        case "findListener":
            if (v instanceof WebView && arg instanceof WebView.FindListener) {
                ((WebView) v).setFindListener((WebView.FindListener) arg);
                return true;
            }
            break;
        case "firstDayOfWeek":
            if (v instanceof CalendarView && arg instanceof Integer) {
                ((CalendarView) v).setFirstDayOfWeek((int) arg);
                return true;
            }
            if (v instanceof DatePicker && arg instanceof Integer) {
                ((DatePicker) v).setFirstDayOfWeek((int) arg);
                return true;
            }
            break;
        case "fitsSystemWindows":
            if (arg instanceof Boolean) {
                v.setFitsSystemWindows((boolean) arg);
                return true;
            }
            break;
        case "flipInterval":
            if (v instanceof AdapterViewFlipper && arg instanceof Integer) {
                ((AdapterViewFlipper) v).setFlipInterval((int) arg);
                return true;
            }
            if (v instanceof ViewFlipper && arg instanceof Integer) {
                ((ViewFlipper) v).setFlipInterval((int) arg);
                return true;
            }
            break;
        case "focusable":
            if (arg instanceof Boolean) {
                v.setFocusable((boolean) arg);
                return true;
            }
            break;
        case "focusableInTouchMode":
            if (arg instanceof Boolean) {
                v.setFocusableInTouchMode((boolean) arg);
                return true;
            }
            break;
        case "focusedMonthDateColor":
            if (v instanceof CalendarView && arg instanceof Integer) {
                ((CalendarView) v).setFocusedMonthDateColor((int) arg);
                return true;
            }
            break;
        case "fontFeatureSettings":
            if (v instanceof TextView && arg instanceof String) {
                ((TextView) v).setFontFeatureSettings((String) arg);
                return true;
            }
            break;
        case "footerDividersEnabled":
            if (v instanceof ListView && arg instanceof Boolean) {
                ((ListView) v).setFooterDividersEnabled((boolean) arg);
                return true;
            }
            break;
        case "foreground":
            if (v instanceof FrameLayout && arg instanceof Drawable) {
                ((FrameLayout) v).setForeground((Drawable) arg);
                return true;
            }
            break;
        case "foregroundGravity":
            if (v instanceof FrameLayout && arg instanceof Integer) {
                ((FrameLayout) v).setForegroundGravity((int) arg);
                return true;
            }
            break;
        case "foregroundTintList":
            if (v instanceof FrameLayout && arg instanceof ColorStateList) {
                ((FrameLayout) v).setForegroundTintList((ColorStateList) arg);
                return true;
            }
            break;
        case "foregroundTintMode":
            if (v instanceof FrameLayout && arg instanceof PorterDuff.Mode) {
                ((FrameLayout) v).setForegroundTintMode((PorterDuff.Mode) arg);
                return true;
            }
            break;
        case "format":
            if (v instanceof Chronometer && arg instanceof String) {
                ((Chronometer) v).setFormat((String) arg);
                return true;
            }
            break;
        case "format12Hour":
            if (v instanceof TextClock && arg instanceof CharSequence) {
                ((TextClock) v).setFormat12Hour((CharSequence) arg);
                return true;
            }
            break;
        case "format24Hour":
            if (v instanceof TextClock && arg instanceof CharSequence) {
                ((TextClock) v).setFormat24Hour((CharSequence) arg);
                return true;
            }
            break;
        case "formatter":
            if (v instanceof NumberPicker && arg instanceof NumberPicker.Formatter) {
                ((NumberPicker) v).setFormatter((NumberPicker.Formatter) arg);
                return true;
            }
            break;
        case "freezesText":
            if (v instanceof TextView && arg instanceof Boolean) {
                ((TextView) v).setFreezesText((boolean) arg);
                return true;
            }
            break;
        case "friction":
            if (v instanceof AbsListView && arg instanceof Float) {
                ((AbsListView) v).setFriction((float) arg);
                return true;
            }
            break;
        case "gLWrapper":
            if (v instanceof GLSurfaceView && arg instanceof GLSurfaceView.GLWrapper) {
                ((GLSurfaceView) v).setGLWrapper((GLSurfaceView.GLWrapper) arg);
                return true;
            }
            break;
        case "gesture":
            if (v instanceof GestureOverlayView && arg instanceof Gesture) {
                ((GestureOverlayView) v).setGesture((Gesture) arg);
                return true;
            }
            break;
        case "gestureColor":
            if (v instanceof GestureOverlayView && arg instanceof Integer) {
                ((GestureOverlayView) v).setGestureColor((int) arg);
                return true;
            }
            break;
        case "gestureStrokeAngleThreshold":
            if (v instanceof GestureOverlayView && arg instanceof Float) {
                ((GestureOverlayView) v).setGestureStrokeAngleThreshold((float) arg);
                return true;
            }
            break;
        case "gestureStrokeLengthThreshold":
            if (v instanceof GestureOverlayView && arg instanceof Float) {
                ((GestureOverlayView) v).setGestureStrokeLengthThreshold((float) arg);
                return true;
            }
            break;
        case "gestureStrokeSquarenessTreshold":
            if (v instanceof GestureOverlayView && arg instanceof Float) {
                ((GestureOverlayView) v).setGestureStrokeSquarenessTreshold((float) arg);
                return true;
            }
            break;
        case "gestureStrokeType":
            if (v instanceof GestureOverlayView && arg instanceof Integer) {
                ((GestureOverlayView) v).setGestureStrokeType((int) arg);
                return true;
            }
            break;
        case "gestureStrokeWidth":
            if (v instanceof GestureOverlayView && arg instanceof Float) {
                ((GestureOverlayView) v).setGestureStrokeWidth((float) arg);
                return true;
            }
            break;
        case "gestureVisible":
            if (v instanceof GestureOverlayView && arg instanceof Boolean) {
                ((GestureOverlayView) v).setGestureVisible((boolean) arg);
                return true;
            }
            break;
        case "gravity":
            if (v instanceof Gallery && arg instanceof Integer) {
                ((Gallery) v).setGravity((int) arg);
                return true;
            }
            if (v instanceof GridView && arg instanceof Integer) {
                ((GridView) v).setGravity((int) arg);
                return true;
            }
            if (v instanceof LinearLayout && arg instanceof Integer) {
                ((LinearLayout) v).setGravity((int) arg);
                return true;
            }
            if (v instanceof RelativeLayout && arg instanceof Integer) {
                ((RelativeLayout) v).setGravity((int) arg);
                return true;
            }
            if (v instanceof Spinner && arg instanceof Integer) {
                ((Spinner) v).setGravity((int) arg);
                return true;
            }
            if (v instanceof TextView && arg instanceof Integer) {
                ((TextView) v).setGravity((int) arg);
                return true;
            }
            break;
        case "groupIndicator":
            if (v instanceof ExpandableListView && arg instanceof Drawable) {
                ((ExpandableListView) v).setGroupIndicator((Drawable) arg);
                return true;
            }
            break;
        case "hapticFeedbackEnabled":
            if (arg instanceof Boolean) {
                v.setHapticFeedbackEnabled((boolean) arg);
                return true;
            }
            break;
        case "hasTransientState":
            if (arg instanceof Boolean) {
                v.setHasTransientState((boolean) arg);
                return true;
            }
            break;
        case "headerDividersEnabled":
            if (v instanceof ListView && arg instanceof Boolean) {
                ((ListView) v).setHeaderDividersEnabled((boolean) arg);
                return true;
            }
            break;
        case "height":
            if (v instanceof TextView && arg instanceof Integer) {
                ((TextView) v).setHeight((int) arg);
                return true;
            }
            break;
        case "highlightColor":
            if (v instanceof TextView && arg instanceof Integer) {
                ((TextView) v).setHighlightColor((int) arg);
                return true;
            }
            break;
        case "hint":
            if (v instanceof TextView && arg instanceof Integer) {
                ((TextView) v).setHint((int) arg);
                return true;
            }
            if (v instanceof TextView && arg instanceof CharSequence) {
                ((TextView) v).setHint((CharSequence) arg);
                return true;
            }
            break;
        case "hintTextColor":
            if (v instanceof TextView && arg instanceof ColorStateList) {
                ((TextView) v).setHintTextColor((ColorStateList) arg);
                return true;
            }
            if (v instanceof TextView && arg instanceof Integer) {
                ((TextView) v).setHintTextColor((int) arg);
                return true;
            }
            break;
        case "horizontalFadingEdgeEnabled":
            if (arg instanceof Boolean) {
                v.setHorizontalFadingEdgeEnabled((boolean) arg);
                return true;
            }
            break;
        case "horizontalGravity":
            if (v instanceof LinearLayout && arg instanceof Integer) {
                ((LinearLayout) v).setHorizontalGravity((int) arg);
                return true;
            }
            if (v instanceof RelativeLayout && arg instanceof Integer) {
                ((RelativeLayout) v).setHorizontalGravity((int) arg);
                return true;
            }
            break;
        case "horizontalScrollBarEnabled":
            if (arg instanceof Boolean) {
                v.setHorizontalScrollBarEnabled((boolean) arg);
                return true;
            }
            break;
        case "horizontalScrollbarOverlay":
            if (v instanceof WebView && arg instanceof Boolean) {
                ((WebView) v).setHorizontalScrollbarOverlay((boolean) arg);
                return true;
            }
            break;
        case "horizontalSpacing":
            if (v instanceof GridView && arg instanceof Integer) {
                ((GridView) v).setHorizontalSpacing((int) arg);
                return true;
            }
            break;
        case "horizontallyScrolling":
            if (v instanceof TextView && arg instanceof Boolean) {
                ((TextView) v).setHorizontallyScrolling((boolean) arg);
                return true;
            }
            break;
        case "hovered":
            if (arg instanceof Boolean) {
                v.setHovered((boolean) arg);
                return true;
            }
            break;
        case "iconified":
            if (v instanceof SearchView && arg instanceof Boolean) {
                ((SearchView) v).setIconified((boolean) arg);
                return true;
            }
            break;
        case "iconifiedByDefault":
            if (v instanceof SearchView && arg instanceof Boolean) {
                ((SearchView) v).setIconifiedByDefault((boolean) arg);
                return true;
            }
            break;
        case "id":
            if (arg instanceof Integer) {
                v.setId((int) arg);
                return true;
            }
            break;
        case "ignoreGravity":
            if (v instanceof RelativeLayout && arg instanceof Integer) {
                ((RelativeLayout) v).setIgnoreGravity((int) arg);
                return true;
            }
            break;
        case "imageAlpha":
            if (v instanceof ImageView && arg instanceof Integer) {
                ((ImageView) v).setImageAlpha((int) arg);
                return true;
            }
            break;
        case "imageBitmap":
            if (v instanceof ImageView && arg instanceof Bitmap) {
                ((ImageView) v).setImageBitmap((Bitmap) arg);
                return true;
            }
            break;
        case "imageDrawable":
            if (v instanceof ImageSwitcher && arg instanceof Drawable) {
                ((ImageSwitcher) v).setImageDrawable((Drawable) arg);
                return true;
            }
            if (v instanceof ImageView && arg instanceof Drawable) {
                ((ImageView) v).setImageDrawable((Drawable) arg);
                return true;
            }
            break;
        case "imageLevel":
            if (v instanceof ImageView && arg instanceof Integer) {
                ((ImageView) v).setImageLevel((int) arg);
                return true;
            }
            break;
        case "imageMatrix":
            if (v instanceof ImageView && arg instanceof Matrix) {
                ((ImageView) v).setImageMatrix((Matrix) arg);
                return true;
            }
            break;
        case "imageResource":
            if (v instanceof ImageSwitcher && arg instanceof Integer) {
                ((ImageSwitcher) v).setImageResource((int) arg);
                return true;
            }
            if (v instanceof ImageView && arg instanceof Integer) {
                ((ImageView) v).setImageResource((int) arg);
                return true;
            }
            break;
        case "imageTintList":
            if (v instanceof ImageView && arg instanceof ColorStateList) {
                ((ImageView) v).setImageTintList((ColorStateList) arg);
                return true;
            }
            break;
        case "imageTintMode":
            if (v instanceof ImageView && arg instanceof PorterDuff.Mode) {
                ((ImageView) v).setImageTintMode((PorterDuff.Mode) arg);
                return true;
            }
            break;
        case "imageURI":
            if (v instanceof ImageSwitcher && arg instanceof Uri) {
                ((ImageSwitcher) v).setImageURI((Uri) arg);
                return true;
            }
            if (v instanceof ImageView && arg instanceof Uri) {
                ((ImageView) v).setImageURI((Uri) arg);
                return true;
            }
            break;
        case "imeOptions":
            if (v instanceof SearchView && arg instanceof Integer) {
                ((SearchView) v).setImeOptions((int) arg);
                return true;
            }
            if (v instanceof TextView && arg instanceof Integer) {
                ((TextView) v).setImeOptions((int) arg);
                return true;
            }
            break;
        case "importantForAccessibility":
            if (arg instanceof Integer) {
                v.setImportantForAccessibility((int) arg);
                return true;
            }
            break;
        case "inAnimation":
            if (v instanceof AdapterViewAnimator && arg instanceof ObjectAnimator) {
                ((AdapterViewAnimator) v).setInAnimation((ObjectAnimator) arg);
                return true;
            }
            if (v instanceof ViewAnimator && arg instanceof Animation) {
                ((ViewAnimator) v).setInAnimation((Animation) arg);
                return true;
            }
            break;
        case "includeFontPadding":
            if (v instanceof TextView && arg instanceof Boolean) {
                ((TextView) v).setIncludeFontPadding((boolean) arg);
                return true;
            }
            break;
        case "indeterminate":
            if (v instanceof ProgressBar && arg instanceof Boolean) {
                ((ProgressBar) v).setIndeterminate((boolean) arg);
                return true;
            }
            break;
        case "indeterminateDrawable":
            if (v instanceof ProgressBar && arg instanceof Drawable) {
                ((ProgressBar) v).setIndeterminateDrawable((Drawable) arg);
                return true;
            }
            break;
        case "indeterminateDrawableTiled":
            if (v instanceof ProgressBar && arg instanceof Drawable) {
                ((ProgressBar) v).setIndeterminateDrawableTiled((Drawable) arg);
                return true;
            }
            break;
        case "indeterminateTintList":
            if (v instanceof ProgressBar && arg instanceof ColorStateList) {
                ((ProgressBar) v).setIndeterminateTintList((ColorStateList) arg);
                return true;
            }
            break;
        case "indeterminateTintMode":
            if (v instanceof ProgressBar && arg instanceof PorterDuff.Mode) {
                ((ProgressBar) v).setIndeterminateTintMode((PorterDuff.Mode) arg);
                return true;
            }
            break;
        case "inflatedId":
            if (v instanceof ViewStub && arg instanceof Integer) {
                ((ViewStub) v).setInflatedId((int) arg);
                return true;
            }
            break;
        case "initialScale":
            if (v instanceof WebView && arg instanceof Integer) {
                ((WebView) v).setInitialScale((int) arg);
                return true;
            }
            break;
        case "inputExtras":
            try {
                if (v instanceof android.widget.TextView && arg instanceof Integer)
                    ((android.widget.TextView) v).setInputExtras((int) arg);
            } catch (org.xmlpull.v1.XmlPullParserException e) {
                e.printStackTrace();
            } catch (java.io.IOException e) {
                e.printStackTrace();
            }
            break;
        case "inputType":
            if (v instanceof SearchView && arg instanceof Integer) {
                ((SearchView) v).setInputType((int) arg);
                return true;
            }
            if (v instanceof TextView && arg instanceof Integer) {
                ((TextView) v).setInputType((int) arg);
                return true;
            }
            break;
        case "interpolator":
            if (v instanceof ProgressBar && arg instanceof Interpolator) {
                ((ProgressBar) v).setInterpolator((Interpolator) arg);
                return true;
            }
            break;
        case "is24HourView":
            if (v instanceof TimePicker && arg instanceof Boolean) {
                ((TimePicker) v).setIs24HourView((Boolean) arg);
                return true;
            }
            break;
        case "isIndicator":
            if (v instanceof RatingBar && arg instanceof Boolean) {
                ((RatingBar) v).setIsIndicator((boolean) arg);
                return true;
            }
            break;
        case "isZoomInEnabled":
            if (v instanceof ZoomControls && arg instanceof Boolean) {
                ((ZoomControls) v).setIsZoomInEnabled((boolean) arg);
                return true;
            }
            break;
        case "isZoomOutEnabled":
            if (v instanceof ZoomControls && arg instanceof Boolean) {
                ((ZoomControls) v).setIsZoomOutEnabled((boolean) arg);
                return true;
            }
            break;
        case "itemsCanFocus":
            if (v instanceof ListView && arg instanceof Boolean) {
                ((ListView) v).setItemsCanFocus((boolean) arg);
                return true;
            }
            break;
        case "keepScreenOn":
            if (arg instanceof Boolean) {
                v.setKeepScreenOn((boolean) arg);
                return true;
            }
            break;
        case "keyListener":
            if (v instanceof TextView && arg instanceof KeyListener) {
                ((TextView) v).setKeyListener((KeyListener) arg);
                return true;
            }
            break;
        case "keyProgressIncrement":
            if (v instanceof AbsSeekBar && arg instanceof Integer) {
                ((AbsSeekBar) v).setKeyProgressIncrement((int) arg);
                return true;
            }
            break;
        case "keyboard":
            if (v instanceof KeyboardView && arg instanceof Keyboard) {
                ((KeyboardView) v).setKeyboard((Keyboard) arg);
                return true;
            }
            break;
        case "labelFor":
            if (arg instanceof Integer) {
                v.setLabelFor((int) arg);
                return true;
            }
            break;
        case "layerPaint":
            if (arg instanceof Paint) {
                v.setLayerPaint((Paint) arg);
                return true;
            }
            break;
        case "layoutAnimation":
            if (v instanceof ViewGroup && arg instanceof LayoutAnimationController) {
                ((ViewGroup) v).setLayoutAnimation((LayoutAnimationController) arg);
                return true;
            }
            break;
        case "layoutAnimationListener":
            if (v instanceof ViewGroup && arg instanceof Animation.AnimationListener) {
                ((ViewGroup) v).setLayoutAnimationListener((Animation.AnimationListener) arg);
                return true;
            }
            break;
        case "layoutDirection":
            if (arg instanceof Integer) {
                v.setLayoutDirection((int) arg);
                return true;
            }
            break;
        case "layoutInflater":
            if (v instanceof ViewStub && arg instanceof LayoutInflater) {
                ((ViewStub) v).setLayoutInflater((LayoutInflater) arg);
                return true;
            }
            break;
        case "layoutMode":
            if (v instanceof ViewGroup && arg instanceof Integer) {
                ((ViewGroup) v).setLayoutMode((int) arg);
                return true;
            }
            break;
        case "layoutParams":
            if (arg instanceof ViewGroup.LayoutParams) {
                v.setLayoutParams((ViewGroup.LayoutParams) arg);
                return true;
            }
            break;
        case "layoutResource":
            if (v instanceof ViewStub && arg instanceof Integer) {
                ((ViewStub) v).setLayoutResource((int) arg);
                return true;
            }
            break;
        case "layoutTransition":
            if (v instanceof ViewGroup && arg instanceof LayoutTransition) {
                ((ViewGroup) v).setLayoutTransition((LayoutTransition) arg);
                return true;
            }
            break;
        case "left":
            if (arg instanceof Integer) {
                v.setLeft((int) arg);
                return true;
            }
            break;
        case "leftStripDrawable":
            if (v instanceof TabWidget && arg instanceof Drawable) {
                ((TabWidget) v).setLeftStripDrawable((Drawable) arg);
                return true;
            }
            if (v instanceof TabWidget && arg instanceof Integer) {
                ((TabWidget) v).setLeftStripDrawable((int) arg);
                return true;
            }
            break;
        case "letterSpacing":
            if (v instanceof TextView && arg instanceof Float) {
                ((TextView) v).setLetterSpacing((float) arg);
                return true;
            }
            break;
        case "lettersWatcher":
            if (v instanceof DialerFilter && arg instanceof TextWatcher) {
                ((DialerFilter) v).setLettersWatcher((TextWatcher) arg);
                return true;
            }
            break;
        case "lines":
            if (v instanceof TextView && arg instanceof Integer) {
                ((TextView) v).setLines((int) arg);
                return true;
            }
            break;
        case "linkTextColor":
            if (v instanceof TextView && arg instanceof ColorStateList) {
                ((TextView) v).setLinkTextColor((ColorStateList) arg);
                return true;
            }
            if (v instanceof TextView && arg instanceof Integer) {
                ((TextView) v).setLinkTextColor((int) arg);
                return true;
            }
            break;
        case "linksClickable":
            if (v instanceof TextView && arg instanceof Boolean) {
                ((TextView) v).setLinksClickable((boolean) arg);
                return true;
            }
            break;
        case "listSelection":
            if (v instanceof AutoCompleteTextView && arg instanceof Integer) {
                ((AutoCompleteTextView) v).setListSelection((int) arg);
                return true;
            }
            break;
        case "logo":
            if (v instanceof Toolbar && arg instanceof Drawable) {
                ((Toolbar) v).setLogo((Drawable) arg);
                return true;
            }
            if (v instanceof Toolbar && arg instanceof Integer) {
                ((Toolbar) v).setLogo((int) arg);
                return true;
            }
            break;
        case "logoDescription":
            if (v instanceof Toolbar && arg instanceof Integer) {
                ((Toolbar) v).setLogoDescription((int) arg);
                return true;
            }
            if (v instanceof Toolbar && arg instanceof CharSequence) {
                ((Toolbar) v).setLogoDescription((CharSequence) arg);
                return true;
            }
            break;
        case "longClickable":
            if (arg instanceof Boolean) {
                v.setLongClickable((boolean) arg);
                return true;
            }
            break;
        case "marqueeRepeatLimit":
            if (v instanceof TextView && arg instanceof Integer) {
                ((TextView) v).setMarqueeRepeatLimit((int) arg);
                return true;
            }
            break;
        case "max":
            if (v instanceof ProgressBar && arg instanceof Integer) {
                ((ProgressBar) v).setMax((int) arg);
                return true;
            }
            break;
        case "maxDate":
            if (v instanceof CalendarView && arg instanceof Long) {
                ((CalendarView) v).setMaxDate((long) arg);
                return true;
            }
            if (v instanceof DatePicker && arg instanceof Long) {
                ((DatePicker) v).setMaxDate((long) arg);
                return true;
            }
            break;
        case "maxEms":
            if (v instanceof TextView && arg instanceof Integer) {
                ((TextView) v).setMaxEms((int) arg);
                return true;
            }
            break;
        case "maxHeight":
            if (v instanceof ImageView && arg instanceof Integer) {
                ((ImageView) v).setMaxHeight((int) arg);
                return true;
            }
            if (v instanceof TextView && arg instanceof Integer) {
                ((TextView) v).setMaxHeight((int) arg);
                return true;
            }
            break;
        case "maxLines":
            if (v instanceof TextView && arg instanceof Integer) {
                ((TextView) v).setMaxLines((int) arg);
                return true;
            }
            break;
        case "maxValue":
            if (v instanceof NumberPicker && arg instanceof Integer) {
                ((NumberPicker) v).setMaxValue((int) arg);
                return true;
            }
            break;
        case "maxVisible":
            if (v instanceof FragmentBreadCrumbs && arg instanceof Integer) {
                ((FragmentBreadCrumbs) v).setMaxVisible((int) arg);
                return true;
            }
            break;
        case "maxWidth":
            if (v instanceof ImageView && arg instanceof Integer) {
                ((ImageView) v).setMaxWidth((int) arg);
                return true;
            }
            if (v instanceof SearchView && arg instanceof Integer) {
                ((SearchView) v).setMaxWidth((int) arg);
                return true;
            }
            if (v instanceof TextView && arg instanceof Integer) {
                ((TextView) v).setMaxWidth((int) arg);
                return true;
            }
            break;
        case "measureAllChildren":
            if (v instanceof FrameLayout && arg instanceof Boolean) {
                ((FrameLayout) v).setMeasureAllChildren((boolean) arg);
                return true;
            }
            break;
        case "measureWithLargestChildEnabled":
            if (v instanceof LinearLayout && arg instanceof Boolean) {
                ((LinearLayout) v).setMeasureWithLargestChildEnabled((boolean) arg);
                return true;
            }
            break;
        case "mediaController":
            if (v instanceof VideoView && arg instanceof MediaController) {
                ((VideoView) v).setMediaController((MediaController) arg);
                return true;
            }
            break;
        case "mediaPlayer":
            if (v instanceof MediaController && arg instanceof MediaController.MediaPlayerControl) {
                ((MediaController) v).setMediaPlayer((MediaController.MediaPlayerControl) arg);
                return true;
            }
            break;
        case "minDate":
            if (v instanceof CalendarView && arg instanceof Long) {
                ((CalendarView) v).setMinDate((long) arg);
                return true;
            }
            if (v instanceof DatePicker && arg instanceof Long) {
                ((DatePicker) v).setMinDate((long) arg);
                return true;
            }
            break;
        case "minEms":
            if (v instanceof TextView && arg instanceof Integer) {
                ((TextView) v).setMinEms((int) arg);
                return true;
            }
            break;
        case "minHeight":
            if (v instanceof TextView && arg instanceof Integer) {
                ((TextView) v).setMinHeight((int) arg);
                return true;
            }
            break;
        case "minLines":
            if (v instanceof TextView && arg instanceof Integer) {
                ((TextView) v).setMinLines((int) arg);
                return true;
            }
            break;
        case "minValue":
            if (v instanceof NumberPicker && arg instanceof Integer) {
                ((NumberPicker) v).setMinValue((int) arg);
                return true;
            }
            break;
        case "minWidth":
            if (v instanceof TextView && arg instanceof Integer) {
                ((TextView) v).setMinWidth((int) arg);
                return true;
            }
            break;
        case "minimumHeight":
            if (arg instanceof Integer) {
                v.setMinimumHeight((int) arg);
                return true;
            }
            break;
        case "minimumWidth":
            if (arg instanceof Integer) {
                v.setMinimumWidth((int) arg);
                return true;
            }
            break;
        case "mode":
            if (v instanceof DialerFilter && arg instanceof Integer) {
                ((DialerFilter) v).setMode((int) arg);
                return true;
            }
            if (v instanceof QuickContactBadge && arg instanceof Integer) {
                ((QuickContactBadge) v).setMode((int) arg);
                return true;
            }
            break;
        case "motionEventSplittingEnabled":
            if (v instanceof ViewGroup && arg instanceof Boolean) {
                ((ViewGroup) v).setMotionEventSplittingEnabled((boolean) arg);
                return true;
            }
            break;
        case "movementMethod":
            if (v instanceof TextView && arg instanceof MovementMethod) {
                ((TextView) v).setMovementMethod((MovementMethod) arg);
                return true;
            }
            break;
        case "multiChoiceModeListener":
            if (v instanceof AbsListView && arg instanceof AbsListView.MultiChoiceModeListener) {
                ((AbsListView) v).setMultiChoiceModeListener((AbsListView.MultiChoiceModeListener) arg);
                return true;
            }
            break;
        case "navigationContentDescription":
            if (v instanceof Toolbar && arg instanceof Integer) {
                ((Toolbar) v).setNavigationContentDescription((int) arg);
                return true;
            }
            if (v instanceof Toolbar && arg instanceof CharSequence) {
                ((Toolbar) v).setNavigationContentDescription((CharSequence) arg);
                return true;
            }
            break;
        case "navigationIcon":
            if (v instanceof Toolbar && arg instanceof Drawable) {
                ((Toolbar) v).setNavigationIcon((Drawable) arg);
                return true;
            }
            if (v instanceof Toolbar && arg instanceof Integer) {
                ((Toolbar) v).setNavigationIcon((int) arg);
                return true;
            }
            break;
        case "navigationOnClickListener":
            if (v instanceof Toolbar && arg instanceof View.OnClickListener) {
                ((Toolbar) v).setNavigationOnClickListener((View.OnClickListener) arg);
                return true;
            }
            break;
        case "nestedScrollingEnabled":
            if (arg instanceof Boolean) {
                v.setNestedScrollingEnabled((boolean) arg);
                return true;
            }
            break;
        case "networkAvailable":
            if (v instanceof WebView && arg instanceof Boolean) {
                ((WebView) v).setNetworkAvailable((boolean) arg);
                return true;
            }
            break;
        case "nextFocusDownId":
            if (arg instanceof Integer) {
                v.setNextFocusDownId((int) arg);
                return true;
            }
            break;
        case "nextFocusForwardId":
            if (arg instanceof Integer) {
                v.setNextFocusForwardId((int) arg);
                return true;
            }
            break;
        case "nextFocusLeftId":
            if (arg instanceof Integer) {
                v.setNextFocusLeftId((int) arg);
                return true;
            }
            break;
        case "nextFocusRightId":
            if (arg instanceof Integer) {
                v.setNextFocusRightId((int) arg);
                return true;
            }
            break;
        case "nextFocusUpId":
            if (arg instanceof Integer) {
                v.setNextFocusUpId((int) arg);
                return true;
            }
            break;
        case "numColumns":
            if (v instanceof GridView && arg instanceof Integer) {
                ((GridView) v).setNumColumns((int) arg);
                return true;
            }
            break;
        case "numStars":
            if (v instanceof RatingBar && arg instanceof Integer) {
                ((RatingBar) v).setNumStars((int) arg);
                return true;
            }
            break;
        case "onApplyWindowInsets":
            if (arg != null) {
                v.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {

                    public WindowInsets onApplyWindowInsets(View a0, WindowInsets a1) {
                        WindowInsets r = ((View.OnApplyWindowInsetsListener) arg).onApplyWindowInsets(a0, a1);
                        Anvil.render();
                        return r;
                    }
                });
            } else {
                v.setOnApplyWindowInsetsListener((View.OnApplyWindowInsetsListener) null);
            }
            return true;
        case "onBreadCrumbClick":
            if (v instanceof FragmentBreadCrumbs && arg instanceof FragmentBreadCrumbs.OnBreadCrumbClickListener) {
                if (arg != null) {
                    ((FragmentBreadCrumbs) v).setOnBreadCrumbClickListener(new FragmentBreadCrumbs.OnBreadCrumbClickListener() {

                        public boolean onBreadCrumbClick(FragmentManager.BackStackEntry a0, int a1) {
                            boolean r = ((FragmentBreadCrumbs.OnBreadCrumbClickListener) arg).onBreadCrumbClick(a0, a1);
                            Anvil.render();
                            return r;
                        }
                    });
                } else {
                    ((FragmentBreadCrumbs) v).setOnBreadCrumbClickListener((FragmentBreadCrumbs.OnBreadCrumbClickListener) null);
                }
                return true;
            }
            break;
        case "onCheckedChange":
            if (v instanceof CompoundButton && arg instanceof CompoundButton.OnCheckedChangeListener) {
                if (arg != null) {
                    ((CompoundButton) v).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

                        public void onCheckedChanged(CompoundButton a0, boolean a1) {
                            ((CompoundButton.OnCheckedChangeListener) arg).onCheckedChanged(a0, a1);
                            Anvil.render();
                        }
                    });
                } else {
                    ((CompoundButton) v).setOnCheckedChangeListener((CompoundButton.OnCheckedChangeListener) null);
                }
                return true;
            }
            if (v instanceof RadioGroup && arg instanceof RadioGroup.OnCheckedChangeListener) {
                if (arg != null) {
                    ((RadioGroup) v).setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

                        public void onCheckedChanged(RadioGroup a0, int a1) {
                            ((RadioGroup.OnCheckedChangeListener) arg).onCheckedChanged(a0, a1);
                            Anvil.render();
                        }
                    });
                } else {
                    ((RadioGroup) v).setOnCheckedChangeListener((RadioGroup.OnCheckedChangeListener) null);
                }
                return true;
            }
            break;
        case "onChildClick":
            if (v instanceof ExpandableListView && arg instanceof ExpandableListView.OnChildClickListener) {
                if (arg != null) {
                    ((ExpandableListView) v).setOnChildClickListener(new ExpandableListView.OnChildClickListener() {

                        public boolean onChildClick(ExpandableListView a0, View a1, int a2, int a3, long a4) {
                            boolean r = ((ExpandableListView.OnChildClickListener) arg).onChildClick(a0, a1, a2, a3, a4);
                            Anvil.render();
                            return r;
                        }
                    });
                } else {
                    ((ExpandableListView) v).setOnChildClickListener((ExpandableListView.OnChildClickListener) null);
                }
                return true;
            }
            break;
        case "onChronometerTick":
            if (v instanceof Chronometer && arg instanceof Chronometer.OnChronometerTickListener) {
                if (arg != null) {
                    ((Chronometer) v).setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() {

                        public void onChronometerTick(Chronometer a0) {
                            ((Chronometer.OnChronometerTickListener) arg).onChronometerTick(a0);
                            Anvil.render();
                        }
                    });
                } else {
                    ((Chronometer) v).setOnChronometerTickListener((Chronometer.OnChronometerTickListener) null);
                }
                return true;
            }
            break;
        case "onClick":
            if (arg != null) {
                v.setOnClickListener(new View.OnClickListener() {

                    public void onClick(View a0) {
                        ((View.OnClickListener) arg).onClick(a0);
                        Anvil.render();
                    }
                });
            } else {
                v.setOnClickListener((View.OnClickListener) null);
            }
            return true;
        case "onClose":
            if (v instanceof SearchView && arg instanceof SearchView.OnCloseListener) {
                if (arg != null) {
                    ((SearchView) v).setOnCloseListener(new SearchView.OnCloseListener() {

                        public boolean onClose() {
                            boolean r = ((SearchView.OnCloseListener) arg).onClose();
                            Anvil.render();
                            return r;
                        }
                    });
                } else {
                    ((SearchView) v).setOnCloseListener((SearchView.OnCloseListener) null);
                }
                return true;
            }
            break;
        case "onCompletion":
            if (v instanceof VideoView && arg instanceof MediaPlayer.OnCompletionListener) {
                if (arg != null) {
                    ((VideoView) v).setOnCompletionListener(new MediaPlayer.OnCompletionListener() {

                        public void onCompletion(MediaPlayer a0) {
                            ((MediaPlayer.OnCompletionListener) arg).onCompletion(a0);
                            Anvil.render();
                        }
                    });
                } else {
                    ((VideoView) v).setOnCompletionListener((MediaPlayer.OnCompletionListener) null);
                }
                return true;
            }
            break;
        case "onCreateContextMenu":
            if (arg != null) {
                v.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {

                    public void onCreateContextMenu(ContextMenu a0, View a1, ContextMenu.ContextMenuInfo a2) {
                        ((View.OnCreateContextMenuListener) arg).onCreateContextMenu(a0, a1, a2);
                        Anvil.render();
                    }
                });
            } else {
                v.setOnCreateContextMenuListener((View.OnCreateContextMenuListener) null);
            }
            return true;
        case "onDateChange":
            if (v instanceof CalendarView && arg instanceof CalendarView.OnDateChangeListener) {
                if (arg != null) {
                    ((CalendarView) v).setOnDateChangeListener(new CalendarView.OnDateChangeListener() {

                        public void onSelectedDayChange(CalendarView a0, int a1, int a2, int a3) {
                            ((CalendarView.OnDateChangeListener) arg).onSelectedDayChange(a0, a1, a2, a3);
                            Anvil.render();
                        }
                    });
                } else {
                    ((CalendarView) v).setOnDateChangeListener((CalendarView.OnDateChangeListener) null);
                }
                return true;
            }
            break;
        case "onDismiss":
            if (v instanceof AutoCompleteTextView && arg instanceof AutoCompleteTextView.OnDismissListener) {
                if (arg != null) {
                    ((AutoCompleteTextView) v).setOnDismissListener(new AutoCompleteTextView.OnDismissListener() {

                        public void onDismiss() {
                            ((AutoCompleteTextView.OnDismissListener) arg).onDismiss();
                            Anvil.render();
                        }
                    });
                } else {
                    ((AutoCompleteTextView) v).setOnDismissListener((AutoCompleteTextView.OnDismissListener) null);
                }
                return true;
            }
            break;
        case "onDrag":
            if (arg != null) {
                v.setOnDragListener(new View.OnDragListener() {

                    public boolean onDrag(View a0, DragEvent a1) {
                        boolean r = ((View.OnDragListener) arg).onDrag(a0, a1);
                        Anvil.render();
                        return r;
                    }
                });
            } else {
                v.setOnDragListener((View.OnDragListener) null);
            }
            return true;
        case "onDrawerClose":
            if (v instanceof SlidingDrawer && arg instanceof SlidingDrawer.OnDrawerCloseListener) {
                if (arg != null) {
                    ((SlidingDrawer) v).setOnDrawerCloseListener(new SlidingDrawer.OnDrawerCloseListener() {

                        public void onDrawerClosed() {
                            ((SlidingDrawer.OnDrawerCloseListener) arg).onDrawerClosed();
                            Anvil.render();
                        }
                    });
                } else {
                    ((SlidingDrawer) v).setOnDrawerCloseListener((SlidingDrawer.OnDrawerCloseListener) null);
                }
                return true;
            }
            break;
        case "onDrawerOpen":
            if (v instanceof SlidingDrawer && arg instanceof SlidingDrawer.OnDrawerOpenListener) {
                if (arg != null) {
                    ((SlidingDrawer) v).setOnDrawerOpenListener(new SlidingDrawer.OnDrawerOpenListener() {

                        public void onDrawerOpened() {
                            ((SlidingDrawer.OnDrawerOpenListener) arg).onDrawerOpened();
                            Anvil.render();
                        }
                    });
                } else {
                    ((SlidingDrawer) v).setOnDrawerOpenListener((SlidingDrawer.OnDrawerOpenListener) null);
                }
                return true;
            }
            break;
        case "onDrawerScroll":
            if (v instanceof SlidingDrawer && arg instanceof SlidingDrawer.OnDrawerScrollListener) {
                if (arg != null) {
                    ((SlidingDrawer) v).setOnDrawerScrollListener(new SlidingDrawer.OnDrawerScrollListener() {

                        public void onScrollEnded() {
                            ((SlidingDrawer.OnDrawerScrollListener) arg).onScrollEnded();
                            Anvil.render();
                        }

                        public void onScrollStarted() {
                            ((SlidingDrawer.OnDrawerScrollListener) arg).onScrollStarted();
                            Anvil.render();
                        }
                    });
                } else {
                    ((SlidingDrawer) v).setOnDrawerScrollListener((SlidingDrawer.OnDrawerScrollListener) null);
                }
                return true;
            }
            break;
        case "onEditorAction":
            if (v instanceof TextView && arg instanceof TextView.OnEditorActionListener) {
                if (arg != null) {
                    ((TextView) v).setOnEditorActionListener(new TextView.OnEditorActionListener() {

                        public boolean onEditorAction(TextView a0, int a1, KeyEvent a2) {
                            boolean r = ((TextView.OnEditorActionListener) arg).onEditorAction(a0, a1, a2);
                            Anvil.render();
                            return r;
                        }
                    });
                } else {
                    ((TextView) v).setOnEditorActionListener((TextView.OnEditorActionListener) null);
                }
                return true;
            }
            break;
        case "onError":
            if (v instanceof VideoView && arg instanceof MediaPlayer.OnErrorListener) {
                if (arg != null) {
                    ((VideoView) v).setOnErrorListener(new MediaPlayer.OnErrorListener() {

                        public boolean onError(MediaPlayer a0, int a1, int a2) {
                            boolean r = ((MediaPlayer.OnErrorListener) arg).onError(a0, a1, a2);
                            Anvil.render();
                            return r;
                        }
                    });
                } else {
                    ((VideoView) v).setOnErrorListener((MediaPlayer.OnErrorListener) null);
                }
                return true;
            }
            break;
        case "onFocusChange":
            if (arg != null) {
                v.setOnFocusChangeListener(new View.OnFocusChangeListener() {

                    public void onFocusChange(View a0, boolean a1) {
                        ((View.OnFocusChangeListener) arg).onFocusChange(a0, a1);
                        Anvil.render();
                    }
                });
            } else {
                v.setOnFocusChangeListener((View.OnFocusChangeListener) null);
            }
            return true;
        case "onGenericMotion":
            if (arg != null) {
                v.setOnGenericMotionListener(new View.OnGenericMotionListener() {

                    public boolean onGenericMotion(View a0, MotionEvent a1) {
                        boolean r = ((View.OnGenericMotionListener) arg).onGenericMotion(a0, a1);
                        Anvil.render();
                        return r;
                    }
                });
            } else {
                v.setOnGenericMotionListener((View.OnGenericMotionListener) null);
            }
            return true;
        case "onGroupClick":
            if (v instanceof ExpandableListView && arg instanceof ExpandableListView.OnGroupClickListener) {
                if (arg != null) {
                    ((ExpandableListView) v).setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {

                        public boolean onGroupClick(ExpandableListView a0, View a1, int a2, long a3) {
                            boolean r = ((ExpandableListView.OnGroupClickListener) arg).onGroupClick(a0, a1, a2, a3);
                            Anvil.render();
                            return r;
                        }
                    });
                } else {
                    ((ExpandableListView) v).setOnGroupClickListener((ExpandableListView.OnGroupClickListener) null);
                }
                return true;
            }
            break;
        case "onGroupCollapse":
            if (v instanceof ExpandableListView && arg instanceof ExpandableListView.OnGroupCollapseListener) {
                if (arg != null) {
                    ((ExpandableListView) v).setOnGroupCollapseListener(new ExpandableListView.OnGroupCollapseListener() {

                        public void onGroupCollapse(int a0) {
                            ((ExpandableListView.OnGroupCollapseListener) arg).onGroupCollapse(a0);
                            Anvil.render();
                        }
                    });
                } else {
                    ((ExpandableListView) v).setOnGroupCollapseListener((ExpandableListView.OnGroupCollapseListener) null);
                }
                return true;
            }
            break;
        case "onGroupExpand":
            if (v instanceof ExpandableListView && arg instanceof ExpandableListView.OnGroupExpandListener) {
                if (arg != null) {
                    ((ExpandableListView) v).setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {

                        public void onGroupExpand(int a0) {
                            ((ExpandableListView.OnGroupExpandListener) arg).onGroupExpand(a0);
                            Anvil.render();
                        }
                    });
                } else {
                    ((ExpandableListView) v).setOnGroupExpandListener((ExpandableListView.OnGroupExpandListener) null);
                }
                return true;
            }
            break;
        case "onHierarchyChange":
            if (v instanceof ViewGroup && arg instanceof ViewGroup.OnHierarchyChangeListener) {
                if (arg != null) {
                    ((ViewGroup) v).setOnHierarchyChangeListener(new ViewGroup.OnHierarchyChangeListener() {

                        public void onChildViewAdded(View a0, View a1) {
                            ((ViewGroup.OnHierarchyChangeListener) arg).onChildViewAdded(a0, a1);
                            Anvil.render();
                        }

                        public void onChildViewRemoved(View a0, View a1) {
                            ((ViewGroup.OnHierarchyChangeListener) arg).onChildViewRemoved(a0, a1);
                            Anvil.render();
                        }
                    });
                } else {
                    ((ViewGroup) v).setOnHierarchyChangeListener((ViewGroup.OnHierarchyChangeListener) null);
                }
                return true;
            }
            break;
        case "onHover":
            if (arg != null) {
                v.setOnHoverListener(new View.OnHoverListener() {

                    public boolean onHover(View a0, MotionEvent a1) {
                        boolean r = ((View.OnHoverListener) arg).onHover(a0, a1);
                        Anvil.render();
                        return r;
                    }
                });
            } else {
                v.setOnHoverListener((View.OnHoverListener) null);
            }
            return true;
        case "onInflate":
            if (v instanceof ViewStub && arg instanceof ViewStub.OnInflateListener) {
                if (arg != null) {
                    ((ViewStub) v).setOnInflateListener(new ViewStub.OnInflateListener() {

                        public void onInflate(ViewStub a0, View a1) {
                            ((ViewStub.OnInflateListener) arg).onInflate(a0, a1);
                            Anvil.render();
                        }
                    });
                } else {
                    ((ViewStub) v).setOnInflateListener((ViewStub.OnInflateListener) null);
                }
                return true;
            }
            break;
        case "onInfo":
            if (v instanceof VideoView && arg instanceof MediaPlayer.OnInfoListener) {
                if (arg != null) {
                    ((VideoView) v).setOnInfoListener(new MediaPlayer.OnInfoListener() {

                        public boolean onInfo(MediaPlayer a0, int a1, int a2) {
                            boolean r = ((MediaPlayer.OnInfoListener) arg).onInfo(a0, a1, a2);
                            Anvil.render();
                            return r;
                        }
                    });
                } else {
                    ((VideoView) v).setOnInfoListener((MediaPlayer.OnInfoListener) null);
                }
                return true;
            }
            break;
        case "onItemClick":
            if (v instanceof AdapterView && arg instanceof AdapterView.OnItemClickListener) {
                if (arg != null) {
                    ((AdapterView) v).setOnItemClickListener(new AdapterView.OnItemClickListener() {

                        public void onItemClick(AdapterView a0, View a1, int a2, long a3) {
                            ((AdapterView.OnItemClickListener) arg).onItemClick(a0, a1, a2, a3);
                            Anvil.render();
                        }
                    });
                } else {
                    ((AdapterView) v).setOnItemClickListener((AdapterView.OnItemClickListener) null);
                }
                return true;
            }
            if (v instanceof AutoCompleteTextView && arg instanceof AdapterView.OnItemClickListener) {
                if (arg != null) {
                    ((AutoCompleteTextView) v).setOnItemClickListener(new AdapterView.OnItemClickListener() {

                        public void onItemClick(AdapterView a0, View a1, int a2, long a3) {
                            ((AdapterView.OnItemClickListener) arg).onItemClick(a0, a1, a2, a3);
                            Anvil.render();
                        }
                    });
                } else {
                    ((AutoCompleteTextView) v).setOnItemClickListener((AdapterView.OnItemClickListener) null);
                }
                return true;
            }
            break;
        case "onItemLongClick":
            if (v instanceof AdapterView && arg instanceof AdapterView.OnItemLongClickListener) {
                if (arg != null) {
                    ((AdapterView) v).setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

                        public boolean onItemLongClick(AdapterView a0, View a1, int a2, long a3) {
                            boolean r = ((AdapterView.OnItemLongClickListener) arg).onItemLongClick(a0, a1, a2, a3);
                            Anvil.render();
                            return r;
                        }
                    });
                } else {
                    ((AdapterView) v).setOnItemLongClickListener((AdapterView.OnItemLongClickListener) null);
                }
                return true;
            }
            break;
        case "onItemSelected":
            if (v instanceof AdapterView && arg instanceof AdapterView.OnItemSelectedListener) {
                if (arg != null) {
                    ((AdapterView) v).setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

                        public void onItemSelected(AdapterView a0, View a1, int a2, long a3) {
                            ((AdapterView.OnItemSelectedListener) arg).onItemSelected(a0, a1, a2, a3);
                            Anvil.render();
                        }

                        public void onNothingSelected(AdapterView a0) {
                            ((AdapterView.OnItemSelectedListener) arg).onNothingSelected(a0);
                            Anvil.render();
                        }
                    });
                } else {
                    ((AdapterView) v).setOnItemSelectedListener((AdapterView.OnItemSelectedListener) null);
                }
                return true;
            }
            if (v instanceof AutoCompleteTextView && arg instanceof AdapterView.OnItemSelectedListener) {
                if (arg != null) {
                    ((AutoCompleteTextView) v).setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

                        public void onItemSelected(AdapterView a0, View a1, int a2, long a3) {
                            ((AdapterView.OnItemSelectedListener) arg).onItemSelected(a0, a1, a2, a3);
                            Anvil.render();
                        }

                        public void onNothingSelected(AdapterView a0) {
                            ((AdapterView.OnItemSelectedListener) arg).onNothingSelected(a0);
                            Anvil.render();
                        }
                    });
                } else {
                    ((AutoCompleteTextView) v).setOnItemSelectedListener((AdapterView.OnItemSelectedListener) null);
                }
                return true;
            }
            break;
        case "onKey":
            if (arg != null) {
                v.setOnKeyListener(new View.OnKeyListener() {

                    public boolean onKey(View a0, int a1, KeyEvent a2) {
                        boolean r = ((View.OnKeyListener) arg).onKey(a0, a1, a2);
                        Anvil.render();
                        return r;
                    }
                });
            } else {
                v.setOnKeyListener((View.OnKeyListener) null);
            }
            return true;
        case "onKeyboardAction":
            if (v instanceof KeyboardView && arg instanceof KeyboardView.OnKeyboardActionListener) {
                if (arg != null) {
                    ((KeyboardView) v).setOnKeyboardActionListener(new KeyboardView.OnKeyboardActionListener() {

                        public void onKey(int a0, int[] a1) {
                            ((KeyboardView.OnKeyboardActionListener) arg).onKey(a0, a1);
                            Anvil.render();
                        }

                        public void onPress(int a0) {
                            ((KeyboardView.OnKeyboardActionListener) arg).onPress(a0);
                            Anvil.render();
                        }

                        public void onRelease(int a0) {
                            ((KeyboardView.OnKeyboardActionListener) arg).onRelease(a0);
                            Anvil.render();
                        }

                        public void onText(CharSequence a0) {
                            ((KeyboardView.OnKeyboardActionListener) arg).onText(a0);
                            Anvil.render();
                        }

                        public void swipeDown() {
                            ((KeyboardView.OnKeyboardActionListener) arg).swipeDown();
                            Anvil.render();
                        }

                        public void swipeLeft() {
                            ((KeyboardView.OnKeyboardActionListener) arg).swipeLeft();
                            Anvil.render();
                        }

                        public void swipeRight() {
                            ((KeyboardView.OnKeyboardActionListener) arg).swipeRight();
                            Anvil.render();
                        }

                        public void swipeUp() {
                            ((KeyboardView.OnKeyboardActionListener) arg).swipeUp();
                            Anvil.render();
                        }
                    });
                } else {
                    ((KeyboardView) v).setOnKeyboardActionListener((KeyboardView.OnKeyboardActionListener) null);
                }
                return true;
            }
            break;
        case "onLongClick":
            if (arg != null) {
                v.setOnLongClickListener(new View.OnLongClickListener() {

                    public boolean onLongClick(View a0) {
                        boolean r = ((View.OnLongClickListener) arg).onLongClick(a0);
                        Anvil.render();
                        return r;
                    }
                });
            } else {
                v.setOnLongClickListener((View.OnLongClickListener) null);
            }
            return true;
        case "onLongPressUpdateInterval":
            if (v instanceof NumberPicker && arg instanceof Long) {
                ((NumberPicker) v).setOnLongPressUpdateInterval((long) arg);
                return true;
            }
            break;
        case "onMenuItemClick":
            if (v instanceof ActionMenuView && arg instanceof ActionMenuView.OnMenuItemClickListener) {
                if (arg != null) {
                    ((ActionMenuView) v).setOnMenuItemClickListener(new ActionMenuView.OnMenuItemClickListener() {

                        public boolean onMenuItemClick(MenuItem a0) {
                            boolean r = ((ActionMenuView.OnMenuItemClickListener) arg).onMenuItemClick(a0);
                            Anvil.render();
                            return r;
                        }
                    });
                } else {
                    ((ActionMenuView) v).setOnMenuItemClickListener((ActionMenuView.OnMenuItemClickListener) null);
                }
                return true;
            }
            if (v instanceof Toolbar && arg instanceof Toolbar.OnMenuItemClickListener) {
                if (arg != null) {
                    ((Toolbar) v).setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {

                        public boolean onMenuItemClick(MenuItem a0) {
                            boolean r = ((Toolbar.OnMenuItemClickListener) arg).onMenuItemClick(a0);
                            Anvil.render();
                            return r;
                        }
                    });
                } else {
                    ((Toolbar) v).setOnMenuItemClickListener((Toolbar.OnMenuItemClickListener) null);
                }
                return true;
            }
            break;
        case "onPrepared":
            if (v instanceof VideoView && arg instanceof MediaPlayer.OnPreparedListener) {
                if (arg != null) {
                    ((VideoView) v).setOnPreparedListener(new MediaPlayer.OnPreparedListener() {

                        public void onPrepared(MediaPlayer a0) {
                            ((MediaPlayer.OnPreparedListener) arg).onPrepared(a0);
                            Anvil.render();
                        }
                    });
                } else {
                    ((VideoView) v).setOnPreparedListener((MediaPlayer.OnPreparedListener) null);
                }
                return true;
            }
            break;
        case "onQueryText":
            if (v instanceof SearchView && arg instanceof SearchView.OnQueryTextListener) {
                if (arg != null) {
                    ((SearchView) v).setOnQueryTextListener(new SearchView.OnQueryTextListener() {

                        public boolean onQueryTextChange(String a0) {
                            boolean r = ((SearchView.OnQueryTextListener) arg).onQueryTextChange(a0);
                            Anvil.render();
                            return r;
                        }

                        public boolean onQueryTextSubmit(String a0) {
                            boolean r = ((SearchView.OnQueryTextListener) arg).onQueryTextSubmit(a0);
                            Anvil.render();
                            return r;
                        }
                    });
                } else {
                    ((SearchView) v).setOnQueryTextListener((SearchView.OnQueryTextListener) null);
                }
                return true;
            }
            break;
        case "onQueryTextFocusChange":
            if (v instanceof SearchView && arg instanceof View.OnFocusChangeListener) {
                if (arg != null) {
                    ((SearchView) v).setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {

                        public void onFocusChange(View a0, boolean a1) {
                            ((View.OnFocusChangeListener) arg).onFocusChange(a0, a1);
                            Anvil.render();
                        }
                    });
                } else {
                    ((SearchView) v).setOnQueryTextFocusChangeListener((View.OnFocusChangeListener) null);
                }
                return true;
            }
            break;
        case "onRatingBarChange":
            if (v instanceof RatingBar && arg instanceof RatingBar.OnRatingBarChangeListener) {
                if (arg != null) {
                    ((RatingBar) v).setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {

                        public void onRatingChanged(RatingBar a0, float a1, boolean a2) {
                            ((RatingBar.OnRatingBarChangeListener) arg).onRatingChanged(a0, a1, a2);
                            Anvil.render();
                        }
                    });
                } else {
                    ((RatingBar) v).setOnRatingBarChangeListener((RatingBar.OnRatingBarChangeListener) null);
                }
                return true;
            }
            break;
        case "onScroll":
            if (v instanceof AbsListView && arg instanceof AbsListView.OnScrollListener) {
                if (arg != null) {
                    ((AbsListView) v).setOnScrollListener(new AbsListView.OnScrollListener() {

                        public void onScroll(AbsListView a0, int a1, int a2, int a3) {
                            ((AbsListView.OnScrollListener) arg).onScroll(a0, a1, a2, a3);
                            Anvil.render();
                        }

                        public void onScrollStateChanged(AbsListView a0, int a1) {
                            ((AbsListView.OnScrollListener) arg).onScrollStateChanged(a0, a1);
                            Anvil.render();
                        }
                    });
                } else {
                    ((AbsListView) v).setOnScrollListener((AbsListView.OnScrollListener) null);
                }
                return true;
            }
            if (v instanceof NumberPicker && arg instanceof NumberPicker.OnScrollListener) {
                if (arg != null) {
                    ((NumberPicker) v).setOnScrollListener(new NumberPicker.OnScrollListener() {

                        public void onScrollStateChange(NumberPicker a0, int a1) {
                            ((NumberPicker.OnScrollListener) arg).onScrollStateChange(a0, a1);
                            Anvil.render();
                        }
                    });
                } else {
                    ((NumberPicker) v).setOnScrollListener((NumberPicker.OnScrollListener) null);
                }
                return true;
            }
            break;
        case "onSearchClick":
            if (v instanceof SearchView && arg instanceof View.OnClickListener) {
                if (arg != null) {
                    ((SearchView) v).setOnSearchClickListener(new View.OnClickListener() {

                        public void onClick(View a0) {
                            ((View.OnClickListener) arg).onClick(a0);
                            Anvil.render();
                        }
                    });
                } else {
                    ((SearchView) v).setOnSearchClickListener((View.OnClickListener) null);
                }
                return true;
            }
            break;
        case "onSeekBarChange":
            if (v instanceof SeekBar && arg instanceof SeekBar.OnSeekBarChangeListener) {
                if (arg != null) {
                    ((SeekBar) v).setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

                        public void onProgressChanged(SeekBar a0, int a1, boolean a2) {
                            ((SeekBar.OnSeekBarChangeListener) arg).onProgressChanged(a0, a1, a2);
                            Anvil.render();
                        }

                        public void onStartTrackingTouch(SeekBar a0) {
                            ((SeekBar.OnSeekBarChangeListener) arg).onStartTrackingTouch(a0);
                            Anvil.render();
                        }

                        public void onStopTrackingTouch(SeekBar a0) {
                            ((SeekBar.OnSeekBarChangeListener) arg).onStopTrackingTouch(a0);
                            Anvil.render();
                        }
                    });
                } else {
                    ((SeekBar) v).setOnSeekBarChangeListener((SeekBar.OnSeekBarChangeListener) null);
                }
                return true;
            }
            break;
        case "onSuggestion":
            if (v instanceof SearchView && arg instanceof SearchView.OnSuggestionListener) {
                if (arg != null) {
                    ((SearchView) v).setOnSuggestionListener(new SearchView.OnSuggestionListener() {

                        public boolean onSuggestionClick(int a0) {
                            boolean r = ((SearchView.OnSuggestionListener) arg).onSuggestionClick(a0);
                            Anvil.render();
                            return r;
                        }

                        public boolean onSuggestionSelect(int a0) {
                            boolean r = ((SearchView.OnSuggestionListener) arg).onSuggestionSelect(a0);
                            Anvil.render();
                            return r;
                        }
                    });
                } else {
                    ((SearchView) v).setOnSuggestionListener((SearchView.OnSuggestionListener) null);
                }
                return true;
            }
            break;
        case "onSystemUiVisibilityChange":
            if (arg != null) {
                v.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {

                    public void onSystemUiVisibilityChange(int a0) {
                        ((View.OnSystemUiVisibilityChangeListener) arg).onSystemUiVisibilityChange(a0);
                        Anvil.render();
                    }
                });
            } else {
                v.setOnSystemUiVisibilityChangeListener((View.OnSystemUiVisibilityChangeListener) null);
            }
            return true;
        case "onTabChanged":
            if (v instanceof TabHost && arg instanceof TabHost.OnTabChangeListener) {
                if (arg != null) {
                    ((TabHost) v).setOnTabChangedListener(new TabHost.OnTabChangeListener() {

                        public void onTabChanged(String a0) {
                            ((TabHost.OnTabChangeListener) arg).onTabChanged(a0);
                            Anvil.render();
                        }
                    });
                } else {
                    ((TabHost) v).setOnTabChangedListener((TabHost.OnTabChangeListener) null);
                }
                return true;
            }
            break;
        case "onTimeChanged":
            if (v instanceof TimePicker && arg instanceof TimePicker.OnTimeChangedListener) {
                if (arg != null) {
                    ((TimePicker) v).setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() {

                        public void onTimeChanged(TimePicker a0, int a1, int a2) {
                            ((TimePicker.OnTimeChangedListener) arg).onTimeChanged(a0, a1, a2);
                            Anvil.render();
                        }
                    });
                } else {
                    ((TimePicker) v).setOnTimeChangedListener((TimePicker.OnTimeChangedListener) null);
                }
                return true;
            }
            break;
        case "onTouch":
            if (arg != null) {
                v.setOnTouchListener(new View.OnTouchListener() {

                    public boolean onTouch(View a0, MotionEvent a1) {
                        boolean r = ((View.OnTouchListener) arg).onTouch(a0, a1);
                        Anvil.render();
                        return r;
                    }
                });
            } else {
                v.setOnTouchListener((View.OnTouchListener) null);
            }
            return true;
        case "onUnhandledInputEvent":
            if (v instanceof TvView && arg instanceof TvView.OnUnhandledInputEventListener) {
                if (arg != null) {
                    ((TvView) v).setOnUnhandledInputEventListener(new TvView.OnUnhandledInputEventListener() {

                        public boolean onUnhandledInputEvent(InputEvent a0) {
                            boolean r = ((TvView.OnUnhandledInputEventListener) arg).onUnhandledInputEvent(a0);
                            Anvil.render();
                            return r;
                        }
                    });
                } else {
                    ((TvView) v).setOnUnhandledInputEventListener((TvView.OnUnhandledInputEventListener) null);
                }
                return true;
            }
            break;
        case "onValueChanged":
            if (v instanceof NumberPicker && arg instanceof NumberPicker.OnValueChangeListener) {
                if (arg != null) {
                    ((NumberPicker) v).setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {

                        public void onValueChange(NumberPicker a0, int a1, int a2) {
                            ((NumberPicker.OnValueChangeListener) arg).onValueChange(a0, a1, a2);
                            Anvil.render();
                        }
                    });
                } else {
                    ((NumberPicker) v).setOnValueChangedListener((NumberPicker.OnValueChangeListener) null);
                }
                return true;
            }
            break;
        case "onZoomInClick":
            if (v instanceof ZoomControls && arg instanceof View.OnClickListener) {
                if (arg != null) {
                    ((ZoomControls) v).setOnZoomInClickListener(new View.OnClickListener() {

                        public void onClick(View a0) {
                            ((View.OnClickListener) arg).onClick(a0);
                            Anvil.render();
                        }
                    });
                } else {
                    ((ZoomControls) v).setOnZoomInClickListener((View.OnClickListener) null);
                }
                return true;
            }
            break;
        case "onZoomOutClick":
            if (v instanceof ZoomControls && arg instanceof View.OnClickListener) {
                if (arg != null) {
                    ((ZoomControls) v).setOnZoomOutClickListener(new View.OnClickListener() {

                        public void onClick(View a0) {
                            ((View.OnClickListener) arg).onClick(a0);
                            Anvil.render();
                        }
                    });
                } else {
                    ((ZoomControls) v).setOnZoomOutClickListener((View.OnClickListener) null);
                }
                return true;
            }
            break;
        case "opaque":
            if (v instanceof TextureView && arg instanceof Boolean) {
                ((TextureView) v).setOpaque((boolean) arg);
                return true;
            }
            break;
        case "orientation":
            if (v instanceof GestureOverlayView && arg instanceof Integer) {
                ((GestureOverlayView) v).setOrientation((int) arg);
                return true;
            }
            if (v instanceof GridLayout && arg instanceof Integer) {
                ((GridLayout) v).setOrientation((int) arg);
                return true;
            }
            if (v instanceof LinearLayout && arg instanceof Integer) {
                ((LinearLayout) v).setOrientation((int) arg);
                return true;
            }
            break;
        case "outAnimation":
            if (v instanceof AdapterViewAnimator && arg instanceof ObjectAnimator) {
                ((AdapterViewAnimator) v).setOutAnimation((ObjectAnimator) arg);
                return true;
            }
            if (v instanceof ViewAnimator && arg instanceof Animation) {
                ((ViewAnimator) v).setOutAnimation((Animation) arg);
                return true;
            }
            break;
        case "outlineProvider":
            if (arg instanceof ViewOutlineProvider) {
                v.setOutlineProvider((ViewOutlineProvider) arg);
                return true;
            }
            break;
        case "overScrollMode":
            if (arg instanceof Integer) {
                v.setOverScrollMode((int) arg);
                return true;
            }
            break;
        case "overlay":
            if (v instanceof QuickContactBadge && arg instanceof Drawable) {
                ((QuickContactBadge) v).setOverlay((Drawable) arg);
                return true;
            }
            break;
        case "overscrollFooter":
            if (v instanceof ListView && arg instanceof Drawable) {
                ((ListView) v).setOverscrollFooter((Drawable) arg);
                return true;
            }
            break;
        case "overscrollHeader":
            if (v instanceof ListView && arg instanceof Drawable) {
                ((ListView) v).setOverscrollHeader((Drawable) arg);
                return true;
            }
            break;
        case "paintFlags":
            if (v instanceof TextView && arg instanceof Integer) {
                ((TextView) v).setPaintFlags((int) arg);
                return true;
            }
            break;
        case "persistentDrawingCache":
            if (v instanceof ViewGroup && arg instanceof Integer) {
                ((ViewGroup) v).setPersistentDrawingCache((int) arg);
                return true;
            }
            break;
        case "pivotX":
            if (arg instanceof Float) {
                v.setPivotX((float) arg);
                return true;
            }
            break;
        case "pivotY":
            if (arg instanceof Float) {
                v.setPivotY((float) arg);
                return true;
            }
            break;
        case "popupBackgroundDrawable":
            if (v instanceof Spinner && arg instanceof Drawable) {
                ((Spinner) v).setPopupBackgroundDrawable((Drawable) arg);
                return true;
            }
            break;
        case "popupBackgroundResource":
            if (v instanceof Spinner && arg instanceof Integer) {
                ((Spinner) v).setPopupBackgroundResource((int) arg);
                return true;
            }
            break;
        case "popupParent":
            if (v instanceof KeyboardView && arg instanceof View) {
                ((KeyboardView) v).setPopupParent((View) arg);
                return true;
            }
            break;
        case "popupTheme":
            if (v instanceof ActionMenuView && arg instanceof Integer) {
                ((ActionMenuView) v).setPopupTheme((int) arg);
                return true;
            }
            if (v instanceof Toolbar && arg instanceof Integer) {
                ((Toolbar) v).setPopupTheme((int) arg);
                return true;
            }
            break;
        case "preserveEGLContextOnPause":
            if (v instanceof GLSurfaceView && arg instanceof Boolean) {
                ((GLSurfaceView) v).setPreserveEGLContextOnPause((boolean) arg);
                return true;
            }
            break;
        case "pressed":
            if (arg instanceof Boolean) {
                v.setPressed((boolean) arg);
                return true;
            }
            break;
        case "previewEnabled":
            if (v instanceof KeyboardView && arg instanceof Boolean) {
                ((KeyboardView) v).setPreviewEnabled((boolean) arg);
                return true;
            }
            break;
        case "privateImeOptions":
            if (v instanceof TextView && arg instanceof String) {
                ((TextView) v).setPrivateImeOptions((String) arg);
                return true;
            }
            break;
        case "progress":
            if (v instanceof ProgressBar && arg instanceof Integer) {
                ((ProgressBar) v).setProgress((int) arg);
                return true;
            }
            break;
        case "progressBackgroundTintList":
            if (v instanceof ProgressBar && arg instanceof ColorStateList) {
                ((ProgressBar) v).setProgressBackgroundTintList((ColorStateList) arg);
                return true;
            }
            break;
        case "progressBackgroundTintMode":
            if (v instanceof ProgressBar && arg instanceof PorterDuff.Mode) {
                ((ProgressBar) v).setProgressBackgroundTintMode((PorterDuff.Mode) arg);
                return true;
            }
            break;
        case "progressDrawable":
            if (v instanceof ProgressBar && arg instanceof Drawable) {
                ((ProgressBar) v).setProgressDrawable((Drawable) arg);
                return true;
            }
            break;
        case "progressDrawableTiled":
            if (v instanceof ProgressBar && arg instanceof Drawable) {
                ((ProgressBar) v).setProgressDrawableTiled((Drawable) arg);
                return true;
            }
            break;
        case "progressTintList":
            if (v instanceof ProgressBar && arg instanceof ColorStateList) {
                ((ProgressBar) v).setProgressTintList((ColorStateList) arg);
                return true;
            }
            break;
        case "progressTintMode":
            if (v instanceof ProgressBar && arg instanceof PorterDuff.Mode) {
                ((ProgressBar) v).setProgressTintMode((PorterDuff.Mode) arg);
                return true;
            }
            break;
        case "prompt":
            if (v instanceof Spinner && arg instanceof CharSequence) {
                ((Spinner) v).setPrompt((CharSequence) arg);
                return true;
            }
            break;
        case "promptId":
            if (v instanceof Spinner && arg instanceof Integer) {
                ((Spinner) v).setPromptId((int) arg);
                return true;
            }
            break;
        case "proximityCorrectionEnabled":
            if (v instanceof KeyboardView && arg instanceof Boolean) {
                ((KeyboardView) v).setProximityCorrectionEnabled((boolean) arg);
                return true;
            }
            break;
        case "queryHint":
            if (v instanceof SearchView && arg instanceof CharSequence) {
                ((SearchView) v).setQueryHint((CharSequence) arg);
                return true;
            }
            break;
        case "queryRefinementEnabled":
            if (v instanceof SearchView && arg instanceof Boolean) {
                ((SearchView) v).setQueryRefinementEnabled((boolean) arg);
                return true;
            }
            break;
        case "rating":
            if (v instanceof RatingBar && arg instanceof Float) {
                ((RatingBar) v).setRating((float) arg);
                return true;
            }
            break;
        case "rawInputType":
            if (v instanceof TextView && arg instanceof Integer) {
                ((TextView) v).setRawInputType((int) arg);
                return true;
            }
            break;
        case "recyclerListener":
            if (v instanceof AbsListView && arg instanceof AbsListView.RecyclerListener) {
                ((AbsListView) v).setRecyclerListener((AbsListView.RecyclerListener) arg);
                return true;
            }
            break;
        case "remoteViewsAdapter":
            if (v instanceof AbsListView && arg instanceof Intent) {
                ((AbsListView) v).setRemoteViewsAdapter((Intent) arg);
                return true;
            }
            if (v instanceof AdapterViewAnimator && arg instanceof Intent) {
                ((AdapterViewAnimator) v).setRemoteViewsAdapter((Intent) arg);
                return true;
            }
            break;
        case "renderMode":
            if (v instanceof GLSurfaceView && arg instanceof Integer) {
                ((GLSurfaceView) v).setRenderMode((int) arg);
                return true;
            }
            break;
        case "renderer":
            if (v instanceof GLSurfaceView && arg instanceof GLSurfaceView.Renderer) {
                ((GLSurfaceView) v).setRenderer((GLSurfaceView.Renderer) arg);
                return true;
            }
            break;
        case "right":
            if (arg instanceof Integer) {
                v.setRight((int) arg);
                return true;
            }
            break;
        case "rightStripDrawable":
            if (v instanceof TabWidget && arg instanceof Drawable) {
                ((TabWidget) v).setRightStripDrawable((Drawable) arg);
                return true;
            }
            if (v instanceof TabWidget && arg instanceof Integer) {
                ((TabWidget) v).setRightStripDrawable((int) arg);
                return true;
            }
            break;
        case "rotation":
            if (arg instanceof Float) {
                v.setRotation((float) arg);
                return true;
            }
            break;
        case "rotationX":
            if (arg instanceof Float) {
                v.setRotationX((float) arg);
                return true;
            }
            break;
        case "rotationY":
            if (arg instanceof Float) {
                v.setRotationY((float) arg);
                return true;
            }
            break;
        case "routeTypes":
            if (v instanceof MediaRouteButton && arg instanceof Integer) {
                ((MediaRouteButton) v).setRouteTypes((int) arg);
                return true;
            }
            break;
        case "rowCount":
            if (v instanceof GridLayout && arg instanceof Integer) {
                ((GridLayout) v).setRowCount((int) arg);
                return true;
            }
            break;
        case "rowOrderPreserved":
            if (v instanceof GridLayout && arg instanceof Boolean) {
                ((GridLayout) v).setRowOrderPreserved((boolean) arg);
                return true;
            }
            break;
        case "saveEnabled":
            if (arg instanceof Boolean) {
                v.setSaveEnabled((boolean) arg);
                return true;
            }
            break;
        case "saveFromParentEnabled":
            if (arg instanceof Boolean) {
                v.setSaveFromParentEnabled((boolean) arg);
                return true;
            }
            break;
        case "scaleType":
            if (v instanceof ImageView && arg instanceof ImageView.ScaleType) {
                ((ImageView) v).setScaleType((ImageView.ScaleType) arg);
                return true;
            }
            break;
        case "scaleX":
            if (arg instanceof Float) {
                v.setScaleX((float) arg);
                return true;
            }
            break;
        case "scaleY":
            if (arg instanceof Float) {
                v.setScaleY((float) arg);
                return true;
            }
            break;
        case "scrollBarDefaultDelayBeforeFade":
            if (arg instanceof Integer) {
                v.setScrollBarDefaultDelayBeforeFade((int) arg);
                return true;
            }
            break;
        case "scrollBarFadeDuration":
            if (arg instanceof Integer) {
                v.setScrollBarFadeDuration((int) arg);
                return true;
            }
            break;
        case "scrollBarSize":
            if (arg instanceof Integer) {
                v.setScrollBarSize((int) arg);
                return true;
            }
            break;
        case "scrollBarStyle":
            if (arg instanceof Integer) {
                v.setScrollBarStyle((int) arg);
                return true;
            }
            break;
        case "scrollContainer":
            if (arg instanceof Boolean) {
                v.setScrollContainer((boolean) arg);
                return true;
            }
            break;
        case "scrollX":
            if (arg instanceof Integer) {
                v.setScrollX((int) arg);
                return true;
            }
            break;
        case "scrollY":
            if (arg instanceof Integer) {
                v.setScrollY((int) arg);
                return true;
            }
            break;
        case "scrollbarFadingEnabled":
            if (arg instanceof Boolean) {
                v.setScrollbarFadingEnabled((boolean) arg);
                return true;
            }
            break;
        case "scroller":
            if (v instanceof TextView && arg instanceof Scroller) {
                ((TextView) v).setScroller((Scroller) arg);
                return true;
            }
            break;
        case "scrollingCacheEnabled":
            if (v instanceof AbsListView && arg instanceof Boolean) {
                ((AbsListView) v).setScrollingCacheEnabled((boolean) arg);
                return true;
            }
            break;
        case "searchableInfo":
            if (v instanceof SearchView && arg instanceof SearchableInfo) {
                ((SearchView) v).setSearchableInfo((SearchableInfo) arg);
                return true;
            }
            break;
        case "secondaryProgress":
            if (v instanceof ProgressBar && arg instanceof Integer) {
                ((ProgressBar) v).setSecondaryProgress((int) arg);
                return true;
            }
            break;
        case "secondaryProgressTintList":
            if (v instanceof ProgressBar && arg instanceof ColorStateList) {
                ((ProgressBar) v).setSecondaryProgressTintList((ColorStateList) arg);
                return true;
            }
            break;
        case "secondaryProgressTintMode":
            if (v instanceof ProgressBar && arg instanceof PorterDuff.Mode) {
                ((ProgressBar) v).setSecondaryProgressTintMode((PorterDuff.Mode) arg);
                return true;
            }
            break;
        case "secure":
            if (v instanceof SurfaceView && arg instanceof Boolean) {
                ((SurfaceView) v).setSecure((boolean) arg);
                return true;
            }
            break;
        case "selectAllOnFocus":
            if (v instanceof TextView && arg instanceof Boolean) {
                ((TextView) v).setSelectAllOnFocus((boolean) arg);
                return true;
            }
            break;
        case "selected":
            if (arg instanceof Boolean) {
                v.setSelected((boolean) arg);
                return true;
            }
            break;
        case "selectedDateVerticalBar":
            if (v instanceof CalendarView && arg instanceof Drawable) {
                ((CalendarView) v).setSelectedDateVerticalBar((Drawable) arg);
                return true;
            }
            if (v instanceof CalendarView && arg instanceof Integer) {
                ((CalendarView) v).setSelectedDateVerticalBar((int) arg);
                return true;
            }
            break;
        case "selectedGroup":
            if (v instanceof ExpandableListView && arg instanceof Integer) {
                ((ExpandableListView) v).setSelectedGroup((int) arg);
                return true;
            }
            break;
        case "selectedWeekBackgroundColor":
            if (v instanceof CalendarView && arg instanceof Integer) {
                ((CalendarView) v).setSelectedWeekBackgroundColor((int) arg);
                return true;
            }
            break;
        case "selection":
            if (v instanceof AdapterView && arg instanceof Integer) {
                ((AdapterView) v).setSelection((int) arg);
                return true;
            }
            if (v instanceof EditText && arg instanceof Integer) {
                ((EditText) v).setSelection((int) arg);
                return true;
            }
            break;
        case "selector":
            if (v instanceof AbsListView && arg instanceof Drawable) {
                ((AbsListView) v).setSelector((Drawable) arg);
                return true;
            }
            if (v instanceof AbsListView && arg instanceof Integer) {
                ((AbsListView) v).setSelector((int) arg);
                return true;
            }
            break;
        case "shifted":
            if (v instanceof KeyboardView && arg instanceof Boolean) {
                ((KeyboardView) v).setShifted((boolean) arg);
                return true;
            }
            break;
        case "showDividers":
            if (v instanceof LinearLayout && arg instanceof Integer) {
                ((LinearLayout) v).setShowDividers((int) arg);
                return true;
            }
            break;
        case "showSoftInputOnFocus":
            if (v instanceof TextView && arg instanceof Boolean) {
                ((TextView) v).setShowSoftInputOnFocus((boolean) arg);
                return true;
            }
            break;
        case "showText":
            if (v instanceof Switch && arg instanceof Boolean) {
                ((Switch) v).setShowText((boolean) arg);
                return true;
            }
            break;
        case "showWeekNumber":
            if (v instanceof CalendarView && arg instanceof Boolean) {
                ((CalendarView) v).setShowWeekNumber((boolean) arg);
                return true;
            }
            break;
        case "shownWeekCount":
            if (v instanceof CalendarView && arg instanceof Integer) {
                ((CalendarView) v).setShownWeekCount((int) arg);
                return true;
            }
            break;
        case "shrinkAllColumns":
            if (v instanceof TableLayout && arg instanceof Boolean) {
                ((TableLayout) v).setShrinkAllColumns((boolean) arg);
                return true;
            }
            break;
        case "singleLine":
            if (v instanceof TextView && arg instanceof Boolean) {
                ((TextView) v).setSingleLine((boolean) arg);
                return true;
            }
            break;
        case "smoothScrollbarEnabled":
            if (v instanceof AbsListView && arg instanceof Boolean) {
                ((AbsListView) v).setSmoothScrollbarEnabled((boolean) arg);
                return true;
            }
            break;
        case "smoothScrollingEnabled":
            if (v instanceof HorizontalScrollView && arg instanceof Boolean) {
                ((HorizontalScrollView) v).setSmoothScrollingEnabled((boolean) arg);
                return true;
            }
            if (v instanceof ScrollView && arg instanceof Boolean) {
                ((ScrollView) v).setSmoothScrollingEnabled((boolean) arg);
                return true;
            }
            break;
        case "soundEffectsEnabled":
            if (arg instanceof Boolean) {
                v.setSoundEffectsEnabled((boolean) arg);
                return true;
            }
            break;
        case "spacing":
            if (v instanceof Gallery && arg instanceof Integer) {
                ((Gallery) v).setSpacing((int) arg);
                return true;
            }
            break;
        case "spannableFactory":
            if (v instanceof TextView && arg instanceof Spannable.Factory) {
                ((TextView) v).setSpannableFactory((Spannable.Factory) arg);
                return true;
            }
            break;
        case "spinnersShown":
            if (v instanceof DatePicker && arg instanceof Boolean) {
                ((DatePicker) v).setSpinnersShown((boolean) arg);
                return true;
            }
            break;
        case "splitTrack":
            if (v instanceof AbsSeekBar && arg instanceof Boolean) {
                ((AbsSeekBar) v).setSplitTrack((boolean) arg);
                return true;
            }
            if (v instanceof Switch && arg instanceof Boolean) {
                ((Switch) v).setSplitTrack((boolean) arg);
                return true;
            }
            break;
        case "stackFromBottom":
            if (v instanceof AbsListView && arg instanceof Boolean) {
                ((AbsListView) v).setStackFromBottom((boolean) arg);
                return true;
            }
            break;
        case "stateListAnimator":
            if (arg instanceof StateListAnimator) {
                v.setStateListAnimator((StateListAnimator) arg);
                return true;
            }
            break;
        case "stepSize":
            if (v instanceof RatingBar && arg instanceof Float) {
                ((RatingBar) v).setStepSize((float) arg);
                return true;
            }
            break;
        case "streamVolume":
            if (v instanceof TvView && arg instanceof Float) {
                ((TvView) v).setStreamVolume((float) arg);
                return true;
            }
            break;
        case "stretchAllColumns":
            if (v instanceof TableLayout && arg instanceof Boolean) {
                ((TableLayout) v).setStretchAllColumns((boolean) arg);
                return true;
            }
            break;
        case "stretchMode":
            if (v instanceof GridView && arg instanceof Integer) {
                ((GridView) v).setStretchMode((int) arg);
                return true;
            }
            break;
        case "stripEnabled":
            if (v instanceof TabWidget && arg instanceof Boolean) {
                ((TabWidget) v).setStripEnabled((boolean) arg);
                return true;
            }
            break;
        case "submitButtonEnabled":
            if (v instanceof SearchView && arg instanceof Boolean) {
                ((SearchView) v).setSubmitButtonEnabled((boolean) arg);
                return true;
            }
            break;
        case "subtitle":
            if (v instanceof Toolbar && arg instanceof Integer) {
                ((Toolbar) v).setSubtitle((int) arg);
                return true;
            }
            if (v instanceof Toolbar && arg instanceof CharSequence) {
                ((Toolbar) v).setSubtitle((CharSequence) arg);
                return true;
            }
            break;
        case "subtitleTextColor":
            if (v instanceof Toolbar && arg instanceof Integer) {
                ((Toolbar) v).setSubtitleTextColor((int) arg);
                return true;
            }
            break;
        case "suggestionsAdapter":
            if (v instanceof SearchView && arg instanceof CursorAdapter) {
                ((SearchView) v).setSuggestionsAdapter((CursorAdapter) arg);
                return true;
            }
            break;
        case "surfaceTexture":
            if (v instanceof TextureView && arg instanceof SurfaceTexture) {
                ((TextureView) v).setSurfaceTexture((SurfaceTexture) arg);
                return true;
            }
            break;
        case "surfaceTextureListener":
            if (v instanceof TextureView && arg instanceof TextureView.SurfaceTextureListener) {
                ((TextureView) v).setSurfaceTextureListener((TextureView.SurfaceTextureListener) arg);
                return true;
            }
            break;
        case "switchMinWidth":
            if (v instanceof Switch && arg instanceof Integer) {
                ((Switch) v).setSwitchMinWidth((int) arg);
                return true;
            }
            break;
        case "switchPadding":
            if (v instanceof Switch && arg instanceof Integer) {
                ((Switch) v).setSwitchPadding((int) arg);
                return true;
            }
            break;
        case "switchTypeface":
            if (v instanceof Switch && arg instanceof Typeface) {
                ((Switch) v).setSwitchTypeface((Typeface) arg);
                return true;
            }
            break;
        case "systemUiVisibility":
            if (arg instanceof Integer) {
                v.setSystemUiVisibility((int) arg);
                return true;
            }
            break;
        case "tag":
            if (arg instanceof Object) {
                v.setTag((Object) arg);
                return true;
            }
            break;
        case "text":
            if (v instanceof TextView && arg instanceof Integer) {
                ((TextView) v).setText((int) arg);
                return true;
            }
            if (v instanceof TextSwitcher && arg instanceof CharSequence) {
                ((TextSwitcher) v).setText((CharSequence) arg);
                return true;
            }
            break;
        case "textAlignment":
            if (arg instanceof Integer) {
                v.setTextAlignment((int) arg);
                return true;
            }
            break;
        case "textColor":
            if (v instanceof TextView && arg instanceof ColorStateList) {
                ((TextView) v).setTextColor((ColorStateList) arg);
                return true;
            }
            if (v instanceof TextView && arg instanceof Integer) {
                ((TextView) v).setTextColor((int) arg);
                return true;
            }
            break;
        case "textDirection":
            if (arg instanceof Integer) {
                v.setTextDirection((int) arg);
                return true;
            }
            break;
        case "textFilterEnabled":
            if (v instanceof AbsListView && arg instanceof Boolean) {
                ((AbsListView) v).setTextFilterEnabled((boolean) arg);
                return true;
            }
            break;
        case "textIsSelectable":
            if (v instanceof TextView && arg instanceof Boolean) {
                ((TextView) v).setTextIsSelectable((boolean) arg);
                return true;
            }
            break;
        case "textKeepState":
            if (v instanceof TextView && arg instanceof CharSequence) {
                ((TextView) v).setTextKeepState((CharSequence) arg);
                return true;
            }
            break;
        case "textLocale":
            if (v instanceof TextView && arg instanceof Locale) {
                ((TextView) v).setTextLocale((Locale) arg);
                return true;
            }
            break;
        case "textOff":
            if (v instanceof Switch && arg instanceof CharSequence) {
                ((Switch) v).setTextOff((CharSequence) arg);
                return true;
            }
            if (v instanceof ToggleButton && arg instanceof CharSequence) {
                ((ToggleButton) v).setTextOff((CharSequence) arg);
                return true;
            }
            break;
        case "textOn":
            if (v instanceof Switch && arg instanceof CharSequence) {
                ((Switch) v).setTextOn((CharSequence) arg);
                return true;
            }
            if (v instanceof ToggleButton && arg instanceof CharSequence) {
                ((ToggleButton) v).setTextOn((CharSequence) arg);
                return true;
            }
            break;
        case "textScaleX":
            if (v instanceof TextView && arg instanceof Float) {
                ((TextView) v).setTextScaleX((float) arg);
                return true;
            }
            break;
        case "threshold":
            if (v instanceof AutoCompleteTextView && arg instanceof Integer) {
                ((AutoCompleteTextView) v).setThreshold((int) arg);
                return true;
            }
            break;
        case "thumb":
            if (v instanceof AbsSeekBar && arg instanceof Drawable) {
                ((AbsSeekBar) v).setThumb((Drawable) arg);
                return true;
            }
            break;
        case "thumbDrawable":
            if (v instanceof Switch && arg instanceof Drawable) {
                ((Switch) v).setThumbDrawable((Drawable) arg);
                return true;
            }
            break;
        case "thumbOffset":
            if (v instanceof AbsSeekBar && arg instanceof Integer) {
                ((AbsSeekBar) v).setThumbOffset((int) arg);
                return true;
            }
            break;
        case "thumbResource":
            if (v instanceof Switch && arg instanceof Integer) {
                ((Switch) v).setThumbResource((int) arg);
                return true;
            }
            break;
        case "thumbTextPadding":
            if (v instanceof Switch && arg instanceof Integer) {
                ((Switch) v).setThumbTextPadding((int) arg);
                return true;
            }
            break;
        case "thumbTintList":
            if (v instanceof AbsSeekBar && arg instanceof ColorStateList) {
                ((AbsSeekBar) v).setThumbTintList((ColorStateList) arg);
                return true;
            }
            break;
        case "thumbTintMode":
            if (v instanceof AbsSeekBar && arg instanceof PorterDuff.Mode) {
                ((AbsSeekBar) v).setThumbTintMode((PorterDuff.Mode) arg);
                return true;
            }
            break;
        case "timeZone":
            if (v instanceof TextClock && arg instanceof String) {
                ((TextClock) v).setTimeZone((String) arg);
                return true;
            }
            break;
        case "title":
            if (v instanceof Toolbar && arg instanceof Integer) {
                ((Toolbar) v).setTitle((int) arg);
                return true;
            }
            if (v instanceof Toolbar && arg instanceof CharSequence) {
                ((Toolbar) v).setTitle((CharSequence) arg);
                return true;
            }
            break;
        case "titleTextColor":
            if (v instanceof Toolbar && arg instanceof Integer) {
                ((Toolbar) v).setTitleTextColor((int) arg);
                return true;
            }
            break;
        case "tokenizer":
            if (v instanceof MultiAutoCompleteTextView && arg instanceof MultiAutoCompleteTextView.Tokenizer) {
                ((MultiAutoCompleteTextView) v).setTokenizer((MultiAutoCompleteTextView.Tokenizer) arg);
                return true;
            }
            break;
        case "top":
            if (arg instanceof Integer) {
                v.setTop((int) arg);
                return true;
            }
            break;
        case "touchDelegate":
            if (arg instanceof TouchDelegate) {
                v.setTouchDelegate((TouchDelegate) arg);
                return true;
            }
            break;
        case "touchscreenBlocksFocus":
            if (v instanceof ViewGroup && arg instanceof Boolean) {
                ((ViewGroup) v).setTouchscreenBlocksFocus((boolean) arg);
                return true;
            }
            break;
        case "trackDrawable":
            if (v instanceof Switch && arg instanceof Drawable) {
                ((Switch) v).setTrackDrawable((Drawable) arg);
                return true;
            }
            break;
        case "trackResource":
            if (v instanceof Switch && arg instanceof Integer) {
                ((Switch) v).setTrackResource((int) arg);
                return true;
            }
            break;
        case "transcriptMode":
            if (v instanceof AbsListView && arg instanceof Integer) {
                ((AbsListView) v).setTranscriptMode((int) arg);
                return true;
            }
            break;
        case "transform":
            if (v instanceof TextureView && arg instanceof Matrix) {
                ((TextureView) v).setTransform((Matrix) arg);
                return true;
            }
            break;
        case "transformationMethod":
            if (v instanceof TextView && arg instanceof TransformationMethod) {
                ((TextView) v).setTransformationMethod((TransformationMethod) arg);
                return true;
            }
            break;
        case "transitionGroup":
            if (v instanceof ViewGroup && arg instanceof Boolean) {
                ((ViewGroup) v).setTransitionGroup((boolean) arg);
                return true;
            }
            break;
        case "transitionName":
            if (arg instanceof String) {
                v.setTransitionName((String) arg);
                return true;
            }
            break;
        case "translationX":
            if (arg instanceof Float) {
                v.setTranslationX((float) arg);
                return true;
            }
            break;
        case "translationY":
            if (arg instanceof Float) {
                v.setTranslationY((float) arg);
                return true;
            }
            break;
        case "translationZ":
            if (arg instanceof Float) {
                v.setTranslationZ((float) arg);
                return true;
            }
            break;
        case "typeface":
            if (v instanceof TextView && arg instanceof Typeface) {
                ((TextView) v).setTypeface((Typeface) arg);
                return true;
            }
            break;
        case "uncertainGestureColor":
            if (v instanceof GestureOverlayView && arg instanceof Integer) {
                ((GestureOverlayView) v).setUncertainGestureColor((int) arg);
                return true;
            }
            break;
        case "unfocusedMonthDateColor":
            if (v instanceof CalendarView && arg instanceof Integer) {
                ((CalendarView) v).setUnfocusedMonthDateColor((int) arg);
                return true;
            }
            break;
        case "unselectedAlpha":
            if (v instanceof Gallery && arg instanceof Float) {
                ((Gallery) v).setUnselectedAlpha((float) arg);
                return true;
            }
            break;
        case "up":
            if (v instanceof TabHost && arg instanceof LocalActivityManager) {
                ((TabHost) v).setup((LocalActivityManager) arg);
                return true;
            }
            break;
        case "useDefaultMargins":
            if (v instanceof GridLayout && arg instanceof Boolean) {
                ((GridLayout) v).setUseDefaultMargins((boolean) arg);
                return true;
            }
            break;
        case "validator":
            if (v instanceof AutoCompleteTextView && arg instanceof AutoCompleteTextView.Validator) {
                ((AutoCompleteTextView) v).setValidator((AutoCompleteTextView.Validator) arg);
                return true;
            }
            break;
        case "value":
            if (v instanceof NumberPicker && arg instanceof Integer) {
                ((NumberPicker) v).setValue((int) arg);
                return true;
            }
            break;
        case "velocityScale":
            if (v instanceof AbsListView && arg instanceof Float) {
                ((AbsListView) v).setVelocityScale((float) arg);
                return true;
            }
            break;
        case "verticalCorrection":
            if (v instanceof KeyboardView && arg instanceof Integer) {
                ((KeyboardView) v).setVerticalCorrection((int) arg);
                return true;
            }
            break;
        case "verticalFadingEdgeEnabled":
            if (arg instanceof Boolean) {
                v.setVerticalFadingEdgeEnabled((boolean) arg);
                return true;
            }
            break;
        case "verticalGravity":
            if (v instanceof LinearLayout && arg instanceof Integer) {
                ((LinearLayout) v).setVerticalGravity((int) arg);
                return true;
            }
            if (v instanceof RelativeLayout && arg instanceof Integer) {
                ((RelativeLayout) v).setVerticalGravity((int) arg);
                return true;
            }
            break;
        case "verticalScrollBarEnabled":
            if (arg instanceof Boolean) {
                v.setVerticalScrollBarEnabled((boolean) arg);
                return true;
            }
            break;
        case "verticalScrollbarOverlay":
            if (v instanceof WebView && arg instanceof Boolean) {
                ((WebView) v).setVerticalScrollbarOverlay((boolean) arg);
                return true;
            }
            break;
        case "verticalScrollbarPosition":
            if (arg instanceof Integer) {
                v.setVerticalScrollbarPosition((int) arg);
                return true;
            }
            break;
        case "verticalSpacing":
            if (v instanceof GridView && arg instanceof Integer) {
                ((GridView) v).setVerticalSpacing((int) arg);
                return true;
            }
            break;
        case "videoPath":
            if (v instanceof VideoView && arg instanceof String) {
                ((VideoView) v).setVideoPath((String) arg);
                return true;
            }
            break;
        case "videoURI":
            if (v instanceof VideoView && arg instanceof Uri) {
                ((VideoView) v).setVideoURI((Uri) arg);
                return true;
            }
            break;
        case "visibility":
            if (arg instanceof Integer) {
                v.setVisibility((int) arg);
                return true;
            }
            break;
        case "webChromeClient":
            if (v instanceof WebView && arg instanceof WebChromeClient) {
                ((WebView) v).setWebChromeClient((WebChromeClient) arg);
                return true;
            }
            break;
        case "webContentsDebuggingEnabled":
            if (v instanceof WebView && arg instanceof Boolean) {
                ((WebView) v).setWebContentsDebuggingEnabled((boolean) arg);
                return true;
            }
            break;
        case "webViewClient":
            if (v instanceof WebView && arg instanceof WebViewClient) {
                ((WebView) v).setWebViewClient((WebViewClient) arg);
                return true;
            }
            break;
        case "weekDayTextAppearance":
            if (v instanceof CalendarView && arg instanceof Integer) {
                ((CalendarView) v).setWeekDayTextAppearance((int) arg);
                return true;
            }
            break;
        case "weekNumberColor":
            if (v instanceof CalendarView && arg instanceof Integer) {
                ((CalendarView) v).setWeekNumberColor((int) arg);
                return true;
            }
            break;
        case "weekSeparatorLineColor":
            if (v instanceof CalendarView && arg instanceof Integer) {
                ((CalendarView) v).setWeekSeparatorLineColor((int) arg);
                return true;
            }
            break;
        case "weightSum":
            if (v instanceof LinearLayout && arg instanceof Float) {
                ((LinearLayout) v).setWeightSum((float) arg);
                return true;
            }
            break;
        case "width":
            if (v instanceof TextView && arg instanceof Integer) {
                ((TextView) v).setWidth((int) arg);
                return true;
            }
            break;
        case "willNotCacheDrawing":
            if (arg instanceof Boolean) {
                v.setWillNotCacheDrawing((boolean) arg);
                return true;
            }
            break;
        case "willNotDraw":
            if (arg instanceof Boolean) {
                v.setWillNotDraw((boolean) arg);
                return true;
            }
            break;
        case "wrapSelectorWheel":
            if (v instanceof NumberPicker && arg instanceof Boolean) {
                ((NumberPicker) v).setWrapSelectorWheel((boolean) arg);
                return true;
            }
            break;
        case "x":
            if (arg instanceof Float) {
                v.setX((float) arg);
                return true;
            }
            break;
        case "y":
            if (arg instanceof Float) {
                v.setY((float) arg);
                return true;
            }
            break;
        case "z":
            if (arg instanceof Float) {
                v.setZ((float) arg);
                return true;
            }
            break;
        case "zOrderMediaOverlay":
            if (v instanceof SurfaceView && arg instanceof Boolean) {
                ((SurfaceView) v).setZOrderMediaOverlay((boolean) arg);
                return true;
            }
            break;
        case "zOrderOnTop":
            if (v instanceof SurfaceView && arg instanceof Boolean) {
                ((SurfaceView) v).setZOrderOnTop((boolean) arg);
                return true;
            }
            break;
        case "zoomSpeed":
            if (v instanceof ZoomButton && arg instanceof Long) {
                ((ZoomButton) v).setZoomSpeed((long) arg);
                return true;
            }
            if (v instanceof ZoomControls && arg instanceof Long) {
                ((ZoomControls) v).setZoomSpeed((long) arg);
                return true;
            }
            break;
    }
    return false;
}
Example 40
Project: XBrowser-master  File: Tab.java View source code
/**
     * Sets the WebView for this tab, correctly removing the old WebView from
     * the container view.
     */
void setWebView(WebView w) {
    if (mMainView == w) {
        return;
    }
    // Geolocation permission requests are void.
    if (mGeolocationPermissionsPrompt != null) {
        mGeolocationPermissionsPrompt.hide();
    }
    mWebViewController.onSetWebView(this, w);
    if (mMainView != null) {
        mMainView.setPictureListener(null);
        if (w != null) {
            syncCurrentState(w, null);
        } else {
            mCurrentState = new PageState(mContext, false);
        }
    }
    // set the new one
    mMainView = w;
    // attach the WebViewClient, WebChromeClient and DownloadListener
    if (mMainView != null) {
        mMainView.setWebViewClient(mWebViewClient);
        mMainView.setWebChromeClient(mWebChromeClient);
        // Attach DownloadManager so that downloads can start in an active
        // or a non-active window. This can happen when going to a site that
        // does a redirect after a period of time. The user could have
        // switched to another tab while waiting for the download to start.
        mMainView.setDownloadListener(mDownloadListener);
        mMainView.setWebBackForwardListClient(mWebBackForwardListClient);
        TabControl tc = mWebViewController.getTabControl();
        if (tc != null && tc.getOnThumbnailUpdatedListener() != null) {
            mMainView.setPictureListener(this);
        }
        if (mSavedState != null) {
            WebBackForwardList restoredState = mMainView.restoreState(mSavedState);
            if (restoredState == null || restoredState.getSize() == 0) {
                Log.w(LOGTAG, "Failed to restore WebView state!");
                loadUrl(mCurrentState.mOriginalUrl, null);
            }
            mSavedState = null;
        }
    }
}
Example 41
Project: materialistic-master  File: ShadowWebView.java View source code
@Implementation
public void setDownloadListener(DownloadListener listener) {
    downloadListener = listener;
}
Example 42
Project: Android_Skin_2.0-master  File: CompatWebView.java View source code
@Override
public void setDownloadListener(DownloadListener listener) {
    if (listener == mDefaultDownloadListener) {
        super.setDownloadListener(listener);
    } else {
        mDelegateDownloadListener = listener;
    }
}
Example 43
Project: chromeview-master  File: ChromeAwContentsClientProxy.java View source code
/** Resets the DownloadListener proxy target. */
public void setDownloadListener(DownloadListener downloadListener) {
    downloadListener_ = downloadListener;
}
Example 44
Project: ChromeBrowser-master  File: WebView.java View source code
public void setDownloadListener(DownloadListener listener) {
    mContentsClientAdapter.setDownloadListener(listener);
}