Search in sources :

Example 1 with WebChromeViewClient

use of org.sitcon.ccip.network.webclient.WebChromeViewClient in project CCIP-Android by CCIP-App.

the class PuzzleFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View view = inflater.inflate(R.layout.fragment_web, container, false);
    setHasOptionsMenu(true);
    mActivity = getActivity();
    progressBar = (ProgressBar) view.findViewById(R.id.progressBar);
    webView = (WebView) view.findViewById(R.id.webView);
    webView.setWebViewClient(new WebViewClient() {

        @Override
        public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
            super.onReceivedError(view, request, error);
            view.loadUrl(URL_NO_NETWORK);
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
            return true;
        }
    });
    webView.setWebChromeClient(new WebChromeViewClient(progressBar));
    if (PreferenceUtil.getToken(getActivity()) != null) {
        webView.loadUrl(URL_PUZZLE + PreferenceUtil.getToken(getActivity()));
    } else {
        webView.loadUrl("data:text/html, <div>Please login</div>");
    }
    WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setDomStorageEnabled(true);
    if (Build.VERSION.SDK_INT >= 21) {
        settings.setMixedContentMode(WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
    }
    return view;
}
Also used : WebChromeViewClient(org.sitcon.ccip.network.webclient.WebChromeViewClient) WebResourceRequest(android.webkit.WebResourceRequest) WebSettings(android.webkit.WebSettings) WebResourceError(android.webkit.WebResourceError) Intent(android.content.Intent) WebView(android.webkit.WebView) View(android.view.View) WebView(android.webkit.WebView) WebViewClient(android.webkit.WebViewClient) Nullable(android.support.annotation.Nullable)

Example 2 with WebChromeViewClient

use of org.sitcon.ccip.network.webclient.WebChromeViewClient in project CCIP-Android by CCIP-App.

the class StaffFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View view = inflater.inflate(R.layout.fragment_web, container, false);
    progressBar = (ProgressBar) view.findViewById(R.id.progressBar);
    webView = (WebView) view.findViewById(R.id.webView);
    webView.setWebChromeClient(new WebChromeViewClient(progressBar));
    webView.setWebViewClient(new OfficialWebViewClient());
    webView.loadUrl(URL_STAFFS);
    WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setDomStorageEnabled(true);
    if (Build.VERSION.SDK_INT >= 21) {
        settings.setMixedContentMode(WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
    }
    return view;
}
Also used : WebChromeViewClient(org.sitcon.ccip.network.webclient.WebChromeViewClient) OfficialWebViewClient(org.sitcon.ccip.network.webclient.OfficialWebViewClient) WebSettings(android.webkit.WebSettings) View(android.view.View) WebView(android.webkit.WebView) Nullable(android.support.annotation.Nullable)

Example 3 with WebChromeViewClient

use of org.sitcon.ccip.network.webclient.WebChromeViewClient in project CCIP-Android by CCIP-App.

the class IRCFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View view = inflater.inflate(R.layout.fragment_web, container, false);
    progressBar = (ProgressBar) view.findViewById(R.id.progressBar);
    webView = (WebView) view.findViewById(R.id.webView);
    webView.setWebViewClient(new WebViewClient() {

        @Override
        public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
            super.onReceivedError(view, request, error);
            view.loadUrl(URL_NO_NETWORK);
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
            return true;
        }
    });
    webView.setWebChromeClient(new WebChromeViewClient(progressBar));
    webView.loadUrl(URL_IRC);
    WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setDomStorageEnabled(true);
    if (Build.VERSION.SDK_INT >= 21) {
        settings.setMixedContentMode(WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
    }
    return view;
}
Also used : WebChromeViewClient(org.sitcon.ccip.network.webclient.WebChromeViewClient) WebResourceRequest(android.webkit.WebResourceRequest) WebSettings(android.webkit.WebSettings) WebResourceError(android.webkit.WebResourceError) Intent(android.content.Intent) WebView(android.webkit.WebView) View(android.view.View) WebView(android.webkit.WebView) WebViewClient(android.webkit.WebViewClient) Nullable(android.support.annotation.Nullable)

Example 4 with WebChromeViewClient

use of org.sitcon.ccip.network.webclient.WebChromeViewClient in project CCIP-Android by CCIP-App.

the class SponsorFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View view = inflater.inflate(R.layout.fragment_web, container, false);
    progressBar = (ProgressBar) view.findViewById(R.id.progressBar);
    webView = (WebView) view.findViewById(R.id.webView);
    webView.setWebChromeClient(new WebChromeViewClient(progressBar));
    webView.setWebViewClient(new OfficialWebViewClient());
    webView.loadUrl(URL_SPONSORS);
    WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setDomStorageEnabled(true);
    if (Build.VERSION.SDK_INT >= 21) {
        settings.setMixedContentMode(WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
    }
    return view;
}
Also used : WebChromeViewClient(org.sitcon.ccip.network.webclient.WebChromeViewClient) OfficialWebViewClient(org.sitcon.ccip.network.webclient.OfficialWebViewClient) WebSettings(android.webkit.WebSettings) View(android.view.View) WebView(android.webkit.WebView) Nullable(android.support.annotation.Nullable)

Example 5 with WebChromeViewClient

use of org.sitcon.ccip.network.webclient.WebChromeViewClient in project CCIP-Android by CCIP-App.

the class VenueFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View view = inflater.inflate(R.layout.fragment_web, container, false);
    progressBar = (ProgressBar) view.findViewById(R.id.progressBar);
    webView = (WebView) view.findViewById(R.id.webView);
    webView.setWebChromeClient(new WebChromeViewClient(progressBar));
    webView.setWebViewClient(new OfficialWebViewClient());
    webView.loadUrl(URL_SPONSORS);
    WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setDomStorageEnabled(true);
    if (Build.VERSION.SDK_INT >= 21) {
        settings.setMixedContentMode(WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
    }
    return view;
}
Also used : WebChromeViewClient(org.sitcon.ccip.network.webclient.WebChromeViewClient) OfficialWebViewClient(org.sitcon.ccip.network.webclient.OfficialWebViewClient) WebSettings(android.webkit.WebSettings) View(android.view.View) WebView(android.webkit.WebView) Nullable(android.support.annotation.Nullable)

Aggregations

Nullable (android.support.annotation.Nullable)5 View (android.view.View)5 WebSettings (android.webkit.WebSettings)5 WebView (android.webkit.WebView)5 WebChromeViewClient (org.sitcon.ccip.network.webclient.WebChromeViewClient)5 OfficialWebViewClient (org.sitcon.ccip.network.webclient.OfficialWebViewClient)3 Intent (android.content.Intent)2 WebResourceError (android.webkit.WebResourceError)2 WebResourceRequest (android.webkit.WebResourceRequest)2 WebViewClient (android.webkit.WebViewClient)2