7979import me .vkryl .core .StringUtils ;
8080import tgx .td .ChatId ;
8181
82- public class InlineResultsWrap extends FrameLayoutFix implements View .OnClickListener , StickerSmallView .StickerMovementCallback , InlineResultsAdapter .HeightProvider , FactorAnimator .Target , View .OnLongClickListener , TGLegacyManager .EmojiLoadListener , BaseView .CustomControllerProvider , RootFrameLayout .InsetsChangeListener , RootFrameLayout . MarginModifier {
82+ public class InlineResultsWrap extends FrameLayoutFix implements View .OnClickListener , StickerSmallView .StickerMovementCallback , InlineResultsAdapter .HeightProvider , FactorAnimator .Target , View .OnLongClickListener , TGLegacyManager .EmojiLoadListener , BaseView .CustomControllerProvider , RootFrameLayout .MarginModifier {
8383 private RecyclerView recyclerView ;
8484 private ShadowView shadowView ;
8585 private GridLayoutManager gridManager ;
@@ -812,6 +812,7 @@ private void updateOffset () {
812812 if (adapter .getItemCount () > 0 ) {
813813 adapter .notifyItemChanged (0 );
814814 }
815+ Views .setBottomMargin (this , bottomInset + lastBottomMargin );
815816 }
816817
817818 @ Override
@@ -830,7 +831,6 @@ protected void onMeasure (int widthMeasureSpec, int heightMeasureSpec) {
830831 private void setBottomMargin (int bottomMargin ) {
831832 if (this .lastBottomMargin != bottomMargin ) {
832833 this .lastBottomMargin = bottomMargin ;
833- Views .setBottomMargin (this , bottomInset + bottomMargin );
834834 updateOffset ();
835835 }
836836 if (lickView != null ) {
@@ -871,29 +871,28 @@ public int provideHeight () {
871871
872872 private int topOffset , bottomInset ;
873873
874- private void setInsets (int topOffset , int bottomInset ) {
874+ private boolean setInsets (int topOffset , int bottomInset ) {
875875 if (this .topOffset != topOffset || this .bottomInset != bottomInset ) {
876876 this .topOffset = topOffset ;
877877 this .bottomInset = bottomInset ;
878- Views .setBottomMargin (this , bottomInset + lastBottomMargin );
879- updateOffset ();
878+ return true ;
880879 }
880+ return false ;
881881 }
882882
883883 @ Override
884884 public void onApplyMarginInsets (View child , LayoutParams params , Rect legacyInsets , Rect insets , Rect insetsWithoutIme ) {
885- Views .setMargins (params ,
885+ boolean changed ;
886+ changed = Views .setMargins (params ,
886887 legacyInsets .left ,
887888 legacyInsets .top ,
888889 legacyInsets .right ,
889890 insets .bottom + lastBottomMargin
890891 );
891- setInsets (insets .top , insets .bottom );
892- }
893-
894- @ Override
895- public void onInsetsChanged (RootFrameLayout viewGroup , Rect effectiveInsets , Rect effectiveInsetsWithoutIme , Rect systemInsets , Rect systemInsetsWithoutIme , boolean isUpdate ) {
896- setInsets (systemInsets .top , systemInsets .bottom );
892+ changed = setInsets (insets .top , insets .bottom ) || changed ;
893+ if (changed ) {
894+ UI .post (this ::updateOffset );
895+ }
897896 }
898897
899898 private RootFrameLayout rootView ;
@@ -902,20 +901,12 @@ public void onInsetsChanged (RootFrameLayout viewGroup, Rect effectiveInsets, Re
902901 protected void onAttachedToWindow () {
903902 super .onAttachedToWindow ();
904903 rootView = Views .findAncestor (this , RootFrameLayout .class , true );
905- if (rootView != null ) {
906- rootView .addInsetsChangeListener (this );
907- Rect systemInsets = rootView .getSystemInsets ();
908- setInsets (systemInsets .top , systemInsets .bottom );
909- }
910904 }
911905
912906 @ Override
913907 protected void onDetachedFromWindow () {
914908 super .onDetachedFromWindow ();
915- if (rootView != null ) {
916- rootView .removeInsetsChangeListener (this );
917- rootView = null ;
918- }
909+ rootView = null ;
919910 }
920911
921912 public int getMinItemsHeight () {
0 commit comments