Skip to content

Commit

Permalink
feat(StatusDisplayItem/WarningFiltered): apply equal inset vertically
Browse files Browse the repository at this point in the history
  • Loading branch information
FineFindus committed Jul 25, 2024
1 parent ec49575 commit 7b31543
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ public void onBind(WarningFilteredStatusDisplayItem item){
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(){}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
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;

Expand Down Expand Up @@ -42,13 +43,16 @@ public void onDraw(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull Rec
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());
Expand Down

0 comments on commit 7b31543

Please sign in to comment.