You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@taverna.apache.org by sagar15795 <gi...@git.apache.org> on 2016/07/09 05:26:37 UTC

[GitHub] incubator-taverna-mobile pull request #22: [WIP]Redesigning Favorite Workflo...

GitHub user sagar15795 opened a pull request:

    https://github.com/apache/incubator-taverna-mobile/pull/22

    [WIP]Redesigning Favorite Workflow List 

    TODO List 
    - [x] Reposition of Favourite Workflows to navigation drawer menu option.
    - [ ] Design xml layout.
    - [ ] Design Data layer to interact DataBase
    - [ ] Design Presenter layer to interact UI
    - [ ] Design UI layer.
    - [ ] Show NO Favourite workflow error screen

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/sagar15795/incubator-taverna-mobile favourite

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-taverna-mobile/pull/22.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #22
    
----
commit 77b4704e5ab8a9ec0dc0c7e6441c378e0bc10fb9
Author: Sagar <ku...@gmail.com>
Date:   2016-07-08T17:05:37Z

    reposition favourite workflows  to navigation drawer menu

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-taverna-mobile pull request #22: Redesigning Favourite Workflow Li...

Posted by therajanmaurya <gi...@git.apache.org>.
Github user therajanmaurya commented on a diff in the pull request:

    https://github.com/apache/incubator-taverna-mobile/pull/22#discussion_r70211188
  
    --- Diff: app/src/main/java/org/apache/taverna/mobile/data/local/DBHelper.java ---
    @@ -184,6 +186,24 @@ public boolean updateFavouriteWorkflow(String id) {
             return false;
         }
     
    +    public Observable<List<Workflow>> getFavouriteWorkflow() {
    +        return Observable.create(new Observable.OnSubscribe<List<Workflow>>() {
    +            @Override
    +            public void call(Subscriber<? super List<Workflow>> subscriber) {
    +                if (subscriber.isUnsubscribed()) return;
    --- End diff --
    
    Remove this subscribe checking don't need because we have single Subscription in Favorite Presenter.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-taverna-mobile pull request #22: Redesigning Favourite Workflow Li...

Posted by therajanmaurya <gi...@git.apache.org>.
Github user therajanmaurya commented on a diff in the pull request:

    https://github.com/apache/incubator-taverna-mobile/pull/22#discussion_r70211640
  
    --- Diff: app/src/main/java/org/apache/taverna/mobile/ui/adapter/FavouriteWorkflowsAdapter.java ---
    @@ -0,0 +1,117 @@
    +package org.apache.taverna.mobile.ui.adapter;
    +
    +import com.bumptech.glide.Glide;
    +import com.bumptech.glide.load.engine.DiskCacheStrategy;
    +
    +import org.apache.taverna.mobile.R;
    +import org.apache.taverna.mobile.data.model.Workflow;
    +
    +import android.content.Context;
    +import android.net.Uri;
    +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.ImageView;
    +import android.widget.TextView;
    +
    +import java.util.List;
    +
    +import butterknife.BindView;
    +import butterknife.ButterKnife;
    +
    +public class FavouriteWorkflowsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    +
    +    private static final String TAG = FavouriteWorkflowsAdapter.class.getName();
    +
    +    private final List<Workflow> mWorkflowList;
    +
    +    private final Context context;
    +
    +    public FavouriteWorkflowsAdapter(List<Workflow> mWorkflowList, Context context) {
    +        this.mWorkflowList = mWorkflowList;
    +        this.context = context;
    +
    +    }
    +
    +    public void addWorkflow(Workflow workflow) {
    +        this.mWorkflowList.add(workflow);
    +        this.notifyDataSetChanged();
    +
    +    }
    +
    +    @Override
    +    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    +        RecyclerView.ViewHolder vh;
    +
    +        View v = LayoutInflater.from(parent.getContext()).inflate(
    +                R.layout.item_recyclerview_favourite_workflow_list, parent, false);
    +        vh = new ViewHolder(v);
    +
    +        return vh;
    +    }
    +
    +    @Override
    +    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    +        if (holder instanceof ViewHolder) {
    +
    +            Workflow workflow = mWorkflowList.get(position);
    +            String date = workflow.getCreatedAt()
    +                    .substring(0, workflow.getCreatedAt().indexOf(' '));
    +
    +            String title = workflow.getTitle().substring(0,
    +                    Math.min(workflow.getTitle().length(), 50));
    +
    +            if (workflow.getTitle().length() > 50) {
    +                title = title + " ... ";
    +            }
    +
    +            ((ViewHolder) holder).tvDate.setText(date);
    +            ((ViewHolder) holder).tvTitle.setText(title);
    +            ((ViewHolder) holder).tvType.setText(workflow.getType().getContent());
    +            ((ViewHolder) holder).tvUploader.setText(workflow.getUploader().getContent());
    +
    +            Uri uri = Uri.parse(workflow.getPreviewUri());
    +
    +            Glide.with(context)
    +                    .load(uri)
    +                    .diskCacheStrategy(DiskCacheStrategy.SOURCE)
    +                    .placeholder(R.drawable.placeholder)
    +                    .error(R.drawable.placeholder)
    +                    .into(((ViewHolder) holder).ivWorkflowImage);
    +        }
    +    }
    +
    +    @Override
    +    public int getItemCount() {
    +        Log.d(TAG, "getItemCount: " + mWorkflowList.size());
    --- End diff --
    
    Comment the Log and uncomment when you debugging.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-taverna-mobile pull request #22: Redesigning Favourite Workflow Li...

Posted by therajanmaurya <gi...@git.apache.org>.
Github user therajanmaurya commented on a diff in the pull request:

    https://github.com/apache/incubator-taverna-mobile/pull/22#discussion_r70211461
  
    --- Diff: app/src/main/java/org/apache/taverna/mobile/ui/adapter/FavouriteWorkflowsAdapter.java ---
    @@ -0,0 +1,117 @@
    +package org.apache.taverna.mobile.ui.adapter;
    +
    +import com.bumptech.glide.Glide;
    +import com.bumptech.glide.load.engine.DiskCacheStrategy;
    +
    +import org.apache.taverna.mobile.R;
    +import org.apache.taverna.mobile.data.model.Workflow;
    +
    +import android.content.Context;
    +import android.net.Uri;
    +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.ImageView;
    +import android.widget.TextView;
    +
    +import java.util.List;
    +
    +import butterknife.BindView;
    +import butterknife.ButterKnife;
    +
    +public class FavouriteWorkflowsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    +
    +    private static final String TAG = FavouriteWorkflowsAdapter.class.getName();
    +
    +    private final List<Workflow> mWorkflowList;
    +
    +    private final Context context;
    +
    +    public FavouriteWorkflowsAdapter(List<Workflow> mWorkflowList, Context context) {
    +        this.mWorkflowList = mWorkflowList;
    +        this.context = context;
    +
    +    }
    +
    +    public void addWorkflow(Workflow workflow) {
    +        this.mWorkflowList.add(workflow);
    +        this.notifyDataSetChanged();
    +
    +    }
    +
    +    @Override
    +    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    +        RecyclerView.ViewHolder vh;
    +
    +        View v = LayoutInflater.from(parent.getContext()).inflate(
    +                R.layout.item_recyclerview_favourite_workflow_list, parent, false);
    +        vh = new ViewHolder(v);
    +
    +        return vh;
    +    }
    +
    +    @Override
    +    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    +        if (holder instanceof ViewHolder) {
    +
    +            Workflow workflow = mWorkflowList.get(position);
    +            String date = workflow.getCreatedAt()
    +                    .substring(0, workflow.getCreatedAt().indexOf(' '));
    +
    +            String title = workflow.getTitle().substring(0,
    --- End diff --
    
    Remove this and add android:singleLine="true" in Xml


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-taverna-mobile pull request #22: Redesigning Favourite Workflow Li...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/incubator-taverna-mobile/pull/22


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-taverna-mobile pull request #22: Redesigning Favourite Workflow Li...

Posted by sagar15795 <gi...@git.apache.org>.
Github user sagar15795 commented on a diff in the pull request:

    https://github.com/apache/incubator-taverna-mobile/pull/22#discussion_r70439444
  
    --- Diff: app/src/main/java/org/apache/taverna/mobile/data/local/DBHelper.java ---
    @@ -184,6 +186,24 @@ public boolean updateFavouriteWorkflow(String id) {
             return false;
         }
     
    +    public Observable<List<Workflow>> getFavouriteWorkflow() {
    +        return Observable.create(new Observable.OnSubscribe<List<Workflow>>() {
    +            @Override
    +            public void call(Subscriber<? super List<Workflow>> subscriber) {
    +                if (subscriber.isUnsubscribed()) return;
    --- End diff --
    
    This is necessary if we use create operator. 
    For further info please refer issue [#12 ](https://github.com/ribot/ribot-app-android/issues/12) at ribot android app


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-taverna-mobile pull request #22: Redesigning Favourite Workflow Li...

Posted by therajanmaurya <gi...@git.apache.org>.
Github user therajanmaurya commented on a diff in the pull request:

    https://github.com/apache/incubator-taverna-mobile/pull/22#discussion_r70210433
  
    --- Diff: app/src/main/java/org/apache/taverna/mobile/activities/DashboardMainActivity.java ---
    @@ -89,13 +101,11 @@ protected void onCreate(Bundle savedInstanceState) {
                 FragmentManager fragmentManager = getSupportFragmentManager();
    --- End diff --
    
    Make a class in utils for Fragment Transaction and use for fragment transaction.
    Example : https://github.com/therajanmaurya/Popular-Movies-Stage-1/blob/master/app/src/main/java/opensource/popularmoviesstage1/utils/ActivityUtils.java



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-taverna-mobile pull request #22: Redesigning Favourite Workflow Li...

Posted by therajanmaurya <gi...@git.apache.org>.
Github user therajanmaurya commented on a diff in the pull request:

    https://github.com/apache/incubator-taverna-mobile/pull/22#discussion_r70212168
  
    --- Diff: app/src/main/java/org/apache/taverna/mobile/ui/favouriteworkflow/FavouriteWorkflowsPresenter.java ---
    @@ -0,0 +1,84 @@
    +/*
    + * 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.ui.favouriteworkflow;
    +
    +import org.apache.taverna.mobile.data.DataManager;
    +import org.apache.taverna.mobile.data.model.Workflow;
    +import org.apache.taverna.mobile.ui.base.BasePresenter;
    +
    +import java.util.List;
    +
    +import rx.Observer;
    +import rx.Subscription;
    +import rx.android.schedulers.AndroidSchedulers;
    +import rx.schedulers.Schedulers;
    +
    +public class FavouriteWorkflowsPresenter extends BasePresenter<FavouriteWorkflowsMvpView> {
    +
    +    public final String LOG_TAG = getClass().getSimpleName();
    +    private DataManager mDataManager;
    +    private Subscription mSubscriptions;
    +
    +
    +    public FavouriteWorkflowsPresenter(DataManager dataManager) {
    +        mDataManager = dataManager;
    +    }
    +
    +    @Override
    +    public void attachView(FavouriteWorkflowsMvpView mvpView) {
    +        super.attachView(mvpView);
    +    }
    +
    +    @Override
    +    public void detachView() {
    +        super.detachView();
    +        if (mSubscriptions != null) mSubscriptions.unsubscribe();
    +    }
    +
    +    public void loadAllWorkflow() {
    +        if (mSubscriptions != null) mSubscriptions.unsubscribe();
    +        mSubscriptions = mDataManager.getFavoriteWorkflowList()
    +                .observeOn(AndroidSchedulers.mainThread())
    +                .subscribeOn(Schedulers.io())
    +                .subscribe(new Observer<List<Workflow>>() {
    +                    @Override
    +                    public void onCompleted() {
    +                        getMvpView().showProgressbar(false);
    +                    }
    +
    +                    @Override
    +                    public void onError(Throwable e) {
    +                        getMvpView().showProgressbar(false);
    +                        getMvpView().showErrorSnackBar();
    +                    }
    +
    +                    @Override
    +                    public void onNext(List<Workflow> workflowList) {
    +                        if (workflowList.size() != 0) {
    +                            getMvpView().showWorkflows(workflowList);
    +                        } else {
    +                            getMvpView().showNoWorkflowError();
    --- End diff --
    
    Change ShowNoWorkflowError -> to ShowEmptyWorkflow


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---