Example usage for android.webkit ConsoleMessage lineNumber

List of usage examples for android.webkit ConsoleMessage lineNumber

Introduction

In this page you can find the example usage for android.webkit ConsoleMessage lineNumber.

Prototype

public int lineNumber() 

Source Link

Usage

From source file:com.irccloud.android.activity.PastebinViewerActivity.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override//  w  ww  .j ava  2  s. c  om
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTheme(ColorScheme.getDialogWhenLargeTheme(ColorScheme.getUserTheme()));
    onMultiWindowModeChanged(isMultiWindow());
    if (savedInstanceState == null && (getWindowManager().getDefaultDisplay().getWidth() < TypedValue
            .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 800, getResources().getDisplayMetrics())
            || isMultiWindow()))
        overridePendingTransition(R.anim.slide_in_right, R.anim.fade_out);
    setContentView(R.layout.activity_pastebin);
    mSpinner = findViewById(R.id.spinner);
    toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    toolbar.setNavigationIcon(android.support.v7.appcompat.R.drawable.abc_ic_ab_back_material);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            finish();
        }
    });

    getSupportActionBar().setTitle("");
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mWebView = findViewById(R.id.image);
    mWebView.setBackgroundColor(ColorScheme.getInstance().contentBackgroundColor);
    mWebView.getSettings().setBuiltInZoomControls(true);
    if (Integer.parseInt(Build.VERSION.SDK) >= 19)
        mWebView.getSettings()
                .setDisplayZoomControls(!getPackageManager().hasSystemFeature("android.hardware.touchscreen"));
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.addJavascriptInterface(new JSInterface(), "Android");
    mWebView.getSettings().setLoadWithOverviewMode(false);
    mWebView.getSettings().setUseWideViewPort(false);
    mWebView.getSettings().setAppCacheEnabled(false);
    mWebView.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageFinished(WebView view, String url) {
        }

        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            fail();
        }

        @Override
        public void onLoadResource(WebView view, String url) {
        }
    });
    mWebView.setWebChromeClient(new WebChromeClient() {
        @Override
        public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
            Crashlytics.log(
                    consoleMessage.messageLevel() == ConsoleMessage.MessageLevel.ERROR ? Log.ERROR : Log.WARN,
                    "IRCCloud", "Javascript error - line: " + consoleMessage.lineNumber() + " message: "
                            + consoleMessage.message());
            return super.onConsoleMessage(consoleMessage);
        }
    });

    if (savedInstanceState != null && savedInstanceState.containsKey("url")) {
        url = savedInstanceState.getString("url");
        html = savedInstanceState.getString("html");
        mWebView.loadDataWithBaseURL(url, html, "text/html", "UTF-8", null);
    } else {
        if (getIntent() != null && getIntent().getDataString() != null) {
            url = getIntent().getDataString().replace(getResources().getString(R.string.PASTE_SCHEME), "https");
            if (!url.contains("?"))
                url += "?";
            try {
                url += "&mobile=android&version="
                        + getPackageManager().getPackageInfo(getPackageName(), 0).versionName + "&theme="
                        + ColorScheme.getUserTheme();
            } catch (PackageManager.NameNotFoundException e) {
            }
            new FetchPastebinTask().execute();
            Answers.getInstance().logContentView(new ContentViewEvent().putContentType("Pastebin"));
        } else {
            finish();
        }
    }
}

From source file:com.chatwingsdk.activities.CommunicationActivity.java

@SuppressLint("SetJavaScriptEnabled")
@Override// w w w. j av  a 2 s  .  c  om
public void ensureWebViewAndSubscribeToChannels() {
    if (mCurrentCommunicationMode == null)
        return;
    // Check whether the web view is available or not.
    // If not, init it and load faye client. When loading finished,
    // this method will be recursively called. At that point,
    // the actual subscribe code will be executed.
    if (mWebView == null) {
        mNotSubscribeToChannels = true;
        mWebView = new WebView(this);

        WebSettings webSettings = mWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);

        mWebView.addJavascriptInterface(mFayeJsInterface, ChatWingJSInterface.CHATWING_JS_NAME);

        mWebView.setWebChromeClient(new WebChromeClient() {
            @Override
            public boolean onConsoleMessage(ConsoleMessage consoleMessage) {

                LogUtils.v(consoleMessage.message() + " -- level " + consoleMessage.messageLevel()
                        + " -- From line " + consoleMessage.lineNumber() + " of " + consoleMessage.sourceId());

                //This workaround tries to fix issue webview is not subscribe successfully
                //when the screen is off, we cant listen for otto event since it's dead before that
                //this likely happens on development or very rare case in production
                if (consoleMessage.messageLevel().equals(ConsoleMessage.MessageLevel.ERROR)) {
                    mWebView = null;
                    mNotSubscribeToChannels = true;
                }
                return true;
            }
        });

        mWebView.setWebViewClient(new WebViewClient() {
            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);

                if (url.equals(Constants.FAYE_CLIENT_URL)) {
                    // Recursively call this method,
                    // to execute subscribe code.
                    ensureWebViewAndSubscribeToChannels();
                }
            }
        });

        mWebView.loadUrl(Constants.FAYE_CLIENT_URL);
        return;
    }
    if (mNotSubscribeToChannels) {
        mNotSubscribeToChannels = false;
        mCurrentCommunicationMode.subscribeToChannels(mWebView);
    }
}

