me.iwf.photopicker.R Java Examples

The following examples show how to use me.iwf.photopicker.R. 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: PhotoDialogAdapter.java    From PhotoPicker with Apache License 2.0 6 votes vote down vote up
public View getView(int position, View view, ViewGroup parent) {

        ViewHolder viewHolder = null;
        if (view == null) {
            viewHolder = new ViewHolder();
            view = LayoutInflater.from(mContext).inflate(R.layout.__picker_item_dialog, null);
            viewHolder.tv_dialog = (TextView) view.findViewById(R.id.tv_dialog);

            view.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }
        if (position == 0) {
            viewHolder.tv_dialog.setBackgroundResource(R.drawable.__picker_item_dialog_selector_top);
        } else if (position == getCount() - 1) {
            viewHolder.tv_dialog.setBackgroundResource(R.drawable.__picker_item_dialog_selector_bottom);
        } else {
            viewHolder.tv_dialog.setBackgroundResource(R.drawable.__picker_item_dialog_selector);
        }

        viewHolder.tv_dialog.setText(lstImageItem.get(position));
        return view;
    }
 
Example #2
Source File: PhotoGridAdapter.java    From PhotoPicker with Apache License 2.0 6 votes vote down vote up
@Override
public PhotoViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    final View itemView = inflater.inflate(R.layout.__picker_item_photo, parent, false);
    final PhotoViewHolder holder = new PhotoViewHolder(itemView);
    if (viewType == ITEM_TYPE_CAMERA) {
        holder.vSelected.setVisibility(View.GONE);
        holder.ivPhoto.setScaleType(ImageView.ScaleType.CENTER);

        holder.ivPhoto.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (onCameraClickListener != null) {
                    onCameraClickListener.onClick(view);
                }
            }
        });
    }
    return holder;
}
 
Example #3
Source File: PhotoGridAdapter.java    From PhotoPicker with Apache License 2.0 6 votes vote down vote up
@Override public PhotoViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
  final View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.__picker_item_photo, parent, false);
  final PhotoViewHolder holder = new PhotoViewHolder(itemView);
  if (viewType == ITEM_TYPE_CAMERA) {
    holder.vSelected.setVisibility(View.GONE);
    holder.ivPhoto.setScaleType(ImageView.ScaleType.CENTER);

    holder.ivPhoto.setOnClickListener(new View.OnClickListener() {
      @Override public void onClick(View view) {
        if (onCameraClickListener != null) {
          onCameraClickListener.onClick(view);
        }
      }
    });
  }
  return holder;
}
 
Example #4
Source File: PhotoPagerAdapter.java    From PhotoPicker with Apache License 2.0 6 votes vote down vote up
private void OnLongDialog(Context context, final String path) {
        final AlertDialog albumDialog = new AlertDialog.Builder(context).create();
        albumDialog.setCanceledOnTouchOutside(true);
        albumDialog.setCancelable(true);
        View v = LayoutInflater.from(context).inflate(
                R.layout.__picker_dialog_photo_pager, null);
        albumDialog.show();
//        ViewGroup.LayoutParams layoutParams = new LinearLayout.LayoutParams(280, ViewGroup.LayoutParams.MATCH_PARENT);
        albumDialog.setContentView(v);
        albumDialog.getWindow().setGravity(Gravity.CENTER);
        albumDialog.getWindow().setBackgroundDrawableResource(R.drawable.__picker_bg_dialog);
        ListView dialog_lv = (ListView) v.findViewById(R.id.dialog_lv);

        PhotoDialogAdapter photoDialogAdapter = new PhotoDialogAdapter(context, longData);
        dialog_lv.setAdapter(photoDialogAdapter);
        dialog_lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                albumDialog.dismiss();
                PhotoOnLongClickManager photoOnLongClickManager = PhotoOnLongClickManager.getInstance();
                photoOnLongClickManager.setOnLongClick(i, path);
            }
        });
    }
 
Example #5
Source File: PhotoDialogAdapter.java    From PhotoPicker with Apache License 2.0 6 votes vote down vote up
public View getView(int position, View view, ViewGroup parent) {

        ViewHolder viewHolder = null;
        if (view == null) {
            viewHolder = new ViewHolder();
            view = LayoutInflater.from(mContext).inflate(R.layout.__picker_item_dialog, null);
            viewHolder.tv_dialog = (TextView) view.findViewById(R.id.tv_dialog);

            view.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }
        if (position == 0) {
            viewHolder.tv_dialog.setBackgroundResource(R.drawable.__picker_item_dialog_selector_top);
        } else if (position == getCount() - 1) {
            viewHolder.tv_dialog.setBackgroundResource(R.drawable.__picker_item_dialog_selector_bottom);
        } else {
            viewHolder.tv_dialog.setBackgroundResource(R.drawable.__picker_item_dialog_selector);
        }

        viewHolder.tv_dialog.setText(lstImageItem.get(position));
        return view;
    }
 
