MultiMediaPicker/multipleImagePickerLib/src/main/java/com/rahul/media/adapters/VideoPreviewAdapter.java
public class VideoPreviewAdapter extends PagerAdapter {

    private final Context mContext;
    private LayoutInflater mLayoutInflater;
    private ArrayList<CustomGallery> dataT;
    private int playResId = R.drawable.video_play;

    public VideoPreviewAdapter(Context mContext, HashMap<String, CustomGallery> dataT) {
        this.mContext = mContext;
        this.dataT = new ArrayList<>(dataT.values());
        mLayoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    public void setPlayResId(int playResId) {
        this.playResId = playResId;
    }

    public void customNotify(HashMap<String, CustomGallery> dataHashmap) {
        dataT.clear();
        ArrayList<CustomGallery> dataT2 = new ArrayList<CustomGallery>(dataHashmap.values());
        this.dataT.addAll(dataT2);
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return dataT.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public int getItemPosition(Object object) {
        return POSITION_NONE;
    }

    @Override
    public Object instantiateItem(ViewGroup container, final int position) {
        View itemView = mLayoutInflater.inflate(R.layout.video_image_pager_item, container, false);

        final SimpleDraweeView imageView = (SimpleDraweeView) itemView.findViewById(R.id.full_screen_image);

        final ImageView playIcon = (ImageView) itemView.findViewById(R.id.play_icon);
        playIcon.setImageResource(playResId);

        imageView.setImageURI(Uri.parse("file://" + dataT.get(position).sdcardPath));

        container.addView(itemView);
        itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try {
                    Intent intent = new Intent(Intent.ACTION_VIEW);
                    intent.setDataAndType(Uri.parse(dataT.get(position).sdcardPath), "video/*");
                    mContext.startActivity(Intent.createChooser(intent, "Complete action using .."));

                } catch (Exception e) {
                    e.printStackTrace();
                    if (e instanceof ActivityNotFoundException) {
                        Toast.makeText(mContext, "Video Player not found", Toast.LENGTH_SHORT).show();
                    }

                }
            }
        });
        return itemView;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((FrameLayout) object);
    }
}
MultiMediaPicker/multipleImagePickerLib/src/main/java/com/rahul/media/adapters/ImageListRecycleAdapter.java
public class ImageListRecycleAdapter extends RecyclerView.Adapter<ImageListRecycleAdapter.VerticalItemHolder> {

    public ArrayList<CustomGallery> mItems;

    private AdapterView.OnItemClickListener mOnItemClickListener;

    public ImageListRecycleAdapter(Context context, HashMap<String, CustomGallery> imagesUri) {
        this.mItems = new ArrayList<>(imagesUri.values());
    }

    public void removeItem(int position) {
        if (position >= mItems.size()) return;
        mItems.remove(position);
        notifyItemRemoved(position);
    }

    public void customNotify(HashMap<String, CustomGallery> dataT) {
        mItems.clear();
        ArrayList<CustomGallery> dataT2 = new ArrayList<CustomGallery>(dataT.values());
        this.mItems.addAll(dataT2);
        notifyDataSetChanged();
    }

    @Override
    public VerticalItemHolder onCreateViewHolder(ViewGroup container, int viewType) {
        LayoutInflater inflater = LayoutInflater.from(container.getContext());
        View root = inflater.inflate(R.layout.image_strip_view, container, false);

        return new VerticalItemHolder(root, this);
    }

    @Override
    public void onBindViewHolder(VerticalItemHolder itemHolder, int position) {
        CustomGallery item = mItems.get(position);
        itemHolder.setImage(item.sdcardPath);
    }

    @Override
    public int getItemCount() {
        return mItems.size();
    }

    public void setOnItemClickListener(AdapterView.OnItemClickListener onItemClickListener) {
        mOnItemClickListener = onItemClickListener;
    }

    private void onItemHolderClick(VerticalItemHolder itemHolder) {
        if (mOnItemClickListener != null) {
            mOnItemClickListener.onItemClick(null, itemHolder.itemView,
                    itemHolder.getAdapterPosition(), itemHolder.getItemId());
        }
    }

