You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by ia...@apache.org on 2016/10/03 14:49:36 UTC

[26/50] [abbrv] incubator-taverna-mobile git commit: add generic WebView fragment

add generic WebView fragment


Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/commit/d411dae8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/tree/d411dae8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/diff/d411dae8

Branch: refs/heads/master
Commit: d411dae8f75f0a48185f40edbf660c8563eb62e4
Parents: afa295d
Author: Sagar <ku...@gmail.com>
Authored: Mon Sep 26 14:36:15 2016 +0530
Committer: Sagar <ku...@gmail.com>
Committed: Mon Sep 26 14:36:15 2016 +0530

----------------------------------------------------------------------
 .../apache/taverna/mobile/utils/WebViewGen.java | 93 ++++++++++++++++++++
 app/src/main/res/layout/webviewgen.xml          | 20 +++++
 2 files changed, 113 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/d411dae8/app/src/main/java/org/apache/taverna/mobile/utils/WebViewGen.java
----------------------------------------------------------------------
diff --git a/app/src/main/java/org/apache/taverna/mobile/utils/WebViewGen.java b/app/src/main/java/org/apache/taverna/mobile/utils/WebViewGen.java
new file mode 100644
index 0000000..abb52d2
--- /dev/null
+++ b/app/src/main/java/org/apache/taverna/mobile/utils/WebViewGen.java
@@ -0,0 +1,93 @@
+package org.apache.taverna.mobile.utils;
+
+import android.graphics.Bitmap;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.webkit.WebView;
+import android.webkit.WebViewClient;
+import android.widget.ProgressBar;
+
+import org.apache.taverna.mobile.R;
+
+public class WebViewGen extends Fragment {
+    private static final String PARAM1 = "URL";
+    private int flag;
+    private ProgressBar progressBar;
+    private WebView web;
+    private String URL;
+
+    public static WebViewGen newInstance(String URL) {
+
+        Bundle args = new Bundle();
+        args.putString(PARAM1, URL);
+        WebViewGen fragment = new WebViewGen();
+        fragment.setArguments(args);
+        return fragment;
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        if (getArguments() != null) {
+            URL = getArguments().getString(PARAM1);
+        }
+    }
+
+    @Nullable
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle
+            savedInstanceState) {
+        View layout = inflater.inflate(R.layout.webviewgen, container, false);
+
+        web = (WebView) layout.findViewById(R.id.webView);
+
+        progressBar = (ProgressBar) layout.findViewById(R.id.progressBar);
+
+        web.setWebViewClient(new myWebClient());
+        web.getSettings().setJavaScriptEnabled(true);
+        web.getSettings().setBuiltInZoomControls(true);
+        web.loadUrl(URL);
+        web.canGoBack();
+        return layout;
+
+    }
+
+    private void getServer() {
+
+    }
+
+
+    public class myWebClient extends WebViewClient {
+
+
+        @Override
+        public void onPageStarted(WebView view, String url, Bitmap favicon) {
+
+            super.onPageStarted(view, url, favicon);
+
+        }
+
+        @Override
+        public boolean shouldOverrideUrlLoading(WebView view, String url) {
+
+            progressBar.setVisibility(View.VISIBLE);
+            view.loadUrl(url);
+            return true;
+
+        }
+
+        @Override
+        public void onPageFinished(WebView view, String url) {
+
+            super.onPageFinished(view, url);
+
+            progressBar.setVisibility(View.GONE);
+        }
+    }
+
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/d411dae8/app/src/main/res/layout/webviewgen.xml
----------------------------------------------------------------------
diff --git a/app/src/main/res/layout/webviewgen.xml b/app/src/main/res/layout/webviewgen.xml
new file mode 100644
index 0000000..212cf39
--- /dev/null
+++ b/app/src/main/res/layout/webviewgen.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <WebView
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:id="@+id/webView"
+        />
+
+    <ProgressBar
+
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:id="@+id/progressBar"
+        android:layout_centerVertical="true"
+        android:layout_centerHorizontal="true" />
+
+</RelativeLayout>
\ No newline at end of file