Example usage for android.webkit WebView setVisibility

List of usage examples for android.webkit WebView setVisibility

Introduction

In this page you can find the example usage for android.webkit WebView setVisibility.

Prototype

@RemotableViewMethod
public void setVisibility(@Visibility int visibility) 

Source Link

Document

Set the visibility state of this view.

Usage

From source file:org.microg.gms.auth.login.LoginActivity.java

private static WebView createWebView(Context context) {
    WebView webView = new WebView(context);
    if (SDK_INT < LOLLIPOP) {
        webView.setVisibility(VISIBLE);
    } else {/*from  www .  j a  va 2 s  . c o m*/
        webView.setVisibility(INVISIBLE);
    }
    webView.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    webView.setBackgroundColor(Color.TRANSPARENT);
    prepareWebViewSettings(webView.getSettings());
    return webView;
}

From source file:com.appnexus.opensdk.ANJAMImplementation.java

private static void callRecordEvent(AdWebView webView, Uri uri) {
    String urlParam = uri.getQueryParameter("url");

    if ((urlParam == null) || (!urlParam.startsWith("http"))) {
        return;//from   w ww  .j  a  va 2  s  . c  om
    }

    // Create a invisible webview to fire the url
    WebView recordEventWebView = new WebView(webView.getContext());
    recordEventWebView.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            Clog.d(Clog.baseLogTag, "RecordEvent completed loading: " + url);

            CookieSyncManager csm = CookieSyncManager.getInstance();
            if (csm != null)
                csm.sync();
        }
    });
    recordEventWebView.loadUrl(urlParam);
    recordEventWebView.setVisibility(View.GONE);
    webView.addView(recordEventWebView);
}

From source file:io.vit.vitio.Fragments.CampusMapFragment.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.campusmap_fragment, container, false);
    setTransitions();//w  w w.  ja v  a  2s  .  com
    WebView view = (WebView) rootView.findViewById(R.id.img_map);
    view.setVisibility(View.GONE);

    view.getSettings().setBuiltInZoomControls(true);

    view.getSettings().setDisplayZoomControls(false);

    view.getSettings().setLoadWithOverviewMode(true);

    view.getSettings().setUseWideViewPort(true);

    view.setWebViewClient(new WebViewClient() {

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            try {
                view.setVisibility(View.VISIBLE);
            } catch (Exception ignore) {
            }

        }

        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            try {
            } catch (Exception ignore) {
            }

        }
    });

    view.loadUrl("file:///android_asset/vit_map.jpg");

    return rootView;
}

From source file:se.eliga.aves.HelpFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    WebView webView = (WebView) getView().findViewById(R.id.help_text);
    webView.loadUrl("file:///android_asset/help.html");
    webView.setBackgroundColor(0x00FFFFFF);
    webView.setVisibility(View.VISIBLE);
}

From source file:se.eliga.aves.AboutFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    WebView webView = (WebView) getView().findViewById(R.id.about_text);
    webView.loadUrl("file:///android_asset/about.html");
    webView.setBackgroundColor(0x00FFFFFF);
    webView.setVisibility(View.VISIBLE);
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);

    webView.addJavascriptInterface(/*from   w w  w. j av  a2s .  c o m*/
            new AboutJSObject(getVersion(), BuildConfig.BUILDTIME, BuildConfig.BUILDTYPE), "AboutData");
}

From source file:de.dreier.mytargets.features.scoreboard.ScoreboardActivity.java

@TargetApi(Build.VERSION_CODES.KITKAT)
private void print() {
    // Get a print adapter instance
    final WebView webViewPrint = new WebView(this);
    webViewPrint.setVisibility(View.INVISIBLE);
    ViewGroup.LayoutParams p = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    webViewPrint.setLayoutParams(p);//from  ww  w.j  av a  2s  . c  o m
    ((ViewGroup) binding.getRoot()).addView(webViewPrint);

    new AsyncTask<Void, Void, String>() {

        @Override
        protected String doInBackground(Void... params) {
            return HtmlUtils.getScoreboard(mTraining, mRound, ScoreboardConfiguration.fromPrintSettings());
        }

        @SuppressWarnings("deprecation")
        @Override
        protected void onPostExecute(String s) {
            webViewPrint.loadDataWithBaseURL("file:///android_asset/", s, "text/html", "UTF-8", "");
            PrintDocumentAdapter printAdapter = webViewPrint.createPrintDocumentAdapter();

            // Create a print job with name and adapter instance
            PrintManager printManager = (PrintManager) getSystemService(PRINT_SERVICE);
            String jobName = getString(R.string.scoreboard) + " Document";
            printManager.print(jobName, printAdapter, new PrintAttributes.Builder().build());
        }
    }.execute();
}

From source file:com.yoavst.quickapps.news.LoginActivity.java

