2015-06-09 14:37:20 +00:00
|
|
|
package org.thoughtcrime.securesms.preferences;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.util.AttributeSet;
|
|
|
|
import android.widget.RelativeLayout;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
import org.thoughtcrime.securesms.R;
|
|
|
|
import org.thoughtcrime.securesms.components.AvatarImageView;
|
2017-08-01 15:56:00 +00:00
|
|
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
|
|
|
import org.thoughtcrime.securesms.recipients.RecipientModifiedListener;
|
2015-07-28 21:19:28 +00:00
|
|
|
import org.thoughtcrime.securesms.util.Util;
|
2015-06-09 14:37:20 +00:00
|
|
|
|
2017-08-01 15:56:00 +00:00
|
|
|
public class BlockedContactListItem extends RelativeLayout implements RecipientModifiedListener {
|
2015-06-09 14:37:20 +00:00
|
|
|
|
|
|
|
private AvatarImageView contactPhotoImage;
|
|
|
|
private TextView nameView;
|
2017-08-01 15:56:00 +00:00
|
|
|
private Recipient recipient;
|
2015-06-09 14:37:20 +00:00
|
|
|
|
|
|
|
public BlockedContactListItem(Context context) {
|
|
|
|
super(context);
|
|
|
|
}
|
|
|
|
|
|
|
|
public BlockedContactListItem(Context context, AttributeSet attrs) {
|
|
|
|
super(context, attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
public BlockedContactListItem(Context context, AttributeSet attrs, int defStyleAttr) {
|
|
|
|
super(context, attrs, defStyleAttr);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFinishInflate() {
|
|
|
|
super.onFinishInflate();
|
|
|
|
this.contactPhotoImage = (AvatarImageView)findViewById(R.id.contact_photo_image);
|
|
|
|
this.nameView = (TextView) findViewById(R.id.name);
|
|
|
|
}
|
|
|
|
|
2017-08-01 15:56:00 +00:00
|
|
|
public void set(Recipient recipients) {
|
|
|
|
this.recipient = recipients;
|
2015-06-09 14:37:20 +00:00
|
|
|
|
|
|
|
onModified(recipients);
|
|
|
|
recipients.addListener(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-01 15:56:00 +00:00
|
|
|
public void onModified(final Recipient recipients) {
|
2015-07-28 21:19:28 +00:00
|
|
|
final AvatarImageView contactPhotoImage = this.contactPhotoImage;
|
|
|
|
final TextView nameView = this.nameView;
|
|
|
|
|
|
|
|
Util.runOnMain(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
contactPhotoImage.setAvatar(recipients, false);
|
|
|
|
nameView.setText(recipients.toShortString());
|
|
|
|
}
|
|
|
|
});
|
2015-06-09 14:37:20 +00:00
|
|
|
}
|
|
|
|
|
2017-08-01 15:56:00 +00:00
|
|
|
public Recipient getRecipient() {
|
|
|
|
return recipient;
|
2015-06-09 14:37:20 +00:00
|
|
|
}
|
|
|
|
}
|