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 2015/06/22 12:28:16 UTC

[04/12] incubator-taverna-mobile git commit: Added pull to refresh functionality as simple view from android support library not third party library

Added pull to refresh functionality as simple view from android support library not third party library


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/4f660cbf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/tree/4f660cbf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/diff/4f660cbf

Branch: refs/heads/master
Commit: 4f660cbf5f5bfa6b21f64c573919935093bb6b5a
Parents: 324da9c
Author: larrytech7 <la...@gmail.com>
Authored: Mon Jun 15 19:32:49 2015 +0100
Committer: larrytech7 <la...@gmail.com>
Committed: Mon Jun 15 19:32:49 2015 +0100

----------------------------------------------------------------------
 .../activities/WorkflowDetailActivity.java      |  1 -
 .../mobile/fragments/WorkflowItemFragment.java  | 32 +++++++++-----------
 app/src/main/res/layout/fragment_item_list.xml  |  6 +++-
 app/src/main/res/layout/workflow_layout.xml     |  5 ++-
 app/src/main/res/values/strings.xml             |  3 +-
 5 files changed, 26 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/4f660cbf/app/src/main/java/org/apache/taverna/mobile/activities/WorkflowDetailActivity.java
----------------------------------------------------------------------
diff --git a/app/src/main/java/org/apache/taverna/mobile/activities/WorkflowDetailActivity.java b/app/src/main/java/org/apache/taverna/mobile/activities/WorkflowDetailActivity.java
index 98c80f8..7c43b73 100644
--- a/app/src/main/java/org/apache/taverna/mobile/activities/WorkflowDetailActivity.java
+++ b/app/src/main/java/org/apache/taverna/mobile/activities/WorkflowDetailActivity.java
@@ -63,7 +63,6 @@ public class WorkflowDetailActivity extends ActionBarActivity {
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
-        supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_workflow_detail);
         // Create the adapter that will return a fragment for each of the three

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/4f660cbf/app/src/main/java/org/apache/taverna/mobile/fragments/WorkflowItemFragment.java
----------------------------------------------------------------------
diff --git a/app/src/main/java/org/apache/taverna/mobile/fragments/WorkflowItemFragment.java b/app/src/main/java/org/apache/taverna/mobile/fragments/WorkflowItemFragment.java
index 798cbf2..5793b33 100644
--- a/app/src/main/java/org/apache/taverna/mobile/fragments/WorkflowItemFragment.java
+++ b/app/src/main/java/org/apache/taverna/mobile/fragments/WorkflowItemFragment.java
@@ -25,10 +25,10 @@ package org.apache.taverna.mobile.fragments;
  */
 
 import android.app.Activity;
+import android.app.ProgressDialog;
 import android.os.Bundle;
 import android.support.v4.app.Fragment;
-import android.support.v4.app.LoaderManager;
-import android.support.v4.content.Loader;
+import android.support.v4.widget.SwipeRefreshLayout;
 import android.support.v7.widget.LinearLayoutManager;
 import android.support.v7.widget.RecyclerView;
 import android.view.LayoutInflater;
@@ -37,11 +37,8 @@ import android.view.MenuInflater;
 import android.view.MenuItem;
 import android.view.View;
 import android.view.ViewGroup;
-import android.view.Window;
 import android.view.animation.Animation;
 import android.view.animation.AnimationUtils;
-import android.widget.AdapterView;
-import android.widget.ProgressBar;
 import android.widget.TextView;
 
 import org.apache.taverna.mobile.R;
@@ -62,14 +59,14 @@ import java.util.List;
  * Activities containing this fragment MUST implement the {@link org.apache.taverna.mobile.fragments.WorkflowItemFragment.OnWorkflowSelectedListener}
  * interface.
  */