From source file:com.google.android.apps.paco.ExperimentExecutorCustomRendering.java

private void setWebChromeClientThatHandlesAlertsAsDialogs() {
    webView.setWebChromeClient(new WebChromeClient() {
        @Override/*from   www .j a  v a2s  .  co  m*/
        public boolean onJsAlert(WebView view, String url, String message, JsResult result) {

            new AlertDialog.Builder(view.getContext()).setMessage(message).setCancelable(true)
                    .setPositiveButton(R.string.ok, new Dialog.OnClickListener() {

                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }

                    }).create().show();
            result.confirm();
            return true;
        }

        public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) {
            if (url.contains("file:///android_asset/map.html")) {
                if (showDialog == false) {
                    result.confirm();
                    return true;
                } else {
                    new AlertDialog.Builder(view.getContext()).setMessage(message).setCancelable(true)
                            .setPositiveButton(R.string.ok, new Dialog.OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    showDialog = false;
                                    dialog.dismiss();
                                    result.confirm();
                                }
                            }).setNegativeButton(R.string.cancel_button, new Dialog.OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                    result.cancel();
                                }
                            }).create().show();
                    return true;
                }
            }
            return super.onJsConfirm(view, url, message, result);
        }

        @Override
        public void onConsoleMessage(String message, int lineNumber, String sourceID) {
            Log.d(PacoConstants.TAG, message + " -- From line " + lineNumber + " of " + sourceID);
        }

        @Override
        public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
            Log.d(PacoConstants.TAG, consoleMessage.message() + " -- From line " + consoleMessage.lineNumber()
                    + " of " + consoleMessage.sourceId());
            return true;
        }

    });
}

From source file:org.artifactly.client.Artifactly.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);//from  w w  w .j  a va  2  s .  co  m

    // Setting up the WebView
    webView = (WebView) findViewById(R.id.webview);
    webView.getSettings().setJavaScriptEnabled(true);

    webView.addJavascriptInterface(new JavaScriptInterface(), JAVASCRIPT_BRIDGE_PREFIX);

    // Disable the vertical scroll bar
    webView.setVerticalScrollBarEnabled(false);

    webView.setWebChromeClient(new WebChromeClient() {

        public boolean onConsoleMessage(ConsoleMessage cm) {

            Log.d(PROD_LOG_TAG, cm.message() + " -- From line " + cm.lineNumber() + " of " + cm.sourceId());
            return true;
        }
    });

    webView.loadUrl(ARTIFACTLY_URL);

    /*
     * Calling startService so that the service keeps running. e.g. After application installation
     * The start of the service at boot is handled via a BroadcastReceiver and the BOOT_COMPLETED action
     */
    startService(new Intent(this, ArtifactlyService.class));

    // Bind to the service
    bindService(new Intent(this, ArtifactlyService.class), serviceConnection, BIND_AUTO_CREATE);
    isBound = true;

    // Instantiate the broadcast receiver
    locationUpdateBroadcastReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {

            new GetArtifactsForCurrentLocationTask().execute();
        }
    };

    connectivityBroadcastReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context arg0, Intent arg1) {

            canAccessInternet = hasConnectivity();
        }
    };

    hasArtifactsAtCurrentLocationReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {

            if (null != localService) {

                Location location = localService.getLocation();
                callJavaScriptFunction(BROADCAST_CURRENT_LOCATION, locationToJSON(location));
            }
        }
    };

    // Initialize connectivity flag
    canAccessInternet = hasConnectivity();

    // Get version information from AndroidManifest.xml
    try {

        version = this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionName;
    } catch (NameNotFoundException e) {

        Log.w(PROD_LOG_TAG, "Exception accessing version information", e);
    }
}

From source file:net.wequick.small.webkit.WebView.java