Example #6
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 #7
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 #8
Source File: PhotoPagerAdapter.java    From PhotoPicker with Apache License 2.0 6 votes vote down vote up
private void OnLongDialog(Context context, final String path) {
        final AlertDialog albumDialog = new AlertDialog.Builder(context).create();
        albumDialog.setCanceledOnTouchOutside(true);
        albumDialog.setCancelable(true);
        View v = LayoutInflater.from(context).inflate(
                R.layout.__picker_dialog_photo_pager, null);
        albumDialog.show();
//        ViewGroup.LayoutParams layoutParams = new LinearLayout.LayoutParams(280, ViewGroup.LayoutParams.MATCH_PARENT);
        albumDialog.setContentView(v);
        albumDialog.getWindow().setGravity(Gravity.CENTER);
        albumDialog.getWindow().setBackgroundDrawableResource(R.drawable.__picker_bg_dialog);
        ListView dialog_lv = (ListView) v.findViewById(R.id.dialog_lv);

        PhotoDialogAdapter photoDialogAdapter = new PhotoDialogAdapter(context, longData);
        dialog_lv.setAdapter(photoDialogAdapter);
        dialog_lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                albumDialog.dismiss();
                PhotoOnLongClickManager photoOnLongClickManager = PhotoOnLongClickManager.getInstance();
                photoOnLongClickManager.setOnLongClick(i, path);
            }
        });
    }
 
Example #9
Source File: PhotoGridAdapter.java    From PhotoPicker with Apache License 2.0 6 votes vote down vote up
@Override
public PhotoViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    final View itemView = inflater.inflate(R.layout.__picker_item_photo, parent, false);
    final PhotoViewHolder holder = new PhotoViewHolder(itemView);
    if (viewType == ITEM_TYPE_CAMERA) {
        holder.vSelected.setVisibility(View.GONE);
        holder.ivPhoto.setScaleType(ImageView.ScaleType.CENTER);

        holder.ivPhoto.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (onCameraClickListener != null) {
                    onCameraClickListener.onClick(view);
                }
            }
        });
    }
    return holder;
}
 
Example #10
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 #11
Source File: PopupDirectoryListAdapter.java    From PhotoPicker with Apache License 2.0 5 votes vote down vote up
@Override public View getView(int position, View convertView, ViewGroup parent) {
  ViewHolder holder;
  if (convertView == null) {
    LayoutInflater mLayoutInflater = LayoutInflater.from(parent.getContext());
    convertView = mLayoutInflater.inflate(R.layout.__picker_item_directory, parent, false);
    holder = new ViewHolder(convertView);
    convertView.setTag(holder);
  } else {
    holder = (ViewHolder) convertView.getTag();
  }

  holder.bindData(directories.get(position));

  return convertView;
}
 
Example #12
Source File: PopupDirectoryListAdapter.java    From PhotoPicker with Apache License 2.0 5 votes vote down vote up
public void bindData(PhotoDirectory directory) {
  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);
  glide.setDefaultRequestOptions(options)
      .load(directory.getCoverPath())
      .thumbnail(0.1f)
      .into(ivCover);
  tvName.setText(directory.getName());
  tvCount.setText(tvCount.getContext().getString(R.string.__picker_image_count, directory.getPhotos().size()));
}
 
Example #13
Source File: PhotoAdapter.java    From PhotoPicker with Apache License 2.0 5 votes vote down vote up
@Override public PhotoViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
  View itemView = null;
  switch (viewType) {
    case TYPE_ADD:
      itemView = inflater.inflate(me.iwf.PhotoPickerDemo.R.layout.item_add, parent, false);
      break;
    case TYPE_PHOTO:
      itemView = inflater.inflate(R.layout.__picker_item_photo, parent, false);
      break;
  }
  return new PhotoViewHolder(itemView);
}
 
Example #14
Source File: PhotoPickerFragment.java    From PhotoPicker with Apache License 2.0 5 votes vote down vote up
public void adjustHeight() {
  if (listAdapter == null) return;
  int count = listAdapter.getCount();
  count = count < COUNT_MAX ? count : COUNT_MAX;
  if (listPopupWindow != null) {
    listPopupWindow.setHeight(count * getResources().getDimensionPixelOffset(R.dimen.__picker_item_directory_height));
  }
}
 
