2015-01-15 13:35:35 -08:00
|
|
|
package org.thoughtcrime.securesms;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.widget.AbsListView;
|
|
|
|
import android.widget.BaseAdapter;
|
|
|
|
|
|
|
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
|
|
|
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
2015-02-26 18:31:22 -08:00
|
|
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
2015-01-15 13:35:35 -08:00
|
|
|
import org.thoughtcrime.securesms.recipients.Recipients;
|
|
|
|
|
|
|
|
public class MessageDetailsRecipientAdapter extends BaseAdapter implements AbsListView.RecyclerListener {
|
|
|
|
|
2015-02-26 18:31:22 -08:00
|
|
|
private final Context context;
|
|
|
|
private final MasterSecret masterSecret;
|
|
|
|
private final MessageRecord record;
|
|
|
|
private final Recipients recipients;
|
|
|
|
private final boolean isPushGroup;
|
2015-01-15 13:35:35 -08:00
|
|
|
|
2015-02-26 18:31:22 -08:00
|
|
|
public MessageDetailsRecipientAdapter(Context context, MasterSecret masterSecret,
|
|
|
|
MessageRecord record, Recipients recipients,
|
|
|
|
boolean isPushGroup)
|
|
|
|
{
|
2015-01-15 13:35:35 -08:00
|
|
|
this.context = context;
|
|
|
|
this.masterSecret = masterSecret;
|
|
|
|
this.record = record;
|
|
|
|
this.recipients = recipients;
|
2015-02-26 18:31:22 -08:00
|
|
|
this.isPushGroup = isPushGroup;
|
2015-01-15 13:35:35 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getCount() {
|
|
|
|
return recipients.getRecipientsList().size();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Object getItem(int position) {
|
|
|
|
return recipients.getRecipientsList().get(position);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public long getItemId(int position) {
|
|
|
|
return recipients.getRecipientsList().get(position).getRecipientId();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public View getView(int position, View convertView, ViewGroup parent) {
|
|
|
|
if (convertView == null) {
|
2015-02-27 11:07:20 -08:00
|
|
|
convertView = LayoutInflater.from(context).inflate(R.layout.message_recipient_list_item, parent, false);
|
2015-01-15 13:35:35 -08:00
|
|
|
}
|
|
|
|
|
2015-02-26 18:31:22 -08:00
|
|
|
Recipient recipient = recipients.getRecipientsList().get(position);
|
|
|
|
((MessageRecipientListItem)convertView).set(masterSecret, record, recipient, isPushGroup);
|
2015-01-15 13:35:35 -08:00
|
|
|
return convertView;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onMovedToScrapHeap(View view) {
|
|
|
|
((MessageRecipientListItem)view).unbind();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|