New York Times Search API is an android app that allows a user to search for articles on web using simple filters. The app utilizes New York Times Search API.
Time spent: 18 hours spent in total
The following required functionality is completed:
- User can search for news article by specifying a query and launching a search. Search displays a grid of image results from the New York Times Search API.
- User can click on "settings" which allows selection of advanced search options to filter results
- User can configure advanced search filters such as:
- Begin Date (using a date picker)
- News desk values (Arts, Fashion & Style, Sports)
- Sort order (oldest or newest)
- Subsequent searches have any filters applied to the search results
- User can tap on any article in results to view the contents in an embedded browser.
- User can scroll down to see more articles. The maximum number of articles is limited by the API search.
The following optional features are implemented:
- Implements robust error handling, check if internet is available, handle error cases, network failures
- Used the ActionBar SearchView or custom layout as the query box instead of an EditText
- User can share an article link to their friends or email it to themselves
- Replaced Filter Settings Activity with a lightweight modal overlay
- Improved the user interface and experiment with image assets and/or styling and coloring
The following bonus features are implemented:
- Use the RecyclerView with the
StaggeredGridLayoutManager
to display improve the grid of image results - For different news articles that only have text or only have images, use Heterogenous Layouts with RecyclerView
- Use Parcelable instead of Serializable using the popular Parceler library.
- Leverages the data binding support module to bind data into layout templates.
- Replace all icon drawables and other static image assets with vector drawables where appropriate.
- Replace Picasso with Glide for more efficient image rendering.
- Uses retrolambda expressions to cleanup event handling blocks.
- Leverages the popular GSON library to streamline the parsing of JSON data.
- Leverages the Retrofit networking library to access the New York Times API.
- Replace the embedded
WebView
with Chrome Custom Tabs using a custom action button for sharing. (2 points)
The following additional features are implemented:
- List anything else that you can get done to improve the app functionality!
- Clear Advanced Search Option Setting
- Use toast to notify user on Network Error, Advance Setting Saved, Advance Setting Cleard to make user experience smothly.
Here's a walkthrough of implemented user stories:
GIF created with LiceCap.
Describe any challenges encountered while building the app.
- Where is the better plance to implement AsyncTask which include OkHttpClient network operations? I was using option 2 in last assignment; however I found the doInBackground operations in my Ansy task will be reused in in different activity. This time I try the option 1; after that, I realized that when I try to reapint (or notify) UI changes it introduced a piece of coupling code related to my Activity. That make me feel option 2 is not a right way to do. Anyone have some suggestion on how to better use of Async task? Thank you so much. (option 1) To create a client (e.g. NYTClient) and then crate a static inner class to extends AsyncTask? (option 2) To create a static inner class to extends AsyncTask at the Activity class.
[Resolved] In the end , I leveraged the asynchronous OkHttpClient to keep the UI coupling call in the Activity class. In the mean time , I wrapped the complexity of OkHttpClient, Request Builder,HttpUrlBuilder, and New York Times API parameters in NYTClient to decouple (also increase reusability) the networking code with UI code.
- Android Async HTTP - Simple asynchronous HTTP requests with JSON parsing
- Picasso - Image loading and caching library for Android
- [parceler]
- [glide]
- [okhttp]
- [stetho]
- [butterknife]
Copyright [2017] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.