private void initSettings() {
    WebSettings webSettings = this.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setUserAgentString(webSettings.getUserAgentString() + " Native");
    this.addJavascriptInterface(new SmallJsBridge(), "_Small");

    this.setWebChromeClient(new WebChromeClient() {
        @Override//  ww  w  .j  a  va2 s. c  om
        public void onReceivedTitle(android.webkit.WebView view, String title) {
            // Call if html title is set
            super.onReceivedTitle(view, title);
            mTitle = title;
            WebActivity activity = (WebActivity) WebViewPool.getContext(view);
            if (activity != null) {
                activity.setTitle(title);
            }
            // May receive head meta at the same time
            initMetas();
        }

        @Override
        public boolean onJsAlert(android.webkit.WebView view, String url, String message,
                final android.webkit.JsResult result) {
            Context context = WebViewPool.getContext(view);
            if (context == null)
                return false;

            AlertDialog.Builder dlg = new AlertDialog.Builder(context);
            dlg.setPositiveButton("OK", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    mConfirmed = true;
                    result.confirm();
                }
            });
            dlg.setMessage(message);
            AlertDialog alert = dlg.create();
            alert.setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialog) {
                    if (!mConfirmed) {
                        result.cancel();
                    }
                }
            });
            mConfirmed = false;
            alert.show();
            return true;
        }

        @Override
        public boolean onJsConfirm(android.webkit.WebView view, String url, String message,
                final android.webkit.JsResult result) {
            Context context = WebViewPool.getContext(view);
            AlertDialog.Builder dlg = new AlertDialog.Builder(context);
            dlg.setPositiveButton("OK", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    mConfirmed = true;
                    result.confirm();
                }
            });
            dlg.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    mConfirmed = true;
                    result.cancel();
                }
            });
            dlg.setMessage(message);
            AlertDialog alert = dlg.create();
            alert.setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialog) {
                    if (!mConfirmed) {
                        result.cancel();
                    }
                }
            });
            mConfirmed = false;
            alert.show();
            return true;
        }

        @Override
        public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
            String msg = consoleMessage.message();
            if (msg == null)
                return false;
            Uri uri = Uri.parse(msg);
            if (uri != null && null != uri.getScheme() && uri.getScheme().equals(SMALL_SCHEME)) {
                String host = uri.getHost();
                String ret = uri.getQueryParameter(SMALL_QUERY_KEY_RET);
                if (host.equals(SMALL_HOST_POP)) {
                    WebActivity activity = (WebActivity) WebViewPool.getContext(WebView.this);
                    activity.finish(ret);
                } else if (host.equals(SMALL_HOST_EXEC)) {
                    if (mOnResultListener != null) {
                        mOnResultListener.onResult(ret);
                    }
                }
                return true;
            }
            Log.d(consoleMessage.sourceId(),
                    "line" + consoleMessage.lineNumber() + ": " + consoleMessage.message());
            return true;
        }

        @Override
        public void onCloseWindow(android.webkit.WebView window) {
            super.onCloseWindow(window);
            close(new OnResultListener() {
                @Override
                public void onResult(String ret) {
                    if (ret.equals("false"))
                        return;

                    WebActivity activity = (WebActivity) WebViewPool.getContext(WebView.this);
                    activity.finish(ret);
                }
            });
        }
    });

    this.setWebViewClient(new android.webkit.WebViewClient() {

        private final String ANCHOR_SCHEME = "anchor";

        @Override
        public boolean shouldOverrideUrlLoading(android.webkit.WebView view, String url) {
            if (mLoadingUrl != null && mLoadingUrl.equals(url)) {
                // reload by window.location.reload or something
                return super.shouldOverrideUrlLoading(view, url);
            }

            Boolean hasStarted = mHasStartedUrl.get(url);
            if (hasStarted != null && hasStarted) {
                // location redirected before page finished
                return super.shouldOverrideUrlLoading(view, url);
            }

            HitTestResult hit = view.getHitTestResult();
            if (hit != null) {
                Uri uri = Uri.parse(url);
                if (uri.getScheme().equals(ANCHOR_SCHEME)) {
                    // Scroll to anchor
                    int anchorY = Integer.parseInt(uri.getHost());
                    view.scrollTo(0, anchorY);
                } else {
                    Small.openUri(uri, WebViewPool.getContext(view));
                }
                return true;
            }
            return super.shouldOverrideUrlLoading(view, url);
        }

        @Override
        public void onPageStarted(android.webkit.WebView view, String url, Bitmap favicon) {
            super.onPageStarted(view, url, favicon);
            mHasStartedUrl.put(url, true);

            if (mLoadingUrl != null && mLoadingUrl.equals(url)) {
                // reload by window.location.reload or something
                mInjected = false;
            }
            if (sWebViewClient != null && url.equals(mLoadingUrl)) {
                sWebViewClient.onPageStarted(WebViewPool.getContext(view), (WebView) view, url, favicon);
            }
        }

        @Override
        public void onPageFinished(android.webkit.WebView view, String url) {
            super.onPageFinished(view, url);
            mHasStartedUrl.remove(url);

            HitTestResult hit = view.getHitTestResult();
            if (hit != null && hit.getType() == HitTestResult.SRC_ANCHOR_TYPE) {
                // Triggered by user clicked
                Uri uri = Uri.parse(url);
                String anchor = uri.getFragment();
                if (anchor != null) {
                    // If is an anchor, calculate the content offset by DOM
                    // and call native to adjust WebView's offset
                    view.loadUrl(JS_PREFIX + "var y=document.body.scrollTop;"
                            + "var e=document.getElementsByName('" + anchor + "')[0];" + "while(e){"
                            + "y+=e.offsetTop-e.scrollTop+e.clientTop;e=e.offsetParent;}" + "location='"
                            + ANCHOR_SCHEME + "://'+y;");
                }
            }

            if (!mInjected) {
                // Re-inject Small Js
                loadJs(SMALL_INJECT_JS);
                initMetas();
                mInjected = true;
            }

            if (sWebViewClient != null && url.equals(mLoadingUrl)) {
                sWebViewClient.onPageFinished(WebViewPool.getContext(view), (WebView) view, url);
            }
        }

        @Override
        public void onReceivedError(android.webkit.WebView view, int errorCode, String description,
                String failingUrl) {
            super.onReceivedError(view, errorCode, description, failingUrl);
            Log.e("Web", "error: " + description);
            if (sWebViewClient != null && failingUrl.equals(mLoadingUrl)) {
                sWebViewClient.onReceivedError(WebViewPool.getContext(view), (WebView) view, errorCode,
                        description, failingUrl);
            }
        }
    });
}

