taverna-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From therajanmaurya <...@git.apache.org>
Subject [GitHub] incubator-taverna-mobile pull request #22: Redesigning Favourite Workflow Li...
Date Mon, 11 Jul 2016 07:26:21 GMT
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.
---

Mime
View raw message