    class VerticalItemHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
        private SquareImageView imageView;
        private ImageListRecycleAdapter mAdapter;

        VerticalItemHolder(View itemView, ImageListRecycleAdapter adapter) {
            super(itemView);
            itemView.setOnClickListener(this);

            mAdapter = adapter;
            imageView = (SquareImageView) itemView.findViewById(R.id.strip_image);
        }

        @Override
        public void onClick(View v) {
            mAdapter.onItemHolderClick(this);
        }

        public void setImage(final String thumbPath) {
            Context mContext = imageView.getContext();
            byte[] imageByte = MediaSingleTon.getInstance().getImageByte(thumbPath);
            if (imageByte != null) {
                Glide.with(mContext)
                        .load(imageByte)
                        .centerCrop()
                        .diskCacheStrategy(DiskCacheStrategy.RESULT)
                        .override(200, 200)
                        .into(imageView);
            } else {
                byte[] thumbnail = MediaUtility.getThumbnail(thumbPath);
                if (thumbnail != null) {
                    MediaSingleTon.getInstance().putImageByte(thumbPath, thumbnail);
                    Glide.with(mContext)
                            .load(thumbnail)
                            .centerCrop()
                            .diskCacheStrategy(DiskCacheStrategy.RESULT)
                            .override(200, 200)
                            .into(imageView);
                } else {
                    Glide.with(mContext)
                            .load(Uri.parse("file://" + thumbPath))
                            .asBitmap()
                            .diskCacheStrategy(DiskCacheStrategy.RESULT)
                            .override(200, 200) // resizes the image to these dimensions (in pixel). does not respect aspect ratio
                            .centerCrop() // this cropping technique scales the image so that it fills the requested bounds and then crops the extra.
                            .into(imageView);

                }
            }
//            imageView.setImageURI(Uri.parse("file://" + url));
        }
    }

}
MultiMediaPicker/multipleImagePickerLib/src/main/java/com/msupport/MSupport.java
public class MSupport {

    private static boolean isMSupportDevice(Context ctx) {
        return Build.VERSION.SDK_INT >= MSupportConstants.SDK_VERSION;
    }

