Load into gallery also videos and images from specific folder
<p>I'm trying to load also videos and images into a Gallery object.
I don't need to see a video in the gallery only the first frame or something like this.</p>

<p>Then, after pressing on image from gallery I want that the image shown in image switch and if video was chosen shown the video on the appropriate object.</p>

<p>for now I succeeded to implement it only with images.</p>

<p>how can I expand this code to work also with videos?</p>

<pre><code> private OnClickListener onClickListener =new OnClickListener(){ 

    // @Override
     public void onClick(View v) {

         switch (v.getId()){
case R.id.BtnGetVideo:
                 Intent VideoIntent = new Intent (android.provider.MediaStore.ACTION_VIDEO_CAPTURE);

                 String videoFileName = "";
                 String timeStampVideo = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());


                 SetPathIfNotExist(PATH);
                 videoFileName = timeStampVideo + ".mp4";

                 File video = new File(PATH,videoFileName);
                 Uri uriSavedVideo = Uri.fromFile(video);
                 VideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedVideo);

                 startActivityForResult(VideoIntent,VIDEO_REQUEST);




private void setAllPicsAndVideos(){
        File images  = new File(PATH);
        File[] imagelist = images.listFiles(new FilenameFilter() {

            @Override
            public boolean accept(File dir, String filename) {
                 return ((filename.endsWith(".jpg"))||(filename.endsWith(".png"))||(filename.endsWith(".mp4")));  
            }
        });
        /* There isn't enough memory to open up more than a couple camera photos */
        /* So pre-scale the target bitmap into which the file is decoded */

        /* Get the size of the ImageView */
        int targetW = 350;//iSwitcher.getWidth();
        int targetH = 220;//iSwitcher.getHeight();


        BitmapFactory.Options bmOptions = new BitmapFactory.Options();


        Bitmap[] Tempbitmap = null;
        mFiles = new String[imagelist.length];
        int photoW[] = null;
        int photoH[] = null; 
        int scaleFactor[] = null ;

        photoW = new int[imagelist.length];
        photoH = new int[imagelist.length];
        scaleFactor = new int[imagelist.length];
        Tempbitmap = new Bitmap[imagelist.length];
        bitmap = new Bitmap[imagelist.length];
        for(int i= 0 ; i&lt; imagelist.length; i++)  
            {               
                bmOptions.inJustDecodeBounds = true;
                mFiles[i] = imagelist[i].getAbsolutePath();  
                Tempbitmap[i] = BitmapFactory.decodeFile(mFiles[i], bmOptions);
                /* Get the size of the image */

                photoW[i] = bmOptions.outWidth;
                photoH[i] = bmOptions.outHeight;
                /* Figure out which way needs to be reduced less */

                if((targetW &gt; 0)  || (targetH &gt; 0 ))
                    scaleFactor[i]  = Math.min(photoW[i]/targetW, photoH[i]/targetH);               
                /* Set bitmap options to scale the image decode target */
                bmOptions.inJustDecodeBounds = false;
                bmOptions.inSampleSize = scaleFactor[i];
                bmOptions.inPurgeable = true;
                try{
                /* Decode the JPEG file into a Bitmap */
                Tempbitmap[i] = BitmapFactory.decodeFile(mFiles[i], bmOptions);

                int tempW = Tempbitmap[i].getWidth();
                int tempH = Tempbitmap[i].getHeight();


                if (tempW&gt;tempH){
                    Matrix matrix = new Matrix();
                    matrix.postRotate(90);
                    bitmap[i] = Bitmap.createBitmap(Tempbitmap[i],0,0,tempW,tempH,matrix,false);
                }
                else {
                    bitmap[i] = Tempbitmap[i];
                }
                //iSwitcher.setImageDrawable(new BitmapDrawable(getResources(),(bitmap[i])));
                } catch (OutOfMemoryError error) {
                    error.printStackTrace();
                }

            }  


        mUrls = new Uri[mFiles.length];  

        for(int i=0; i &lt; mFiles.length; i++)  
                {  
                    mUrls[i] = Uri.parse(mFiles[i]);     
                }


    }
</code></pre>