From source file:com.scoreflex.ScoreflexView.java

/**
 * The constructor of the view./*from   ww  w  .  j a v  a 2s . c o  m*/
 * @param activity The activity holding the view.
 * @param attrs
 * @param defStyle
 */
@SuppressWarnings("deprecation")
public ScoreflexView(Activity activity, AttributeSet attrs, int defStyle) {
    super(activity, attrs, defStyle);

    // Keep a reference on the activity
    mParentActivity = activity;

    // Default layout params
    if (null == getLayoutParams()) {
        setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                Scoreflex.getDensityIndependantPixel(R.dimen.scoreflex_panel_height)));
    }

    // Set our background color
    setBackgroundColor(getContext().getResources().getColor(R.color.scoreflex_background_color));

    // Create the top bar
    View topBar = new View(getContext());
    topBar.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            getResources().getDimensionPixelSize(R.dimen.scoreflex_topbar_height), Gravity.TOP));
    topBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.scoreflex_gradient_background));
    addView(topBar);

    // Create the retry button
    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    mErrorLayout = (ViewGroup) inflater.inflate(R.layout.scoreflex_error_layout, null);
    if (mErrorLayout != null) {

        // Configure refresh button
        Button refreshButton = (Button) mErrorLayout.findViewById(R.id.scoreflex_retry_button);
        if (null != refreshButton) {
            refreshButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View arg0) {
                    if (null == Scoreflex.getPlayerId()) {
                        setUserInterfaceState(new LoadingState());
                        loadUrlAfterLoggedIn(mInitialResource, mInitialRequestParams);
                    } else if (null == mWebView.getUrl()) {
                        setResource(mInitialResource);
                    } else {
                        mWebView.reload();
                    }
                }
            });
        }

        // Configure cancel button
        Button cancelButton = (Button) mErrorLayout.findViewById(R.id.scoreflex_cancel_button);
        if (null != cancelButton) {
            cancelButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View arg0) {
                    close();
                }
            });
        }

        // Get hold of the message view
        mMessageView = (TextView) mErrorLayout.findViewById(R.id.scoreflex_error_message_view);
        addView(mErrorLayout);

    }

    // Create the close button
    mCloseButton = new ImageButton(getContext());
    Drawable closeButtonDrawable = getResources().getDrawable(R.drawable.scoreflex_close_button);
    int closeButtonMargin = (int) ((getResources().getDimensionPixelSize(R.dimen.scoreflex_topbar_height)
            - closeButtonDrawable.getIntrinsicHeight()) / 2.0f);
    FrameLayout.LayoutParams closeButtonLayoutParams = new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT,
            Gravity.TOP | Gravity.RIGHT);
    closeButtonLayoutParams.setMargins(0, closeButtonMargin, closeButtonMargin, 0);
    mCloseButton.setLayoutParams(closeButtonLayoutParams);
    mCloseButton.setImageDrawable(closeButtonDrawable);
    mCloseButton.setBackgroundDrawable(null);
    mCloseButton.setPadding(0, 0, 0, 0);
    mCloseButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            close();
        }
    });
    addView(mCloseButton);

    // Create the web view
    mWebView = new WebView(mParentActivity);
    mWebView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    // mWebView.setBackgroundColor(Color.RED);
    mWebView.setWebViewClient(new ScoreflexWebViewClient());
    mWebView.setWebChromeClient(new WebChromeClient() {

        @Override
        public boolean onConsoleMessage(ConsoleMessage cm) {
            Log.d("Scoreflex", "javascript Error: "
                    + String.format("%s @ %d: %s", cm.message(), cm.lineNumber(), cm.sourceId()));
            return true;
        }

        public void openFileChooser(ValueCallback<Uri> uploadMsg) {
            // mtbActivity.mUploadMessage = uploadMsg;
            mUploadMessage = uploadMsg;

            String fileName = "picture.jpg";
            ContentValues values = new ContentValues();
            values.put(MediaStore.Images.Media.TITLE, fileName);
            // mOutputFileUri = mParentActivity.getContentResolver().insert(
            // MediaStore.Images.Media.DATA, values);
            final List<Intent> cameraIntents = new ArrayList<Intent>();
            final Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            final PackageManager packageManager = mParentActivity.getPackageManager();
            final List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0);
            for (ResolveInfo res : listCam) {
                final String packageName = res.activityInfo.packageName;
                final Intent intent = new Intent(captureIntent);
                intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));
                intent.setPackage(packageName);
                cameraIntents.add(intent);
            }

            // Filesystem.
            final Intent galleryIntent = new Intent();
            galleryIntent.setType("image/*");
            galleryIntent.setAction(Intent.ACTION_GET_CONTENT);

            // Chooser of filesystem options.
            final Intent chooserIntent = Intent.createChooser(galleryIntent, "Select Source please");

            // Add the camera options.
            chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[] {}));

            mParentActivity.startActivityForResult(chooserIntent, Scoreflex.FILECHOOSER_RESULTCODE);
        }

        public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {
            openFileChooser(uploadMsg);
        }

        public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
            openFileChooser(uploadMsg);
        }
    });
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setDomStorageEnabled(true);
    mWebView.getSettings().setDatabasePath(
            getContext().getFilesDir().getPath() + "/data/" + getContext().getPackageName() + "/databases/");
    addView(mWebView);

    TypedArray a = mParentActivity.obtainStyledAttributes(attrs, R.styleable.ScoreflexView, defStyle, 0);
    String resource = a.getString(R.styleable.ScoreflexView_resource);
    if (null != resource)
        setResource(resource);

    a.recycle();

    // Create the animated spinner

    mProgressBar = (ProgressBar) ((LayoutInflater) getContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.scoreflex_progress_bar, null);
    mProgressBar.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER));
    addView(mProgressBar);
    LocalBroadcastManager.getInstance(activity).registerReceiver(mLoginReceiver,
            new IntentFilter(Scoreflex.INTENT_USER_LOGED_IN));
    setUserInterfaceState(new InitialState());
}