    public static boolean checkMultiplePermission(final Activity mActivity, String[] permissionsList2, final int requestCode) {
        if (MSupport.isMSupportDevice(mActivity)) {

            List<String> permissionsNeeded = new ArrayList<>();
            final List<String> permissionsList = new ArrayList<>();

            for (String permission : permissionsList2) {
                if (addPermission(mActivity, permission, permissionsList)) {
                    permissionsNeeded.add(MSupportConstants.getPermissionRationaleMessage(permission));
                }
            }

            if (permissionsList.size() > 0) {
                if (permissionsNeeded.size() > 0) {
                    // Need Rationale case
                    String message = "You need to grant access to " + permissionsNeeded.get(0);
                    for (int i = 1; i < permissionsNeeded.size(); i++)
                        message = message + ", " + permissionsNeeded.get(i);
                    showMessageOKCancel(mActivity, message,
                            new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    requestPermissions(permissionsList, null, mActivity,
                                            requestCode);
                                }
                            });
                    return false;
                }
                requestPermissions(permissionsList, null, mActivity,
                        requestCode);
                return false;
            } else
                return true;
        } else
            return true;
    }

    @TargetApi(Build.VERSION_CODES.M)
    private static boolean addPermission(final Activity mActivity, String permission, List<String> permissionsList) {
        if (mActivity.checkSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) {
            permissionsList.add(permission);
            // Check for Rationale Option
            if (mActivity.shouldShowRequestPermissionRationale(permission))
                return true;
        }
        return false;
    }

    @TargetApi(Build.VERSION_CODES.M)
    public static boolean checkPermission(final Activity mActivity, final Fragment fragment, String[] permissionSet,
                                          final int requestCode) {

        if (MSupport.isMSupportDevice(mActivity)) {

            final List<String> permissions = new ArrayList<>();
            for (final String aPermissionSet : permissionSet) {
                int hasPermission = mActivity.checkSelfPermission(aPermissionSet);
                if (hasPermission != PackageManager.PERMISSION_GRANTED) {

                    if (ActivityCompat.shouldShowRequestPermissionRationale(mActivity, aPermissionSet)) {

                        String msg = "";
                        if (aPermissionSet.equals(MSupportConstants.CAMERA)) {
                            msg = mActivity.getString(R.string.camera_permission_rationale);
                        } else if (aPermissionSet.equals(MSupportConstants.WRITE_EXTERNAL_STORAGE)) {
                            msg = mActivity.getString(R.string.storage_permission_rationale);
                        }

                        showMessageOKCancel(mActivity, msg,
                                new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {

                                        permissions.add(aPermissionSet);
                                        requestPermissions(permissions, fragment, mActivity, requestCode);
                                    }
                                });
                    } else {
                        permissions.add(aPermissionSet);
                        requestPermissions(permissions, fragment, mActivity, requestCode);
                    }
                }
            }

            if (!permissions.isEmpty()) {
                if (fragment != null)
                    fragment.requestPermissions(permissions.toArray(new String[permissions.size()]), requestCode);
                else
                    mActivity.requestPermissions(permissions.toArray(new String[permissions.size()]), requestCode);
                return false;
            } else
                return true;

        } else
            return true;
    }


    @TargetApi(23)
    public static boolean checkPermissionWithRationale(final Activity mActivity, final Fragment fragment,
                                                       final String permission, final int requestCode) {

        if (MSupport.isMSupportDevice(mActivity)) {

            final List<String> permissions = new ArrayList<>();
            int hasPermission = mActivity.checkSelfPermission(permission);

            if (hasPermission != PackageManager.PERMISSION_GRANTED)
                if (ActivityCompat.shouldShowRequestPermissionRationale(mActivity, permission)) {

                    String msg = "";
                    if (requestCode == MSupportConstants.CAMERA_PERMISSIONS_REQUEST_CODE) {
                        msg = mActivity.getString(R.string.camera_permission_rationale);
                    } else if (requestCode == MSupportConstants.REQUEST_STORAGE_READ_WRITE) {
                        msg = mActivity.getString(R.string.storage_permission_rationale);
                    }

                    showMessageOKCancel(mActivity, msg,
                            new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {

                                    permissions.add(permission);
                                    requestPermissions(permissions, fragment, mActivity, requestCode);
                                }
                            });


                    return false;

                } else {
                    permissions.add(permission);
                    requestPermissions(permissions, fragment, mActivity, requestCode);
                    return false;
                }
            else
                return true;

        }
        return true;
    }

    @TargetApi(23)
    private static boolean requestPermissions(List<String> permissions, Fragment fragment, Activity mActivity, int requestCode) {
        if (!permissions.isEmpty()) {
            if (fragment != null)
                fragment.requestPermissions(permissions.toArray(new String[permissions.size()]), requestCode);
            else
                mActivity.requestPermissions(permissions.toArray(new String[permissions.size()]), requestCode);
            return false;
        } else
            return true;
    }

    private static void showMessageOKCancel(Activity activity, String message
            , DialogInterface.OnClickListener okListener) {
        new AlertDialog.Builder(new ContextThemeWrapper(activity, R.style.Theme_AppCompat_Dialog_Alert))
                .setMessage(message)
                .setPositiveButton("OK", okListener)
                .create()
                .show();
    }


}
MultiMediaPicker/multipleImagePickerLib/src/main/java/com/rahul/media/videomodule/VideoAlbumActivity.java
public class VideoAlbumActivity extends AppCompatActivity {

