60 lines
1.9 KiB
Java
60 lines
1.9 KiB
Java
package com.xxpatx.os.adapter;
|
|
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.TextView;
|
|
|
|
import androidx.annotation.NonNull;
|
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
import com.xxpatx.os.R;
|
|
import com.xxpatx.os.activity.emergency.EmergencyActivity;
|
|
import com.xxpatx.os.bean.Contact;
|
|
|
|
import java.util.List;
|
|
|
|
public class SosNnmberAdapter extends RecyclerView.Adapter<SosNnmberAdapter.ViewHolder> {
|
|
private List<Contact> phoneNumberList;
|
|
private Context mContext;
|
|
|
|
public void setPhoneNumberList(List<Contact> contactList) {
|
|
this.phoneNumberList = contactList;
|
|
notifyDataSetChanged();
|
|
}
|
|
|
|
@NonNull
|
|
@Override
|
|
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
|
mContext = parent.getContext();
|
|
return new SosNnmberAdapter.ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_sosnumber, parent, false));
|
|
}
|
|
|
|
@Override
|
|
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
|
Contact contact = phoneNumberList.get(position);
|
|
holder.tv_name.setText(contact.getName());
|
|
holder.tv_number.setText(contact.getMobile());
|
|
}
|
|
|
|
@Override
|
|
public int getItemCount() {
|
|
return phoneNumberList == null ? 0 : phoneNumberList.size();
|
|
}
|
|
|
|
static class ViewHolder extends RecyclerView.ViewHolder {
|
|
ConstraintLayout root;
|
|
TextView tv_name,tv_number;
|
|
|
|
ViewHolder(@NonNull View itemView) {
|
|
super(itemView);
|
|
root = itemView.findViewById(R.id.root);
|
|
tv_number = itemView.findViewById(R.id.tv_number);
|
|
tv_name = itemView.findViewById(R.id.tv_name);
|
|
}
|
|
}
|
|
}
|