示例#1
0
 public void onEvent(CropEvent cropEvent) {
   mCropImageView.setCropMode(cropEvent.getCropMode());
   mCropImageView.setImageBitmap(
       APP.getInstance()
           .imageLoader
           .loadImageSync(
               "file:///" + cropEvent.getImagePath(),
               new ImageSize(DevicesUtil.screenWidth, DevicesUtil.screenHeight)));
 }
  @Override
  public void onBindViewHolder(final ViewHolder holder, final int position) {

    RelativeLayout.LayoutParams params =
        (RelativeLayout.LayoutParams) holder.ivIcon.getLayoutParams();
    params.width = DevicesUtil.screenWidth;
    params.height = DevicesUtil.screenWidth;
    holder.ivIcon.setLayoutParams(params);

    final ActicleMod mod = mylist.get(position);

    holder.tvName.setText(mod.title);
    holder.tvDesc.setText(mod.descriptions);

    APP.getInstance()
        .imageLoader
        .displayImage(
            mod.image,
            holder.ivIcon,
            APP.options,
            new SimpleImageLoadingListener() {

              final List<String> displayedImages =
                  Collections.synchronizedList(new LinkedList<String>());

              @Override
              public void onLoadingStarted(String imageUri, View view) {
                holder.progressBar.setProgress(0);
                holder.progressBar.setVisibility(View.VISIBLE);
              }

              @Override
              public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
                holder.progressBar.setVisibility(View.GONE);
              }

              @Override
              public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
                holder.progressBar.setVisibility(View.GONE);
                if (loadedImage != null) {
                  ImageView imageView = (ImageView) view;
                  boolean firstDisplay = !displayedImages.contains(imageUri);
                  if (firstDisplay) {
                    FadeInBitmapDisplayer.animate(imageView, 500); // 动画效果
                    displayedImages.add(imageUri);
                  }
                }
              }
            },
            new ImageLoadingProgressListener() {
              @Override
              public void onProgressUpdate(String imageUri, View view, int current, int total) {
                holder.progressBar.setProgress(Math.round(100.0f * current / total));
              }
            });
    //        APP.getInstance().imageLoader.displayImage(mod.image, holder.ivIcon, APP.options,
    //                new UILUtils.AnimateFirstDisplayListener());

    holder.mView.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Context context = v.getContext();
            Intent intent = new Intent(context, ArticleAct.class);
            EventBus.getDefault().postSticky(position);
            EventBus.getDefault().postSticky(mylist);
            context.startActivity(intent);
          }
        });
  }