Repository: incubator-taverna-mobile
Updated Branches:
  refs/heads/master 665531ea6 -> 8a6819eed


Remove empty line at end from build.gradle


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

Branch: refs/heads/master
Commit: a3ef86f9f32c2a9aed70225091b6da8c22731e4f
Parents: 665531e
Author: Ian Dunlop <ian.dun...@manchester.ac.uk>
Authored: Tue Oct 11 15:51:14 2016 +0100
Committer: Ian Dunlop <ian.dun...@manchester.ac.uk>
Committed: Tue Oct 11 15:51:14 2016 +0100

----------------------------------------------------------------------
 app/build.gradle                                |   2 +-
 .../mobile/ui/licences/LicenceFragment.java     | 109 +++++++++++++++++++
 .../ui/licences/LicenceRecyclerViewAdapter.java |  78 +++++++++++++
 .../ui/licences/licence/LicenceContent.java     |  80 ++++++++++++++
 app/src/main/res/layout/fragment_licence.xml    |  20 ++++
 .../main/res/layout/fragment_licence_list.xml   |  13 +++
 6 files changed, 301 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/a3ef86f9/app/build.gradle
----------------------------------------------------------------------
diff --git a/app/build.gradle b/app/build.gradle
index 2282111..051a337 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -81,4 +81,4 @@ dependencies {
 
     compile 'com.anton46:stepsview:0.0.2'
 
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/a3ef86f9/app/src/main/java/org/apache/taverna/mobile/ui/licences/LicenceFragment.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/ui/licences/LicenceFragment.java 
b/app/src/main/java/org/apache/taverna/mobile/ui/licences/LicenceFragment.java
new file mode 100644
index 0000000..f97be38
--- /dev/null
+++ 
b/app/src/main/java/org/apache/taverna/mobile/ui/licences/LicenceFragment.java
@@ -0,0 +1,109 @@
+package org.apache.taverna.mobile.ui.licences;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v7.widget.GridLayoutManager;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import mobile.taverna.apache.org.tavernamobile.R;
+
+import org.apache.taverna.mobile.ui.licences.dummy.DummyContent;
+import org.apache.taverna.mobile.ui.licences.dummy.DummyContent.DummyItem;
+
+/**
+ * A fragment representing a list of Items.
+ * <p/>
+ * Activities containing this fragment MUST implement the {@link 
OnListFragmentInteractionListener}
+ * interface.
+ */
+public class LicenceFragment extends Fragment {
+
+    // TODO: Customize parameter argument names
+    private static final String ARG_COLUMN_COUNT = "column-count";
+    // TODO: Customize parameters
+    private int mColumnCount = 1;
+    private OnListFragmentInteractionListener mListener;
+
+    /**
+     * Mandatory empty constructor for the fragment manager to instantiate the
+     * fragment (e.g. upon screen orientation changes).
+     */
+    public LicenceFragment() {
+    }
+
+    // TODO: Customize parameter initialization
+    @SuppressWarnings("unused")
+    public static LicenceFragment newInstance(int columnCount) {
+        LicenceFragment fragment = new LicenceFragment();
+        Bundle args = new Bundle();
+        args.putInt(ARG_COLUMN_COUNT, columnCount);
+        fragment.setArguments(args);
+        return fragment;
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        if (getArguments() != null) {
+            mColumnCount = getArguments().getInt(ARG_COLUMN_COUNT);
+        }
+    }
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+                             Bundle savedInstanceState) {
+        View view = inflater.inflate(R.layout.fragment_licence_list, 
container, false);
+
+        // Set the adapter
+        if (view instanceof RecyclerView) {
+            Context context = view.getContext();
+            RecyclerView recyclerView = (RecyclerView) view;
+            if (mColumnCount <= 1) {
+                recyclerView.setLayoutManager(new 
LinearLayoutManager(context));
+            } else {
+                recyclerView.setLayoutManager(new GridLayoutManager(context, 
mColumnCount));
+            }
+            recyclerView.setAdapter(new 
MyLicenceRecyclerViewAdapter(DummyContent.ITEMS, mListener));
+        }
+        return view;
+    }
+
+
+    @Override
+    public void onAttach(Context context) {
+        super.onAttach(context);
+        if (context instanceof OnListFragmentInteractionListener) {
+            mListener = (OnListFragmentInteractionListener) context;
+        } else {
+            throw new RuntimeException(context.toString()
+                    + " must implement OnListFragmentInteractionListener");
+        }
+    }
+
+    @Override
+    public void onDetach() {
+        super.onDetach();
+        mListener = null;
+    }
+
+    /**
+     * This interface must be implemented by activities that contain this
+     * fragment to allow an interaction in this fragment to be communicated
+     * to the activity and potentially other fragments contained in that
+     * activity.
+     * <p/>
+     * See the Android Training lesson <a href=
+     * 
"http://developer.android.com/training/basics/fragments/communicating.html";
+     * >Communicating with Other Fragments</a> for more information.
+     */
+    public interface OnListFragmentInteractionListener {
+        // TODO: Update argument type and name
+        void onListFragmentInteraction(DummyItem item);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/a3ef86f9/app/src/main/java/org/apache/taverna/mobile/ui/licences/LicenceRecyclerViewAdapter.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/ui/licences/LicenceRecyclerViewAdapter.java
 
b/app/src/main/java/org/apache/taverna/mobile/ui/licences/LicenceRecyclerViewAdapter.java
new file mode 100644
index 0000000..85ff0b5
--- /dev/null
+++ 
b/app/src/main/java/org/apache/taverna/mobile/ui/licences/LicenceRecyclerViewAdapter.java
@@ -0,0 +1,78 @@
+package org.apache.taverna.mobile.ui.licences;
+
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import org.apache.taverna.mobile.R;
+import 
org.apache.taverna.mobile.ui.licences.LicenceFragment.OnListFragmentInteractionListener;
+import org.apache.taverna.mobile.ui.licences.licence.LicenceContent.DummyItem;
+
+import java.util.List;
+
+/**
+ * {@link RecyclerView.Adapter} that can display a {@link DummyItem} and makes 
a call to the
+ * specified {@link OnListFragmentInteractionListener}.
+ * TODO: Replace the implementation with code for your data type.
+ */
+public class LicenceRecyclerViewAdapter extends 
RecyclerView.Adapter<LicenceRecyclerViewAdapter.ViewHolder> {
+
+    private final List<DummyItem> mValues;
+    private final OnListFragmentInteractionListener mListener;
+
+    public LicenceRecyclerViewAdapter(List<DummyItem> items, 
OnListFragmentInteractionListener listener) {
+        mValues = items;
+        mListener = listener;
+    }
+
+    @Override
+    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+        View view = LayoutInflater.from(parent.getContext())
+                .inflate(R.layout.fragment_item, parent, false);
+        return new ViewHolder(view);
+    }
+
+    @Override
+    public void onBindViewHolder(final ViewHolder holder, int position) {
+        holder.mItem = mValues.get(position);
+        holder.mIdView.setText(mValues.get(position).id);
+        holder.mContentView.setText(mValues.get(position).content);
+
+        holder.mView.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                if (null != mListener) {
+                    // Notify the active callbacks interface (the activity, if 
the
+                    // fragment is attached to one) that an item has been 
selected.
+                    mListener.onListFragmentInteraction(holder.mItem);
+                }
+            }
+        });
+    }
+
+    @Override
+    public int getItemCount() {
+        return mValues.size();
+    }
+
+    public class ViewHolder extends RecyclerView.ViewHolder {
+        public final View mView;
+        public final TextView mIdView;
+        public final TextView mContentView;
+        public DummyItem mItem;
+
+        public ViewHolder(View view) {
+            super(view);
+            mView = view;
+            mIdView = (TextView) view.findViewById(R.id.id);
+            mContentView = (TextView) view.findViewById(R.id.content);
+        }
+
+        @Override
+        public String toString() {
+            return super.toString() + " '" + mContentView.getText() + "'";
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/a3ef86f9/app/src/main/java/org/apache/taverna/mobile/ui/licences/licence/LicenceContent.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/ui/licences/licence/LicenceContent.java
 
b/app/src/main/java/org/apache/taverna/mobile/ui/licences/licence/LicenceContent.java
new file mode 100644
index 0000000..3b403ff
--- /dev/null
+++ 
b/app/src/main/java/org/apache/taverna/mobile/ui/licences/licence/LicenceContent.java
@@ -0,0 +1,80 @@
+package org.apache.taverna.mobile.ui.licences.licence;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Helper class for providing sample content for user interfaces created by
+ * Android template wizards.
+ * <p>
+ * TODO: Replace all uses of this class before publishing your app.
+ */
+public class LicenceContent {
+
+    /**
+     * An array of sample (dummy) items.
+     */
+    public static final List<LicenceItem> ITEMS = new ArrayList<LicenceItem>();
+    private static String licence_json = "[{'library': 
'dropbox-android-sdk','version': '1.6.3'}, {'library': 'json_simple','version': 
'1.1'}, {'libary': 'sjxp','version': '2.2'}, {'library': 
'com.android.support:appcompat','version': 'v7:23.3.0'}, {'library': 
'com.android.support:cardview','version': 'v7:23.3.0'}, {'library': 
'com.android.support:recyclerview','version': 'v7:23.3.0'}, {'library': 
'com.android.support:support','version': 'v4:23.3.0'}, {'library': 
'com.android.support:design','version': ':23.3.0'}, {'library': 
'com.squareup.retrofit2:retrofit','version': '2.0.2'}, {'library': 
'com.squareup.retrofit2:adapter-rxjava',    'version': '2.0.2'}, {    
'library': 'com.squareup.okhttp3:logging-interceptor',    'version': '3.2.0'}, 
{    'library': 'com.squareup.retrofit2:converter-simplexml',    'version': 
'2.0.2'}, {    'library': 'com.jakewharton:butterknife',    'version': 
'8.0.1'}, {    'library': 'com.jakewharton:butterknife-compiler',    'version': 
'8.0.1'}, {'library': 
 'io.reactivex:rxandroid', 'version': '1.2.0'}, {'library': 
'io.reactivex:rxjava', 'version': '1.1.4'}, {'library': 
'org.simpleframework:simple-xml',    'version': '2.7. +'}, {    'library': 
'com.github.bumptech.glide:glide',    'version': '3.6.0'}, {    'libray': 
'com.caverock:androidsvg',    'version': '1.2.1'}, {    'library': 
'com.github.Raizlabs.DBFlow:dbflow-processor',    'version': '3.0.1'}, {    
'library': 'com.github.Raizlabs.DBFlow:dbflow-core',    'version': '3.0.1'}, {  
  'library': 'com.github.Raizlabs.DBFlow:dbflow',    'version': '3.0.1'}, {    
'library': 'com.facebook.stetho:stetho',    'version': '1.3.1'}, {    
'library': 'com.facebook.stetho:stetho-okhttp',    'version': '3: 1.3.1'}, {    
'library': 'com.github.chrisbanes:PhotoView',    'version': '1.2.6'}, {    
'library': 'com.androidsupport:multidex','version': '1.0.0'}, {'library': 
'com.google.code.gson:gson','version': '2.7'}, {'library': 
'com.squareup.retrofit2:converter-gson','version': '2.0.2'}, {'library': 
 'com.anton46:stepsview','version': '0.0.2'}]";
+
+    /**
+     * A map of sample (dummy) items, by ID.
+     */
+    public static final Map<String, LicenceItem> ITEM_MAP = new 
HashMap<String, LicenceItem>();
+
+    private static final int COUNT = 25;
+
+    static {
+        JSONArray licenceList = null;
+        try {
+            licenceList = new JSONArray(licence_json);
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+        for (int i=0; i < licenceList.length(); i++) {
+            try {
+                JSONObject libraryDetails = licenceList.getJSONObject(i);
+                String libraryName = libraryDetails.getString("library");
+                String libraryVersion = libraryDetails.getString("version");
+                addItem(createLicenceItem(i, libraryName, libraryVersion));
+            } catch (JSONException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    private static void addItem(LicenceItem item) {
+        ITEMS.add(item);
+        ITEM_MAP.put(item.id, item);
+    }
+
+    private static LicenceItem createLicenceItem(int position, String name, 
String version) {
+        return new LicenceItem(String.valueOf(position), name, version);
+    }
+
+    /**
+     * A dummy item representing a piece of content.
+     */
+    public static class LicenceItem {
+        public final String id;
+        public final String name;
+        public final String version;
+
+        public LicenceItem(String id, String name, String version) {
+            this.id = id;
+            this.name = name;
+            this.version = version;
+        }
+
+        @Override
+        public String toString() {
+            return name + " " + version;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/a3ef86f9/app/src/main/res/layout/fragment_licence.xml
----------------------------------------------------------------------
diff --git a/app/src/main/res/layout/fragment_licence.xml 
b/app/src/main/res/layout/fragment_licence.xml
new file mode 100644
index 0000000..ba5b613
--- /dev/null
+++ b/app/src/main/res/layout/fragment_licence.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android";
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:orientation="horizontal">
+
+    <TextView
+        android:id="@+id/id"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_margin="@dimen/text_margin"
+        android:textAppearance="?attr/textAppearanceListItem" />
+
+    <TextView
+        android:id="@+id/content"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_margin="@dimen/text_margin"
+        android:textAppearance="?attr/textAppearanceListItem" />
+</LinearLayout>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/a3ef86f9/app/src/main/res/layout/fragment_licence_list.xml
----------------------------------------------------------------------
diff --git a/app/src/main/res/layout/fragment_licence_list.xml 
b/app/src/main/res/layout/fragment_licence_list.xml
new file mode 100644
index 0000000..350829d
--- /dev/null
+++ b/app/src/main/res/layout/fragment_licence_list.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.v7.widget.RecyclerView 
xmlns:android="http://schemas.android.com/apk/res/android";
+    xmlns:app="http://schemas.android.com/apk/res-auto";
+    xmlns:tools="http://schemas.android.com/tools";
+    android:id="@+id/list"
+    
android:name="org.apache.taverna.mobile.ui.org.apache.taverna.mobile.ui.licences.LicenceFragment"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:layout_marginLeft="16dp"
+    android:layout_marginRight="16dp"
+    app:layoutManager="LinearLayoutManager"
+    
tools:context="org.apache.taverna.mobile.ui.org.apache.taverna.mobile.ui.licences.LicenceFragment"
+    tools:listitem="@layout/fragment_licence" />

Reply via email to