Created
March 15, 2016 15:43
-
-
Save AhmedBadrSayed/65eb2fc285d9f21ac18f to your computer and use it in GitHub Desktop.
MoviesGridAdapter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.projects.ahmedbadr.moviesapp.Adapters; | |
import android.content.Context; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.BaseAdapter; | |
import android.widget.ImageView; | |
import android.widget.TextView; | |
import com.projects.ahmedbadr.moviesapp.R; | |
import com.squareup.picasso.Picasso; | |
import java.util.ArrayList; | |
/** | |
* Created by Ahmed Badr for MoviesApp on 14/3/2016. | |
*/ | |
public class MoviesGridAdapter extends BaseAdapter { | |
Context activity; | |
ArrayList<String> Posters = new ArrayList<String>(); | |
public MoviesGridAdapter(ArrayList<String> Posters, Context activity) | |
{ | |
this.Posters = Posters; | |
this.activity = activity; | |
} | |
@Override | |
public int getCount() { | |
return Posters.size(); | |
} | |
@Override | |
public Object getItem(int position) { | |
return Posters.get(position); | |
} | |
@Override | |
public long getItemId(int position) { | |
return 0; | |
} | |
@Override | |
public View getView(int position, View convertView, ViewGroup parent) { | |
LayoutInflater inflater = (LayoutInflater) activity.getSystemService(activity.LAYOUT_INFLATER_SERVICE); | |
convertView = inflater.inflate(R.layout.movie_view,null); | |
ImageView poster_image = (ImageView) convertView.findViewById(R.id.movie_poster); | |
Picasso.with(activity).load(Posters.get(position)).into(poster_image); | |
return poster_image; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment