@Override public void onBindViewHolder(MyViewHolder holder, int position) { Bookmark current = data.get(position); if (current.getPlace().firstImageURL != null) { DisplayImageOptions dio = new DisplayImageOptions.Builder() .displayer( new BitmapDisplayer() { @Override public void display( Bitmap bitmap, ImageAware imageAware, LoadedFrom loadedFrom) { int gradientStartColor = Color.argb(0, 0, 0, 0); int gradientEndColor = Color.argb(255, 0, 0, 0); GradientOverImageDrawable gradientDrawable = new GradientOverImageDrawable(context.getResources(), bitmap); gradientDrawable.setGradientColors(gradientStartColor, gradientEndColor); imageAware.setImageDrawable(gradientDrawable); } }) .cacheOnDisc(true) .cacheInMemory(true) .imageScaleType(ImageScaleType.EXACTLY) .build(); ImageLoader.getInstance() .displayImage(current.getPlace().firstImageURL, holder.imagePlace, dio); } else { holder.imagePlace.setImageResource(R.drawable.ic_logo); } holder.Name.setText(current.getPlace().getPlaceName()); holder.Location.setText(current.getPlace().getAddress()); holder.Description.setText(current.getPlace().getPlaceDescription()); }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder = new ViewHolder(); if (convertView == null) { convertView = inflater.inflate(R.layout.trans_list_row, parent, false); holder.Description = (TextView) convertView.findViewById(R.id.Description); holder.Category = (TextView) convertView.findViewById(R.id.Category); holder.Amount = (TextView) convertView.findViewById(R.id.Amount); holder.imageView = (ImageView) convertView.findViewById(R.id.imageView); holder.Description.setTypeface( Typeface.createFromAsset(context.getAssets(), "Roboto-Regular.ttf")); holder.Category.setTypeface( Typeface.createFromAsset(context.getAssets(), "Roboto-Light.ttf")); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } Transaction trans = transactions.get(position); holder.Description.setText(trans.Description); holder.Category.setText(trans.Category); if (trans.Amount < 0) { holder.Amount.setTextColor(Color.parseColor("#E62117")); int temp = -trans.Amount; holder.Amount.setText(context.getResources().getString(R.string.Euro) + " " + temp); holder.imageView.setImageDrawable( context.getResources().getDrawable(R.drawable.transaction_list_icon_edited_expenses)); } else { holder.Amount.setTextColor(Color.parseColor("#037D03")); int temp = trans.Amount; holder.Amount.setText(context.getResources().getString(R.string.Euro) + " " + temp); holder.imageView.setImageDrawable( context.getResources().getDrawable(R.drawable.transaction_list_icon_edited_income)); } return convertView; }