    private RecyclerView recyclerView;
    private RelativeLayout noAlbum;
    private ArrayList<GalleryPhotoAlbum> arrayListAlbums = new ArrayList<>();
    private int pickCount;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_photo_album);
        pickCount = getIntent().getIntExtra("pickCount", 1);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        noAlbum = (RelativeLayout) findViewById(R.id.no_album);
        setSupportActionBar(toolbar);
        toolbar.setBackgroundColor(Define.ACTIONBAR_COLOR);

        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        recyclerView = (RecyclerView) findViewById(R.id.recyclerview);
        recyclerView.setLayoutManager(new GridLayoutManager(this, MeasureUtils.getAlbumsColumns(getApplicationContext())));
        recyclerView.addItemDecoration(new ItemOffsetDecoration(4));

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            boolean isStoragePermissionGiven = MSupport.checkPermissionWithRationale(VideoAlbumActivity.this,
                    null, MSupportConstants.WRITE_EXTERNAL_STORAGE, MSupportConstants.REQUEST_STORAGE_READ_WRITE);
            if (isStoragePermissionGiven)
                new GetVideoListAsync().execute();
        } else
            new GetVideoListAsync().execute();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == ENTER_ALBUM_REQUEST_CODE) {
            if (resultCode == RESULT_OK) {
                setResult(RESULT_OK, data);
                finish();
            }
        }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode,
                                           String permissions[], int[] grantResults) {

        switch (requestCode) {
            case MSupportConstants.REQUEST_STORAGE_READ_WRITE: {
                if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                    new GetVideoListAsync().execute();
                } else {
                    Toast.makeText(VideoAlbumActivity.this, "Storage permission not granted", Toast.LENGTH_SHORT).show();
                    finish();
                }
            }
        }
    }

    private void getVideoList() {

        // which image properties are we querying
        String[] PROJECTION_BUCKET = {MediaStore.Video.VideoColumns.BUCKET_ID,
                MediaStore.Video.VideoColumns.BUCKET_DISPLAY_NAME, MediaStore.Video.VideoColumns.DATE_TAKEN,
                MediaStore.Video.VideoColumns.DATA};
        // We want to order the albums by reverse chronological order. We abuse
        // the
        // "WHERE" parameter to insert a "GROUP BY" clause into the SQL
        // statement.
        // The template for "WHERE" parameter is like:
        // SELECT ... FROM ... WHERE (%s)
        // and we make it look like:
        // SELECT ... FROM ... WHERE (1) GROUP BY 1,(2)
        // The "(1)" means true. The "1,(2)" means the first two columns
        // specified
        // after SELECT. Note that because there is a ")" in the template, we
        // use
        // "(2" to match it.
        String BUCKET_GROUP_BY = "1) GROUP BY 1,(2";
        String BUCKET_ORDER_BY = "MAX(datetaken) DESC";

        // Get the base URI for the People table in the Contacts content
        // provider.
        Uri images = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;

        Cursor cur = getContentResolver().query(images, PROJECTION_BUCKET,
                BUCKET_GROUP_BY, null, BUCKET_ORDER_BY);

        Log.v("ListingImages", " query count=" + cur.getCount());

        GalleryPhotoAlbum album;

        if (cur.moveToFirst()) {
            String bucket;
            String date;
            String data;
            long bucketId;

            int bucketColumn = cur
                    .getColumnIndex(MediaStore.Video.Media.BUCKET_DISPLAY_NAME);

            int dateColumn = cur
                    .getColumnIndex(MediaStore.Video.Media.DATE_TAKEN);
            int dataColumn = cur.getColumnIndex(MediaStore.Video.Media.DATA);

            int bucketIdColumn = cur
                    .getColumnIndex(MediaStore.Video.Media.BUCKET_ID);

            do {
                // Get the field values
                bucket = cur.getString(bucketColumn);
                date = cur.getString(dateColumn);
                data = cur.getString(dataColumn);
                bucketId = cur.getInt(bucketIdColumn);

                if (bucket != null && bucket.length() > 0) {
                    album = new GalleryPhotoAlbum();
                    album.setBucketId(bucketId);
                    album.setBucketName(bucket);
                    album.setDateTaken(date);
                    album.setData(data);
                    videoCountByAlbum(album);
                    arrayListAlbums.add(album);
                    // Do something with the values.
                    Log.v("ListingImages", " bucket=" + bucket
                            + "  date_taken=" + date + "  _data=" + data
                            + " bucket_id=" + bucketId);
                }

            } while (cur.moveToNext());
        }
        cur.close();
    }

    private void videoCountByAlbum(GalleryPhotoAlbum bucketName) {

        try {
            final String orderBy = MediaStore.Video.Media.DATE_TAKEN;
            String searchParams = null;
            String bucket = bucketName.getBucketName();
            searchParams = "bucket_display_name = \"" + bucket + "\"";

            // final String[] columns = { MediaStore.Video.Media.DATA,
            // MediaStore.Video.Media._ID };
            Cursor mVideoCursor = getContentResolver().query(
                    MediaStore.Video.Media.EXTERNAL_CONTENT_URI, null,
                    searchParams, null, orderBy + " DESC");

            if (mVideoCursor != null && mVideoCursor.moveToFirst()) {
                String filePath = mVideoCursor.getString(mVideoCursor.getColumnIndex(MediaStore.Video.Media.DATA));
                bucketName.setTotalCount(mVideoCursor.getCount());
                bucketName.setFilePath(filePath);

                return;
            }
            mVideoCursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }


    private class GetVideoListAsync extends AsyncTask<Void, Void, Boolean> {

        @Override
        protected Boolean doInBackground(Void... params) {
            arrayListAlbums.clear();
            getVideoList();
            return !arrayListAlbums.isEmpty();
        }

        @Override
        protected void onPostExecute(Boolean result) {
            super.onPostExecute(result);
            if (result) {
                noAlbum.setVisibility(View.GONE);
                VideoAlbumListAdapter galleryAlbumAdapter = new VideoAlbumListAdapter(
                        VideoAlbumActivity.this, arrayListAlbums) {
                    @Override
                    public void onItemClick(ViewHolder holder) {
                        Intent intent = new Intent(VideoAlbumActivity.this, VideoAlbumGalleryActivity.class);
                        intent.putExtra("bucketName", arrayListAlbums.get(holder.getAdapterPosition()).getBucketName());
                        intent.putExtra("pickCount", pickCount);
                        startActivityForResult(intent, ENTER_ALBUM_REQUEST_CODE);
                    }
                };
                recyclerView.setAdapter(galleryAlbumAdapter);
//                GetVideoThumbnailAsync thumbnailAsync = new GetVideoThumbnailAsync();
//                thumbnailAsync.execute();
            } else {
                noAlbum.setVisibility(View.VISIBLE);
            }
        }
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                finish();
                break;
        }
        return super.onOptionsItemSelected(item);
    }


    /*private class GetVideoThumbnailAsync extends AsyncTask<Void, Void, Void> {
        @Override
        protected Void doInBackground(Void... voids) {
            for (int i = 0; i < arrayListAlbums.size(); i++) {

            }
            Bitmap bmp = null;
            try {
                bmp = ImageLoader.getInstance().getMemoryCache().get(Uri.fromFile(new File(filePath)).toString() + "_");
            } catch (Exception e) {
                Log.e(ProcessGalleryFile.class.getSimpleName(), "" + e);
            }
            if (bmp == null) {
                try {
                    bmp = ThumbnailUtils.createVideoThumbnail(filePath, MediaStore.Images.Thumbnails.MINI_KIND);
                    if (bmp != null) {
                        ImageLoader.getInstance().getMemoryCache().put(Uri.fromFile(new File(filePath)).toString() + "_", bmp);
                    }
                } catch (Exception e) {
                    Log.e(getClass().getSimpleName(), "Exception when rotating thumbnail for gallery", e);
                } catch (OutOfMemoryError e) {
                    Log.e(ProcessGalleryFile.class.getSimpleName(), "" + e);
                }
            }

            return null;
        }
    }*/
}
MultiMediaPicker/multipleImagePickerLib/src/main/java/com/rahul/media/model/CustomGallery.java
public class CustomGallery {

