From 06066378d25f0f57f5bb218e61a9ea12701835f1 Mon Sep 17 00:00:00 2001 From: Kevin Meyer Date: Tue, 19 Aug 2014 16:00:09 +0200 Subject: [PATCH] adding progress indicator to article. --- res/layout/article.xml | 1 + src/fr/gaulupeau/apps/Poche/ReadArticle.java | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/res/layout/article.xml b/res/layout/article.xml index 4e9b073..c26632a 100644 --- a/res/layout/article.xml +++ b/res/layout/article.xml @@ -33,6 +33,7 @@ android:id="@+id/btnMarkRead" android:layout_width="fill_parent" android:layout_height="wrap_content" + android:layout_marginBottom="5dp" android:text="@string/btnMarkRead" /> diff --git a/src/fr/gaulupeau/apps/Poche/ReadArticle.java b/src/fr/gaulupeau/apps/Poche/ReadArticle.java index 7da3c52..bc722c5 100644 --- a/src/fr/gaulupeau/apps/Poche/ReadArticle.java +++ b/src/fr/gaulupeau/apps/Poche/ReadArticle.java @@ -19,7 +19,10 @@ import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnTouchListener; +import android.view.Window; +import android.webkit.WebChromeClient; import android.webkit.WebView; +import android.webkit.WebViewClient; import android.widget.Button; import android.widget.ScrollView; import android.widget.TextView; @@ -37,6 +40,8 @@ public class ReadArticle extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); + requestWindowFeature(Window.FEATURE_PROGRESS); setContentView(R.layout.article); view = (ScrollView) findViewById(R.id.scroll); ArticlesSQLiteOpenHelper helper = new ArticlesSQLiteOpenHelper(getApplicationContext()); @@ -86,9 +91,20 @@ public class ReadArticle extends Activity { ""; - webViewContent = (WebView)findViewById(R.id.webViewContent); - webViewContent.loadDataWithBaseURL("file:///android_asset/", htmlHeader + htmlContent + htmlFooter, "text/html", "utf-8", null); + setProgressBarIndeterminateVisibility(true); + setProgressBarVisibility(true); + webViewContent = (WebView)findViewById(R.id.webViewContent); + webViewContent.setWebChromeClient(new WebChromeClient() { + public void onProgressChanged(WebView view, int progress) { + setProgress(progress * 100); + if(progress == 100) { + setProgressBarIndeterminateVisibility(false); + setProgressBarVisibility(false); + } + } + }); + webViewContent.loadDataWithBaseURL("file:///android_asset/", htmlHeader + htmlContent + htmlFooter, "text/html", "utf-8", null); btnMarkRead = (Button)findViewById(R.id.btnMarkRead); btnMarkRead.setOnClickListener(new OnClickListener() {