package com.example.TreballFiGrau;

import io.vov.vitamio.widget.VideoView;



import java.util.ArrayList;

import android.content.Context;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

import com.squareup.picasso.Picasso;

public class NoticiaCreadaGAVideos extends BaseAdapter {
	public static Context mContext;
	public static ArrayList<String> mThumbIds = new ArrayList<String>();

    public NoticiaCreadaGAVideos(Context c) {
        mContext = c;
    }

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

    @Override
    public String getItem(int posicion) {
    	Log.d("aki","dintre fet item ");
        return mThumbIds.get(posicion);
    }

    public long getItemId(int position) {
        return 0;
    }

    // create a new ImageView for each item referenced by the Adapter
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
    	io.vov.vitamio.widget.VideoView mVideoView;
        if (convertView == null) {  // if it's not recycled, initialize some attributes
        	mVideoView = new VideoView(mContext);
        	mVideoView.setLayoutParams(new GridView.LayoutParams(85, 85));
        	//mVideoView.setScrollY(ImageView.ScaleType.CENTER_CROP);
        	mVideoView.setPadding(8, 8, 8, 8);
        } else {
        	mVideoView = (VideoView) convertView;
        }

        //imageView.setImageResource(mThumbIds.get(position));
        Log.d("aki","dintre adapter "+mThumbIds.get(position));
        Log.d("aki","dintre adapter "+mThumbIds.size());
         //mVideoView.setImageBitmap(BitmapFactory.decodeFile(mThumbIds.get(position)));
        //Uri uri=Uri.parse(mThumbIds.get(position));


        //mVideoView.setVideoURI(uri);
        mVideoView.setVideoPath(mThumbIds.get(position));
        mVideoView.start();
        return mVideoView;
    }
    
   
    

 
    
}
