me.iwf.photopicker.utils.AndroidLifecycleUtils Java Examples

The following examples show how to use me.iwf.photopicker.utils.AndroidLifecycleUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PhotoAdapter.java    From PhotoPicker with Apache License 2.0 6 votes vote down vote up
@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);
    }
  }
}
 
Example #2
Source File: PhotoAdapter.java    From PhotoPicker with Apache License 2.0 6 votes vote down vote up
@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);
    }
  }
}
 
Example #3
Source File: PhotoAdapter.java    From PhotoPicker with Apache License 2.0 6 votes vote down vote up
@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);
    }
  }
}
 
Example #4
Source File: PhotoPickerFragment.java    From PhotoPicker with Apache License 2.0 5 votes vote down vote up
private void resumeRequestsIfNotDestroyed() {
    if (!AndroidLifecycleUtils.canLoadImage(this)) {
        return;
    }

    mGlideRequestManager.resumeRequests();
}
 
Example #5
Source File: PhotoPickerFragment.java    From PhotoPicker with Apache License 2.0 5 votes vote down vote up
private void resumeRequestsIfNotDestroyed() {
    if (!AndroidLifecycleUtils.canLoadImage(this)) {
        return;
    }

    mGlideRequestManager.resumeRequests();
}
 
Example #6
Source File: PhotoPickerFragment.java    From PhotoPicker with Apache License 2.0 5 votes vote down vote up
private void resumeRequestsIfNotDestroyed() {
  if (!AndroidLifecycleUtils.canLoadImage(this)) {
    return;
  }

  mGlideRequestManager.resumeRequests();
}
 
Example #7
Source File: PhotoPagerAdapter.java    From PhotoPicker with Apache License 2.0 4 votes vote down vote up
@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;
}