From source file:org.globalquakemodel.org.idctdo.EQForm_MapView.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (DEBUG_LOG)
        Log.d(TAG, "ON CREATE");
    setContentView(R.layout.map_view);/* www  . j  av a  2s. c  o m*/
    mContext = this;

    MyStateSaver data = (MyStateSaver) getLastNonConfigurationInstance();
    if (data != null) {
        // Show splash screen if still loading
        if (data.showSplashScreen) {
            showSplashScreen();
        }
        setContentView(R.layout.map_view);

        // Rebuild your UI with your saved state here
    } else {
        showSplashScreen();
        setContentView(R.layout.map_view);
        // Do your heavy loading here on a background thread

    }

    //showSplashScreen();

    mWebView = (WebView) findViewById(R.id.map_webview);
    mWebView.getSettings().setAllowFileAccess(true);
    mWebView.getSettings().setJavaScriptEnabled(true);

    mWebView.setWebChromeClient(new WebChromeClient() {
        public boolean onConsoleMessage(ConsoleMessage cm) {
            if (DEBUG_LOG)
                Log.d(TAG, cm.message() + " -- From line " + cm.lineNumber() + " of " + cm.sourceId());
            return true;
        }
    });

    if (DEBUG_LOG)
        Log.d(TAG, "adding JS interface");
    mWebView.addJavascriptInterface(this, "webConnector");

    mWebView.loadUrl("file:///android_asset/idct_map.html");
    mWebView.setWebViewClient(new MapWebViewClient());
    progressBar = new ProgressDialog(EQForm_MapView.this);
    progressBar.setMessage("Loading maps...");
    progressBar.setCancelable(false);
    progressBar.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    //Create Folder
    mediaFile = new File(Environment.getExternalStorageDirectory().toString() + "/idctdo/gemmedia");
    mediaFile.mkdirs();

    //Create Folder
    vectorsFile = new File(Environment.getExternalStorageDirectory().toString() + "/idctdo/kml");
    vectorsFile.mkdirs();

    mapTilesFile = new File(Environment.getExternalStorageDirectory().toString() + "/idctdo/maptiles");
    mapTilesFile.mkdirs();

    File testFile = new File(
            Environment.getExternalStorageDirectory().toString() + "/idctdo/kml/PUT_KML_FILES_HERE");
    try {
        testFile.createNewFile();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    File testFile2 = new File(Environment.getExternalStorageDirectory().toString()
            + "/idctdo/maptiles/PUT_DIRECTORIES_OF_ZYX_TILES_HERE");
    try {
        testFile2.createNewFile();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    /** Creating a progress dialog window */
    mProgressDialog = new ProgressDialog(this);

    /** Close the dialog window on pressing back button */
    mProgressDialog.setCancelable(true);

    /** Setting a horizontal style progress bar */
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);

    /** Setting a message for this progress dialog
    * Use the method setTitle(), for setting a title
    * for the dialog window
    *  */
    mProgressDialog.setMessage("Loading map data...");

    vectorsFile.toString();
    new SingleMediaScanner(this, testFile);
    new SingleMediaScanner(this, testFile2);

    sdCardPath = "file:///" + Environment.getExternalStorageDirectory().getAbsolutePath() + "/";
    if (DEBUG_LOG)
        Log.d(TAG, "sdcard Path: " + sdCardPath);
    // Restore preferences
    PreferenceManager.getDefaultSharedPreferences(this);
    //SharedPreferences settings = getSharedPreferences("R.xml.prefs"), 0);

    mlocListener = new MyLocationListener();
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    currentLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

    btn_locateMe = (Button) findViewById(R.id.btn_locate_me);
    btn_locateMe.setOnClickListener(locateMeListener);

    btn_takeCameraPhoto = (Button) findViewById(R.id.btn_take_photo);
    btn_takeCameraPhoto.setOnClickListener(takePhotoListener);

    //btn_take_survey_photo=(Button)findViewById(R.id.btn_take_survey_photo);
    //btn_take_survey_photo.setVisibility(View.INVISIBLE);//Poss Dodgy threading stuff using this

    btn_startSurvey = (Button) findViewById(R.id.btn_start_survey);
    btn_startSurvey.setVisibility(View.INVISIBLE);//Dodgy threading stuff using this
    btn_startSurvey.setOnClickListener(startSurveyListener);

    btn_cancelSurveyPoint = (Button) findViewById(R.id.btn_cancel_survey_point);
    btn_cancelSurveyPoint.setVisibility(View.INVISIBLE);//Dodgy threading stuff using this
    btn_cancelSurveyPoint.setOnClickListener(cancelSurveyPointListener);

    btn_startSurveyFavourite = (Button) findViewById(R.id.btn_start_survey_with_favourite);
    btn_startSurveyFavourite.setVisibility(View.INVISIBLE);//Dodgy threading stuff using this
    btn_startSurveyFavourite.setOnClickListener(selectFavouriteListener);

    btn_selectLayer = (Button) findViewById(R.id.btn_select_layer);
    btn_selectLayer.setOnClickListener(selectLayerListener);

    btn_selectVectorLayer = (Button) findViewById(R.id.btn_select_vector_layer);
    btn_selectVectorLayer.setOnClickListener(selectVectorLayerListener);

    btn_zoomIn = (Button) findViewById(R.id.btn_zoom_in);
    btn_zoomIn.setOnClickListener(zoomInListener);
    btn_zoomOut = (Button) findViewById(R.id.btn_zoom_out);
    btn_zoomOut.setOnClickListener(zoomOutListener);

    btn_edit_points = (ToggleButton) findViewById(R.id.btn_edit_points);
    btn_edit_points.setOnClickListener(editPointsListener);

    text_view_gpsInfo = (TextView) findViewById(R.id.text_view_gpsInfo);
    text_view_gpsInfo2 = (TextView) findViewById(R.id.text_view_gpsInfo2);

    //Load any of the previous survey points
    loadPrevSurveyPoints();
}

