Search in sources :

Example 6 with PhotoInfo

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));
}
Also used : PhotoInfo(cn.finalteam.galleryfinal.model.PhotoInfo) Drawable(android.graphics.drawable.Drawable)

Example 7 with PhotoInfo

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);
    }
}
Also used : PhotoInfo(cn.finalteam.galleryfinal.model.PhotoInfo) Drawable(android.graphics.drawable.Drawable)

Example 8 with PhotoInfo

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);
}
Also used : PhotoInfo(cn.finalteam.galleryfinal.model.PhotoInfo) Drawable(android.graphics.drawable.Drawable)

Example 9 with PhotoInfo

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);
}
Also used : PhotoInfo(cn.finalteam.galleryfinal.model.PhotoInfo) ArrayList(java.util.ArrayList) Intent(android.content.Intent) File(java.io.File)

Example 10 with PhotoInfo

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);
    }
}
Also used : PhotoInfo(cn.finalteam.galleryfinal.model.PhotoInfo) IOException(java.io.IOException)

Aggregations

PhotoInfo (cn.finalteam.galleryfinal.model.PhotoInfo)19 File (java.io.File)9 ArrayList (java.util.ArrayList)5 Drawable (android.graphics.drawable.Drawable)4 PhotoFolderInfo (cn.finalteam.galleryfinal.model.PhotoFolderInfo)4 Intent (android.content.Intent)3 IOException (java.io.IOException)3 Message (android.os.Message)2 PhotoTempModel (cn.finalteam.galleryfinal.model.PhotoTempModel)2 Cursor (android.database.Cursor)1 Bitmap (android.graphics.Bitmap)1 ImageView (android.widget.ImageView)1 PhotoEditListAdapter (cn.finalteam.galleryfinal.adapter.PhotoEditListAdapter)1 PhotoListAdapter (cn.finalteam.galleryfinal.adapter.PhotoListAdapter)1 PhotoPreviewAdapter (cn.finalteam.galleryfinal.adapter.PhotoPreviewAdapter)1 DisplayImageOptions (com.nostra13.universalimageloader.core.DisplayImageOptions)1 HashMap (java.util.HashMap)1