Feb 21 | 7:25 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Feb 21 | 7:35 PM |
jth | has entered the room |
jth |
hello
|
Mark M. |
hello, jth!
|
jth |
I'm back with more questions
|
Mark M. |
how can I help you today?
|
jth |
Ok #1
|
jth |
I posted on Stack Overflow, having issues with Volley and 301/302 Redirects
|
jth |
I have a large app that I have switch to Volley
|
jth |
Not thrilled with decision
|
jth | |
Mark M. |
I already commented on that question
|
jth |
What if I cannot get rid of volley
|
Feb 21 | 7:40 PM |
jth |
and I only want to use OkHttp3 for the httpstack replacement
|
Mark M. |
the Volley source code is at https://android.googlesource.com/platform/frame...
|
Mark M. |
you would have to try to figure out why it is not doing what you want
|
jth |
ok
|
Mark M. |
I do not live and breathe Volley; outside of the one book example, I have never touched it
|
Mark M. |
(actually, not true, I worked with it for NetCipher)
|
Mark M. |
but I was not testing redirect scenarios
|
jth |
Seems like they said to use it and then forgot it
|
Mark M. |
this is one of the reasons why I have never recommended it
|
Mark M. |
it was a classic "throw the bits over the wall" sort of release
|
Mark M. |
if it wasn't for one Google I|O conference presentation from Ficus Fitzpatrick, we might not even know about Volley
|
Mark M. |
OkHttp handles most of what Volley does directly
|
jth |
Almost all calls I am dealing with is JSON data, but do I have to use retrofit?
|
Mark M. |
no
|
Mark M. |
you *can* use Retrofit, but it is not required
|
jth |
ok seems like it might be easier dev effort and testing effort to just switch volley to okhttp.
|
jth |
without retrofit
|
Mark M. |
in the book, I have a lot of variations of a sample app that loads the latest Android questions from Stack Overflow
|
Mark M. |
it includes implementations using OkHttp, without Retrofit
|
Feb 21 | 7:45 PM |
Mark M. |
you will need a JSON parser, but you have a variety of options for that
|
jth |
already using GSON
|
jth |
and found your book after going down the volley route :(
|
jth |
ok I will speak of it no more
|
jth |
Multi-select listviews
|
jth |
GetCheckedItemPositions
|
jth |
should I use that, seems like a lot of extra work to found out the items selected
|
jth |
or should I have an onClick listener and keep track of the items the user selects?
|
Mark M. |
getCheckedItemPositions() works in concert with rows that implement Checkable
|
Mark M. |
the SparseBooleanArray is a pain, but that's because they designed the API to take into account recycling
|
Mark M. |
you would basically have to reimplement that part yourself, if you wanted to roll your own selection tracking
|
jth |
ok so that is the way I am doing it now, I will leave it that way. I am using checkable row
|
Feb 21 | 7:50 PM |
jth |
#3 I am having issues with ListView onitemclicklistener on older 4.x devices. Only solution I have found is using OnClick on each item in row.
|
Mark M. |
um, what sort of issues?
|
jth |
only have imageview, spacerview, textview, imageview in the row
|
jth |
On the 4.x the onitemclicklistener is not firing
|
jth |
how terrible is putting the onClick on each item in the adapter?
|
Mark M. |
there have been plenty of ListViews implemented, by plenty of developers, with simple rows, that work fine with onItemClickListener(), going back to Android 1.0
|
jth |
hmm ok
|
Mark M. |
the biggest problem with onClick() is visual feedback, showing the click
|
jth |
is it true that you then have x number of listeners instead of just 1
|
Mark M. |
if you still have that now, even though your OnItemClickListener is not being invoked for some reason, and you want to use OnClickListeners on individual widgets, you can do that
|
Mark M. |
but, yet, is requires MxN listeners (M rows, N widgets per row on which the user can tap)
|
Feb 21 | 7:55 PM |
Mark M. |
er, that should have been "but, yes, ..."
|
Mark M. |
for example, some of the recent-Android-questions sample apps that I cited earlier have ListViews with rows showing the question title and the asker's avatar
|
Mark M. |
they all respond to item clicks just fine, as I use that to launch an ACTION_VIEW activity to view the Stack Overflow question in a Web browser
|
jth |
I wonder if it is because the listview is in a popupwindow
|
Mark M. |
that could have an impact
|
Mark M. |
I don't use those much
|
Mark M. |
and there is a ListPopupWindow specifically to deal with scrolling and stuff in a popu
|
Mark M. |
er, popup
|
jth |
You suggested before a dialogfragment, so I will try switching to that
|
jth |
last question and then I will leave you alone
|
jth |
The listview allow the user to select filter options and then outside the listview is a button that the user selects when they are finished
|
Feb 21 | 8:00 PM |
Mark M. |
so, like an OK button?
|
jth |
yes "Apply"
|
jth |
what is the best way to reference the listview from the button's onclick
|
jth |
current I have a local reference in the fragment
|
Mark M. |
um, well, the button and the ListView are in the same container, right?
|
Mark M. |
some controller should be managing both
|
Mark M. |
the controller therefore should have access to both
|
Mark M. |
so, route the onClick to the controller, which handles doing whatever needs to be done with the ListView
|
Mark M. |
here, by "controller", it could be some dedicated controller or presenter class, or it could be a fragment, or it even could be the activity
|
jth |
ok
|
Mark M. |
but something set up the PopupWindow and its contents, and it is that "something" that is responsible for handling the click event
|
jth |
yes popupwindow is also in the fragment
|
jth |
so when I inflate the listview and setup the adapter, the fragment has a reference to the listview
|
Feb 21 | 8:05 PM |
jth |
and on the onclick I use that reference to find the items selected
|
Mark M. |
if the fragment is setting up the ListView and the Button, that seems fine
|
jth |
ok that is all my questions for tonight
|
jth |
thank you for your time
|
Mark M. |
you're welcome!
|
Feb 21 | 8:20 PM |
jth | has left the room |
Feb 21 | 8:25 PM |
Mark M. | turned off guest access |