Example #15
Source File: PhotoPickerFragment.java    From PhotoPicker with Apache License 2.0 5 votes vote down vote up
public void adjustHeight() {
    if (listAdapter == null) return;
    int count = listAdapter.getCount();
    count = count < COUNT_MAX ? count : COUNT_MAX;
    if (listPopupWindow != null) {
        listPopupWindow.setHeight(count * getResources().getDimensionPixelOffset(R.dimen.__picker_item_directory_height));
    }
}
 
Example #16
Source File: ImagePagerFragment.java    From PhotoPicker with Apache License 2.0 5 votes vote down vote up
@Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,
    Bundle savedInstanceState) {

  View rootView = inflater.inflate(R.layout.__picker_picker_fragment_image_pager, container, false);

  mViewPager = rootView.findViewById(R.id.vp_photos);
  mViewPager.setAdapter(mPagerAdapter);
  mViewPager.setCurrentItem(currentItem);
  mViewPager.setOffscreenPageLimit(5);

  return rootView;
}
 
Example #17
Source File: PopupDirectoryListAdapter.java    From PhotoPicker with Apache License 2.0 5 votes vote down vote up
@Override public View getView(int position, View convertView, ViewGroup parent) {
  ViewHolder holder;
  if (convertView == null) {
    LayoutInflater mLayoutInflater = LayoutInflater.from(parent.getContext());
    convertView = mLayoutInflater.inflate(R.layout.__picker_item_directory, parent, false);
    holder = new ViewHolder(convertView);
    convertView.setTag(holder);
  } else {
    holder = (ViewHolder) convertView.getTag();
  }

  holder.bindData(directories.get(position));

  return convertView;
}
 
Example #18
Source File: PopupDirectoryListAdapter.java    From PhotoPicker with Apache License 2.0 5 votes vote down vote up
public void bindData(PhotoDirectory directory) {
  glide.load(directory.getCoverPath())
      .dontAnimate()
      .thumbnail(0.1f)
      .into(ivCover);
  tvName.setText(directory.getName());
  tvCount.setText(tvCount.getContext().getString(R.string.__picker_image_count, directory.getPhotos().size()));
}
 
Example #19
Source File: PhotoPickerFragment.java    From PhotoPicker with Apache License 2.0 5 votes vote down vote up
public void adjustHeight() {
    if (listAdapter == null) return;
    int count = listAdapter.getCount();
    count = count < COUNT_MAX ? count : COUNT_MAX;
    if (listPopupWindow != null) {
        listPopupWindow.setHeight(count * getResources().getDimensionPixelOffset(R.dimen.__picker_item_directory_height));
    }
}
 
Example #20
Source File: PhotoAdapter.java    From PhotoPicker with Apache License 2.0 5 votes vote down vote up
@Override public PhotoViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
  View itemView = null;
  switch (viewType) {
    case TYPE_ADD:
      itemView = inflater.inflate(me.iwf.PhotoPickerDemo.R.layout.item_add, parent, false);
      break;
    case TYPE_PHOTO:
      itemView = inflater.inflate(R.layout.__picker_item_photo, parent, false);
      break;
  }
  return new PhotoViewHolder(itemView);
}
 
Example #21
Source File: PhotoAdapter.java    From PhotoPicker with Apache License 2.0 5 votes vote down vote up
@Override public PhotoViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
  View itemView = null;
  switch (viewType) {
    case TYPE_ADD:
      itemView = inflater.inflate(me.iwf.PhotoPickerDemo.R.layout.item_add, parent, false);
      break;
    case TYPE_PHOTO:
      itemView = inflater.inflate(R.layout.__picker_item_photo, parent, false);
      break;
  }
  return new PhotoViewHolder(itemView);
}
 
Example #22
Source File: PopupDirectoryListAdapter.java    From PhotoPicker with Apache License 2.0 5 votes vote down vote up
public void bindData(PhotoDirectory directory) {
  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);
  glide.setDefaultRequestOptions(options)
          .load(directory.getCoverPath())
          .thumbnail(0.1f)
          .into(ivCover);
  tvName.setText(directory.getName());
  tvCount.setText(tvCount.getContext().getString(R.string.__picker_image_count, directory.getPhotos().size()));
}
 