	public String sdcardPath;
	public Uri sdCardUri;
}
MultiMediaPicker/multipleImagePickerLib/src/main/java/com/rahul/media/model/Define.java
public class Define {
    public static final int MIN_MEDIA_COUNT = 5;
    public static String MEDIA_PROVIDER = "";
    public static int ALBUM_THUMBNAIL_SIZE = 70;


    //    public static int ACTIONBAR_COLOR = "#3F51B5";
    public static int ACTIONBAR_COLOR = Color.parseColor("#3F51B5");
    //    public static int STATUSBAR_COLOR = "#303F9F";
    public static int STATUSBAR_COLOR = Color.parseColor("#303F9F");

    public static final String INTENT_PATH = "all_path";
    public static int ENTER_ALBUM_REQUEST_CODE = 123;

}
MultiMediaPicker/multipleImagePickerLib/src/main/java/com/msupport/MSupportConstants.java
public class MSupportConstants {
    public static final int SDK_VERSION = 23;
    public static final int CAMERA_PERMISSIONS_REQUEST_CODE = 123;
    public static final int REQUEST_CODE_ASK_MULTIPLE_PERMISSIONS = 124;
    public static final int REQUEST_STORAGE_READ_WRITE = 2;

    public static final String SEND_SMS = Manifest.permission.SEND_SMS;
    public static final String CAMERA = Manifest.permission.CAMERA;
    public static final String CALL_PHONE = Manifest.permission.CALL_PHONE;
    public static final String INTERNET_ACCESS_FULL = Manifest.permission.INTERNET;
    public static final String AUDIO_SETTING = Manifest.permission.MODIFY_AUDIO_SETTINGS;
    public static final String RECORD_AUDIO = Manifest.permission.RECORD_AUDIO;
    public static final String BLUETOOTH = Manifest.permission.BLUETOOTH;
    public static final String BLUETOOTH_ADMIN = Manifest.permission.BLUETOOTH_ADMIN;
    public static final String WAKE_LOCK = Manifest.permission.WAKE_LOCK;
    public static final String GET_ACCOUNT = Manifest.permission.GET_ACCOUNTS;
    public static final String VIBRATE = Manifest.permission.VIBRATE;
    public static final String WRITE_EXTERNAL_STORAGE = Manifest.permission.WRITE_EXTERNAL_STORAGE;
    public static final String READ_EXTERNAL_STORAGE = Manifest.permission.READ_EXTERNAL_STORAGE;
    public static final String ACCESS_WIFI_STATE = Manifest.permission.ACCESS_WIFI_STATE;
    public static final String ACCESS_NETWORK_STATE = Manifest.permission.ACCESS_NETWORK_STATE;
    public static final String ACCESS_FINE_LOCATION = Manifest.permission.ACCESS_FINE_LOCATION;
    public static final String ACCESS_COARSE_LOCATION = Manifest.permission.ACCESS_COARSE_LOCATION;
    public static final String READ_PHONE_STATE = Manifest.permission.READ_PHONE_STATE;
    public static final String GET_ACCOUNTS = Manifest.permission.GET_ACCOUNTS;

