Office Hours — Today, May 8

Yesterday, May 7

May 8
8:55 AM
Mark M.
has entered the room
Mark M.
turned on guest access
Yossi E.
has entered the room
Yossi E.
Hi, Good morning.
Mark M.
hello, Yossi!
how can I help you today?
Yossi E.
I was wondering about the proper way to create an animation on recyclerview items
Bryan
has entered the room
Yossi E.
Item animator does animation for enter and remove
9:00 AM
Mark M.
I haven't played with RecyclerView animations, other than to see the defaults
Yossi E.
and i would like to do an animation when scrolling
Mark M.
(BTW, hello Bryan -- I will be with you shortly!)
Bryan
do I just put my question in here?
sounds good
Yossi E.
i see, i was wondering if my approach is a good take on it
Mark M.
Yossi: I'm sorry, but I don't know what it would mean to do an animation while scrolling
Yossi E.
i am creating a layout manager and i override the dy moving
animate the views as they scroll - translate animation ?
Mark M.
that feels like it'll be janky, but that's just a gut reaction
Yossi E.
it's janky as hell
and i don't have any other idea on how to tackle it
Mark M.
to be honest, I doubt that trying to do an animation of your own on top of the effective animation of a scrolling event will work out well
though, again, that's a gut reaction
animations are not one of my stronger areas
Yossi E.
thanks anyway
Mark M.
sorry I could not be of more help
Yossi E.
i would wait for my turn again - it's ok
Mark M.
OK
Bryan: your turn! do you have a question?
Bryan
I am trying to figure out the best way to get a reusable function that will take a Uri (file/web/etc) for an image file and resize the image, returning the image. My first choice is to use good, proven libaries that will handle functions like this instead of writing my own. My initial idea was to use Picasso with a custom Target, since Picasso can also perform a number of other transformations on the image that I might want later. The problem I am still struggling with is how to "synchronously" use this function when Picasso runs asynchronously. My current working theory is to just call Picasso asyncronously and onBitmapLoaded to push the resized Bitmap to some area of the app that is accessible (ideas are global variable on the class that holds this code, internal file, ?????) and to have some sort of function that "waits" for the expected resource to show up, indicating the Picasso process did it's job. Any ideas on a better way to accomplish my main goal (reusable method to resize an image by passing in a Uri)???
Mark M.
um
after the resize operation, what is your intended use for the image?
9:05 AM
Bryan
I would hope that I could leave that open, but the current use case is to base64encode it and pass it to an API that requires that as an image upload
btw, I am coming from mainly PHP development, so are some paradigm shifts that I am still making to java
Mark M.
well, you have two main options, as I see it
option #1: skip the synchronous part, and do the upload only after Picasso (or whoever) has loaded and resized the image
option #2: do your own image loading/resizing yourself, perhaps leveraging code from a library like Picasso as inspiration
image loaders for Android are usually designed for async operatoin
er, operation
as usually we are trying to put the images in an ImageView or something
Bryan
do you know of any good libraries out there that do #2 already? Or do people ususally roll their own?
Mark M.
I'm not aware that "usually" people have your use case :-)
you could try Universal Image Loader
it seems to have a loadImageSync() method
looks like it has a few flavors, including one that will resize
Bryan
Interesting, ok, great, thank you! I will look at that, and/or end up doing #1 and just do my api call in a callback that I pass to the resize function
Mark M.
Yossi: back to you! do you have another question?
9:10 AM
Yossi E.
Hi again, do you have more experience in listview item scrolling animation?
Mark M.
not really
Yossi E.
:(
Mark M.
I mean, it scrolls on its own
Yossi E.
lol
Mark M.
we don't usually get involved much with that
are you trying to do some sort of parallax thing?
Yossi E.
nope , i'm trying to make the items attach to one another like a rubber band
Mark M.
oh
yeah, that's way outside my areas of expertise
I'd say that RecyclerView has greater hope of being able to do that, just because it's more extensible in general
Yossi E.
Thanks again, i just wanted to brain storm ideas or get a pointer
Mark M.
you might poke around Dave Smith's blog, as he's done some fancier-than-average work with RecyclerView
Bryan
has left the room
Yossi E.
i'll take a look there. Thanks
Mark M.
yes
9:15 AM
Yossi E.
Thanks, good bye for now.
Mark M.
you are very welcome
Yossi E.
has left the room
9:20 AM
Vasanthi
has entered the room
Mark M.
hello, Vasanthi!
how can I help you today?
Vasanthi
Hello Mark
Thank you very much. I am new to Android programming. Started with your book and doing the sample projects. Have couple of questions
Mark M.
go right ahead!
if somebody else joins the chat, I will alternate taking questions from you and the new person
Vasanthi
I originally installed Android 1.o. About a week ago, installed 1.2. Opened a project I created already under 1.0. I got the error mgs
View paste
1)	Had Android Studio 1.0 and was building projects without any problems. Then installed Android Studio 1.1 – with that, 
Unable to save plugin settings: The plugin org.jetbrains.android failed to save settings and has been disabled. Please restart Android Studio (show balloon). Restarting Android Studio didn’t help.
Is it to do with the new version of Android Studio?
Mark M.
possibly
from outside of Android Studio, delete the .iml file and the .idea/ directory
then import the project back into Android Studio
that usually cleans up this sort of problem
9:25 AM
Mark M.
since the .iml and .idea/ contents are generated based on the build.gradle files, you shouldn't lose anything in this process
Vasanthi
Oh, OK. Instead I installed the plug-ins. Is that OK?
Mark M.
I don't know what plugins you are referring to
Vasanthi
View paste
Error Loading Project: Cannot load 3 facets Details...
10:29:19 Plugins Suggestion
         Features covered by non-bundled plugins are detected.
         Enable plugins
