Beispiel #1
0
 @Override
 public void onEventRunEnd(Event event) {
   int code = event.getEventCode();
   if (code == EventCode.SC_DownloadImage) {
     DownloadEvent dEvent = (DownloadEvent) event;
     String url = (String) dEvent.getTag();
     if (TextUtils.isEmpty(url)) {
       return;
     }
     Bitmap bitmap = null;
     if (dEvent.isSuccess()) {
       bitmap = PosterBmpProvider.getInstance().loadImage(url);
     } else {
       bitmap =
           BitmapFactory.decodeResource(
               mContext.getResources(), R.drawable.user_center_avator_default);
     }
     Bitmap aimBitmap =
         BitmapFactory.decodeResource(
             mContext.getResources(), R.drawable.user_center_avator_default);
     if (bitmap != null) {
       ViewHolder viewHolder = imageViews.get(url);
       Bitmap newBitmap =
           ImageUtils.zoomBitmap(bitmap, aimBitmap.getWidth(), aimBitmap.getHeight());
       if (newBitmap != null && viewHolder != null && viewHolder.customers_pic != null) {
         viewHolder.customers_pic.setImageBitmap(newBitmap);
         return;
       }
     }
   }
 }
Beispiel #2
0
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   passIndex = position;
   CustomerBean customer = getItem(position);
   View view;
   ViewHolder vh;
   if (convertView == null) {
     view = LayoutInflater.from(mContext).inflate(ResourceId, null);
     vh = new ViewHolder();
     vh.customers_pic = (ImageView) view.findViewById(R.id.customer_head);
     vh.customers_name = (TextView) view.findViewById(R.id.customer_name);
     view.setTag(vh);
   } else {
     view = convertView;
     vh = (ViewHolder) view.getTag();
   }
   // vh.customers_pic.setBackgroundDrawable(this.getContext().getResources()
   // .getDrawable(customer.getPic_url()));
   vh.customers_name.setText(customer.getName());
   // *****
   Bitmap originBitmap =
       BitmapFactory.decodeResource(
           mContext.getResources(), R.drawable.user_center_avator_default);
   vh.customers_pic.setImageBitmap(originBitmap);
   // ******判断位置
   if (passIndex == position) {
     String url = customer.getPic_url();
     // 下载图片
     Bitmap bitmap = PosterBmpProvider.getInstance().loadImage(url);
     if (bitmap != null) {
       vh.customers_pic.setImageBitmap(bitmap);
     }
     // Log.e("ysz", "picUrl===="+url);
     imageViews.put(url, vh);
   }
   Log.d(TAG, "getView");
   return view;
 }