2015-06-09 14:37:20 +00:00
|
|
|
package org.thoughtcrime.securesms.preferences;
|
|
|
|
|
|
|
|
import android.content.Context;
|
2017-10-16 20:11:42 +00:00
|
|
|
import android.support.annotation.NonNull;
|
2015-06-09 14:37:20 +00:00
|
|
|
import android.util.AttributeSet;
|
|
|
|
import android.widget.RelativeLayout;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
import org.thoughtcrime.securesms.R;
|
|
|
|
import org.thoughtcrime.securesms.components.AvatarImageView;
|
2017-10-16 20:11:42 +00:00
|
|
|
import org.thoughtcrime.securesms.mms.GlideRequests;
|
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-10-16 20:11:42 +00:00
|
|
|
private GlideRequests glideRequests;
|
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();
|
2017-10-16 20:11:42 +00:00
|
|
|
this.contactPhotoImage = findViewById(R.id.contact_photo_image);
|
|
|
|
this.nameView = findViewById(R.id.name);
|
2015-06-09 14:37:20 +00:00
|
|
|
}
|
|
|
|
|
2017-10-16 20:11:42 +00:00
|
|
|
public void set(@NonNull GlideRequests glideRequests, @NonNull Recipient recipients) {
|
|
|
|
this.glideRequests = glideRequests;
|
|
|
|
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;
|
|
|
|
|
2017-10-16 20:11:42 +00:00
|
|
|
Util.runOnMain(() -> {
|
|
|
|
contactPhotoImage.setAvatar(glideRequests, recipients, false);
|
|
|
|
nameView.setText(recipients.toShortString());
|
2015-07-28 21:19:28 +00:00
|
|
|
});
|
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
|
|
|
}
|
|
|
|
}
|