Mark M. | has entered the room |
Mark M. | turned on guest access |
Jan 12 | 4:10 PM |
ndrocchietto i. | has entered the room |
Mark M. |
hello, Ivano!
|
Mark M. |
how can I help you today?
|
ndrocchietto i. |
Hi Mark good afternoon
|
ndrocchietto i. |
I have an adapter where I set data for three different recyclerview different. Inside the adapter I change the state depending by the three different list i want
|
ndrocchietto i. |
my problem is that i need now to add an header on top of the recycler view
|
ndrocchietto i. |
( a title)
|
ndrocchietto i. |
I obtained that but the problem is that i have overriden
|
Jan 12 | 4:15 PM |
ndrocchietto i. |
View paste
|
Jan 12 | 4:15 PM |
ndrocchietto i. |
and where Adress Search Item retrieves the state so that the adapter knows that have to manage the third case
|
ndrocchietto i. |
but the problem is : that everything works perfectly except the first item, where instead to have the header+the first item(adress)
|
ndrocchietto i. |
I get only the header
|
ndrocchietto i. |
i would like to have the header+the first item
|
ndrocchietto i. |
stop
|
Mark M. |
a given position has only one View, so if you want the first View to show a header plus the first item, the View has to handle that
|
ndrocchietto i. |
yes but i want the header also for the other items
|
Mark M. |
"my problem is that i need now to add an header on top of the recycler view" -- this implies that there is only one header
|
ndrocchietto i. |
yes
|
ndrocchietto i. |
i can share the small class
|
Mark M. |
does this header scroll with the RecyclerView contents? or is this header fixed at the top?
|
ndrocchietto i. |
the header is fixed no scrolls
|
ndrocchietto i. |
View paste
(111 more lines)
|
Jan 12 | 4:20 PM |
Mark M. |
then why is it *in* the RecyclerView -- put it above the RecyclerView instead
|
ndrocchietto i. |
i just want a normal list with the adapter visible if there is at least one item
|
ndrocchietto i. |
I ca't
|
ndrocchietto i. |
i can't
|
Mark M. |
if it is inside the RecyclerView, it will scroll with the content
|
Mark M. |
because it is part of the content, along with your items
|
ndrocchietto i. |
omg you are right
|
ndrocchietto i. |
but i can't separate from the recycler view
|
Mark M. |
why not?
|
ndrocchietto i. |
because i get the state only from inside the adapter, while the activity where i call the recycler view has this call
|
Mark M. |
it is possible that some third-party RecyclerView layout managers offer some sort of sticky headers that you could use
|
Mark M. |
that sounds like you have too much responsibility in this adapter
|
ndrocchietto i. |
yes
|
ndrocchietto i. |
this is the call
|
ndrocchietto i. |
View paste
(7 more lines)
|
ndrocchietto i. |
where set data takes one of the three lists
|
Mark M. |
add a second line to the subscribe() lambda that calls something other than your adapter and sets up the header
|
Jan 12 | 4:25 PM |
Mark M. |
so instead of .subscribe { values -> adapter.setData(values) } you have .subscribe { values -> adapter.setData(values); andSetUpMyHeaderPlease(values) }
|
ndrocchietto i. |
the problem is that in this way, all the three list would take the header
|
ndrocchietto i. |
ah no
|
ndrocchietto i. |
mark
|
Mark M. |
ok, so it is then .subscribe { values -> adapter.setData(values); if (theHeaderIsNeeded(values)) andSetUpMyHeaderPlease(values) }
|
ndrocchietto i. |
I need to retrieve only 5 items
|
ndrocchietto i. |
so the problem of the scroll does not exist
|
Mark M. |
that depends entirely on the screen size
|
ndrocchietto i. |
they will be visible from whatever phone bigger than 4 inches
|
Mark M. |
I have two phones within reach that are smaller than that
|
ndrocchietto i. |
so I can make it work from my adapter
|
ndrocchietto i. |
because the boolean condition you mention cannot be easily taken from on subscribe
|
Mark M. |
then you have to be willing to say that the header will scroll with the content on small screens, or you have to use a third-party layout manager that offers some sort of sticky header feature
|
Mark M. |
or, change your code such that the boolean is not tied to this adapter (which, as I mentioned, seems to be doing too much work)
|
ndrocchietto i. |
I would agree but there is a huge problem
|
ndrocchietto i. |
one sec
|
Jan 12 | 4:30 PM |
ndrocchietto i. |
give me a couple of minutes please
|
Mark M. |
sure
|
ndrocchietto i. |
thanks
|
Jan 12 | 4:35 PM |
ndrocchietto i. |
here it is
|
ndrocchietto i. |
I have the RealmObject that is
|
ndrocchietto i. |
View paste
(3 more lines)
|
Mark M. |
searchFilter seems like a very odd thing for a model object to hae
|
Mark M. |
er, to have
|
ndrocchietto i. |
i agree
|
ndrocchietto i. |
but if I do
|
ndrocchietto i. |
View paste
|
ndrocchietto i. |
scope filter is not recognized
|
ndrocchietto i. |
unresolved reference
|
Mark M. |
AddressRealm is a model object
|
Mark M. |
my guess is that your RecyclerView is showing a list of these
|
Mark M. |
if so, searchFilter has nothing to do with AddressRealm, and IMHO does not belong there
|
ndrocchietto i. |
if only I could make recognize at the subscribe method that I am in the case RECENT ADRESS, it would work
|
Mark M. |
the "case" is not tied to an individual address
|
Mark M. |
at least, from what I am inferring, based on the particular class names and stuff that you are presenting here
|
ndrocchietto i. |
my senior has extended adressRealm with the Adress Interface as you can see
|
ndrocchietto i. |
so that I wrap the realm object
|
ndrocchietto i. |
adding the state
|
ndrocchietto i. |
(is a kinda of strategy pattern i guess)
|
Jan 12 | 4:40 PM |
Mark M. |
IMHO, that makes no sense
|
Jan 12 | 4:40 PM |
ndrocchietto i. |
ok
|
Mark M. |
for example, if you have 5 AddressRealm objects in this list, you can have 5 different values for searchFilter
|
ndrocchietto i. |
no
|
Mark M. |
well, no, that's not true -- my apologies
|
ndrocchietto i. |
always the same
|
Mark M. |
you have it hard-coded
|
ndrocchietto i. |
:)
|
ndrocchietto i. |
yes
|
Mark M. |
but if it is always the same, there is only one case, not three
|
ndrocchietto i. |
i would like just to return the boolean
|
ndrocchietto i. |
this is the wrap on the db realm
|
ndrocchietto i. |
then we have retrofit
|
ndrocchietto i. |
and a google search adress call
|
ndrocchietto i. |
are three different typologies of adresses
|
Mark M. |
use if (values[0].searchFilter == AddressSearchItem.RECENT_LOCATION)
|
ndrocchietto i. |
with different layout
|
Mark M. |
or, use if (values.any { it.searchFilter == AddressSearchItem.RECENT_LOCATION}), if the list might have a mix of searchFilter values
|
ndrocchietto i. |
mark you are a genius
|
ndrocchietto i. |
I want ot become like you
|
ndrocchietto i. |
thank you, really
|
ndrocchietto i. |
it works perfect
|
ndrocchietto i. |
now I am going to add an header and play withinvisibility
|
ndrocchietto i. |
thank you
|
Mark M. |
you're welcome!
|
Mark M. |
though, if I remember your time zone correctly... don't forget to sleep! :-)
|
ndrocchietto i. |
bye I go to sleep I am in a meditation center, playing with the pc
|
ndrocchietto i. |
better i close I am not supposed to do coding
|
Jan 12 | 4:45 PM |
ndrocchietto i. |
have a pleasant day
|
Mark M. |
you too!
|
ndrocchietto i. |
thanks
|
Jan 12 | 5:00 PM |
ndrocchietto i. | has left the room |
Mark M. | turned off guest access |