Jul 21 | 7:25 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Jul 21 | 7:55 PM |
Steve S. | has entered the room |
Mark M. |
hello, Steve!
|
Steve S. |
Hi, Mark!
|
Mark M. |
how can I help you today?
|
Steve S. |
Let me paste in my question:
|
Steve S. |
View paste
|
Mark M. |
if you mean rotating the screen, that's not your biggest problem
|
Steve S. |
ok
|
Mark M. |
your biggest problem is recycling in RecyclerView
|
Steve S. |
ok
|
Mark M. |
when the user scrolls, and your row gets recycled, you need to be able to save off the old data before you blow it away by filling in the widgets with the new position's data
|
Mark M. |
how you tackle that will tie into how you tackle orientation changes
|
Blue D. | has entered the room |
Mark M. |
one approach is to do what you say: use continuous listeners to update your view model (or whatever) with the changed data
|
Steve S. |
I see. I should mention that there are never more than six cycles, and no scrolling is needed
|
Steve S. |
ok
|
Mark M. |
(Blue: hi! I will be with you shortly!)
|
Blue D. |
Sure!
|
Mark M. |
never say "no scrolling is needed" until you've tested on a device whose screen is the size of a postage stamp :-)
|
Mark M. |
or, to flip it around, if you are sure that no scrolling is needed, get rid of the RecyclerView
|
Steve S. |
ok
|
Mark M. |
as the point behind RecyclerView is to recycle views during scrolling and similar events
|
Mark M. |
anyway, back to your problem
|
Mark M. |
the listener approach can work, assuming that the widgets offer the desired listeners
|
Mark M. |
and in your case, they do
|
Steve S. |
ok
|
Jul 21 | 8:00 PM |
Mark M. |
so long as you are retaining your view model (or whatever) across configuration changes, you are OK
|
Mark M. |
that could be a retained fragment, onRetainNonConfigurationInstance(), the new ViewModel stuff in the Architecture Components, a singleton POJO cache, etc.
|
Steve S. |
ok
|
Mark M. |
if you run into cases where the listeners are problematic, you can also keep track of state as the rows get recycled -- there's a callback for that on the Adapter, IIRC
|
Mark M. |
however, then on a configuration change, you need to capture whatever data is in the on-screen widgets
|
Mark M. |
the listener approach is probably easier
|
Steve S. |
ok
|
Mark M. |
at least in your case
|
Steve S. |
back to your point about not using a RecyclerView
|
Mark M. |
if you dump the RecyclerView, then you have nothing that you need to do on a configuration change, as onSaveInstanceState() processing should handle your widgets
|
Mark M. |
actually, it'll handle the EditTexts, and I forget how well it handles Spinner
|
Mark M. |
let me take a question from Blue, and I'll be back with you shortly
|
Mark M. |
Blue: your turn! do you have a question?
|
Steve S. |
sure
|
Jul 21 | 8:05 PM |
Mark M. |
Blue: do you have a question?
|
Mark M. |
Blue, if you come up with a question, chime in and let me know
|
Mark M. |
meantime, back to you, Steve
|
Blue D. |
Hi Mark! Yes, I have small question. I have an app which has "category.HOME" and to act as a home screen. Every time I install this app, android asks me to choose the home showing the stock home app and my home app. Is there a way to make this switch and make my home app a default app without user input?
|
Mark M. |
no, for security reasons
|
Mark M. |
allowing an app to blindly take over the home screen would be bad
|
Mark M. |
ransomware developers would have a field day
|
Mark M. |
now, AFAIK, you should only get prompted for a fresh install, not just running your app again from the IDE
|
Mark M. |
though it's been quite some time since I wrote a home screen activity, so the run-from-the-IDE behavior might have changed
|
Mark M. |
did that answer your question?
|
Blue D. |
what is the "run -from -the-IDE"? is the just clicking run from the Android studio? If yes, yeah. the app is installing and opens up asking to choose between the Homes.
|
Jul 21 | 8:10 PM |
Blue D. |
What is my Home app is firmware signed?
|
Mark M. |
really? that's unexpected
|
Mark M. |
that should not change the behavior
|
Mark M. |
what would change the behavior is if yours is the only home screen implementation
|
Blue D. |
Okay. Got your point. I think that answered the question. Thank you!
|
Mark M. |
OK
|
Mark M. |
Steve: your turn! do you have another question?
|
Steve S. |
back to your point about dumping the RecyclerView
|
Steve S. |
in my first version, I in fact used a TableLayout with sixteen views (they were all edit texts).
|
Steve S. |
but that was a bit complicated to manage. So someone suggested I try List/RecyclerView instead
|
Mark M. |
what does "complicated to manage" mean?
|
Steve S. |
The user can add and remove rows in the matrix
|
Mark M. |
earlier, you said there was always six rows
|
Jul 21 | 8:15 PM |
Mark M. |
unless I misunderstood
|
Steve S. |
right, i misspoke - i should have said there are never more than six rows
|
Mark M. |
adding new rows in a TableLayout is slightly more annoying than having them in a RecyclerView
|
Mark M. |
that being said, I doubt that I would use a RecyclerView in your use case, given what I know
|
Steve S. |
ok. so perhaps in this case the TableLayout would be a better approach?
|
Mark M. |
I would use a TableLayout or ConstraintLayout, personally (again, given what I know)
|
Steve S. |
ok. this is very helpful
|
Steve S. |
no more questions today
|
Steve S. |
Thank you so much, Mark!
|
Mark M. |
you're welcome!
|
Mark M. |
Blue: your turn! do you have another question?
|
Steve S. |
have a great rest of the day!
|
Steve S. | has left the room |
Blue D. |
Yes Mark. one last question for today.
|
Jul 21 | 8:20 PM |
Blue D. |
Yesterday, I have stackoverflow bumped a question regarding the google play silent install. I got your reply. But with experience you have could you point me in a direction where that can be achieved if you have any idea?
|
Blue D. | |
Mark M. |
yes, we discussed this by email, after your bump request
|
Blue D. |
Yes. So any suggestions?
|
Mark M. |
I do not work with rooted devices
|
Mark M. |
and so I have no suggestions
|
Mark M. |
other than to make sure that you have your attorney's phone number handy, as Google might not like what you are proposing
|
Blue D. |
Oh no, I am not very serious about it. I am not sure if that can be done. That is a requirement in one of my projects. So I want to know if this can be achieved. If not I can mention that its not possible.
|
Jul 21 | 8:25 PM |
Blue D. |
Okay Mark. Thank you so much for answering the questions. Thats all from me today.
|
Mark M. |
sorry I could not be of more help on that second one
|
Blue D. |
Thanks for trying. Have a great weekend!
|
Mark M. |
you too!
|
Blue D. | has left the room |
Jul 21 | 8:30 PM |
Mark M. | turned off guest access |