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!
|
Mark M. |
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
|
May 8 | 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?
|
Bryan |
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
|
Yossi E. |
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
|
Yossi E. |
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
|
Mark M. |
though, again, that's a gut reaction
|
Mark M. |
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
|
Mark M. |
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
|
Mark M. |
after the resize operation, what is your intended use for the image?
|
May 8 | 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
|
Bryan |
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
|
Mark M. |
option #1: skip the synchronous part, and do the upload only after Picasso (or whoever) has loaded and resized the image
|
Mark M. |
option #2: do your own image loading/resizing yourself, perhaps leveraging code from a library like Picasso as inspiration
|
Mark M. |
image loaders for Android are usually designed for async operatoin
|
Mark M. |
er, operation
|
Mark M. |
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 :-)
|
Mark M. |
you could try Universal Image Loader
|
Mark M. | |
Mark M. |
it seems to have a loadImageSync() method
|
Mark M. |
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?
|
May 8 | 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
|
Mark M. |
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
|
Mark M. |
yeah, that's way outside my areas of expertise
|
Mark M. |
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
|
Yossi E. |
http://blog.wiresareobsolete.com/ this one right?
|
Mark M. |
yes
|
May 8 | 9:15 AM |
Yossi E. |
Thanks, good bye for now.
|
Mark M. |
you are very welcome
|
Yossi E. | has left the room |
May 8 | 9:20 AM |
Vasanthi | has entered the room |
Mark M. |
hello, Vasanthi!
|
Mark M. |
how can I help you today?
|
Vasanthi |
Hello Mark
|
Vasanthi |
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!
|
Mark M. |
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
|
Vasanthi |
View paste
|
Vasanthi |
Is it to do with the new version of Android Studio?
|
Mark M. |
possibly
|
Mark M. |
from outside of Android Studio, delete the .iml file and the .idea/ directory
|
Mark M. |
then import the project back into Android Studio
|
Mark M. |
that usually cleans up this sort of problem
|
May 8 | 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
|
Mark M. |
I have not encountered that message before
|
Mark M. |
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
|
Mark M. |
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
|
May 8 | 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
|
Vasanthi |
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
|
Mark M. |
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
|
Mark M. |
ListActivity implements an OnItemClickListener and registers it with the ListView for you
|
May 8 | 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
|
Mark M. |
onClick is a replacement for an OnClickListener
|
Mark M. |
OnClickListener is not the same as OnItemClickListener
|
Mark M. |
OnClickListener is for clicks anywhere on a widget, like a Button
|
Mark M. |
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
|
Mark M. |
and, as you'll see later in the book, android:onClick is not used in many cases anyway
|
Vasanthi |
OK. Thank you. Next question...
|
Vasanthi |
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
|
Mark M. |
there needs to be a single root element, for XML reasons as much as anything else
|
Mark M. |
for example, earlier in the book, we had layout resources that were just a Button widget
|
Mark M. |
you only need a container like LinearLayout if you want to organize multiple children
|
Mark M. |
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
|
Mark M. |
in the earlier example, I had a TextView along with the ListView
|
Mark M. |
and so I needed a container to organize those
|
Vasanthi |
Yes
|
May 8 | 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
|
Mark M. |
it supports only two levels of hierarchy, though
|
Mark M. |
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. | |
Mark M. | |
Mark M. |
those are two that came up in a search for "tree" on the Android Arsenal (http://android-arsenal.com)
|
Mark M. |
I haven't used either of them
|
Mark M. |
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
|
Mark M. |
understood
|
Mark M. |
that's why I rotate between three time slots
|
Mark M. |
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.
|
Vasanthi |
Thank you very much for helping me. Will join you in the next chat. Bye for now.
|
Mark M. |
you are very welcome
|
May 8 | 9:45 AM |
Vasanthi | has left the room |
May 8 | 9:55 AM |
Mark M. | turned off guest access |