Mark M.
I have not encountered that message before
many IDEA plugins work on Android Studio
Vasanthi
Can I send the screenshot?
Mark M.
I have installed a couple myself, mostly syntax highlighters for other languages
you are welcome to upload a screenshot to the chat (see the "Upload a file" link on the right), though I doubt it will help me much
Vasanthi
It said Java-gradle, android-gradle and android can't be loaded. With Ignore all and Keep All buttons. I clicked on Keep all. Then I had the "And Gradle Sync Issue of “Warning:The project encoding (windows-1252) does not match the encoding specified in the Gradle build files (UTF-8)" error
Mark M.
with regards to the buttons, you definitely need those plugins
9:30 AM
Mark M.
with regards to the file encoding, did you happen to edit any of these files outside of the IDE?
Vasanthi
Went to project settings and changed the project encoding (that was showing Windows 1252) to UTF-8. This was few days ago. No, I didn't edit the files outside the IDE
Then today, opened the same project and had the same encoding error.
Mark M.
I don't know what to tell you about that
Vasanthi
Prior to that after selecting to keep the three plugins, I had to install the jetbrains.
Mark M.
if this can be reproduced in a scrap project, one that you don't mind publishing, you might ZIP it up and file an issue (Android Studio bug) on http://b.android.com
but overall, you may need to do a complete uninstall and reinstall of Studio to try to stabilize matters
Vasanthi
OK. Thank you very much. I have few more questions.
Mark M.
go right ahead!
Vasanthi
In the List sample project (pg 251 of your book) in the XML layout for the ListView element, without setting the the call back method on clicking a list item, the ListDemo::onListItemClck gets called? (for e.g. page 171 button clicks – says if we want a method to be called for eg on clicking a button a call back method to be called)
Mark M.
that sample inherits from ListActivity
Vasanthi
So, it has the ability to know that the call back should be onListItemClick?
Mark M.
View paste
quoting page 252: "To find out when the list selection changes, override onListItemClick() and take appropriate steps based on the supplied child view and position (in this case, updating the label
with the text for that position)."
ListActivity implements an OnItemClickListener and registers it with the ListView for you
9:35 AM
Mark M.
if you are not using ListActivity, you will have to handle the OnItemClickListener yourself
Vasanthi
Ah, understand it now. Does it mean, if I have extended the activity only from Activity, then, in the XML, I should have included the property android:onClick=onListItemClick?
Mark M.
no
onClick is a replacement for an OnClickListener
OnClickListener is not the same as OnItemClickListener
OnClickListener is for clicks anywhere on a widget, like a Button
OnItemClickListener is used by some subclasses of AdapterView, like ListView, for clicks on a "row" or "cell" or something inside the AdapterView
Vasanthi
OK, so is there a replacement for OnItemClickListener?
Mark M.
not in layout files, no
and, as you'll see later in the book, android:onClick is not used in many cases anyway
Vasanthi
OK. Thank you. Next question...
On Page 254, CheckList sample – the ListView is the root element in the XML layout. Don’t we need a Layout as a root?
Mark M.
no
there needs to be a single root element, for XML reasons as much as anything else
for example, earlier in the book, we had layout resources that were just a Button widget
you only need a container like LinearLayout if you want to organize multiple children
ListView knows how to manage its rows already
Vasanthi
So, if there were more than that ListView widgets, then there needs to be a layout root?
Mark M.
correct
in the earlier example, I had a TextView along with the ListView
and so I needed a container to organize those
Vasanthi
Yes
9:40 AM
Vasanthi
I have been reading on the ExpandableListView. Is that that one to use to implement a TreeView?
Mark M.
it is the closest thing that Android has to a tree widget
it supports only two levels of hierarchy, though
I have an ExpandableListView chapter towards the back of the book, in the "Widget Catalog" of miscellaenous widgets
Vasanthi
So any thoughts on how I could do a TreeView with multiple level of children? Yes, I read that and was going to try out.
Mark M.
those are two that came up in a search for "tree" on the Android Arsenal (http://android-arsenal.com)
I haven't used either of them
on phones, traversing deep hierarchies that way will get awkward
Vasanthi
Thank you very much, Mark. I am sure I will be there for your next office hours at the same time. I am from UK, so it is bit hard for me to attend the 7:30pm sessions
Mark M.
might not be as bad on a tablet
understood
that's why I rotate between three time slots
however, they also tie into my travel schedule and stuff
Vasanthi
Yes, I have got those two, but have not had a chance to read them yet.
Thank you very much for helping me. Will join you in the next chat. Bye for now.
Mark M.
you are very welcome
9:45 AM
Vasanthi
has left the room
9:55 AM
Mark M.
turned off guest access

Yesterday, May 7

 

Office Hours

People in this transcript

  • Bryan
  • Mark Murphy
  • Vasanthi
  • Yossi Elkrief