Search in sources :

Example 1 with PhotoEditListAdapter

use of cn.finalteam.galleryfinal.adapter.PhotoEditListAdapter in project GalleryFinal by pengjianbo.

the class PhotoEditActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (GalleryFinal.getFunctionConfig() == null || GalleryFinal.getGalleryTheme() == null) {
        resultFailureDelayed(getString(R.string.please_reopen_gf), true);
    } else {
        setContentView(R.layout.gf_activity_photo_edit);
        mDefaultDrawable = getResources().getDrawable(R.drawable.ic_gf_default_photo);
        mSelectPhotoList = (ArrayList<PhotoInfo>) getIntent().getSerializableExtra(SELECT_MAP);
        mTakePhotoAction = this.getIntent().getBooleanExtra(TAKE_PHOTO_ACTION, false);
        mCropPhotoAction = this.getIntent().getBooleanExtra(CROP_PHOTO_ACTION, false);
        mEditPhotoAction = this.getIntent().getBooleanExtra(EDIT_PHOTO_ACTION, false);
        if (mSelectPhotoList == null) {
            mSelectPhotoList = new ArrayList<>();
        }
        mPhotoTempMap = new LinkedHashMap<>();
        mPhotoList = new ArrayList<>(mSelectPhotoList);
        mEditPhotoCacheFile = GalleryFinal.getCoreConfig().getEditPhotoCacheFolder();
        if (mPhotoList == null) {
            mPhotoList = new ArrayList<>();
        }
        for (PhotoInfo info : mPhotoList) {
            mPhotoTempMap.put(info.getPhotoId(), new PhotoTempModel(info.getPhotoPath()));
        }
        findViews();
        setListener();
        setTheme();
        mPhotoEditListAdapter = new PhotoEditListAdapter(this, mPhotoList, mScreenWidth);
        mLvGallery.setAdapter(mPhotoEditListAdapter);
        try {
            File nomediaFile = new File(mEditPhotoCacheFile, ".nomedia");
            if (!nomediaFile.exists()) {
                nomediaFile.createNewFile();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (GalleryFinal.getFunctionConfig().isCamera()) {
            mIvTakePhoto.setVisibility(View.VISIBLE);
        }
        if (GalleryFinal.getFunctionConfig().isCrop()) {
            mIvCrop.setVisibility(View.VISIBLE);
        }
        if (GalleryFinal.getFunctionConfig().isRotate()) {
            mIvRotate.setVisibility(View.VISIBLE);
        }
        if (!GalleryFinal.getFunctionConfig().isMutiSelect()) {
            mLlGallery.setVisibility(View.GONE);
        }
        initCrop(mIvCropPhoto, GalleryFinal.getFunctionConfig().isCropSquare(), GalleryFinal.getFunctionConfig().getCropWidth(), GalleryFinal.getFunctionConfig().getCropHeight());
        if (mPhotoList.size() > 0 && !mTakePhotoAction) {
            loadImage(mPhotoList.get(0));
        }
        if (mTakePhotoAction) {
            //打开相机
            takePhotoAction();
        }
        if (mCropPhotoAction) {
            mIvCrop.performClick();
            if (!GalleryFinal.getFunctionConfig().isRotate() && !GalleryFinal.getFunctionConfig().isCamera()) {
                mIvCrop.setVisibility(View.GONE);
            }
        } else {
            //判断是否强制裁剪
            hasForceCrop();
        }
        if (GalleryFinal.getFunctionConfig().isEnablePreview()) {
            mIvPreView.setVisibility(View.VISIBLE);
        }
    }
}
Also used : PhotoInfo(cn.finalteam.galleryfinal.model.PhotoInfo) PhotoEditListAdapter(cn.finalteam.galleryfinal.adapter.PhotoEditListAdapter) PhotoTempModel(cn.finalteam.galleryfinal.model.PhotoTempModel) IOException(java.io.IOException) File(java.io.File)

Aggregations

PhotoEditListAdapter (cn.finalteam.galleryfinal.adapter.PhotoEditListAdapter)1 PhotoInfo (cn.finalteam.galleryfinal.model.PhotoInfo)1 PhotoTempModel (cn.finalteam.galleryfinal.model.PhotoTempModel)1 File (java.io.File)1 IOException (java.io.IOException)1