Java源码示例:me.iwf.photopicker.utils.AndroidLifecycleUtils

示例1
@Override
public void onBindViewHolder(final PhotoViewHolder holder, final int position) {

  if (getItemViewType(position) == TYPE_PHOTO) {
    Uri uri = Uri.fromFile(new File(photoPaths.get(position)));

    boolean canLoadImage = AndroidLifecycleUtils.canLoadImage(holder.ivPhoto.getContext());

    if (canLoadImage) {
      final RequestOptions options = new RequestOptions();
      options.centerCrop()
              .placeholder(R.drawable.__picker_ic_photo_black_48dp)
              .error(R.drawable.__picker_ic_broken_image_black_48dp);
      Glide.with(mContext)
              .load(uri)
              .apply(options)
              .thumbnail(0.1f)
              .into(holder.ivPhoto);
    }
  }
}
 
示例2
@Override
public void onBindViewHolder(final PhotoViewHolder holder, final int position) {

  if (getItemViewType(position) == TYPE_PHOTO) {
    Uri uri = Uri.fromFile(new File(photoPaths.get(position)));

    boolean canLoadImage = AndroidLifecycleUtils.canLoadImage(holder.ivPhoto.getContext());

    if (canLoadImage) {
      Glide.with(mContext)
              .load(uri)
              .centerCrop()
              .thumbnail(0.1f)
              .placeholder(R.drawable.__picker_ic_photo_black_48dp)
              .error(R.drawable.__picker_ic_broken_image_black_48dp)
              .into(holder.ivPhoto);
    }
  }
}
 
示例3
@Override
public void onBindViewHolder(final PhotoViewHolder holder, final int position) {

  if (getItemViewType(position) == TYPE_PHOTO) {
    Uri uri = Uri.fromFile(new File(photoPaths.get(position)));

    boolean canLoadImage = AndroidLifecycleUtils.canLoadImage(holder.ivPhoto.getContext());

    if (canLoadImage) {
      final RequestOptions options = new RequestOptions();
      options.centerCrop()
          .placeholder(R.drawable.__picker_ic_photo_black_48dp)
          .error(R.drawable.__picker_ic_broken_image_black_48dp);
      Glide.with(mContext)
              .load(uri)
              .apply(options)
              .thumbnail(0.1f)
              .into(holder.ivPhoto);
    }
  }
}
 
示例4
private void resumeRequestsIfNotDestroyed() {
    if (!AndroidLifecycleUtils.canLoadImage(this)) {
        return;
    }

    mGlideRequestManager.resumeRequests();
}
 
示例5
private void resumeRequestsIfNotDestroyed() {
    if (!AndroidLifecycleUtils.canLoadImage(this)) {
        return;
    }

    mGlideRequestManager.resumeRequests();
}
 
示例6
private void resumeRequestsIfNotDestroyed() {
  if (!AndroidLifecycleUtils.canLoadImage(this)) {
    return;
  }

  mGlideRequestManager.resumeRequests();
}
 
示例7
@Override public Object instantiateItem(ViewGroup container, int position) {
  final Context context = container.getContext();
  View itemView = LayoutInflater.from(context)
      .inflate(R.layout.__picker_picker_item_pager, container, false);

  final ImageView imageView = (ImageView) itemView.findViewById(R.id.iv_pager);

  final String path = paths.get(position);
  final Uri uri;
  if (path.startsWith("http")) {
    uri = Uri.parse(path);
  } else {
    uri = Uri.fromFile(new File(path));
  }

  boolean canLoadImage = AndroidLifecycleUtils.canLoadImage(context);

  if (canLoadImage) {
    final RequestOptions options = new RequestOptions();
    options.dontAnimate()
        .dontTransform()
        .override(800, 800)
        .placeholder(R.drawable.__picker_ic_photo_black_48dp)
        .error(R.drawable.__picker_ic_broken_image_black_48dp);
    mGlide.setDefaultRequestOptions(options).load(uri)
            .thumbnail(0.1f)
            .into(imageView);
  }

  imageView.setOnClickListener(new View.OnClickListener() {
    @Override public void onClick(View view) {
      if (context instanceof Activity) {
        if (!((Activity) context).isFinishing()) {
          ((Activity) context).onBackPressed();
        }
      }
    }
  });

  container.addView(itemView);

  return itemView;
}