nehakarajgikar / AndroidGridImageSearch

App to search for images and display in grid style
0 stars 0 forks source link

[Android Bootcamp] Almost ready for review #1

Open nehakarajgikar opened 10 years ago

nehakarajgikar commented 10 years ago

Hi Nathan, my app is almost ready, but I'm facing a problem in this one particular case: 1) I type a search term, click search, items show up ( it loads all items in smooth scrolling format) 2)Then I delete the previous search term and enter a new term, and click search. Here, it shows me only 8 results, it doesn't load all the items and doesn't show you endless scrolling. However, if I click on search a second time without modifying the search term, it loads everything correctly. Do you know what could be wrong? /cc @nesquena

Thanks! Neha

nesquena commented 10 years ago

Do you know what could be wrong?

Don't set the scroll listener in searchImages instead set it when you initialize the activity here. Resetting the listener each time is probably what is causing that issue (i.e the listener is intended to be setup just once)

Also start in the api call is the total item offset not the page number. You should use totalItemsCount parameter instead to act as the offset. Otherwise I have to assume you are getting a lot of image duplicates.

Can you try this and see if that helps?

nehakarajgikar commented 10 years ago

I made both changes, and while the offset helped in getting my next issue resolved (why was I seeing so many repetitons?), the scroll listener didn't work. It now only works for the first request. Subsequent searches yield only 8 results. Previously, when it was in searchImages, it would work if I navigated to settings and came back or clicked on the search button twice. /cc @nesquena

nesquena commented 10 years ago

Setting in initialization should work, I've tested it recently and seen it in multiple other submissions and it works across any number of search requests. I'll download your project and see if I can track down where it's going wrong. If the only story left is the endless pagination, feel free to submit an issue for code feedback and i'll mark your homework submitted (provide the feedback) and we can get this working afterwards.

nesquena commented 10 years ago

Found why it's not working for you! It's arguably a bug with the listener but it has to do with the fact that you don't clear out the adapter, you go directly to the array here. Try changing that to imageAdapter.clear() and it works like a charm. Glad I found this though going to see if I can make it work in either case.

Edit: Fixed the guide so that it works in both cases now (I think).

nehakarajgikar commented 10 years ago

Thank you so much! I did make the change you suggested and it works perfectly now. I also tried creating an implicit intent to share, but for some reason it doesn't open the chooser dialog, and takes me directly to text message. And the second problem is how do I attach an image and send it. I thought it was to use the Intent.ACTION_SEND along with Intent.ACTION_ATTACH_DATA, but it seems now like the later is used when you are on a screen and you click on attach and it opens up a chooser for images (like gallery, etc). So I guess it should be the Intent.ACTION_SEND, but how do I send the image? Do I download it temporarily and just send it by set Intent.setType ("image/*")?

Thanks again! Also, its ready for review right now, I can incorporate the optional changes later.

nesquena commented 10 years ago

Neha, :+1: great work. A few notes after checking out the code:

Nicely done submission! Also, here's provided a more detailed Project 2 Feedback Guide here which covers the most common issues with this submitted project. Read through the feedback guide point-by-point to determine how you could improve your submission.

Let us know if you have any other thoughts or questions about this assignment. The next assignment (Twitter Client) will be especially important since it introduces the majority of the remaining pieces necessary to build a fully functional API client with complex feeds of data and user creation.

I also tried creating an implicit intent to share, but for some reason it doesn't open the chooser dialog, and takes me directly to text message.

Check out this guide for how to do sharing correctly. It's actually a bit more complex which is why it is optional but it's a good learning exercise!