Office Hours — Today, February 21

Thursday, February 16

Feb 21
7:25 PM
Mark M.
has entered the room
Mark M.
turned on guest access
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
I posted on Stack Overflow, having issues with Volley and 301/302 Redirects
I have a large app that I have switch to Volley
Not thrilled with decision
Mark M.
I already commented on that question
jth
What if I cannot get rid of volley
7:40 PM
jth
and I only want to use OkHttp3 for the httpstack replacement
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
(actually, not true, I worked with it for NetCipher)
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
it was a classic "throw the bits over the wall" sort of release
if it wasn't for one Google I|O conference presentation from Ficus Fitzpatrick, we might not even know about Volley
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
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.
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
it includes implementations using OkHttp, without Retrofit
7:45 PM
Mark M.
you will need a JSON parser, but you have a variety of options for that
jth
already using GSON
and found your book after going down the volley route :(
ok I will speak of it no more
Multi-select listviews
GetCheckedItemPositions
should I use that, seems like a lot of extra work to found out the items selected
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
the SparseBooleanArray is a pain, but that's because they designed the API to take into account recycling
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
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
On the 4.x the onitemclicklistener is not firing
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
but, yet, is requires MxN listeners (M rows, N widgets per row on which the user can tap)
7:55 PM
Mark M.
er, that should have been "but, yes, ..."
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
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
I don't use those much
and there is a ListPopupWindow specifically to deal with scrolling and stuff in a popu
er, popup
jth
You suggested before a dialogfragment, so I will try switching to that
last question and then I will leave you alone
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
8:00 PM
Mark M.
so, like an OK button?
jth
yes "Apply"
what is the best way to reference the listview from the button's onclick
current I have a local reference in the fragment
Mark M.
um, well, the button and the ListView are in the same container, right?
some controller should be managing both
the controller therefore should have access to both
so, route the onClick to the controller, which handles doing whatever needs to be done with the ListView
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
so when I inflate the listview and setup the adapter, the fragment has a reference to the listview
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
thank you for your time
Mark M.
you're welcome!
8:20 PM
jth
has left the room
8:25 PM
Mark M.
turned off guest access

Thursday, February 16

 

Office Hours

People in this transcript

  • jth
  • Mark Murphy