Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Latest_Product extends BaseAdapter {
- // variiables declaration
- View gridView;
- private Context context;
- Function_List lib_function = new Function_List();
- private ArrayList<HashMap<String, String>> MyArr = new ArrayList<HashMap<String, String>>();
- private DisplayImageOptions options;
- //contsructor
- public Latest_Product(Context c, ArrayList<HashMap<String, String>> json_value) {
- // TODO Auto-generated method stub
- context = c;
- MyArr = json_value;
- Log.d("latest product calling","calling");
- TextView product_name;
- TextView product_price;
- }
- public int getCount() {
- // TODO Auto-generated method stub
- Log.d("size of item", "" + MyArr.size());
- return MyArr.size();
- }
- public Object getItem(int position) {
- // TODO Auto-generated method stub
- return position;
- }
- public long getItemId(int position) {
- // TODO Auto-generated method stub
- HashMap<String, String> mapAtPostion = MyArr.get(position);
- return Long.valueOf(MyArr.get(position).get("product_id"));
- }
- public View getView(int position, View convertView, ViewGroup parent) {
- final ViewHolder holder;
- View view = convertView;
- TextView product_name;
- TextView product_price;
- LayoutInflater inflater = (LayoutInflater) context
- .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- if (view == null) {
- view = inflater.inflate(R.layout.home_best_collection, parent, false);
- holder = new ViewHolder();
- assert view != null;
- ImageView imageView = (ImageView) view.findViewById(R.id.imageView26);
- holder.imageView = (ImageView) view.findViewById(R.id.imageView26);
- holder.progressBar = (ProgressBar) view.findViewById(R.id.progress);
- product_name = (TextView) view.findViewById(R.id.textView21);
- product_price = (TextView) view.findViewById(R.id.textView23);
- String name = MyArr.get(position).get("product_name");
- int namelength = name.length();
- if(namelength >= 33)
- {
- product_name.setText(MyArr.get(position).get("product_name").substring(0,29)+"..."+MyArr.get(position).get("product_id"));
- }
- else{product_name.setText(MyArr.get(position).get("product_name")+MyArr.get(position).get("product_id"));}
- product_price.setText(MyArr.get(position).get("product_price"));
- String product_status = MyArr.get(position).get("product_status");
- if(product_status.equals("false"))
- {
- Button add_to_cart = (Button) view.findViewById(R.id.add_to_cart1);
- add_to_cart.setVisibility(View.GONE);
- View background_height = (View) view.findViewById(R.id.bestproduct1);
- }
- else
- {
- Button add_to_cart = (Button) view.findViewById(R.id.add_to_cart1);
- add_to_cart.setVisibility(View.VISIBLE);
- }
- //using picasoo
- Picasso.with(context)
- .load(MyArr.get(position).get("product_image"))
- .placeholder(R.drawable.ic_stub) // optional
- .error(R.drawable.ic_error) // optional
- .resize(100, 120)
- .centerCrop()
- /*.memoryPolicy(MemoryPolicy.NO_CACHE) /* // to disable cache
- .into(imageView);
- // view.setTag(holder);
- } else {
- holder = (ViewHolder) view.getTag();
- }
- return view;
- }
- }
Add Comment
Please, Sign In to add comment