@SuppressLint("SetJavaScriptEnabled")
private WebView createWebView(final Context context) {
    WebView webView = new WebView(context);
    webView.setWebViewClient(createWebViewClient());
    webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    webView.setVisibility(View.VISIBLE);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setLoadWithOverviewMode(true);
    webView.getSettings().setSupportZoom(true);
    webView.getSettings().setBuiltInZoomControls(false);
    return webView;
}

From source file:com.cryart.sabbathschool.ui.fragment.SSWebViewFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View _view = inflater.inflate(R.layout.ss_webview_fragment, null);

    _SSPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());

    _SSWebView = (SSWebView) _view.findViewById(R.id.ss_webview);
    _SSWebViewLoading = (ProgressBar) _view.findViewById(R.id.ss_webview_loading);
    _SSWebView.setBackgroundColor(Color.TRANSPARENT);

    _SSHero = (KenBurnsView) getActivity().findViewById(R.id.ss_hero);

    _SSWebView.addJavascriptInterface(new SSWebInterface(getActivity()), "SSBridge");
    _SSWebView.getSettings().setJavaScriptEnabled(true);
    _SSWebView.setWebViewClient(new WebViewClient() {
        public void onPageFinished(WebView view, String url) {
            _SSWebViewLoading.setVisibility(View.INVISIBLE);
            view.setVisibility(View.VISIBLE);

            setHighlights(_SSDay._day_highlights);
            setComments(_SSDay._day_comments);
        }/*from  w w w.ja v  a  2 s.c o  m*/
    });

    this.loadDay(_SSDayDate);

    _SSWebView.setOnScrollChangedCallback((SSMainActivity) getActivity());

    return _view;
}

From source file:org.brandroid.openmanager.fragments.DialogHandler.java

public static void showAboutDialog(final Context mContext) {
    LayoutInflater li = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = li.inflate(R.layout.about, null);

    String sVersionInfo = "";
    try {/*w w w .j a va  2  s .co  m*/
        PackageInfo pi = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0);
        sVersionInfo += pi.versionName;
        if (!pi.versionName.contains("" + pi.versionCode))
            sVersionInfo += " (" + pi.versionCode + ")";
        if (OpenExplorer.IS_DEBUG_BUILD)
            sVersionInfo += " *debug*";
    } catch (NameNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    String sBuildTime = "";
    try {
        sBuildTime = SimpleDateFormat.getInstance()
                .format(new Date(new ZipFile(
                        mContext.getPackageManager().getApplicationInfo(mContext.getPackageName(), 0).sourceDir)
                                .getEntry("classes.dex").getTime()));
    } catch (Exception e) {
        Logger.LogError("Couldn't get Build Time.", e);
    }

    WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    DisplayMetrics dm = new DisplayMetrics();
    wm.getDefaultDisplay().getMetrics(dm);
    Display d = wm.getDefaultDisplay();
    String sHardwareInfo = "Display:\n";
    sHardwareInfo += "Size: " + d.getWidth() + "x" + d.getHeight() + "\n";
    if (dm != null)
        sHardwareInfo += "Density: " + dm.density + "\n";
    sHardwareInfo += "Rotation: " + d.getRotation() + "\n\n";
    sHardwareInfo += getNetworkInfo(mContext);
    sHardwareInfo += getDeviceInfo();
    ((TextView) view.findViewById(R.id.about_hardware)).setText(sHardwareInfo);

    final String sSubject = "Feedback for OpenExplorer " + sVersionInfo;
    OnClickListener email = new OnClickListener() {
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("text/plain");
            //intent.addCategory(Intent.CATEGORY_APP_EMAIL);
            intent.putExtra(android.content.Intent.EXTRA_TEXT, "\n" + getDeviceInfo());
            intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "brandroid64@gmail.com" });
            intent.putExtra(android.content.Intent.EXTRA_SUBJECT, sSubject);
            mContext.startActivity(Intent.createChooser(intent, mContext.getString(R.string.s_chooser_email)));
        }
    };
    OnClickListener viewsite = new OnClickListener() {
        public void onClick(View v) {
            mContext.startActivity(
                    new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://brandroid.org/open/")));
        }
    };
    view.findViewById(R.id.about_email).setOnClickListener(email);
    view.findViewById(R.id.about_email_btn).setOnClickListener(email);
    view.findViewById(R.id.about_site).setOnClickListener(viewsite);
    view.findViewById(R.id.about_site_btn).setOnClickListener(viewsite);
    final View mRecentLabel = view.findViewById(R.id.about_recent_status_label);
    final WebView mRecent = (WebView) view.findViewById(R.id.about_recent);
    final OpenChromeClient occ = new OpenChromeClient();
    occ.mStatus = (TextView) view.findViewById(R.id.about_recent_status);
    mRecent.setWebChromeClient(occ);
    mRecent.setWebViewClient(new WebViewClient() {
        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            occ.mStatus.setVisibility(View.GONE);
            mRecent.setVisibility(View.GONE);
            mRecentLabel.setVisibility(View.GONE);
        }
    });
    mRecent.setBackgroundColor(Color.TRANSPARENT);
    mRecent.loadUrl("http://brandroid.org/open/?show=recent");

    ((TextView) view.findViewById(R.id.about_version)).setText(sVersionInfo);
    if (sBuildTime != "")
        ((TextView) view.findViewById(R.id.about_buildtime)).setText(sBuildTime);
    else
        ((TableRow) view.findViewById(R.id.row_buildtime)).setVisibility(View.GONE);

    fillShortcutsTable((TableLayout) view.findViewById(R.id.shortcuts_table));

    final View tab1 = view.findViewById(R.id.tab1);
    final View tab2 = view.findViewById(R.id.tab2);
    final View tab3 = view.findViewById(R.id.tab3);
    ((Button) view.findViewById(R.id.btn_recent)).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            tab1.setVisibility(View.VISIBLE);
            tab2.setVisibility(View.GONE);
            tab3.setVisibility(View.GONE);
        }
    });
    ((Button) view.findViewById(R.id.btn_hardware)).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            tab1.setVisibility(View.GONE);
            tab2.setVisibility(View.VISIBLE);
            tab3.setVisibility(View.GONE);
        }
    });
    ((Button) view.findViewById(R.id.btn_shortcuts)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            tab1.setVisibility(View.GONE);
            tab2.setVisibility(View.GONE);
            tab3.setVisibility(View.VISIBLE);
        }
    });

    AlertDialog mDlgAbout = new AlertDialog.Builder(mContext).setTitle(R.string.app_name).setView(view)
            .create();

    mDlgAbout.getWindow().getAttributes().windowAnimations = R.style.SlideDialogAnimation;
    mDlgAbout.getWindow().getAttributes().alpha = 0.9f;

    mDlgAbout.show();
}

