//TODO: Add functionality for edit button
@Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        ParseUser currentUser = ParseUser.getCurrentUser();
        String role = currentUser.getString("role");
        if(convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.product_list_item, null);
            holder = new ViewHolder();
            holder.companyNameLabel = (TextView) convertView.findViewById(R.id.companyName);
            holder.productNameLabel = (TextView) convertView.findViewById(R.id.productNameLabel);
            holder.priceNameLabel = (TextView) convertView.findViewById(R.id.productPriceLabel);
            holder.addItemButton = (Button) convertView.findViewById(R.id.btnAddToCart);
            holder.editItemButton = (Button) convertView.findViewById(R.id.btnEditButton);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        if (role.equals("Company Account")) {
            holder.editItemButton.setVisibility(View.VISIBLE);
        }
        else if (role.equals("Personal Account")) {
            holder.addItemButton.setVisibility(View.VISIBLE);
        }
        final Product product = mProducts.get(position);
        holder.companyNameLabel.setText(product.getCompany());
        holder.productNameLabel.setText(product.getProductName());
        holder.priceNameLabel.setText(product.getPrice() + "");
        holder.addItemButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(mContext, CheckoutActivity.class);
                intent.putExtra("product", product.getProductName());
                mContext.startActivity(intent);
                //TODO: Add functionality for edit button
            }
        });
        return convertView;
    }
intent.putExtra("product", product.getProductName());
mContext.startActivity(intent);
//TODO: Add functionality for edit button
}
});
final Product product = mProducts.get(position);
holder.companyNameLabel.setText(product.getCompany());
holder.productNameLabel.setText(product.getProductName());
holder.priceNameLabel.setText(product.getPrice() + "");
holder.addItemButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, CheckoutActivity.class);
intent.putExtra("product", product.getProductName());
mContext.startActivity(intent);
//TODO: Add functionality for edit button
}
});
return convertView;
}
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
if (role.equals("Company Account")) {
holder.editItemButton.setVisibility(View.VISIBLE);
}
else if (role.equals("Personal Account")) {
holder.addItemButton.setVisibility(View.VISIBLE);
}
final Product product = mProducts.get(position);
holder.companyNameLabel.setText(product.getCompany());
holder.productNameLabel.setText(product.getProductName());
holder.priceNameLabel.setText(product.getPrice() + "");
holder.addItemButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, CheckoutActivity.class);
intent.putExtra("product", product.getProductName());
mContext.startActivity(intent);
//TODO: Add functionality for edit button
}
});
return convertView;
}