-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPostadpter.java
More file actions
52 lines (44 loc) · 1.8 KB
/
Postadpter.java
File metadata and controls
52 lines (44 loc) · 1.8 KB
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
package com.pranay.mynews;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView.Adapter;
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
import com.bumptech.glide.Glide;
import java.util.ArrayList;
import java.util.List;
public class Postadpter extends Adapter<postviewholder> {
private List<Article> articles;
private Context context;
public class postviewholder extends ViewHolder {
TextView description;
ImageView imageView;
TextView posttitle;
public postviewholder(View itemView) {
super(itemView);
this.imageView = (ImageView) itemView.findViewById(C0548R.C0550id.postimg);
this.posttitle = (TextView) itemView.findViewById(C0548R.C0550id.posttitle);
this.description = (TextView) itemView.findViewById(C0548R.C0550id.description);
}
}
public Postadpter(Context context2, List<Article> articles2) {
this.context = context2;
this.articles = articles2;
}
public postviewholder onCreateViewHolder(ViewGroup parent, int viewType) {
return new postviewholder(LayoutInflater.from(this.context).inflate(C0548R.layout.item, parent, false));
}
public void onBindViewHolder(postviewholder holder, int position) {
Article article = (Article) this.articles.get(position);
holder.posttitle.setText(article.getTitle());
holder.description.setText(article.getDescription());
new ArrayList();
Glide.with(this.context).load(article.getUrlToImage()).into(holder.imageView);
}
public int getItemCount() {
return this.articles.size();
}
}