From source file:com.androzic.waypoint.WaypointInfo.java

@SuppressLint("NewApi")
private void updateWaypointInfo(double lat, double lon) {
    Androzic application = Androzic.getApplication();
    Activity activity = getActivity();/*from   w  w  w .  ja va2  s  .co  m*/
    Dialog dialog = getDialog();
    View view = getView();

    WebView description = (WebView) view.findViewById(R.id.description);

    if ("".equals(waypoint.description)) {
        description.setVisibility(View.GONE);
    } else {
        String descriptionHtml;
        try {
            TypedValue tv = new TypedValue();
            Theme theme = activity.getTheme();
            Resources resources = getResources();
            theme.resolveAttribute(android.R.attr.textColorSecondary, tv, true);
            int secondaryColor = resources.getColor(tv.resourceId);
            String css = String.format(
                    "<style type=\"text/css\">html,body{margin:0;background:transparent} *{color:#%06X}</style>\n",
                    (secondaryColor & 0x00FFFFFF));
            descriptionHtml = css + waypoint.description;
            description.setWebViewClient(new WebViewClient() {
                @Override
                public void onPageFinished(WebView view, String url) {
                    view.setBackgroundColor(Color.TRANSPARENT);
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
                        view.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);
                }
            });
            description.setBackgroundColor(Color.TRANSPARENT);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
                description.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);
        } catch (Resources.NotFoundException e) {
            description.setBackgroundColor(Color.LTGRAY);
            descriptionHtml = waypoint.description;
        }

        WebSettings settings = description.getSettings();
        settings.setDefaultTextEncodingName("utf-8");
        settings.setAllowFileAccess(true);
        Uri baseUrl = Uri.fromFile(new File(application.dataPath));
        description.loadDataWithBaseURL(baseUrl.toString() + "/", descriptionHtml, "text/html", "utf-8", null);
    }

    String coords = StringFormatter.coordinates(" ", waypoint.latitude, waypoint.longitude);
    ((TextView) view.findViewById(R.id.coordinates)).setText(coords);

    if (waypoint.altitude != Integer.MIN_VALUE) {
        ((TextView) view.findViewById(R.id.altitude)).setText(StringFormatter.elevationH(waypoint.altitude));
    }

    double dist = Geo.distance(lat, lon, waypoint.latitude, waypoint.longitude);
    double bearing = Geo.bearing(lat, lon, waypoint.latitude, waypoint.longitude);
    bearing = application.fixDeclination(bearing);
    String distance = StringFormatter.distanceH(dist) + " " + StringFormatter.angleH(bearing);
    ((TextView) view.findViewById(R.id.distance)).setText(distance);

    if (waypoint.date != null)
        ((TextView) view.findViewById(R.id.date))
                .setText(DateFormat.getDateFormat(activity).format(waypoint.date) + " "
                        + DateFormat.getTimeFormat(activity).format(waypoint.date));
    else
        ((TextView) view.findViewById(R.id.date)).setVisibility(View.GONE);

    dialog.setTitle(waypoint.name);
}