From source file:com.android.mail.ui.ConversationViewFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.conversation_view, container, false);
    mConversationContainer = (ConversationContainer) rootView.findViewById(R.id.conversation_container);
    mConversationContainer.setAccountController(this);

    mTopmostOverlay = (ViewGroup) mConversationContainer.findViewById(R.id.conversation_topmost_overlay);
    mTopmostOverlay.setOnKeyListener(this);
    inflateSnapHeader(mTopmostOverlay, inflater);
    mConversationContainer.setupSnapHeader();

    setupNewMessageBar();/*from  w  w w.j  ava  2s  .  co m*/

    mProgressController = new ConversationViewProgressController(this, getHandler());
    mProgressController.instantiateProgressIndicators(rootView);

    mWebView = (ConversationWebView) mConversationContainer.findViewById(R.id.conversation_webview);

    mWebView.addJavascriptInterface(mJsBridge, "mail");
    // On JB or newer, we use the 'webkitAnimationStart' DOM event to signal load complete
    // Below JB, try to speed up initial render by having the webview do supplemental draws to
    // custom a software canvas.
    // TODO(mindyp):
    //PAGE READINESS SIGNAL FOR JELLYBEAN AND NEWER
    // Notify the app on 'webkitAnimationStart' of a simple dummy element with a simple no-op
    // animation that immediately runs on page load. The app uses this as a signal that the
    // content is loaded and ready to draw, since WebView delays firing this event until the
    // layers are composited and everything is ready to draw.
    // This signal does not seem to be reliable, so just use the old method for now.
    final boolean isJBOrLater = Utils.isRunningJellybeanOrLater();
    final boolean isUserVisible = isUserVisible();
    mWebView.setUseSoftwareLayer(!isJBOrLater);
    mEnableContentReadySignal = isJBOrLater && isUserVisible;
    mWebView.onUserVisibilityChanged(isUserVisible);
    mWebView.setWebViewClient(mWebViewClient);
    final WebChromeClient wcc = new WebChromeClient() {
        @Override
        public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
            if (consoleMessage.messageLevel() == ConsoleMessage.MessageLevel.ERROR) {
                LogUtils.e(LOG_TAG, "JS: %s (%s:%d) f=%s", consoleMessage.message(), consoleMessage.sourceId(),
                        consoleMessage.lineNumber(), ConversationViewFragment.this);
            } else {
                LogUtils.i(LOG_TAG, "JS: %s (%s:%d) f=%s", consoleMessage.message(), consoleMessage.sourceId(),
                        consoleMessage.lineNumber(), ConversationViewFragment.this);
            }
            return true;
        }
    };
    mWebView.setWebChromeClient(wcc);

    final WebSettings settings = mWebView.getSettings();

    final ScrollIndicatorsView scrollIndicators = (ScrollIndicatorsView) rootView
            .findViewById(R.id.scroll_indicators);
    scrollIndicators.setSourceView(mWebView);

    settings.setJavaScriptEnabled(true);

    ConversationViewUtils.setTextZoom(getResources(), settings);

    if (Utils.isRunningLOrLater()) {
        CookieManager.getInstance().setAcceptThirdPartyCookies(mWebView, true /* accept */);
    }

    mViewsCreated = true;
    mWebViewLoadedData = false;

    return rootView;
}