-public class WorkflowItemFragment extends Fragment implements android.app.LoaderManager.LoaderCallbacks<List<Workflow>> {
+public class WorkflowItemFragment extends Fragment implements android.app.LoaderManager.LoaderCallbacks<List<Workflow>>, SwipeRefreshLayout.OnRefreshListener {
 
     // TODO: Rename parameter arguments, choose names that match
     // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
     private static final String ARG_PARAM1 = "param1";
     private static final String ARG_PARAM2 = "param2";
     private Animation in;
-    private ProgressBar wpb; //progressbar used to indicate the state of the workflow loaders
+    private ProgressDialog mProgressDialog; //progressbar used to indicate the state of the workflow loaders
 
     // TODO: Rename and change types of parameters
     private String mParam1;
@@ -81,6 +78,7 @@ public class WorkflowItemFragment extends Fragment implements android.app.Loader
      * The fragment's ListView/GridView.
      */
     private RecyclerView mListView;
+    private SwipeRefreshLayout swipeRefreshLayout;
 
     /**
      * The Adapter which will be used to populate the ListView/GridView with
@@ -129,7 +127,8 @@ public class WorkflowItemFragment extends Fragment implements android.app.Loader
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.fragment_item, container, false);
-        wpb = (ProgressBar) view.findViewById(R.id.workflow_pb);
+        swipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.refresh);
+        swipeRefreshLayout.setOnRefreshListener(this);
         // Set the adapter
         mListView = (RecyclerView) view.findViewById(android.R.id.list);
         mListView.setHasFixedSize(true);
@@ -235,24 +234,18 @@ public class WorkflowItemFragment extends Fragment implements android.app.Loader
      */
     @Override
     public android.content.Loader<List<Workflow>> onCreateLoader(int id, Bundle args) {
-        if (null != wpb)
-            wpb.setVisibility(View.VISIBLE);
+        swipeRefreshLayout.setRefreshing(true);
         return new WorkflowLoader(getActivity());
     }
 
     @Override
     public void onLoadFinished(android.content.Loader<List<Workflow>> loader, List<Workflow> workflows) {
-       // getActivity().setProgressBarIndeterminateVisibility(false);
-        if (null != wpb)
-        wpb.setVisibility(View.GONE);
+        swipeRefreshLayout.setRefreshing(false);
         loader.stopLoading();
         workflowAdapter = new WorkflowAdapter(getActivity(), workflows);
         if(workflows.size() > 0)
             mListView.swapAdapter(workflowAdapter, true);
-        else {
-           // mListView.setVisibility(View.GONE);
-//            setEmptyText("No views available");
-        }
+
     }
 
     @Override
@@ -261,6 +254,11 @@ public class WorkflowItemFragment extends Fragment implements android.app.Loader
         mListView.swapAdapter(null, false);
     }
 
+    @Override
+    public void onRefresh() {
+        getActivity().getLoaderManager().initLoader(0,null,this);
+    }
+
     /**
      * This interface must be implemented by activities that contain this
      * fragment to allow an interaction in this fragment to be communicated

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/4f660cbf/app/src/main/res/layout/fragment_item_list.xml
----------------------------------------------------------------------
diff --git a/app/src/main/res/layout/fragment_item_list.xml b/app/src/main/res/layout/fragment_item_list.xml
index 522164c..9852dfb 100644
--- a/app/src/main/res/layout/fragment_item_list.xml
+++ b/app/src/main/res/layout/fragment_item_list.xml
@@ -27,6 +27,10 @@ limitations under the License.
 
     <!--<ListView android:id="@android:id/list" android:layout_width="match_parent"-->
         <!--android:layout_height="match_parent" />-->
+    <android.support.v4.widget.SwipeRefreshLayout
+        android:id="@+id/refresh"
+        android:layout_height="match_parent"
+        android:layout_width="match_parent">
     <android.support.v7.widget.RecyclerView
         xmlns:recycler_view="http://schemas.android.com/apk/res-auto"
         android:id="@android:id/list"
@@ -37,7 +41,7 @@ limitations under the License.
         >
 
     </android.support.v7.widget.RecyclerView>
-
+</android.support.v4.widget.SwipeRefreshLayout>
     <TextView
         android:id="@android:id/empty"
         android:layout_width="match_parent"

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/4f660cbf/app/src/main/res/layout/workflow_layout.xml
----------------------------------------------------------------------
diff --git a/app/src/main/res/layout/workflow_layout.xml b/app/src/main/res/layout/workflow_layout.xml
index 564979c..6bc3160 100644
--- a/app/src/main/res/layout/workflow_layout.xml
+++ b/app/src/main/res/layout/workflow_layout.xml
@@ -19,8 +19,11 @@ See the License for the specific language governing permissions and
 limitations under the License.
 -->
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:orientation="vertical" android:layout_width="match_parent"
+    android:orientation="vertical"
+    android:layout_width="match_parent"
     android:layout_height="match_parent">
+
+
     <android.support.v7.widget.RecyclerView
         xmlns:recycler_view="http://schemas.android.com/apk/res-auto"
         android:id="@+id/recycler_list"

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/4f660cbf/app/src/main/res/values/strings.xml
----------------------------------------------------------------------
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 309ad1c..e7b2221 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -53,7 +53,7 @@ limitations under the License.
     <string name="workflow_download">Download</string>
     <string name="workflow_read">View</string>
     <string name="workflow_mark">Favorite</string>
-    <string name="workflow_authorhint">Workflow Author</string>
+    <string name="workflow_authorhint">Workflow Author  </string>
     <string name="workflow_component">Workflow component</string>
     <string name="favorite_empty"> No Favorites Added Yet</string>
     <string name="workflow_empty"> No <b>Workflows</b> Available. Check your Connection to the Internet</string>
@@ -78,5 +78,6 @@ limitations under the License.
     <string name="downloadcomplete">  download complete</string>
     <string name="seemore"> See more &amp;raquo</string>
     <string name="loading">Loading details</string>
+    <string name="loadworkflows">Loading Workflows</string>
 
 </resources>