VerticalGridFragment
– Android TV application hands on tutorial 19

verticalgridfragment

Showing icons on vertical alignment We learned BrowseFragment to show icons, where icons are aligned horizontally when the size increases. VerticalGridFragment is another Fragment provided by leanback support library, where it shows the icons with vertical alignment.   For example, I guess Sideload Launcher – Android TV is using this VerticalGridFragment to show installed app icons.  This post explains how to implement VerticalGridFragment. The implementation is referenced from Google’s sample implementation in the same way as before. Create parent Activity – VerticalGridActivity Starting by creating Activity. right click on “ui” package, [New] → [Activity] → [Blank Activity], type Activity Name as “VerticalGridActivity” and click [Finish]. It will automatically create VerticalGridActivity class, activity_vertical_grid.xml layout resource and add this […]

Continue reading →

BrowseFragment ListRow customization
– Android TV application hands on tutorial 18

CustomListRow

More customization of BrowseFragment – Multiple rows icon alignment on ListRow Continuing from the previous chapter, BrowseFragment Header customization, I proceed to customizing ListRow. Chapter 17: Customizing Header Chapter 18: Customizing ListRow (we are here!) Leanback Launcher app shows multiple rows in Apps, Games bar if the number of icon is many (2 rows are used for “Apps” category in above picture). But original ListRow provided by Leanback support library only allows to show contents in one line. In this chapter, goal is to allow ListRow to show multiple rows in each header, by making customized class of ListRow (Model) and ListRowPresenter (Presenter). Explanation: Dig in source code  ListRow (Model), ListRowView (View), ListRowPresenter (Presenter) is used for […]

Continue reading →

BrowseFragment Header customization
– Android TV application hands on tutorial 17

icon_header_item_presenter

More customization of BrowseFragment – Showing icon beside the Header title The basic implementation of BrowseFragment is already explained in this tutorial. I’m going to proceed some advanced customization in following chapters. Chapter 17: Customizing Header (we are here!) Chapter 18: Customizing ListRow Aim is to change the design of header, to show icons on the left of header title text, as shown in the above image. How to customize header design Leanback support library adopts MVP (Model-View-Presenter) architecture*, and HeaderItem (Model) is not an exception. We can prepare our own View and Presenter to customize the design of header. * MVP is explained in Chapter 14.  Step is as follows, Make own Model (If necessary): Java class which […]

Continue reading →

Background data loading
– Android TV application hands on tutorial 15

LoaderManager_Loader

Background data loading using Loader class This Tutorial was explaining about Leanback support library, which is usually used to show list of contents information. So developers may want to load a many meta data to show contents. When Activity or Fragment need to prepare big size of data, it is better to load the data in background. For this purpose, we can use Loader and LoaderManager. They are useful to implement background data loading followed by updating UI based on these loaded data. I’m going to implement this Loader in this chapter. To study about Loader, I found a very nice article to understand Loader and the LoaderManager in detail (from part 1 to part 4). This post is […]

Continue reading →

Data loading from web
– Android TV application hands on tutorial 16

video-data-from-web

  * You can see the JSON video data used in this post at here: https://raw.githubusercontent.com/corochann/AndroidTVappTutorial/master/app/src/main/assets/video_lists.json  Manage data online, keep updated. In the previous chapter, Background data loading – Android TV application hands on tutorial 15, I introduced LoaderManager and Loader class which helps to load/prepare (maybe time consuming) data in background. One of the example of “time consuming” data preparation is loading data from network. If you can provide the data from the web, app can always show updated, latest information. In this chapter I will implement web data loading, to show our video contents information. We will prepare data in json format, and upload it to the web (https://raw.githubusercontent.com/corochann/AndroidTVappTutorial/master/app/src/main/assets/video_lists.json for now). It […]

Continue reading →

Updating your Nexus Player to Android M 6.0

Android 6.0 Marshmallow Factory Images are released for Nexus 6, Nexus 5, Nexus 9, Nexus 7, Nexus 10, Neus4 and Nexus Player. Google Releases Android 6.0 Marshmallow Factory Images for Nexus Devices Android 6.0 Factory Images Are Live For The Nexus 5, 6, 7, 9, And Player I will explain the steps to update software of your Nexus Player to Android M. The steps should be almost similar to other Nexus devices as well.  Flashing factory image to Nexus Player Step 0. install adb and fastboot command This method is for developers since it requires Android SDK tools set up such as, “adb” and “fastboot” command. If you haven’t set up these […]

Continue reading →

Building adb and fastboot command from AOSP source code

adb, android debugging brige, is used for connecting your PC and Android devices to get log, send command to Android devices etc which is very useful for Android software development. fastboot command is used to control bootloader mode for Nexus devices, it can be used to flash new factory image etc. Here the method of how to build adb command and fastboot command manually from Android Open Source Project source code is written. If you feel it trouble some to build adb and fastboot command manually in your PC, see also The Easiest Way to Install Android’s ADB and Fastboot Tools on Any OS [Guide] How To Setup And Use […]

Continue reading →

Spinner Fragment: show loading progress bar
– Android TV app hands on Tutorial Appendix A

spinner-2015-09-17-111126

In the Appendix of this Tutorial, I will introduce useful Android common library/function. These are usually applicable not only for Android TV, but also for Android phone/tablet device as well.   Spinner Fragment – show loading progress bar While user is downloading big contents from web, you might want to show progress bar to notify user that some process (in this time downloading) is being done in background. It helps navigating user to wait this process. Here, SpinnerFragment can be used to show circle arrow progress bar. Starting by making class by right click on “ui” package → [New] → [Java Class] → put Name as “SpinnerFragment”. This class is a subclass of […]

Continue reading →

Refactoring source code construction
– Android TV app hands on Tutorial 14

Refactoring I have explained Android TV specific UI implementations (sample source code referenced from Android TV sample application) through this tutorial. So I conclude this project by reorganizing the source code files. I did refactoring based on the role of each classes, and finished with below structure. com.corochann.androidtvapptutorial common – common functions. This module has no dependency of this application’s specific implementation so that you can “re-use” the code in other project as well.  PlaybackController Utils data – the data set of “Model” MovieProvider model – “Model” part of MVP architecture Movie recommendation – Recommendation function part RecommendationBuilder RecommendationFactory ui – UI handling modules (Activity & Fragments) MainActivity & MainFragment DetailsActivity & […]

Continue reading →

In-app Search function implementation
– Android TV app hands on Tutorial 13

Search function implementation The usage of SearchFragment of Leanback support library and UI related implementation are explained in previous chapter. In this chapter, I will explain (background) search function logic. Most of the implementation in this chapter is just a explanation of googlesamples. In-app search algorithm Search algorithm is implemented in loadRows method, especially the main logic is in doInBackground method of AsyncTask. It is actually simple, just checking the string “query” is contained in either title or description of Movie items. The UI related task Adapter handling is done in UI thread. onPreExecute initializes mRowsAdapter, which will contain the search results, by clear method. Searching itself is executed in background thread in […]

Continue reading →