    public static String getPermissionRationaleMessage(String permission) {
        switch (permission) {
            case ACCESS_COARSE_LOCATION:
            case ACCESS_FINE_LOCATION:
                return "GPS";
            case CAMERA:
                return "CAMERA";
            case WRITE_EXTERNAL_STORAGE:
            case READ_EXTERNAL_STORAGE:
                return "STORAGE";
            default:
                return "PERMISSION";
        }
    }
}
MultiMediaPicker/multipleImagePickerLib/src/main/java/com/rahul/media/model/VideoQuality.java
public enum VideoQuality {
    HIGH_QUALITY(1), LOW_QUALITY(0);

    int quality;

    VideoQuality(int i) {
        quality = i;
    }

    public int getQuality() {
        return quality;
    }
}
MultiMediaPicker/multipleImagePickerLib/src/main/java/com/rahul/media/utils/MediaUtility.java
public class MediaUtility {
    public static String getUserImageDir(Context mContext) {
        return Environment.getExternalStorageDirectory().getAbsolutePath()
                + "/MultipleImageCache/data/" + mContext.getPackageName() + "/images";
    }

    public static File initializeImageLoader(Context mContext) {
        File cacheDir = new File(getUserImageDir(mContext));
        if (!cacheDir.exists())
            cacheDir.mkdirs();
        return cacheDir;
    }

    public static Uri createImageFile(Context mContext) throws IOException {

        File image = null;

        // Create an image file name
        String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
        String imageFileName = "JPEG_" + timeStamp + "_";

        if (MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
            File storageDir = new File(Environment.getExternalStorageDirectory(),
                    mContext.getString(R.string.imagepicker_parent));
            boolean parentCreationResult = storageDir.mkdirs();
            image = File.createTempFile(
                    imageFileName,  /* prefix */
                    ".jpg",         /* suffix */
                    storageDir      /* directory */
            );

        } else {

            File storageDir = mContext.getFilesDir();
            image = File.createTempFile(
                    imageFileName,  /* prefix */
                    ".jpg",         /* suffix */
                    storageDir      /* directory */
            );

        }

        // Save a file: path for use with ACTION_VIEW intents
        Log.d(CameraPickActivity.class.getSimpleName(), "file:" + image.getAbsolutePath());
        return Uri.fromFile(image);
    }

