Remove unnecessary resolves.
This commit is contained in:
parent
3632a2cc95
commit
2248acb9f2
1 changed files with 16 additions and 12 deletions
|
@ -197,7 +197,7 @@ public class Recipient {
|
|||
}
|
||||
|
||||
public @Nullable String getName() {
|
||||
if (this.name == null && isMmsGroup()) {
|
||||
if (this.name == null && address != null && address.isMmsGroup()) {
|
||||
List<String> names = new LinkedList<>();
|
||||
|
||||
for (Recipient recipient : participants) {
|
||||
|
@ -225,10 +225,10 @@ public class Recipient {
|
|||
}
|
||||
|
||||
public @NonNull MaterialColor getColor() {
|
||||
if (isGroup()) return MaterialColor.GROUP;
|
||||
else if (color != null) return color;
|
||||
else if (name != null) return ContactColors.generateFor(name);
|
||||
else return ContactColors.UNKNOWN_COLOR;
|
||||
if (isGroupInternal()) return MaterialColor.GROUP;
|
||||
else if (color != null) return color;
|
||||
else if (name != null) return ContactColors.generateFor(name);
|
||||
else return ContactColors.UNKNOWN_COLOR;
|
||||
}
|
||||
|
||||
public @NonNull Address requireAddress() {
|
||||
|
@ -263,6 +263,10 @@ public class Recipient {
|
|||
return requireAddress().isGroup();
|
||||
}
|
||||
|
||||
private boolean isGroupInternal() {
|
||||
return address != null && address.isGroup();
|
||||
}
|
||||
|
||||
public boolean isMmsGroup() {
|
||||
return requireAddress().isMmsGroup();
|
||||
}
|
||||
|
@ -277,7 +281,7 @@ public class Recipient {
|
|||
}
|
||||
|
||||
public @NonNull String toShortString() {
|
||||
return Optional.fromNullable(getName()).or(Optional.of(requireAddress().serialize())).get();
|
||||
return Optional.fromNullable(getName()).or(Optional.fromNullable(address != null ? address.serialize() : null)).or("");
|
||||
}
|
||||
|
||||
public @NonNull Drawable getFallbackContactPhotoDrawable(Context context, boolean inverted) {
|
||||
|
@ -287,17 +291,17 @@ public class Recipient {
|
|||
public @NonNull FallbackContactPhoto getFallbackContactPhoto() {
|
||||
if (localNumber) return new ResourceContactPhoto(R.drawable.ic_note_to_self);
|
||||
if (isResolving()) return new TransparentContactPhoto();
|
||||
else if (isGroup()) return new ResourceContactPhoto(R.drawable.ic_group_white_24dp, R.drawable.ic_group_large);
|
||||
else if (isGroupInternal()) return new ResourceContactPhoto(R.drawable.ic_group_white_24dp, R.drawable.ic_group_large);
|
||||
else if (!TextUtils.isEmpty(name)) return new GeneratedContactPhoto(name, R.drawable.ic_profile_default);
|
||||
else return new ResourceContactPhoto(R.drawable.ic_profile_default, R.drawable.ic_person_large);
|
||||
}
|
||||
|
||||
public @Nullable ContactPhoto getContactPhoto() {
|
||||
if (localNumber) return null;
|
||||
else if (isGroup() && groupAvatarId.isPresent()) return new GroupRecordContactPhoto(address, groupAvatarId.get());
|
||||
else if (systemContactPhoto != null) return new SystemContactPhoto(address, systemContactPhoto, 0);
|
||||
else if (profileAvatar != null) return new ProfileContactPhoto(address, profileAvatar);
|
||||
else return null;
|
||||
if (localNumber) return null;
|
||||
else if (isGroupInternal() && groupAvatarId.isPresent()) return new GroupRecordContactPhoto(address, groupAvatarId.get());
|
||||
else if (systemContactPhoto != null) return new SystemContactPhoto(address, systemContactPhoto, 0);
|
||||
else if (profileAvatar != null) return new ProfileContactPhoto(address, profileAvatar);
|
||||
else return null;
|
||||
}
|
||||
|
||||
public @Nullable Uri getMessageRingtone() {
|
||||
|
|
Loading…
Add table
Reference in a new issue