Search in sources :

Example 1 with CacheableWebView

use of io.github.hidroh.materialistic.widget.CacheableWebView in project materialistic by hidroh.

the class SyncDelegate method loadArticle.

private void loadArticle(@NonNull final HackerNewsItem item) {
    mWebView = new CacheableWebView(mContext);
    mWebView.setWebViewClient(new AdBlockWebViewClient(Preferences.adBlockEnabled(mContext)));
    mWebView.setWebChromeClient(new CacheableWebView.ArchiveClient() {

        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            super.onProgressChanged(view, newProgress);
            notifyArticle(newProgress);
        }
    });
    notifyArticle(0);
    mWebView.loadUrl(item.getUrl());
}
Also used : AdBlockWebViewClient(io.github.hidroh.materialistic.widget.AdBlockWebViewClient) CacheableWebView(io.github.hidroh.materialistic.widget.CacheableWebView) WebView(android.webkit.WebView) CacheableWebView(io.github.hidroh.materialistic.widget.CacheableWebView) SuppressLint(android.annotation.SuppressLint)

Example 2 with CacheableWebView

use of io.github.hidroh.materialistic.widget.CacheableWebView in project materialistic by hidroh.

the class WebCacheService method onStartCommand.

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (intent == null) {
        // restarted
        stopSelf(startId);
        return START_STICKY;
    }
    CacheableWebView webView = new CacheableWebView(this);
    webView.setWebViewClient(new AdBlockWebViewClient(Preferences.adBlockEnabled(this)));
    webView.setWebChromeClient(new CacheableWebView.ArchiveClient() {

        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            super.onProgressChanged(view, newProgress);
            if (newProgress == 100) {
                stopSelf(startId);
            }
        }
    });
    webView.loadUrl(intent.getStringExtra(EXTRA_URL));
    return START_STICKY;
}
Also used : AdBlockWebViewClient(io.github.hidroh.materialistic.widget.AdBlockWebViewClient) CacheableWebView(io.github.hidroh.materialistic.widget.CacheableWebView) CacheableWebView(io.github.hidroh.materialistic.widget.CacheableWebView) WebView(android.webkit.WebView)

Aggregations

WebView (android.webkit.WebView)2 AdBlockWebViewClient (io.github.hidroh.materialistic.widget.AdBlockWebViewClient)2 CacheableWebView (io.github.hidroh.materialistic.widget.CacheableWebView)2 SuppressLint (android.annotation.SuppressLint)1