    public static Uri createVideoFile(Context mContext) throws IOException {

        File image = null;

        // Create an image file name
        String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
        String imageFileName = "VID_" + timeStamp + "_";

        if (MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
            File storageDir = new File(Environment.getExternalStorageDirectory(),
                    mContext.getString(R.string.imagepicker_parent));
            boolean parentCreationResult = storageDir.mkdirs();
            image = File.createTempFile(
                    imageFileName,  /* prefix */
                    ".mp4",         /* suffix */
                    storageDir      /* directory */
            );

        } else {

            File storageDir = mContext.getFilesDir();
            image = File.createTempFile(
                    imageFileName,  /* prefix */
                    ".mp4",         /* suffix */
                    storageDir      /* directory */
            );

        }

        // Save a file: path for use with ACTION_VIEW intents
        Log.d(CameraPickActivity.class.getSimpleName(), "file:" + image.getAbsolutePath());
        return Uri.fromFile(image);
    }

    public static byte[] getThumbnail(String path) {
        ExifInterface exif;
        try {
            exif = new ExifInterface(path);
        } catch (IOException e) {
            return null;
        }
        byte[] imageData = exif.getThumbnail();
        if (imageData != null)
            return imageData;
        return null;
    }

}
MultiMediaPicker/multipleImagePickerLib/src/main/java/com/rahul/media/utils/ViewPagerSwipeLess.java
public class ViewPagerSwipeLess extends ViewPager {

    private boolean isPagingEnabled = false;

    public ViewPagerSwipeLess(Context context) {
        super(context);
    }

    public ViewPagerSwipeLess(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        return this.isPagingEnabled && super.onTouchEvent(event);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        return this.isPagingEnabled && super.onInterceptTouchEvent(event);
    }

    public void setPagingEnabled(boolean b) {
        this.isPagingEnabled = b;
    }
}
MultiMediaPicker/multipleImagePickerLib/src/main/java/com/rahul/media/utils/ProcessGalleryFile.java
public class ProcessGalleryFile extends AsyncTask<Void, Void, Bitmap> {

    private static int WIDTH = 80;
    private static int HEIGHT = 80;

    ImageView photoHolder;
    TextView durationHolder;
    MediaType type;
    String filePath;
    MediaMetadataRetriever retriever = new MediaMetadataRetriever();