Example #23
Source File: PopupDirectoryListAdapter.java    From PhotoPicker with Apache License 2.0 5 votes vote down vote up
@Override public View getView(int position, View convertView, ViewGroup parent) {
  ViewHolder holder;
  if (convertView == null) {
    LayoutInflater mLayoutInflater = LayoutInflater.from(parent.getContext());
    convertView = mLayoutInflater.inflate(R.layout.__picker_item_directory, parent, false);
    holder = new ViewHolder(convertView);
    convertView.setTag(holder);
  } else {
    holder = (ViewHolder) convertView.getTag();
  }

  holder.bindData(directories.get(position));

  return convertView;
}
 
Example #24
Source File: PhotoGridAdapter.java    From PhotoPicker with Apache License 2.0 4 votes vote down vote up
public PhotoViewHolder(View itemView) {
    super(itemView);
    ivPhoto = (ImageView) itemView.findViewById(R.id.iv_photo);
    vSelected = itemView.findViewById(R.id.v_selected);
}
 
Example #25
Source File: PhotoGridAdapter.java    From PhotoPicker with Apache License 2.0 4 votes vote down vote up
public PhotoViewHolder(View itemView) {
  super(itemView);
  ivPhoto   = (ImageView) itemView.findViewById(R.id.iv_photo);
  vSelected = itemView.findViewById(R.id.v_selected);
}
 
Example #26
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;
}
 
Example #27
Source File: PopupDirectoryListAdapter.java    From PhotoPicker with Apache License 2.0 4 votes vote down vote up
public ViewHolder(View rootView) {
  ivCover = rootView.findViewById(R.id.iv_dir_cover);
  tvName  = rootView.findViewById(R.id.tv_dir_name);
  tvCount = rootView.findViewById(R.id.tv_dir_count);
}
 
Example #28
Source File: PhotoAdapter.java    From PhotoPicker with Apache License 2.0 4 votes vote down vote up
public PhotoViewHolder(View itemView) {
  super(itemView);
  ivPhoto   = (ImageView) itemView.findViewById(R.id.iv_photo);
  vSelected = itemView.findViewById(R.id.v_selected);
  if (vSelected != null) vSelected.setVisibility(View.GONE);
}
 
Example #29
Source File: MediaStoreHelper.java    From PhotoPicker with Apache License 2.0 4 votes vote down vote up
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) {

      if (data == null)  return;
      List<PhotoDirectory> directories = new ArrayList<>();
      PhotoDirectory photoDirectoryAll = new PhotoDirectory();
      photoDirectoryAll.setName(context.getString(R.string.__picker_all_image));
      photoDirectoryAll.setId("ALL");

      data.moveToFirst();

      while (data.moveToNext()) {

        int imageId  = data.getInt(data.getColumnIndexOrThrow(_ID));
        String bucketId = data.getString(data.getColumnIndexOrThrow(BUCKET_ID));
        String name = data.getString(data.getColumnIndexOrThrow(BUCKET_DISPLAY_NAME));
        String path = data.getString(data.getColumnIndexOrThrow(DATA));
        long size = data.getInt(data.getColumnIndexOrThrow(SIZE));

        if (size < 1) continue;

        PhotoDirectory photoDirectory = new PhotoDirectory();
        photoDirectory.setId(bucketId);
        photoDirectory.setName(name);

        if (!directories.contains(photoDirectory)) {
          photoDirectory.setCoverPath(path);
          photoDirectory.addPhoto(imageId, path);
          photoDirectory.setDateAdded(data.getLong(data.getColumnIndexOrThrow(DATE_ADDED)));
          directories.add(photoDirectory);
        } else {
          directories.get(directories.indexOf(photoDirectory)).addPhoto(imageId, path);
        }

        photoDirectoryAll.addPhoto(imageId, path);
      }
      if (photoDirectoryAll.getPhotoPaths().size() > 0) {
        photoDirectoryAll.setCoverPath(photoDirectoryAll.getPhotoPaths().get(0));
      }
      directories.add(INDEX_ALL_PHOTOS, photoDirectoryAll);
      if (resultCallback != null) {
        resultCallback.onResultCallback(directories);
      }
    }
 
Example #30
Source File: PhotoAdapter.java    From PhotoPicker with Apache License 2.0 4 votes vote down vote up
public PhotoViewHolder(View itemView) {
  super(itemView);
  ivPhoto   = (ImageView) itemView.findViewById(R.id.iv_photo);
  vSelected = itemView.findViewById(R.id.v_selected);
  if (vSelected != null) vSelected.setVisibility(View.GONE);
}