From source file:com.tct.mail.ui.ConversationViewFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    //TS: chao-zhang 2015-12-10 EMAIL BUGFIX_1121860 MOD_S    544
    //NOTE: when infalte conversationView which is implements from WebView,webview.jar is not exist
    //or not found,NameNotFoundException exception thrown,and InflateException thrown in Email,BAD!!!
    View rootView;//from w  ww.  j  a v a  2  s.c  om
    try {
        rootView = inflater.inflate(R.layout.conversation_view, container, false);
    } catch (InflateException e) {
        LogUtils.e(LOG_TAG, e, "InflateException happen during inflate conversationView");
        //TS: xing.zhao 2016-4-1 EMAIL BUGFIX_1892015 MOD_S
        if (getActivity() == null) {
            return null;
        } else {
            rootView = new View(getActivity().getApplicationContext());
            return rootView;
        }
        //TS: xing.zhao 2016-4-1 EMAIL BUGFIX_1892015 MOD_E
    }
    //TS: chao-zhang 2015-12-10 EMAIL BUGFIX_1121860 MOD_E
    //TS: tao.gan 2015-09-10 EMAIL FEATURE-559891 ADD_S
    //Here we romve the imagebutton and then add it ,to make it show on the top level.
    //Because we can't add the fab button at last on the layout xml.
    mFabButton = (ConversationReplyFabView) rootView.findViewById(R.id.conversation_view_fab);
    FrameLayout framelayout = (FrameLayout) rootView.findViewById(R.id.conversation_view_framelayout);
    framelayout.removeView(mFabButton);
    framelayout.addView(mFabButton);
    //TS: tao.gan 2015-09-10 EMAIL FEATURE-559891 ADD_E
    mConversationContainer = (ConversationContainer) rootView.findViewById(R.id.conversation_container);
    mConversationContainer.setAccountController(this);

    mTopmostOverlay = (ViewGroup) mConversationContainer.findViewById(R.id.conversation_topmost_overlay);
    mTopmostOverlay.setOnKeyListener(this);
    inflateSnapHeader(mTopmostOverlay, inflater);
    mConversationContainer.setupSnapHeader();

    setupNewMessageBar();

    mProgressController = new ConversationViewProgressController(this, getHandler());
    mProgressController.instantiateProgressIndicators(rootView);

    mWebView = (ConversationWebView) mConversationContainer.findViewById(R.id.conversation_webview);
    //TS: junwei-xu 2015-3-25 EMAIL BUGFIX_919767 ADD_S
    if (mWebView != null) {
        mWebView.setActivity(getActivity());
    }
    //TS: junwei-xu 2015-3-25 EMAIL BUGFIX_919767 ADD_E
    //TS: tao.gan 2015-09-10 EMAIL FEATURE-559891 ADD_S
    mWebView.setFabButton(mFabButton);
    //TS: tao.gan 2015-09-10 EMAIL FEATURE-559891 ADD_E

    mWebView.addJavascriptInterface(mJsBridge, "mail");
    // On JB or newer, we use the 'webkitAnimationStart' DOM event to signal load complete
    // Below JB, try to speed up initial render by having the webview do supplemental draws to
    // custom a software canvas.
    // TODO(mindyp):
    //PAGE READINESS SIGNAL FOR JELLYBEAN AND NEWER
    // Notify the app on 'webkitAnimationStart' of a simple dummy element with a simple no-op
    // animation that immediately runs on page load. The app uses this as a signal that the
    // content is loaded and ready to draw, since WebView delays firing this event until the
    // layers are composited and everything is ready to draw.
    // This signal does not seem to be reliable, so just use the old method for now.
    final boolean isJBOrLater = Utils.isRunningJellybeanOrLater();
    final boolean isUserVisible = isUserVisible();
    mWebView.setUseSoftwareLayer(!isJBOrLater);
    mEnableContentReadySignal = isJBOrLater && isUserVisible;
    mWebView.onUserVisibilityChanged(isUserVisible);
    mWebView.setWebViewClient(mWebViewClient);
    final WebChromeClient wcc = new WebChromeClient() {
        @Override
        public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
            if (consoleMessage.messageLevel() == ConsoleMessage.MessageLevel.ERROR) {
                //TS: wenggangjin 2015-01-29 EMAIL BUGFIX_-917007 MOD_S
                //                    LogUtils.wtf(LOG_TAG, "JS: %s (%s:%d) f=%s", consoleMessage.message(),
                LogUtils.w(LOG_TAG, "JS: %s (%s:%d) f=%s", consoleMessage.message(), consoleMessage.sourceId(),
                        consoleMessage.lineNumber(), ConversationViewFragment.this);
                //TS: wenggangjin 2015-01-29 EMAIL BUGFIX_-917007 MOD_E
            } else {
                LogUtils.i(LOG_TAG, "JS: %s (%s:%d) f=%s", consoleMessage.message(), consoleMessage.sourceId(),
                        consoleMessage.lineNumber(), ConversationViewFragment.this);
            }
            return true;
        }
    };
    mWebView.setWebChromeClient(wcc);

    final WebSettings settings = mWebView.getSettings();

    final ScrollIndicatorsView scrollIndicators = (ScrollIndicatorsView) rootView
            .findViewById(R.id.scroll_indicators);
    scrollIndicators.setSourceView(mWebView);

    settings.setJavaScriptEnabled(true);

    ConversationViewUtils.setTextZoom(getResources(), settings);
    //Enable third-party cookies. b/16014255
    if (Utils.isRunningLOrLater()) {
        CookieManager.getInstance().setAcceptThirdPartyCookies(mWebView, true /* accept */);
    }

    mViewsCreated = true;
    mWebViewLoadedData = false;

    return rootView;
}