use of cn.finalteam.galleryfinal.model.PhotoInfo in project GalleryFinal by pengjianbo.
the class PhotoEditListAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
String path = "";
PhotoInfo photoInfo = getDatas().get(position);
if (photoInfo != null) {
path = photoInfo.getPhotoPath();
}
holder.mIvPhoto.setImageResource(R.drawable.ic_gf_default_photo);
holder.mIvDelete.setImageResource(GalleryFinal.getGalleryTheme().getIconDelete());
Drawable defaultDrawable = mActivity.getResources().getDrawable(R.drawable.ic_gf_default_photo);
GalleryFinal.getCoreConfig().getImageLoader().displayImage(mActivity, path, holder.mIvPhoto, defaultDrawable, 100, 100);
if (!GalleryFinal.getFunctionConfig().isMutiSelect()) {
holder.mIvDelete.setVisibility(View.GONE);
} else {
holder.mIvDelete.setVisibility(View.VISIBLE);
}
holder.mIvDelete.setOnClickListener(new OnDeletePhotoClickListener(position));
}
use of cn.finalteam.galleryfinal.model.PhotoInfo in project GalleryFinal by pengjianbo.
the class PhotoListAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(PhotoViewHolder holder, int position) {
PhotoInfo photoInfo = getDatas().get(position);
String path = "";
if (photoInfo != null) {
path = photoInfo.getPhotoPath();
}
holder.mIvThumb.setImageResource(R.drawable.ic_gf_default_photo);
Drawable defaultDrawable = mActivity.getResources().getDrawable(R.drawable.ic_gf_default_photo);
GalleryFinal.getCoreConfig().getImageLoader().displayImage(mActivity, path, holder.mIvThumb, defaultDrawable, mRowWidth, mRowWidth);
holder.mView.setAnimation(null);
if (GalleryFinal.getCoreConfig().getAnimation() > 0) {
holder.mView.setAnimation(AnimationUtils.loadAnimation(mActivity, GalleryFinal.getCoreConfig().getAnimation()));
}
holder.mIvCheck.setImageResource(GalleryFinal.getGalleryTheme().getIconCheck());
if (GalleryFinal.getFunctionConfig().isMutiSelect()) {
holder.mIvCheck.setVisibility(View.VISIBLE);
if (mSelectList.contains(photoInfo)) {
holder.mIvCheck.setBackgroundColor(GalleryFinal.getGalleryTheme().getCheckSelectedColor());
} else {
holder.mIvCheck.setBackgroundColor(GalleryFinal.getGalleryTheme().getCheckNornalColor());
}
} else {
holder.mIvCheck.setVisibility(View.GONE);
}
}
use of cn.finalteam.galleryfinal.model.PhotoInfo in project GalleryFinal by pengjianbo.
the class PhotoPreviewAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(PreviewViewHolder holder, int position) {
PhotoInfo photoInfo = getDatas().get(position);
String path = "";
if (photoInfo != null) {
path = photoInfo.getPhotoPath();
}
holder.mImageView.setImageResource(R.drawable.ic_gf_default_photo);
Drawable defaultDrawable = mActivity.getResources().getDrawable(R.drawable.ic_gf_default_photo);
GalleryFinal.getCoreConfig().getImageLoader().displayImage(mActivity, path, holder.mImageView, defaultDrawable, mDisplayMetrics.widthPixels / 2, mDisplayMetrics.heightPixels / 2);
}
use of cn.finalteam.galleryfinal.model.PhotoInfo in project GalleryFinal by pengjianbo.
the class GalleryFinal method openCrop.
/**
* 打开裁剪
* @param requestCode
* @param config
* @param photoPath
* @param callback
*/
public static void openCrop(int requestCode, FunctionConfig config, String photoPath, OnHanlderResultCallback callback) {
if (mCoreConfig.getImageLoader() == null) {
ILogger.e("Please init GalleryFinal.");
if (callback != null) {
callback.onHanlderFailure(requestCode, mCoreConfig.getContext().getString(R.string.open_gallery_fail));
}
return;
}
if (config == null && mGlobalFunctionConfig == null) {
if (callback != null) {
callback.onHanlderFailure(requestCode, mCoreConfig.getContext().getString(R.string.open_gallery_fail));
}
return;
}
if (!DeviceUtils.existSDCard()) {
Toast.makeText(mCoreConfig.getContext(), R.string.empty_sdcard, Toast.LENGTH_SHORT).show();
return;
}
if (config == null || StringUtils.isEmpty(photoPath) || !new File(photoPath).exists()) {
ILogger.d("config为空或文件不存在");
return;
}
mRequestCode = requestCode;
mCallback = callback;
//必须设置这个三个选项
//拍照为单选
config.mutiSelect = false;
config.editPhoto = true;
config.crop = true;
mCurrentFunctionConfig = config;
ArrayList<PhotoInfo> map = new ArrayList<>();
PhotoInfo photoInfo = new PhotoInfo();
photoInfo.setPhotoPath(photoPath);
photoInfo.setPhotoId(Utils.getRandom(10000, 99999));
map.add(photoInfo);
Intent intent = new Intent(mCoreConfig.getContext(), PhotoEditActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(PhotoEditActivity.CROP_PHOTO_ACTION, true);
intent.putExtra(PhotoEditActivity.SELECT_MAP, map);
mCoreConfig.getContext().startActivity(intent);
}
use of cn.finalteam.galleryfinal.model.PhotoInfo in project GalleryFinal by pengjianbo.
the class PhotoEditActivity method deleteIndex.
public void deleteIndex(int position, PhotoInfo dPhoto) {
if (dPhoto != null) {
PhotoSelectActivity activity = (PhotoSelectActivity) ActivityManager.getActivityManager().getActivity(PhotoSelectActivity.class.getName());
if (activity != null) {
activity.deleteSelect(dPhoto.getPhotoId());
}
try {
for (Iterator<PhotoInfo> iterator = mSelectPhotoList.iterator(); iterator.hasNext(); ) {
PhotoInfo info = iterator.next();
if (info != null && info.getPhotoId() == dPhoto.getPhotoId()) {
iterator.remove();
break;
}
}
} catch (Exception e) {
}
}
if (mPhotoList.size() == 0) {
mSelectIndex = 0;
mTvEmptyView.setText(R.string.no_photo);
mTvEmptyView.setVisibility(View.VISIBLE);
mIvSourcePhoto.setVisibility(View.GONE);
mIvCropPhoto.setVisibility(View.GONE);
mIvPreView.setVisibility(View.GONE);
} else {
if (position == 0) {
mSelectIndex = 0;
} else if (position == mPhotoList.size()) {
mSelectIndex = position - 1;
} else {
mSelectIndex = position;
}
PhotoInfo photoInfo = mPhotoList.get(mSelectIndex);
loadImage(photoInfo);
}
}
Aggregations