The aim of the app is to fetch news from different wordpress websites and display in the application. While the news are displayed, the app gives you the ability to click and view each news within the app. Instead of taking you out of the app, it gives you the comfort of viewing within the
User can now search for Contents in the app
| User can Enter Search Query | The adapter Filters based on Users search query |
|---|---|
| An Empty Screen is shown when nothing is found | Life cycle awareness when the app is rotated, search Query is preserved |
|---|---|
The resources for the icons were gotten from google icons. Commit can be found here
Handling Searching was a bit tricky but was achieved by using custom Adapter that implemented Searchable Adapter.
The Search View was instantiated here
searchView.setOnQueryTextListener(this); searchView.setOnQueryTextListener(this);
if (mSearchQuery != null && !mSearchQuery.isEmpty()){
String s = mSearchQuery;
searchItem.expandActionView();
searchView.setQuery(s, false);
searchView.clearFocus();
}
The Fragment implemented a listener which watched for change in the text when the user entered his search query in onQueryTextChange() method. This method contains the filter logic which used a for loop to scan through the List for matching text. The code for this can be found here
Saving the User search query was very important as i was able to cater for orientation changes in the activity in onSavedInstanceState method and was restored in onCreate method of the activity. This can be found here. Doing this i was able to preserve the fragment it self an the search Query.
Other Updates included introducing Databinding to the architecture i am already using. i am able to bind views direct with the data and it helped reduced a lot of broiler plate. A FragmentBindingAdapter was introduced to help directly bind the data to the xml. (no more setText() method in our fragment/activity).
Major Commit here