align username etc vertical if no status message is set

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2022-02-24 22:03:56 +01:00
parent c746b95ac2
commit 305ceedc75
No known key found for this signature in database
GPG key ID: C793F8B59F43CE7B
3 changed files with 18 additions and 1 deletions

View file

@ -41,6 +41,7 @@ import java.util.List;
import java.util.Objects;
import java.util.regex.Pattern;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.res.ResourcesCompat;
import eu.davidea.flexibleadapter.FlexibleAdapter;
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem;
@ -193,6 +194,7 @@ public class MentionAutocompleteItem extends AbstractFlexibleItem<UserItem.UserI
holder.statusMessage.setText(statusMessage);
} else {
holder.statusMessage.setText("");
alignUsernameVertical(holder);
}
if (statusIcon != null && !statusIcon.isEmpty()) {
@ -213,6 +215,13 @@ public class MentionAutocompleteItem extends AbstractFlexibleItem<UserItem.UserI
}
}
private void alignUsernameVertical(UserItem.UserItemViewHolder holder) {
ConstraintLayout.LayoutParams layoutParams =
(ConstraintLayout.LayoutParams) holder.contactDisplayName.getLayoutParams();
layoutParams.topMargin = (int) DisplayUtils.convertDpToPixel(10, context);
holder.contactDisplayName.setLayoutParams(layoutParams);
}
@Override
public boolean filter(String constraint) {
return objectId != null &&

View file

@ -47,6 +47,7 @@ import java.util.List;
import java.util.regex.Pattern;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.res.ResourcesCompat;
import androidx.emoji.widget.EmojiTextView;
import butterknife.BindView;
@ -282,6 +283,7 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
holder.statusMessage.setText(participant.statusMessage);
} else {
holder.statusMessage.setText("");
alignUsernameVertical(holder);
}
if (participant.statusIcon != null && !participant.statusIcon.isEmpty()) {
@ -302,6 +304,13 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
}
}
private void alignUsernameVertical(UserItemViewHolder holder) {
ConstraintLayout.LayoutParams layoutParams =
(ConstraintLayout.LayoutParams) holder.contactDisplayName.getLayoutParams();
layoutParams.topMargin = (int) DisplayUtils.convertDpToPixel(10, context);
holder.contactDisplayName.setLayoutParams(layoutParams);
}
@Override
public boolean filter(String constraint) {
return participant.getDisplayName() != null &&

View file

@ -21,7 +21,6 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/standard_half_margin"