-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppListAdapter.java
More file actions
50 lines (42 loc) · 1.48 KB
/
Copy pathAppListAdapter.java
File metadata and controls
50 lines (42 loc) · 1.48 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
// AppListAdapter.java
package com.example.appverify;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.List;
public class AppListAdapter extends RecyclerView.Adapter<AppListAdapter.ViewHolder> {
private final List<AppInfo> apps;
public static class ViewHolder extends RecyclerView.ViewHolder {
public TextView appName;
public TextView status;
public ViewHolder(View view) {
super(view);
appName = view.findViewById(R.id.app_name);
status = view.findViewById(R.id.app_status);
}
}
public AppListAdapter(List<AppInfo> apps) {
this.apps = apps;
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.item_app, parent, false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
AppInfo app = apps.get(position);
holder.appName.setText(app.getAppName());
holder.status.setText(app.isOfficial() ? "Official" : "Suspicious");
holder.status.setTextColor(app.isOfficial() ? 0xFF00FF00 : 0xFFFF0000);
}
@Override
public int getItemCount() {
return apps.size();
}
}