feat(StatusDisplayItem/WarningFiltered): apply equal inset vertically

This commit is contained in:
FineFindus 2024-07-25 17:55:17 +02:00
parent ec495750fe
commit 7b31543d7a
No known key found for this signature in database
GPG Key ID: 64873EE210FF8E6B
2 changed files with 12 additions and 8 deletions

View File

@ -52,13 +52,13 @@ public class WarningFilteredStatusDisplayItem extends StatusDisplayItem{
String title=item.applyingFilter.title;
text.setText(item.parentFragment.getString(R.string.sk_filtered, title));
itemView.setClipToOutline(item.inset);
itemView.setOutlineProvider(item.inset ? OutlineProviders.roundedRect(12) : null);
if(item.inset){
itemView.setClipToOutline(true);
itemView.setOutlineProvider(OutlineProviders.roundedRect(12));
}
}
@Override
public void onClick(){
}
public void onClick(){}
}
}

View File

@ -11,6 +11,7 @@ import org.joinmastodon.android.fragments.BaseStatusListFragment;
import org.joinmastodon.android.ui.displayitems.StatusDisplayItem;
import org.joinmastodon.android.ui.displayitems.LinkCardStatusDisplayItem;
import org.joinmastodon.android.ui.displayitems.MediaGridStatusDisplayItem;
import org.joinmastodon.android.ui.displayitems.WarningFilteredStatusDisplayItem;
import java.util.List;
@ -42,13 +43,16 @@ public class InsetStatusItemDecoration extends RecyclerView.ItemDecoration{
boolean inset=(holder instanceof StatusDisplayItem.Holder<?> sdi) && sdi.getItem().inset;
if(inset){
if(rect.isEmpty()){
if(holder instanceof MediaGridStatusDisplayItem.Holder || holder instanceof LinkCardStatusDisplayItem.Holder){
rect.set(child.getX(), i == 0 && pos > 0 && displayItems.get(pos - 1).inset ? V.dp(-10) : child.getY(), child.getX() + child.getWidth(), child.getY() + child.getHeight() + V.dp(4));
if(holder instanceof MediaGridStatusDisplayItem.Holder || holder instanceof LinkCardStatusDisplayItem.Holder || holder instanceof WarningFilteredStatusDisplayItem.Holder){
float topInset=i == 0 && pos > 0 && displayItems.get(pos - 1).inset ? V.dp(-10) : child.getY();
if(holder instanceof WarningFilteredStatusDisplayItem.Holder)
topInset-=V.dp(4);
rect.set(child.getX(), topInset, child.getX() + child.getWidth(), child.getY() + child.getHeight() + V.dp(4));
}else {
rect.set(child.getX(), i == 0 && pos > 0 && displayItems.get(pos - 1).inset ? V.dp(-10) : child.getY(), child.getX() + child.getWidth(), child.getY() + child.getHeight());
}
}else{
if(holder instanceof MediaGridStatusDisplayItem.Holder || holder instanceof LinkCardStatusDisplayItem.Holder){
if(holder instanceof MediaGridStatusDisplayItem.Holder || holder instanceof LinkCardStatusDisplayItem.Holder || holder instanceof WarningFilteredStatusDisplayItem.Holder){
rect.bottom=Math.max(rect.bottom, child.getY()+child.getHeight()) + V.dp(4);
}else {
rect.bottom=Math.max(rect.bottom, child.getY()+child.getHeight());