Search in sources :

Example 1 with ImageCaptureManager

use of me.iwf.photopicker.utils.ImageCaptureManager in project PhotoPicker by donglua.

the class PhotoPickerFragment method onActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == ImageCaptureManager.REQUEST_TAKE_PHOTO && resultCode == RESULT_OK) {
        if (captureManager == null) {
            FragmentActivity activity = getActivity();
            captureManager = new ImageCaptureManager(activity);
        }
        captureManager.galleryAddPic();
        if (directories.size() > 0) {
            String path = captureManager.getCurrentPhotoPath();
            PhotoDirectory directory = directories.get(INDEX_ALL_PHOTOS);
            directory.getPhotos().add(INDEX_ALL_PHOTOS, new Photo(path.hashCode(), path));
            directory.setCoverPath(path);
            photoGridAdapter.notifyDataSetChanged();
        }
    }
}
Also used : PhotoDirectory(me.iwf.photopicker.entity.PhotoDirectory) FragmentActivity(android.support.v4.app.FragmentActivity) Photo(me.iwf.photopicker.entity.Photo) ImageCaptureManager(me.iwf.photopicker.utils.ImageCaptureManager)

Example 2 with ImageCaptureManager

use of me.iwf.photopicker.utils.ImageCaptureManager in project PhotoPicker by donglua.

the class PhotoPickerFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRetainInstance(true);
    mGlideRequestManager = Glide.with(this);
    directories = new ArrayList<>();
    originalPhotos = getArguments().getStringArrayList(EXTRA_ORIGIN);
    column = getArguments().getInt(EXTRA_COLUMN, DEFAULT_COLUMN_NUMBER);
    boolean showCamera = getArguments().getBoolean(EXTRA_CAMERA, true);
    boolean previewEnable = getArguments().getBoolean(EXTRA_PREVIEW_ENABLED, true);
    photoGridAdapter = new PhotoGridAdapter(getActivity(), mGlideRequestManager, directories, originalPhotos, column);
    photoGridAdapter.setShowCamera(showCamera);
    photoGridAdapter.setPreviewEnable(previewEnable);
    listAdapter = new PopupDirectoryListAdapter(mGlideRequestManager, directories);
    Bundle mediaStoreArgs = new Bundle();
    boolean showGif = getArguments().getBoolean(EXTRA_GIF);
    mediaStoreArgs.putBoolean(EXTRA_SHOW_GIF, showGif);
    MediaStoreHelper.getPhotoDirs(getActivity(), mediaStoreArgs, new MediaStoreHelper.PhotosResultCallback() {

        @Override
        public void onResultCallback(List<PhotoDirectory> dirs) {
            directories.clear();
            directories.addAll(dirs);
            photoGridAdapter.notifyDataSetChanged();
            listAdapter.notifyDataSetChanged();
            adjustHeight();
        }
    });
    captureManager = new ImageCaptureManager(getActivity());
}
Also used : PhotoDirectory(me.iwf.photopicker.entity.PhotoDirectory) PhotoGridAdapter(me.iwf.photopicker.adapter.PhotoGridAdapter) Bundle(android.os.Bundle) PopupDirectoryListAdapter(me.iwf.photopicker.adapter.PopupDirectoryListAdapter) ImageCaptureManager(me.iwf.photopicker.utils.ImageCaptureManager) MediaStoreHelper(me.iwf.photopicker.utils.MediaStoreHelper)

Aggregations

PhotoDirectory (me.iwf.photopicker.entity.PhotoDirectory)2 ImageCaptureManager (me.iwf.photopicker.utils.ImageCaptureManager)2 Bundle (android.os.Bundle)1 FragmentActivity (android.support.v4.app.FragmentActivity)1 PhotoGridAdapter (me.iwf.photopicker.adapter.PhotoGridAdapter)1 PopupDirectoryListAdapter (me.iwf.photopicker.adapter.PopupDirectoryListAdapter)1 Photo (me.iwf.photopicker.entity.Photo)1 MediaStoreHelper (me.iwf.photopicker.utils.MediaStoreHelper)1