    public ProcessGalleryFile(ImageView photoHolder, TextView durationHolder, String filePath, MediaType type) {
        HEIGHT = WIDTH = (int) photoHolder.getContext().getResources().getDimension(R.dimen.thumbnail_width);
        this.filePath = filePath;
        this.durationHolder = durationHolder;
        this.photoHolder = photoHolder;
        this.type = type;
        try {
            ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(photoHolder.getContext()));
        } catch (Exception ignored) {

        }
    }

    @Override
    protected Bitmap doInBackground(Void... params) {

        Bitmap bmp = null;
        Log.d(getClass().getSimpleName(), "" + Thread.getAllStackTraces().keySet().size());
        if (type != MediaType.PHOTO) {
            try {
                bmp = ImageLoader.getInstance().getMemoryCache().get(Uri.fromFile(new File(filePath)).toString() + "_");
            } catch (Exception e) {
                Log.e(ProcessGalleryFile.class.getSimpleName(), "" + e);
            }
            if (bmp == null) {
                try {
                    bmp = ThumbnailUtils.createVideoThumbnail(filePath, MediaStore.Images.Thumbnails.MINI_KIND);
                    if (bmp != null) {
                        ImageLoader.getInstance().getMemoryCache().put(Uri.fromFile(new File(filePath)).toString() + "_", bmp);
                    }
                } catch (Exception e) {
                    Log.e(getClass().getSimpleName(), "Exception when rotating thumbnail for gallery", e);
                } catch (OutOfMemoryError e) {
                    Log.e(ProcessGalleryFile.class.getSimpleName(), "" + e);
                }
            }
        }
        return bmp;
    }

    @Override
    protected void onPostExecute(Bitmap result) {
        super.onPostExecute(result);
        if (type == MediaType.PHOTO) {
            durationHolder.setVisibility(View.GONE);
            ImageAware aware = new ImageViewAware(photoHolder) {

                @Override
                public int getWidth() {
                    return WIDTH;
                }

                @Override
                public int getHeight() {
                    return HEIGHT;
                }
            };
            ImageLoader.getInstance().displayImage(Uri.fromFile(new File(filePath)).toString(), aware,
                    ImageOption.GALLERY_OPTIONS.getDisplayImageOptions());
        } else {
            durationHolder.setText(getDurationMark(filePath, retriever));
            durationHolder.setVisibility(View.VISIBLE);
            photoHolder.setImageBitmap(result);
        }
    }

    public static String getDurationMark(String filePath, MediaMetadataRetriever retriever) {
        try {
            retriever.setDataSource(filePath);
        } catch (Exception e) {
            Log.e("getDurationMark", e.toString());
            return "?:??";
        }
        String time = null;

        //fix for the gallery picker crash
        // if it couldn't detect the media file
        try {
            Log.e("file", filePath);

            time = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
        } catch (Exception ex) {
            Log.e("getDurationMark", ex.toString());
        }

        //fix for the gallery picker crash
        // if it couldn't extractMetadata() of a media file
        //time was null
        time = time == null ? "0" : time.isEmpty() ? "0" : time;
        //bam crash - no more :)
        int timeInMillis = Integer.parseInt(time);
        int duration = timeInMillis / 1000;
        int hours = duration / 3600;
        int minutes = (duration % 3600) / 60;
        int seconds = duration % 60;
        StringBuilder sb = new StringBuilder();
        if (hours > 0) {
            sb.append(hours).append(":");
        }
        if (minutes < 10) {
            sb.append("0").append(minutes);
        } else {
            sb.append(minutes);
        }
        sb.append(":");
        if (seconds < 10) {
            sb.append("0").append(seconds);
        } else {
            sb.append(seconds);
        }
        return sb.toString();
    }

    @Override
    public int hashCode() {
        return filePath != null ? filePath.hashCode() : super.hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if (o == null || !(o instanceof ProcessGalleryFile)) return false;
        ProcessGalleryFile file = (ProcessGalleryFile) o;
        return filePath != null && file.filePath != null && filePath.equals(file.filePath);
    }
}


Question: package com.rahul.media.activity;
import android.annotation.SuppressLint;
import android.app.ProgressDialog;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.media.ThumbnailUtils;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.support.v4.content.FileProvider;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Toast;
import com.msupport.MSupport;
import com.msupport.MSupportConstants;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.rahul.media.R;
import com.rahul.media.adapters.ImageListRecycleAdapter;
import com.rahul.media.adapters.VideoPreviewAdapter;
import com.rahul.media.model.CustomGallery;
import com.rahul.media.model.Define;
import com.rahul.media.model.VideoQuality;
import com.rahul.media.utils.MediaUtility;
import com.rahul.media.utils.ProcessGalleryFile;
import com.rahul.media.utils.ViewPagerSwipeLess;
import com.rahul.media.videomodule.VideoAlbumActivity;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;




/**
 * Created by rahul on 22/5/15.
 */
public class VideoPickActivity extends AppCompatActivity {
    private static final int ACTION_REQUEST_VIDEO_FROM_CAMERA = 201;
    private static final int ACTION_REQUEST_VIDEO_FROM_GALLERY = 202;
    private AlertDialog alertDialog;
    private ViewPagerSwipeLess mPager;
    private HashMap<String, CustomGallery> dataT;
    private VideoPreviewAdapter adapter;
    private ImageListRecycleAdapter mImageListAdapter;
    private long videoSize;
    private int videoDuration;
Answer:     private int videoQuality = VideoQuality.HIGH_QUALITY.getQuality();