Thursday, 15 September 2016

Mobile App Developer

Now we’re into mobile app developer territory, however there’s really nothing unusual happening - it's a standard RecyclerView.Adapter implementation without a penny specific to Data Binding - that will get completed in the StatusViewHolder as we’ll see shortly - but so far as the Adapter is worried case a typical RecyclerView.ViewHolder. The only real factor that's really happening here that’s specific towards the MVVM pattern may be the marshalling from twitter4j.Status to .data.Status
library works. The RelativeLayout using the ID status_container is a nice standard layout (but a few of the Sights possess some weird stuff in a few of their characteristics, which we’ll arrived at in just a minute). However this parent layout is covered with its very own <layout> parent that is specific towards the Data Binding library. Along with the RelativeLayout, the <layout> also consists of an information section which defines the information objects that we’re likely to bind to - within this situation we’re proclaiming b .information.Standing named status. We are able to now reference this through the layout.

So inside the layout we've the weird android:text characteristics - mobile app developer are basically getters from your .data.Status object. The @ wrapper signifies that this can be a data binding expression, and also the status.name is the same as calling status.getName() in Java. That’s the center of methods Data Binding works but there’s a great deal more into it that that once we shall see.

But there's something a little more complex happening within the TextView with ID status_screen_name: @. Even though this looks quote frightening, all it's is a few simple string concatenation to prepend a ‘@’ symbol towards the Twitter screen name. We have to place the @ inside quotes which have to be steered clear of inside an XML layout, but basically all it's doing is: "@"   status.getScreenName() in Java. However, this does further hint that there's more that people can perform with this particular expression language, as we’ll discover once we progress.

That’s a great deal simpler than the usual normal ViewHolder where we have to discover the child Sights inside the parent layout within the constructor after which set their characteristics within the bind() method. The very first factor to note is the fact that we’re using StatusItemBinding which we’re acquiring from DataBindingUtil.bind(), but we haven’t covered that. This is because we do not need to create it since it is produced for all of us through the Data Binding library.

No comments:

Post a Comment