-
Notifications
You must be signed in to change notification settings - Fork 0
/
RecipeList_Adapter.java
64 lines (51 loc) · 1.78 KB
/
RecipeList_Adapter.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.foodapp.food.recipe.adapter;
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.foodapp.food.recipe.helper.ImageHelper;
import com.foodapp.food.recipe.model.RecipeItem;
import com.foodapp.food.recipe.R;
import java.util.ArrayList;
public class RecipeList_Adapter extends BaseAdapter
{
private LayoutInflater inflater;
private ArrayList<RecipeItem> recipeList;
private int layout;
private ImageHelper imageHelper = new ImageHelper();
public RecipeList_Adapter(Context context, ArrayList<RecipeItem> recipeList, int layout)
{
this.inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.recipeList = recipeList;
this.layout = layout;
}
@Override
public int getCount() {
return recipeList.size();
}
@Override
public Object getItem(int position) {
return recipeList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
if(convertView==null)
{
convertView=inflater.inflate(layout,parent,false);
}
RecipeItem recipeItem = recipeList.get(position);
ImageView ListView_Image= convertView.findViewById(R.id.listItem_image);
ListView_Image.setImageBitmap(imageHelper.getBitmapFromByteArray(recipeItem.get_thumbnail()));
TextView listView_title=convertView.findViewById(R.id.listItem_title);
listView_title.setText(recipeItem.get_recipeName());
return convertView;
}
}