clear codebase
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/b93d871c Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/tree/b93d871c Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/diff/b93d871c Branch: refs/heads/master Commit: b93d871c7e94541d6f2fd2da3f56279aa61e23f0 Parents: c850e05 Author: Sagar <[email protected]> Authored: Tue Oct 18 17:22:25 2016 +0530 Committer: Sagar <[email protected]> Committed: Tue Oct 18 19:13:36 2016 +0530 ---------------------------------------------------------------------- app/libs/dropbox-android-sdk-1.6.3.jar | Bin 168350 -> 0 bytes app/libs/json_simple-1.1.jar | Bin 16046 -> 0 bytes app/libs/sjxp-2.2.jar | Bin 24390 -> 0 bytes .../taverna/mobile/activities/RunResult.java | 56 -- .../activities/WorkflowDetailActivity.java | 142 ---- .../adapters/FavoriteWorkflowAdapter.java | 198 ----- .../taverna/mobile/adapters/RunAdapter.java | 158 ---- .../mobile/adapters/SliderMenuAdapter.java | 114 --- .../mobile/adapters/WorkflowAdapter.java | 352 -------- .../WorkflowDownloadReceiver.java | 66 -- .../customviews/WorkflowPreviewImageView.java | 277 ------- .../mobile/fragments/FavoriteFragment.java | 228 ------ .../mobile/fragments/WorkflowItemFragment.java | 492 ----------- .../mobile/fragments/WorkflowViewpager.java | 140 ---- .../fragments/workflowdetails/RunFragment.java | 321 -------- .../workflowdetails/WorkflowAboutFragment.java | 87 -- .../WorkflowLicenceFragment.java | 93 --- .../WorkflowRunHistoryFragment.java | 172 ---- .../workflowdetails/WorkflowdetailFragment.java | 811 ------------------- .../taverna/mobile/tavernamobile/Runs.java | 113 --- .../mobile/tavernamobile/TavernaPlayerAPI.java | 107 --- .../taverna/mobile/tavernamobile/User.java | 171 ---- .../taverna/mobile/tavernamobile/Workflow.java | 361 --------- .../mobile/tavernamobile/WorkflowComponent.java | 36 - .../taverna/mobile/utils/AvatarLoader.java | 84 -- .../apache/taverna/mobile/utils/DBUtility.java | 65 -- .../taverna/mobile/utils/DetailsLoader.java | 280 ------- .../apache/taverna/mobile/utils/HttpUtil.java | 108 --- .../apache/taverna/mobile/utils/RunTask.java | 124 --- .../apache/taverna/mobile/utils/WorkflowDB.java | 328 -------- .../mobile/utils/WorkflowDataCallback.java | 39 - .../mobile/utils/WorkflowDownloadManager.java | 118 --- .../taverna/mobile/utils/WorkflowLoader.java | 106 --- .../mobile/utils/WorkflowLoaderMain.java | 45 - .../taverna/mobile/utils/WorkflowOpen.java | 339 -------- .../utils/xmlparsers/AvatarXMLParser.java | 47 -- .../xmlparsers/MyExperimentXmlParserRules.java | 380 --------- .../utils/xmlparsers/WorkflowDetailParser.java | 56 -- .../mobile/utils/xmlparsers/WorkflowParser.java | 52 -- app/src/main/res/layout/activity_run_result.xml | 28 - .../res/layout/activity_workflow_detail.xml | 39 - .../main/res/layout/favorite_item_layout.xml | 138 ---- .../main/res/layout/fragment_dashboard_main.xml | 39 - app/src/main/res/layout/fragment_item_grid.xml | 51 -- app/src/main/res/layout/fragment_item_list.xml | 50 -- app/src/main/res/layout/fragment_run_result.xml | 164 ---- .../main/res/layout/fragment_workflow_about.xml | 39 - .../res/layout/fragment_workflow_detail.xml | 190 ----- .../res/layout/fragment_workflow_licence.xml | 39 - .../layout/fragment_workflow_run_history.xml | 44 - app/src/main/res/layout/menu_item_layout.xml | 44 - app/src/main/res/layout/viewpager_workflow.xml | 56 -- .../main/res/layout/workflow_item_layout.xml | 173 ---- app/src/main/res/layout/workflow_layout.xml | 36 - app/src/main/res/layout/workflow_run_item.xml | 136 ---- app/src/main/res/menu/run_result.xml | 34 - app/src/main/res/values-large/refs.xml | 31 - app/src/main/res/values-large/strings.xml | 33 - app/src/main/res/values-sw600dp/refs.xml | 31 - app/src/main/res/values-sw600dp/strings.xml | 25 - app/src/main/res/values-w820dp/strings.xml | 28 - app/src/main/res/values/refs.xml | 31 - app/src/main/res/values/strings.xml | 22 + .../res/values/strings_activity_settings.xml | 46 -- 64 files changed, 22 insertions(+), 8191 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/b93d871c/app/libs/dropbox-android-sdk-1.6.3.jar ---------------------------------------------------------------------- diff --git a/app/libs/dropbox-android-sdk-1.6.3.jar b/app/libs/dropbox-android-sdk-1.6.3.jar deleted file mode 100644 index 1a0ee36..0000000 Binary files a/app/libs/dropbox-android-sdk-1.6.3.jar and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/b93d871c/app/libs/json_simple-1.1.jar ---------------------------------------------------------------------- diff --git a/app/libs/json_simple-1.1.jar b/app/libs/json_simple-1.1.jar deleted file mode 100644 index f395f41..0000000 Binary files a/app/libs/json_simple-1.1.jar and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/b93d871c/app/libs/sjxp-2.2.jar ---------------------------------------------------------------------- diff --git a/app/libs/sjxp-2.2.jar b/app/libs/sjxp-2.2.jar deleted file mode 100644 index 67960bc..0000000 Binary files a/app/libs/sjxp-2.2.jar and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/b93d871c/app/src/main/java/org/apache/taverna/mobile/activities/RunResult.java ---------------------------------------------------------------------- diff --git a/app/src/main/java/org/apache/taverna/mobile/activities/RunResult.java b/app/src/main/java/org/apache/taverna/mobile/activities/RunResult.java deleted file mode 100644 index 8034706..0000000 --- a/app/src/main/java/org/apache/taverna/mobile/activities/RunResult.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.taverna.mobile.activities; - -import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; -import android.view.Menu; -import android.view.MenuItem; - -import org.apache.taverna.mobile.R; -import org.apache.taverna.mobile.fragments.workflowdetails.RunFragment; - -public class RunResult extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_run_result); - if (savedInstanceState == null) { - getSupportFragmentManager().beginTransaction() - .add(R.id.container, RunFragment.newInstance()) - .commit(); - } - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - // Inflate the menu; this adds items to the action bar if it is present. - return false; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - - this.finish(); - - return super.onOptionsItemSelected(item); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/b93d871c/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 deleted file mode 100644 index 2ee4384..0000000 --- a/app/src/main/java/org/apache/taverna/mobile/activities/WorkflowDetailActivity.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.taverna.mobile.activities; - - -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentPagerAdapter; -import android.support.v4.view.ViewPager; -import android.support.v7.app.AppCompatActivity; -import android.view.Menu; -import android.view.MenuItem; - -import org.apache.taverna.mobile.R; -import org.apache.taverna.mobile.fragments.workflowdetails.WorkflowAboutFragment; -import org.apache.taverna.mobile.fragments.workflowdetails.WorkflowLicenceFragment; -import org.apache.taverna.mobile.fragments.workflowdetails.WorkflowRunHistoryFragment; -import org.apache.taverna.mobile.fragments.workflowdetails.WorkflowdetailFragment; - -import java.util.Locale; - -public class WorkflowDetailActivity extends AppCompatActivity { - - /** - * The {@link android.support.v4.view.PagerAdapter} that will provide - * fragments for each of the sections. We use a - * {@link FragmentPagerAdapter} derivative, which will keep every - * loaded fragment in memory. If this becomes too memory intensive, it - * may be best to switch to a - * {@link android.support.v4.app.FragmentStatePagerAdapter}. - */ - SectionsPagerAdapter mSectionsPagerAdapter; - - /** - * The {@link ViewPager} that will host the section contents. - */ - ViewPager mViewPager; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_workflow_detail); - // Create the adapter that will return a fragment for each of the three - // primary sections of the activity. - mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); - - // Set up the ViewPager with the sections adapter. - mViewPager = (ViewPager) findViewById(R.id.pager); - if (mViewPager != null) { - mViewPager.setAdapter(mSectionsPagerAdapter); - } - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - return false; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - // Handle action bar item clicks here. The action bar will - if (item.getItemId() == android.R.id.home) { - finish(); - this.overridePendingTransition(android.R.anim.fade_in, android.R.anim.slide_out_right); - } - return super.onOptionsItemSelected(item); - } - - @Override - public void onBackPressed() { - finish(); - this.overridePendingTransition(android.R.anim.fade_in, android.R.anim.slide_out_right); - } - - /** - * A {@link FragmentPagerAdapter} that returns a fragment corresponding to - * one of the sections/tabs/pages. - */ - public class SectionsPagerAdapter extends FragmentPagerAdapter { - - public SectionsPagerAdapter(FragmentManager fm) { - super(fm); - } - - @Override - public Fragment getItem(int position) { - switch (position + 1) { - case 1: - return WorkflowdetailFragment.newInstance(position + 1); - case 2: - //System.out.println(""+getIntent().getStringExtra("wtitle")); - return WorkflowRunHistoryFragment.newInstance(getIntent().getStringExtra - ("wtitle")); - case 3: - return WorkflowLicenceFragment.newInstance("", ""); - case 4: - return WorkflowAboutFragment.newInstance("", ""); - } - return WorkflowdetailFragment.newInstance(position + 1); - } - - @Override - public int getCount() { - // Show 4 total pages. - return 3; - } - - @Override - public CharSequence getPageTitle(int position) { - Locale l = Locale.getDefault(); - switch (position) { - case 0: - return getString(R.string.detail_title_section1).toUpperCase(l); - case 1: - return getString(R.string.detail_title_section2).toUpperCase(l); - case 2: - return getString(R.string.detail_title_section3).toUpperCase(l); - case 3: - return getString(R.string.detail_title_section4).toUpperCase(l); - } - return ""; - } - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/b93d871c/app/src/main/java/org/apache/taverna/mobile/adapters/FavoriteWorkflowAdapter.java ---------------------------------------------------------------------- diff --git a/app/src/main/java/org/apache/taverna/mobile/adapters/FavoriteWorkflowAdapter.java b/app/src/main/java/org/apache/taverna/mobile/adapters/FavoriteWorkflowAdapter.java deleted file mode 100644 index 9522a3a..0000000 --- a/app/src/main/java/org/apache/taverna/mobile/adapters/FavoriteWorkflowAdapter.java +++ /dev/null @@ -1,198 +0,0 @@ -package org.apache.taverna.mobile.adapters; -/** - * Apache Taverna Mobile - * Copyright 2015 The Apache Software Foundation - * - * This product includes software developed at - * The Apache Software Foundation (http://www.apache.org/). - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.taverna.mobile.R; -import org.apache.taverna.mobile.utils.WorkflowDB; -import org.json.JSONException; - -import android.app.Dialog; -import android.content.Context; -import android.content.SharedPreferences; -import android.graphics.Color; -import android.preference.PreferenceManager; -import android.support.design.widget.FloatingActionButton; -import android.support.v7.widget.RecyclerView; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.Button; -import android.widget.ImageView; -import android.widget.TextView; -import android.widget.Toast; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * Created by Larry Akah on 6/9/15. - */ -public class FavoriteWorkflowAdapter extends RecyclerView.Adapter<FavoriteWorkflowAdapter - .FViewHolder> { - private static final String TAG = "FavoriteWorkflowAdapter"; - public WorkflowDB favDB; - private Context context; - private List<ArrayList<Object>> dataSet; - - public FavoriteWorkflowAdapter(Context c, List<ArrayList<Object>> data) { - context = c; - dataSet = data; - favDB = new WorkflowDB(context, WorkflowAdapter.WORKFLOW_FAVORITE_KEY); - } - - @Override - public FViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { - View itemview = LayoutInflater.from(context).inflate(R.layout.favorite_item_layout, - viewGroup, false); - FViewHolder vh = new FViewHolder(itemview); - return vh; - } - - /** - * Register a new observer to listen for data changes. - * <p/> - * <p>The adapter may publish a variety of events describing specific changes. - * Not all adapters may support all change types and some may fall back to a generic - * {@link android.support.v7.widget.RecyclerView.AdapterDataObserver#onChanged() - * "something changed"} event if more specific data is not available.</p> - * <p/> - * <p>Components registering observers with an adapter are responsible for - * {@link #unregisterAdapterDataObserver(android.support.v7.widget.RecyclerView - * .AdapterDataObserver) - * unregistering} those observers when finished.</p> - * - * @param observer Observer to register - * @see #unregisterAdapterDataObserver(android.support.v7.widget.RecyclerView - * .AdapterDataObserver) - */ - @Override - public void registerAdapterDataObserver(RecyclerView.AdapterDataObserver observer) { - super.registerAdapterDataObserver(observer); - //observer.onChanged(); - } - - /** - * Unregister an observer currently listening for data changes. - * <p/> - * <p>The unregistered observer will no longer receive events about changes - * to the adapter.</p> - * - * @param observer Observer to unregister - * @see #registerAdapterDataObserver(android.support.v7.widget.RecyclerView.AdapterDataObserver) - */ - @Override - public void unregisterAdapterDataObserver(RecyclerView.AdapterDataObserver observer) { - super.unregisterAdapterDataObserver(observer); - } - - @Override - public void onBindViewHolder(FViewHolder fViewHolder, int i) { - //get data 0,1,3 from set; - final ArrayList<Object> data = dataSet.get(i); - - //String[] mdata = dataSet.get(i); - fViewHolder.author.setText((CharSequence) data.get(6)); - fViewHolder.title.setText((CharSequence) data.get(2)); - fViewHolder.dateMarked.setText((CharSequence) data.get(4)); - fViewHolder.btn_delete.setOnClickListener(new FloatingActionButton.OnClickListener() { - @Override - public void onClick(View view) { - try { - Toast.makeText(context, String.format("%s", "Removed "), Toast.LENGTH_SHORT) - .show(); - //removeMarkedWorkflow(String.valueOf(data.get(0))); - favDB.delete(String.valueOf(data.get(0))); - notifyDataSetChanged(); - } catch (JSONException e) { - Log.e(TAG, "onClick: ", e); - } catch (Exception ex) { - Log.e(TAG, "onClick: ", ex); - } - - } - }); - fViewHolder.btn_view_fav.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - Dialog d = new Dialog(context); - TextView textView = new TextView(context); - String text = "Author -> " + (String) data.get(6) + "\nTitle: " + data.get(2) + - "\nDescription\n" + data.get(3); - textView.setText(text); - textView.setTextSize(22); - textView.setTextColor(Color.BLACK); - d.setTitle("" + data.get(2)); - d.setContentView(textView); - d.show(); - } - }); - } - - //remove a workflow from the marked state - private void removeMarkedWorkflow(String strToRemove) { - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences - (context); - char[] charsequence = sharedPreferences.getString(WorkflowAdapter.FAVORITE_LIST_DB, "") - .toCharArray(); - for (int i = 0; i < charsequence.length; i++) { - if (charsequence[i] == strToRemove.charAt(0)) { - charsequence[i] = '0'; - break; - } - } - sharedPreferences.edit().putString(WorkflowAdapter.FAVORITE_LIST_DB, Arrays.toString - (charsequence) - ).apply(); - } - - @Override - public int getItemCount() { - return dataSet.size(); - } - - public ArrayList<Object> getDataItemAt(int position) { - return dataSet.size() == 0 ? null : dataSet.get(position); - } - - public class FViewHolder extends RecyclerView.ViewHolder { - - public final ImageView favorite_thumb; - public final TextView author, title, dateMarked; // dateAdd; - public final FloatingActionButton btn_delete; - public final Button btn_view_fav; - - public FViewHolder(View itemView) { - super(itemView); - favorite_thumb = (ImageView) itemView.findViewById(R.id.author_profile_image); - author = (TextView) itemView.findViewById(R.id.author); - title = (TextView) itemView.findViewById(R.id.favorite_title); - dateMarked = (TextView) itemView.findViewById(R.id.date_set); - btn_delete = (FloatingActionButton) itemView.findViewById(R.id.favoriteButtonDelete); - btn_view_fav = (Button) itemView.findViewById(R.id.buttonOpenFavorite); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/b93d871c/app/src/main/java/org/apache/taverna/mobile/adapters/RunAdapter.java ---------------------------------------------------------------------- diff --git a/app/src/main/java/org/apache/taverna/mobile/adapters/RunAdapter.java b/app/src/main/java/org/apache/taverna/mobile/adapters/RunAdapter.java deleted file mode 100644 index b6a0e23..0000000 --- a/app/src/main/java/org/apache/taverna/mobile/adapters/RunAdapter.java +++ /dev/null @@ -1,158 +0,0 @@ -package org.apache.taverna.mobile.adapters; -/** - * Apache Taverna Mobile - * Copyright 2015 The Apache Software Foundation - * - * This product includes software developed at - * The Apache Software Foundation (http://www.apache.org/). - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.taverna.mobile.R; -import org.apache.taverna.mobile.tavernamobile.Runs; - -import android.content.Context; -import android.support.v7.widget.RecyclerView; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageButton; -import android.widget.TextView; - -import java.util.List; - - -/** - * Created by root on 6/14/15. - */ -public class RunAdapter extends RecyclerView.Adapter<RunAdapter.RunHolder> { - private Context context; - private List<Runs> runList; - - public RunAdapter(Context context, List<Runs> runs) { - this.context = context; - this.runList = runs; - } - - /** - * Called when RecyclerView needs a new - * {@link android.support.v7.widget.RecyclerView.ViewHolder} - * of the given type to represent - * an item. - * <p/> - * This new ViewHolder should be constructed with a new View that can represent the items - * of the given type. You can either create a new View manually or inflate it from an XML - * layout file. - * <p/> - * The new ViewHolder will be used to display items of the adapter using - * . Since it will be re-used to display different - * items in the data set, it is a good idea to cache references to sub views of the View to - * avoid unnecessary {@link android.view.View#findViewById(int)} calls. - * - * @param parent The ViewGroup into which the new View will be added after it is bound to - * an adapter position. - * @param viewType The view type of the new View. - * @return A new ViewHolder that holds a View of the given view type. - * @see #getItemViewType(int) - */ - @Override - public RunHolder onCreateViewHolder(ViewGroup parent, int viewType) { - View v = LayoutInflater.from(context).inflate(R.layout.workflow_run_item, parent, false); - return new RunHolder(v); - } - - /** - * Called by RecyclerView to display the data at the specified position. This method - * should update the contents of the - * {@link android.support.v7.widget.RecyclerView.ViewHolder#itemView} - * to reflect the item at - * the given position. - * <p/> - * Note that unlike {@link android.widget.ListView}, RecyclerView will not call this - * method again if the position of the item changes in the data set unless the item itself - * is invalidated or the new position cannot be determined. For this reason, you should only - * use the <code>position</code> parameter while acquiring the related data item inside this - * method and should not keep a copy of it. If you need the position of an item later on - * (e.g. in a click listener), use - * {@link android.support.v7.widget.RecyclerView.ViewHolder#getAdapterPosition()} - * which will have - * the updated adapter position. - * - * @param holder The ViewHolder which should be updated to represent the contents of the - * item at the given position in the data set. - * @param position The position of the item within the adapter's data set. - */ - @Override - public void onBindViewHolder(RunHolder holder, int position) { - Runs lRun = runList.get(position); - holder.runtitle.setText(lRun.getRunName()); - holder.runstarted.setText(lRun.getRunStartedDate()); - holder.runfinished.setText(lRun.getRunEndedDate()); - holder.runAuthor.setText("Author->" + lRun.getRunAuthor()); - switch (lRun.getState()) { - case RUNNING: - holder.runStatus.setImageResource(android.R.drawable.presence_busy); - holder.textState.setText("Running"); - break; - case FINISHED: - holder.runStatus.setImageResource(android.R.drawable.presence_online); - holder.textState.setText("Finished"); - break; - case FAILED: - holder.runStatus.setImageResource(android.R.drawable.presence_offline); - holder.textState.setText("Failed"); - break; - } - - } - - public List<Runs> getRunList() { - return this.runList; - } - - public void setRunList(List<Runs> runList) { - this.runList = runList; - } - - /** - * Returns the total number of items in the data set hold by the adapter. - * - * @return The total number of items in this adapter. - */ - @Override - public int getItemCount() { - //return 0; - return runList.size(); - } - - public static class RunHolder extends RecyclerView.ViewHolder { - public final TextView runtitle, runstarted, runfinished, textState, runAuthor; - public final ImageButton runStatus; - - public RunHolder(View itemView) { - super(itemView); - runtitle = (TextView) itemView.findViewById(R.id.runtitle); - runAuthor = (TextView) itemView.findViewById(R.id.run_authorTextview); - runstarted = (TextView) itemView.findViewById(R.id.runstarted); - runfinished = (TextView) itemView.findViewById(R.id.runfinished); - runStatus = (ImageButton) itemView.findViewById(R.id.imageButtonState); - textState = (TextView) itemView.findViewById(R.id.textState); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/b93d871c/app/src/main/java/org/apache/taverna/mobile/adapters/SliderMenuAdapter.java ---------------------------------------------------------------------- diff --git a/app/src/main/java/org/apache/taverna/mobile/adapters/SliderMenuAdapter.java b/app/src/main/java/org/apache/taverna/mobile/adapters/SliderMenuAdapter.java deleted file mode 100644 index 5a4bbc2..0000000 --- a/app/src/main/java/org/apache/taverna/mobile/adapters/SliderMenuAdapter.java +++ /dev/null @@ -1,114 +0,0 @@ -package org.apache.taverna.mobile.adapters; -/** - * Apache Taverna Mobile - * Copyright 2015 The Apache Software Foundation - * - * This product includes software developed at - * The Apache Software Foundation (http://www.apache.org/). - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.taverna.mobile.R; - -import android.content.Context; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.BaseAdapter; -import android.widget.ImageView; -import android.widget.TextView; - -import java.util.List; - -/** - * Created by root on 6/7/15. - */ -public class SliderMenuAdapter extends BaseAdapter { - - private List<String> dataItems; - private Context context; - - public SliderMenuAdapter(Context c, List<String> items) { - dataItems = items; - context = c; - } - - @Override - public int getCount() { - return dataItems.size(); - } - - @Override - public String getItem(int i) { - return dataItems.get(i); - } - - @Override - public long getItemId(int i) { - return 0; - } - - @Override - public View getView(int i, View view, ViewGroup viewGroup) { - - View menuitemview = LayoutInflater.from(context).inflate(R.layout.menu_item_layout, - viewGroup, false); - - ImageView menuicon = (ImageView) menuitemview.findViewById(R.id.menuIcon); - TextView menuitem = (TextView) menuitemview.findViewById(R.id.menuItemText); - switch (i + 1) { - case 1: - menuicon.setImageResource(R.mipmap.ic_dashboard_home); - menuitem.setText(dataItems.get(i)); - break; - case 2: - menuicon.setImageResource(R.mipmap.ic_openwk); - menuitem.setText(dataItems.get(i)); - break; - case 3: - menuicon.setImageResource(R.mipmap.ic_usage); - menuitem.setText(dataItems.get(i)); - break; - case 4: - menuicon.setImageResource(R.mipmap.ic_about); - menuitem.setText(dataItems.get(i)); - break; - case 5: - menuicon.setImageResource(R.mipmap.ic_workflows); - menuitem.setText(dataItems.get(i)); - break; - case 6: - menuicon.setImageResource(R.mipmap.ic_logout); - menuitem.setText(dataItems.get(i)); - break; - } - return menuitemview; - } - - public static class ViewHolder { - public final ImageView menuicon; - public final TextView menuitem; - - public ViewHolder(View view) { - menuicon = (ImageView) view.findViewById(R.id.menuIcon); - menuitem = (TextView) view.findViewById(R.id.menuItemText); - } - - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/b93d871c/app/src/main/java/org/apache/taverna/mobile/adapters/WorkflowAdapter.java ---------------------------------------------------------------------- diff --git a/app/src/main/java/org/apache/taverna/mobile/adapters/WorkflowAdapter.java b/app/src/main/java/org/apache/taverna/mobile/adapters/WorkflowAdapter.java deleted file mode 100644 index 03c28fe..0000000 --- a/app/src/main/java/org/apache/taverna/mobile/adapters/WorkflowAdapter.java +++ /dev/null @@ -1,352 +0,0 @@ -package org.apache.taverna.mobile.adapters; -/** - * Apache Taverna Mobile - * Copyright 2015 The Apache Software Foundation - * - * This product includes software developed at - * The Apache Software Foundation (http://www.apache.org/). - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import com.thebuzzmedia.sjxp.rule.IRule; - -import org.apache.taverna.mobile.R; -import org.apache.taverna.mobile.activities.WorkflowDetailActivity; -import org.apache.taverna.mobile.fragments.workflowdetails.WorkflowdetailFragment; -import org.apache.taverna.mobile.tavernamobile.User; -import org.apache.taverna.mobile.tavernamobile.Workflow; -import org.apache.taverna.mobile.utils.WorkflowDB; -import org.apache.taverna.mobile.utils.xmlparsers.MyExperimentXmlParserRules; -import org.apache.taverna.mobile.utils.xmlparsers.WorkflowDetailParser; - -import android.app.Activity; -import android.content.Context; -import android.content.Intent; -import android.os.AsyncTask; -import android.preference.PreferenceManager; -import android.support.v7.widget.RecyclerView; -import android.text.Html; -import android.text.util.Linkify; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.Button; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.TextView; -import android.widget.Toast; - -import java.io.IOException; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -/** - * Created by Larry Akah on 6/8/15. - */ -public class WorkflowAdapter extends RecyclerView.Adapter<WorkflowAdapter.ViewHolder> { - public static final String WORKFLOW_FAVORITE_KEY = "WORKFLOW_FAVORITES"; //workflow key used - // to save workflows when marked as favorites - public static final String FAVORITE_LIST_DB = "FAVORITE_LIST"; - private static final String TAG = "WorkflowAdapter"; - public WorkflowDB favDB; //favorited keeps items that have been favorited in order to - // identify them during - private Context context; - private List<Workflow> workflowList; //workflow data to bind to the UI - private WorkflowAdapter.ViewHolder mViewHolder; - - // display in the list. - public WorkflowAdapter(Context c, List<Workflow> wk) { - context = c; - workflowList = wk; - favDB = new WorkflowDB(context, WORKFLOW_FAVORITE_KEY); - } - - public WorkflowAdapter(Context c) { - context = c; - workflowList = new ArrayList<Workflow>(); - favDB = new WorkflowDB(context, WORKFLOW_FAVORITE_KEY); - } - - public void addItems(List<Workflow> workflow, int position) throws ClassCastException { - //add items to the current list of list - //workflowList.add(position,workflow); - workflowList.addAll(workflow); - notifyItemRangeInserted(position + 24, 25); - } - - public void removeItem(Workflow workflow) { - workflowList.remove(workflow); - //notifyItemRemoved(); - } - - /** - * Register a new observer to listen for data changes. - * <p/> - * <p>The adapter may publish a variety of events describing specific changes. - * Not all adapters may support all change types and some may fall back to a generic - * {@link android.support.v7.widget.RecyclerView.AdapterDataObserver#onChanged() - * "something changed"} event if more specific data is not available.</p> - * <p/> - * <p>Components registering observers with an adapter are responsible for - * {@link #registerAdapterDataObserver(android.support.v7.widget.RecyclerView - * .AdapterDataObserver) - * unregistering} those observers when finished.</p> - * - * @param observer Observer to register - * @see #registerAdapterDataObserver(android.support.v7.widget.RecyclerView - * .AdapterDataObserver) - */ - @Override - public void registerAdapterDataObserver(RecyclerView.AdapterDataObserver observer) { - super.registerAdapterDataObserver(observer); - } - - /** - * Unregister an observer currently listening for data changes. - * <p/> - * <p>The unregistered observer will no longer receive events about changes - * to the adapter.</p> - * - * @param observer Observer to unregister - * @see #registerAdapterDataObserver(android.support.v7.widget.RecyclerView.AdapterDataObserver) - */ - @Override - public void unregisterAdapterDataObserver(RecyclerView.AdapterDataObserver observer) { - super.unregisterAdapterDataObserver(observer); - } - - @Override - public WorkflowAdapter.ViewHolder onCreateViewHolder(ViewGroup parentViewGroup, int viewType) { - View v = LayoutInflater.from(context).inflate(R.layout.workflow_item_layout, - parentViewGroup, false); - mViewHolder = new ViewHolder(v); - return mViewHolder; - } - - /** - * Bind data set items for each data - * - * @param viewHolder the recycled view used to bind data (Overwrite data values) - * @param i position of data in the dataset to use. - */ - @Override - public void onBindViewHolder(final ViewHolder viewHolder, int i) { - - final long wid = workflowList.get(i).getId(); - final String author = workflowList.get(i).getWorkflowAuthor(); -// final String author = workflowList.get(i).getUploader().getName(); - final String title = workflowList.get(i).getWorkflowTitle(); - String description = workflowList.get(i).getWorkflowDescription(); - final String uri = workflowList.get(i).getWorkflowDetailsUrl(); - final String desc_full = description; - - if (description.length() > 80) description = description.substring(0, 79) + " ..."; - viewHolder.author_name.setHint(author); - viewHolder.wk_title.setHint(title); - viewHolder.wk_description.setText(description); - Linkify.addLinks(viewHolder.wk_description, Linkify.WEB_URLS); - - final Intent it = new Intent(); - Log.d(TAG, "Workflow_uri:" + uri); - it.setClass(context, WorkflowDetailActivity.class); -// it.putExtra("workflowid", workflow.get(i).getId()); //workflow_url - it.putExtra("uri", uri); //uri - it.putExtra("wtitle", title); //pass this workflow's title to the detail activity so the - // corresponding run can be fetched - it.putExtra("wid", wid); - WorkflowdetailFragment.mWorkfloId = title; //workflow.get(i).getId(); - - //determine whether to mark button as favorited or not - final String favs = PreferenceManager.getDefaultSharedPreferences(context).getString - (FAVORITE_LIST_DB, ""); - String[] ids = favs.split(","); - if (ids.length > 0) { - for (String id : ids) { - if (id.equalsIgnoreCase("" + wid)) { - viewHolder.btn_mark_workflow.setBackgroundResource(R.drawable - .abc_list_selector_disabled_holo_light); - break; - } - } - } - - viewHolder.btn_view_workflow.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - context.startActivity(it); - ((Activity) context).overridePendingTransition(android.R.anim.slide_in_left, - android.R.anim.fade_out); - } - }); - - viewHolder.btn_mark_workflow.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - ArrayList<Object> mfav = new ArrayList<Object>(); - //save current workflow as favorite - mfav.add(wid); - mfav.add(author); - mfav.add(title); - mfav.add(desc_full); - mfav.add(SimpleDateFormat.getDateTimeInstance().format(new Date())); - mfav.add(uri); - mfav.add(viewHolder.author_name.getText()); - int saved = favDB.insert(mfav); - - if (saved > 0) { - viewHolder.btn_mark_workflow.setBackgroundResource(R.drawable - .abc_list_selector_disabled_holo_light); - - PreferenceManager.getDefaultSharedPreferences(context).edit().putString - (FAVORITE_LIST_DB, favs + wid + ",").apply(); - //refresh fragment since data has changed - FavoriteWorkflowAdapter favoriteWorkflowAdapter = (FavoriteWorkflowAdapter) ( - (RecyclerView) ((Activity) context).findViewById(R.id.favoriteList)) - .getAdapter(); - //try { - if (null != favoriteWorkflowAdapter) - favoriteWorkflowAdapter.notifyDataSetChanged(); - //}catch(NullPointerException np){ - // np.printStackTrace(); - // } - Toast.makeText(context, "Workflow marked as favorite", Toast.LENGTH_SHORT) - .show(); - } else if (saved == -1) { - Toast.makeText(context, "Sorry! This workflow has already been marked as a " + - "favourite", Toast.LENGTH_SHORT).show(); - } else { - Toast.makeText(context, "Error! Please try again", Toast.LENGTH_SHORT).show(); - } - } - }); - viewHolder.wk_showmore.setText(Html.fromHtml(context.getResources().getString(R.string - .seemore))); - viewHolder.wk_showmore.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if (viewHolder.infolayout.getVisibility() == View.GONE) { - viewHolder.infolayout.setVisibility(View.VISIBLE); - } else { - viewHolder.infolayout.setVisibility(View.GONE); - } - } - }); - - synchronized (this) { - new DetailLinkLoader(viewHolder).execute(uri, String.valueOf(i)); - } - } - - public void setData(List<Workflow> workflowList) { - this.workflowList = workflowList; - } - - @Override - public long getItemId(int i) { - return workflowList.get(i).getId(); - } - - @Override - public int getItemCount() { - return workflowList.size(); - } - - public Workflow getItem(int position) { - return workflowList.get(position); - } - - public void addWorkflow(Workflow wk) { - workflowList.add(wk); - } - - public static class ViewHolder extends RecyclerView.ViewHolder { - public final ImageView author_profile; - public final TextView author_name, wk_title, wk_showmore, wk_description; - public final Button btn_view_workflow; - public final Button btn_download_workflow; - public final Button btn_mark_workflow; - public final LinearLayout infolayout; - - public ViewHolder(View v) { - super(v); - infolayout = (LinearLayout) v.findViewById(R.id.layoutinfo); - //cache text fields - author_profile = (ImageView) v.findViewById(R.id.author_profile_image); - author_name = (TextView) v.findViewById(R.id.workflow_author); - wk_title = (TextView) v.findViewById(R.id.workflow_title); - wk_showmore = (TextView) v.findViewById(R.id.show_more); - // wk_created = (TextView) v.findViewById(R.id.workflow_datecreated); - // wk_modified = (TextView) v.findViewById(R.id.workflow_dateupdated); - wk_description = (TextView) v.findViewById(R.id.workflow_brief_description); - //cache buttons - btn_download_workflow = (Button) v.findViewById(R.id.button_download_workflow); - btn_mark_workflow = (Button) v.findViewById(R.id.button_mark_workflow); - btn_view_workflow = (Button) v.findViewById(R.id.button_view_workflow); - } - } - - /** - * Loads partially details of a given workflow to retrieve author information - */ - private class DetailLinkLoader extends AsyncTask<String, Void, Void> { - ViewHolder mViewHolder; - - public DetailLinkLoader(ViewHolder vh) { - this.mViewHolder = vh; - } - - @Override - protected Void doInBackground(String... strings) { - URL url = null; - HttpURLConnection connection = null; - try { - url = new URL(strings[0]); //fetch workflow detail - connection = (HttpURLConnection) url.openConnection(); - connection.setDoInput(true); - connection.connect(); - InputStream input = connection.getInputStream(); - IRule avatarRule = new MyExperimentXmlParserRules.UploaderRule(IRule.Type - .ATTRIBUTE, "/workflow/uploader", "resource", "uri", "id"); - IRule uploaderRule = new MyExperimentXmlParserRules.UploaderRule(IRule.Type - .CHARACTER, "/workflow/uploader"); - WorkflowDetailParser detailMinParser = new WorkflowDetailParser(new - IRule[]{avatarRule, uploaderRule}); - detailMinParser.parse(input, new User(strings[1], this.mViewHolder)); - - } catch (MalformedURLException e) { - Log.e(TAG, "doInBackground: ", e); - } catch (IOException e) { - Log.e(TAG, "doInBackground: ", e); - } - return null; - } - - @Override - protected void onPostExecute(Void aVoid) { - - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/b93d871c/app/src/main/java/org/apache/taverna/mobile/broadcastreceivers/WorkflowDownloadReceiver.java ---------------------------------------------------------------------- diff --git a/app/src/main/java/org/apache/taverna/mobile/broadcastreceivers/WorkflowDownloadReceiver.java b/app/src/main/java/org/apache/taverna/mobile/broadcastreceivers/WorkflowDownloadReceiver.java deleted file mode 100644 index 383f707..0000000 --- a/app/src/main/java/org/apache/taverna/mobile/broadcastreceivers/WorkflowDownloadReceiver.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.apache.taverna.mobile.broadcastreceivers; -/** - * Apache Taverna Mobile - * Copyright 2015 The Apache Software Foundation - * - * This product includes software developed at - * The Apache Software Foundation (http://www.apache.org/). - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.taverna.mobile.R; -import org.apache.taverna.mobile.utils.WorkflowDownloadManager; - -import android.app.DownloadManager; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.database.Cursor; - -public class WorkflowDownloadReceiver extends BroadcastReceiver { - public WorkflowDownloadReceiver() { - } - - @Override - public void onReceive(Context context, Intent intent) { - - long receivedID = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1L); - DownloadManager mgr = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE); - WorkflowDownloadManager wdm = new WorkflowDownloadManager(context, mgr); - - DownloadManager.Query query = new DownloadManager.Query(); //ask for information about - // the download queue - query.setFilterById(receivedID); - Cursor cur = mgr.query(query); - int index = cur.getColumnIndex(DownloadManager.COLUMN_STATUS); -// String workflow = cur.getString(cur.getColumnIndex(DownloadManager -// .COLUMN_LOCAL_FILENAME)); - - if (cur.moveToFirst()) { - if (cur.getInt(index) == DownloadManager.STATUS_SUCCESSFUL) { - wdm.sendNotification(context.getResources().getString(R.string.downloadcomplete)); - } else { - wdm.sendNotification(context.getResources().getString(R.string.downloadfailed)); - } - } else { - wdm.sendNotification(context.getResources().getString(R.string.downloadfailed)); - } - cur.close(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/b93d871c/app/src/main/java/org/apache/taverna/mobile/customviews/WorkflowPreviewImageView.java ---------------------------------------------------------------------- diff --git a/app/src/main/java/org/apache/taverna/mobile/customviews/WorkflowPreviewImageView.java b/app/src/main/java/org/apache/taverna/mobile/customviews/WorkflowPreviewImageView.java deleted file mode 100644 index 32a9389..0000000 --- a/app/src/main/java/org/apache/taverna/mobile/customviews/WorkflowPreviewImageView.java +++ /dev/null @@ -1,277 +0,0 @@ -package org.apache.taverna.mobile.customviews; -/** - * Apache Taverna Mobile - * Copyright 2015 The Apache Software Foundation - * - * This product includes software developed at - * The Apache Software Foundation (http://www.apache.org/). - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.Matrix; -import android.graphics.PointF; -import android.util.AttributeSet; -import android.view.MotionEvent; -import android.view.ScaleGestureDetector; -import android.view.View; -import android.widget.ImageView; - -/** - * Created by Akah Harvey on 6/29/15. - */ -public class WorkflowPreviewImageView extends ImageView { - static final int NONE = 0; - static final int DRAG = 1; - static final int ZOOM = 2; - static final int CLICK = 3; - Matrix matrix = new Matrix(); - int mode = NONE; - - PointF last = new PointF(); - PointF start = new PointF(); - float minScale = 1f; - float maxScale = 4f; - float[] m; - - float redundantXSpace, redundantYSpace; - float width, height; - float saveScale = 1f; - float right, bottom, origWidth, origHeight, bmWidth, bmHeight; - - ScaleGestureDetector mScaleDetector; - Context context; - - public WorkflowPreviewImageView(Context context, AttributeSet attr) { - super(context, attr); - super.setClickable(true); - this.context = context; - mScaleDetector = new ScaleGestureDetector(context, new ScaleListener()); - matrix.setTranslate(1f, 1f); - m = new float[9]; - setImageMatrix(matrix); - setScaleType(ScaleType.MATRIX); - - setOnTouchListener(new OnTouchListener() { - - @Override - public boolean onTouch(View v, MotionEvent event) { - mScaleDetector.onTouchEvent(event); - - matrix.getValues(m); - float x = m[Matrix.MTRANS_X]; - float y = m[Matrix.MTRANS_Y]; - PointF curr = new PointF(event.getX(), event.getY()); - - switch (event.getAction()) { - //when one finger is touching - //set the mode to DRAG - case MotionEvent.ACTION_DOWN: - last.set(event.getX(), event.getY()); - start.set(last); - mode = DRAG; - break; - //when two fingers are touching - //set the mode to ZOOM - case MotionEvent.ACTION_POINTER_DOWN: - last.set(event.getX(), event.getY()); - start.set(last); - mode = ZOOM; - break; - //when a finger moves - //If mode is applicable move image - case MotionEvent.ACTION_MOVE: - //if the mode is ZOOM or - //if the mode is DRAG and already zoomed - if (mode == ZOOM || (mode == DRAG && saveScale > minScale)) { - float deltaX = curr.x - last.x; // x difference - float deltaY = curr.y - last.y; // y difference - float scaleWidth = Math.round(origWidth * saveScale); // width after - // applying current scale - float scaleHeight = Math.round(origHeight * saveScale); // height - // after applying current scale - //if scaleWidth is smaller than the views width - //in other words if the image width fits in the view - //limit left and right movement - if (scaleWidth < width) { - deltaX = 0; - if (y + deltaY > 0) { - deltaY = -y; - } else if (y + deltaY < -bottom) { - deltaY = -(y + bottom); - } - } else if (scaleHeight < height) { - //if scaleHeight is smaller than the views height - //in other words if the image height fits in the view - //limit up and down movement - deltaY = 0; - if (x + deltaX > 0) { - deltaX = -x; - } else if (x + deltaX < -right) { - deltaX = -(x + right); - } - } else { - //if the image doesnt fit in the width or height - //limit both up and down and left and right - if (x + deltaX > 0) { - deltaX = -x; - } else if (x + deltaX < -right) { - deltaX = -(x + right); - } - if (y + deltaY > 0) { - deltaY = -y; - } else if (y + deltaY < -bottom) { - deltaY = -(y + bottom); - } - } - //move the image with the matrix - matrix.postTranslate(deltaX, deltaY); - //set the last touch location to the current - last.set(curr.x, curr.y); - } - break; - //first finger is lifted - case MotionEvent.ACTION_UP: - mode = NONE; - int xDiff = (int) Math.abs(curr.x - start.x); - int yDiff = (int) Math.abs(curr.y - start.y); - if (xDiff < CLICK && yDiff < CLICK) - performClick(); - break; - // second finger is lifted - case MotionEvent.ACTION_POINTER_UP: - mode = NONE; - break; - } - setImageMatrix(matrix); - invalidate(); - return true; - } - - }); - } - - @Override - public void setImageBitmap(Bitmap bm) { - super.setImageBitmap(bm); - bmWidth = bm.getWidth(); - bmHeight = bm.getHeight(); - } - - public void setMaxZoom(float x) { - maxScale = x; - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - width = MeasureSpec.getSize(widthMeasureSpec); - height = MeasureSpec.getSize(heightMeasureSpec); - //Fit to screen. - float scale; - float scaleX = width / bmWidth; - float scaleY = height / bmHeight; - scale = Math.min(scaleX, scaleY); - matrix.setScale(scale, scale); - setImageMatrix(matrix); - saveScale = 1f; - - // Center the image - redundantYSpace = height - (scale * bmHeight); - redundantXSpace = width - (scale * bmWidth); - redundantYSpace /= 2; - redundantXSpace /= 2; - - matrix.postTranslate(redundantXSpace, redundantYSpace); - - origWidth = width - 2 * redundantXSpace; - origHeight = height - 2 * redundantYSpace; - right = width * saveScale - width - (2 * redundantXSpace * saveScale); - bottom = height * saveScale - height - (2 * redundantYSpace * saveScale); - setImageMatrix(matrix); - } - - private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener { - - @Override - public boolean onScaleBegin(ScaleGestureDetector detector) { - mode = ZOOM; - return true; - } - - @Override - public boolean onScale(ScaleGestureDetector detector) { - float mScaleFactor = detector.getScaleFactor(); - float origScale = saveScale; - saveScale *= mScaleFactor; - if (saveScale > maxScale) { - saveScale = maxScale; - mScaleFactor = maxScale / origScale; - } else if (saveScale < minScale) { - saveScale = minScale; - mScaleFactor = minScale / origScale; - } - right = width * saveScale - width - (2 * redundantXSpace * saveScale); - bottom = height * saveScale - height - (2 * redundantYSpace * saveScale); - if (origWidth * saveScale <= width || origHeight * saveScale <= height) { - matrix.postScale(mScaleFactor, mScaleFactor, width / 2, height / 2); - if (mScaleFactor < 1) { - matrix.getValues(m); - float x = m[Matrix.MTRANS_X]; - float y = m[Matrix.MTRANS_Y]; - if (mScaleFactor < 1) { - if (Math.round(origWidth * saveScale) < width) { - if (y < -bottom) { - matrix.postTranslate(0, -(y + bottom)); - } else if (y > 0) { - matrix.postTranslate(0, -y); - } - } else { - if (x < -right) { - matrix.postTranslate(-(x + right), 0); - } else if (x > 0) { - matrix.postTranslate(-x, 0); - } - } - } - } - } else { - matrix.postScale(mScaleFactor, mScaleFactor, detector.getFocusX(), detector - .getFocusY()); - matrix.getValues(m); - float x = m[Matrix.MTRANS_X]; - float y = m[Matrix.MTRANS_Y]; - if (mScaleFactor < 1) { - if (x < -right) { - matrix.postTranslate(-(x + right), 0); - } else if (x > 0) { - matrix.postTranslate(-x, 0); - } - if (y < -bottom) { - matrix.postTranslate(0, -(y + bottom)); - } else if (y > 0) { - matrix.postTranslate(0, -y); - } - } - } - return true; - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/b93d871c/app/src/main/java/org/apache/taverna/mobile/fragments/FavoriteFragment.java ---------------------------------------------------------------------- diff --git a/app/src/main/java/org/apache/taverna/mobile/fragments/FavoriteFragment.java b/app/src/main/java/org/apache/taverna/mobile/fragments/FavoriteFragment.java deleted file mode 100644 index 3cca379..0000000 --- a/app/src/main/java/org/apache/taverna/mobile/fragments/FavoriteFragment.java +++ /dev/null @@ -1,228 +0,0 @@ -package org.apache.taverna.mobile.fragments; - -/* -* Apache Taverna Mobile -* Copyright 2015 The Apache Software Foundation - -* This product includes software developed at -* The Apache Software Foundation (http://www.apache.org/). - -* Licensed to the Apache Software Foundation (ASF) under one -* or more contributor license agreements. See the NOTICE file -* distributed with this work for additional information -* regarding copyright ownership. The ASF licenses this file -* to you under the Apache License, Version 2.0 (the -* "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ - -import org.apache.taverna.mobile.R; -import org.apache.taverna.mobile.adapters.FavoriteWorkflowAdapter; -import org.apache.taverna.mobile.adapters.WorkflowAdapter; -import org.apache.taverna.mobile.utils.WorkflowDB; -import org.json.JSONException; - -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; -import android.util.Log; -import android.view.ContextMenu; -import android.view.LayoutInflater; -import android.view.MenuItem; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; -import android.widget.Toast; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * Created by Larry Akah on 6/6/15. - */ -public class FavoriteFragment extends Fragment implements RecyclerView.OnCreateContextMenuListener { - /** - * The fragment argument representing the section number for this - * fragment. - */ - private static final String TAG = "FavoriteFragment"; - private static final String ARG_SECTION_NUMBER = "SECTION_NUMBER"; - public FavoriteWorkflowAdapter favoriteAdapter; - public WorkflowDB myWorkflowDb; - private RecyclerView wFavoriteListView; - private RecyclerView.AdapterDataObserver dataObserver; - - public FavoriteFragment() { - } - - /** - * Returns a new instance of this fragment for the given section - * number. - */ - public static FavoriteFragment newInstance(int sectionNumber) { - FavoriteFragment fragment = new FavoriteFragment(); - Bundle args = new Bundle(); - args.putInt(ARG_SECTION_NUMBER, sectionNumber); - fragment.setArguments(args); - - return fragment; - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - dataObserver = new RecyclerView.AdapterDataObserver() { - @Override - public void onChanged() { - super.onChanged(); - // Toast.makeText(getActivity(), "data changed", Toast.LENGTH_SHORT).show(); - setUpFavoriteData(); - setUpListView(); - } - }; - setUpFavoriteData(); - - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_dashboard_main, container, false); - wFavoriteListView = (RecyclerView) rootView.findViewById(R.id.favoriteList); - wFavoriteListView.setHasFixedSize(true); - wFavoriteListView.setLayoutManager(new LinearLayoutManager(getActivity())); - wFavoriteListView.setAdapter(favoriteAdapter); - return rootView; - } - - /** - * Prepare the data to be used in the list as favorite items - */ - private void setUpFavoriteData() { - myWorkflowDb = new WorkflowDB(getActivity(), WorkflowAdapter.WORKFLOW_FAVORITE_KEY); - try { - List<ArrayList<Object>> mfavorites = myWorkflowDb.get(); - favoriteAdapter = new FavoriteWorkflowAdapter(getActivity(), mfavorites); - favoriteAdapter.registerAdapterDataObserver(dataObserver); - } catch (JSONException e) { - Log.e(TAG, "setUpFavoriteData: ", e); - favoriteAdapter = new FavoriteWorkflowAdapter(getActivity(), Collections - .<ArrayList<Object>>emptyList()); - favoriteAdapter.registerAdapterDataObserver(dataObserver); - } - } - - /** - * Populate the listview using the adapter - */ - private void setUpListView() { - wFavoriteListView.setAdapter(favoriteAdapter); - } - - /** - * Called when a context menu for the {@code view} is about to be shown. - * Unlike {@link #onCreateOptionsMenu}, this will be called every - * time the context menu is about to be shown and should be populated for - * the view (or item inside the view for {@link android.widget.AdapterView} subclasses, - * this can be found in the {@code menuInfo})). - * <p/> - * Use {@link #onContextItemSelected(android.view.MenuItem)} to know when an - * item has been selected. - * <p/> - * The default implementation calls up to - * {@link android.app.Activity#onCreateContextMenu Activity.onCreateContextMenu}, though - * you can not call this implementation if you don't want that behavior. - * <p/> - * It is not safe to hold onto the context menu after this method returns. - * {@inheritDoc} - */ - @Override - public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo - menuInfo) { - // super.onCreateContextMenu(menu, v, menuInfo); - menu.add("View"); - menu.add("Remove"); - menu.setHeaderIcon(R.mipmap.ic_launcher); - menu.setHeaderTitle("Favorite"); - - } - - /** - * This hook is called whenever an item in a context menu is selected. The - * default implementation simply returns false to have the normal processing - * happen (calling the item's Runnable or sending a message to its Handler - * as appropriate). You can use this method for any items for which you - * would like to do processing without those other facilities. - * <p/> - * Use {@link android.view.MenuItem#getMenuInfo()} to get extra information set by the - * View that added this menu item. - * <p/> - * Derived classes should call through to the base class for it to perform - * the default menu handling. - * - * @param item The context menu item that was selected. - * @return boolean Return false to allow normal context menu processing to - * proceed, true to consume it here. - */ - @Override - public boolean onContextItemSelected(MenuItem item) { - String title = (String) item.getTitle(); - if (title.equals("View")) { - Toast.makeText(getActivity(), "View", Toast.LENGTH_SHORT).show(); - return true; - } else if (title.equals("Remove")) { - Toast.makeText(getActivity(), "Removing", Toast.LENGTH_SHORT).show(); - return true; - } else { - return super.onContextItemSelected(item); - } - } - - /** - * Called when the fragment is visible to the user and actively running. - * This is generally - * tied to {@link android.app.Activity#onResume() Activity.onResume} of the containing - * Activity's lifecycle. - */ - @Override - public void onResume() { - super.onResume(); - // setUpListView(); - //wFavoriteListView.setOnCreateContextMenuListener(this); - //registerForContextMenu(wFavoriteListView); - - } - - /** - * Called when the fragment is no longer in use. This is called - * after {@link #onStop()} and before {@link #onDetach()}. - */ - @Override - public void onDestroy() { - super.onDestroy(); - favoriteAdapter.unregisterAdapterDataObserver(dataObserver); - unregisterForContextMenu(wFavoriteListView); - } - - /** - * Causes the empty textView to be set and become visible - */ - private void setEmptyText() { - View emptyView = wFavoriteListView.getChildAt(1); - if (emptyView instanceof TextView) { - emptyView.setVisibility(View.VISIBLE); - } - } - -}
