nandaja / androiddummy

My Android applications !
0 stars 1 forks source link

Grid Image Search - Week #2 assignment #3

Open nandaja opened 9 years ago

nandaja commented 9 years ago

@codepathreview @codepath

My Grid Image Search App (Refer https://github.com/nandaja/androiddummy/tree/master/GridImageSearchApp) is complete with all required & the suggested features.

I had some questions with respect to the line items on this assignment.

1) Very few of the images in the grid fail to load in the detailed view intermittently - in most cases the images load fine. When load fails in the detailed view, there is no error message in logs / an exception stack trace either. 2) At times, the loadMore on the grid view which is fired onScroll with a different offset / page number each time fires again with the same offset / page number. Due to this, it ends up loading the same image multiple times. This is very intermittent as well. Is this a known issue and is there something that I may be missing here ? 3) When I scroll back up on the grid view, images shift position at times, is the grid not expected to render the images in fixed positions even when we scroll up ? 4) How do we detect the background color of an underlying activity programmatically ( dynamically ) and decide on the color settings for the modal overlay ?

codepathreview commented 9 years ago

:+1: Looks great overall. Impressive submission, good job on finishing so many optionals.

I have provided a 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 very 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.

codepathreview commented 9 years ago

For the question you asked -

  1. Try to load image into a bitmap drawable and debug that how it works and what it transforms into. This is a hint to the approach you should follow. I need to find out a bit more on rest of the 3 issues before I can comment.
nesquena commented 9 years ago

1) Very few of the images in the grid fail to load in the detailed view intermittently - in most cases the images load fine. When load fails in the detailed view, there is no error message in logs / an exception stack trace either.

Picasso supports error handling most simply with:

Picasso.with(context)
    .load(url)
    .placeholder(R.drawable.user_placeholder)
    .error(R.drawable.user_placeholder_error)
    .into(imageView);

In short, some images are simply now invalid and can't ever be loaded. Ideally these errors would be noticed and handled in an error block and removed from the stream.

2) At times, the loadMore on the grid view which is fired onScroll with a different offset / page number each time fires again with the same offset / page number. Due to this, it ends up loading the same image multiple times. This is very intermittent as well. Is this a known issue and is there something that I may be missing here ?

This could be caused by https://github.com/nandaja/androiddummy/blob/master/GridImageSearchApp/app/src/main/java/com/yahoo/gridimagesearchapp/activities/ImageSearchActivity.java#L187-L192 where you clear the adapter and the array at the same time. Clearing the adapter automatically clears the array as well. There's no point in clearing or adding the items twice. Instead only modify the adapter OR only modify the array (and then call adapter.notifyDatasetChanged). I suspect that is causing this intermittent race condition. The thing to keep in mind is that changing the adapter also automatically manipulates the underlying data source. Try that and it might help resolve this issue.

3) When I scroll back up on the grid view, images shift position at times, is the grid not expected to render the images in fixed positions even when we scroll up ?

Generally speaking, the positions shouldn't shift around as you scroll. Try applying the ViewHolder pattern in the adapter to improve performance: http://guides.codepath.com/android/Using-an-ArrayAdapter-with-ListView#improving-performance-with-the-viewholder-pattern. You might also want to check the issues to see if anyone discusses this problem: https://github.com/etsy/AndroidStaggeredGrid/issues

4) How do we detect the background color of an underlying activity programmatically ( dynamically ) and decide on the color settings for the modal overlay ?

This is a great question! See http://guides.codepath.com/android/Dynamic-Color-using-Palettes for a powerful palette system that allows for dynamic coloring based on the image!

nandaja commented 9 years ago

Appreciate your responses, Nathan ! I will definitely try out your pointers and work towards resolution.