adding progress indicator to article.

This commit is contained in:
Kevin Meyer 2014-08-19 16:00:09 +02:00
parent 65089ff16c
commit 06066378d2
2 changed files with 19 additions and 2 deletions

View File

@ -33,6 +33,7 @@
android:id="@+id/btnMarkRead" android:id="@+id/btnMarkRead"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="@string/btnMarkRead" /> android:text="@string/btnMarkRead" />
</LinearLayout> </LinearLayout>

View File

@ -19,7 +19,10 @@ import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.View.OnTouchListener; import android.view.View.OnTouchListener;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebView; import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button; import android.widget.Button;
import android.widget.ScrollView; import android.widget.ScrollView;
import android.widget.TextView; import android.widget.TextView;
@ -37,6 +40,8 @@ public class ReadArticle extends Activity {
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
requestWindowFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.article); setContentView(R.layout.article);
view = (ScrollView) findViewById(R.id.scroll); view = (ScrollView) findViewById(R.id.scroll);
ArticlesSQLiteOpenHelper helper = new ArticlesSQLiteOpenHelper(getApplicationContext()); ArticlesSQLiteOpenHelper helper = new ArticlesSQLiteOpenHelper(getApplicationContext());
@ -86,9 +91,20 @@ public class ReadArticle extends Activity {
"</html>"; "</html>";
webViewContent = (WebView)findViewById(R.id.webViewContent); setProgressBarIndeterminateVisibility(true);
webViewContent.loadDataWithBaseURL("file:///android_asset/", htmlHeader + htmlContent + htmlFooter, "text/html", "utf-8", null); 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 = (Button)findViewById(R.id.btnMarkRead);
btnMarkRead.setOnClickListener(new OnClickListener() { btnMarkRead.setOnClickListener(new OnClickListener() {