android - Using SuperSLiM Library in nested RecyclerView -


i use superslim library github
need use library in nested recyclerview, when put recyclerview stick's it's header on top, in recyclerview, seems misses it's properties. adapter root recyclerview in each row of have recyclerview , textview.

public class adapter extends recyclerview.adapter<adapter.viewholder> {           private context mcontext;         private layoutinflater mlayoutinflater;           public adapter(context context) {              this.mcontext = context;             this.mlayoutinflater = layoutinflater.from(context);         }           @override         public viewholder oncreateviewholder(viewgroup viewgroup, int viewtype) {              view view = mlayoutinflater.inflate(r.layout.row, viewgroup, false);             viewholder viewholder = new viewholder(view);             return viewholder;         }          @override         public void onbindviewholder(viewholder viewholder, int position) {              //             recyclerview mrecyclerview = viewholder.mrecyclerview;             textview mtextview = viewholder.mtextview;              //              mtextview.settext("pos: " + position);              //set layoutmanager             mrecyclerview.setlayoutmanager(new nestedlinearlayoutmanager(mcontext));              //set adapter             countrynamesadapter adapter = new countrynamesadapter(mcontext, 18);             adapter.setmarginsfixed(true);             adapter.setheaderdisplay(18);             mrecyclerview.setadapter(adapter);          }          @override         public int getitemcount() {             return 10;         }          class viewholder extends recyclerview.viewholder {              textview mtextview;             recyclerview mrecyclerview;              public viewholder(view itemview) {                 super(itemview);                  mtextview = (textview) itemview.findviewbyid(r.id.title);                 mrecyclerview = (recyclerview) itemview.findviewbyid(r.id.list);               }         } 

this nestedlinearlayoutmanager class showing child recyclerview nice.

public class nestedlinearlayoutmanager extends linearlayoutmanager {      public nestedlinearlayoutmanager(context context){         super(context);     }     public nestedlinearlayoutmanager(context context, int orientation, boolean reverselayout)    {         super(context, orientation, reverselayout);     }      private int[] mmeasureddimension = new int[2];      @override     public void onmeasure(recyclerview.recycler recycler, recyclerview.state state,                           int widthspec, int heightspec) {         final int widthmode = view.measurespec.getmode(widthspec);         final int heightmode = view.measurespec.getmode(heightspec);         final int widthsize = view.measurespec.getsize(widthspec);         final int heightsize = view.measurespec.getsize(heightspec);         int width = 0;         int height = 0;         (int = 0; < getitemcount(); i++) {             measurescrapchild(recycler, i,                     view.measurespec.makemeasurespec(i, view.measurespec.unspecified),                     view.measurespec.makemeasurespec(i, view.measurespec.unspecified),                     mmeasureddimension);              if (getorientation() == horizontal) {                 width = width + mmeasureddimension[0];                 if (i == 0) {                     height = mmeasureddimension[1];                 }             } else {                 height = height + mmeasureddimension[1];                 if (i == 0) {                     width = mmeasureddimension[0];                 }             }         }         switch (widthmode) {             case view.measurespec.exactly:                 width = widthsize;             case view.measurespec.at_most:             case view.measurespec.unspecified:         }          switch (heightmode) {             case view.measurespec.exactly:                 height = heightsize;             case view.measurespec.at_most:             case view.measurespec.unspecified:         }          setmeasureddimension(width, height);     }      private void measurescrapchild(recyclerview.recycler recycler, int position, int widthspec,                                    int heightspec, int[] measureddimension) {         view view = recycler.getviewforposition(position);         if (view != null) {             recyclerview.layoutparams p = (recyclerview.layoutparams) view.getlayoutparams();             int childwidthspec = viewgroup.getchildmeasurespec(widthspec,                     getpaddingleft() + getpaddingright(), p.width);             int childheightspec = viewgroup.getchildmeasurespec(heightspec,                     getpaddingtop() + getpaddingbottom(), p.height);             view.measure(childwidthspec, childheightspec);             measureddimension[0] = view.getmeasuredwidth() + p.leftmargin + p.rightmargin;             measureddimension[1] = view.getmeasuredheight() + p.bottommargin + p.topmargin;             recycler.recycleview(view);         }     } } 

does library work in nested recyclerview too?


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -