Android Programming The Big Nerd Ranch Guide by Bill Phillips, Chris Stewart, Kristin Marsicano (z-lib.org)
Lambda expressions Lambda expressions You can write short callbacks directly in your layout file by using lambda expressions. Th ...
Chapter 20 Data Binding and MVVM public class BeatBoxBindingAdapter { @BindingAdapter("app:soundName") public static void bindA ...
21. Unit Testing and Audio Playback One reason MVVM architecture is so appealing is that it makes a critical programming practic ...
Chapter 21 Unit Testing and Audio Playback Lollipop introduced a new way of creating a SoundPool using a SoundPool.Builder. How ...
Loading Sounds Now to load your sounds. Add a load(Sound) method to BeatBox to load a Sound into your SoundPool. Listing 21.3 L ...
Chapter 21 Unit Testing and Audio Playback Playing Sounds BeatBox also needs to be able to play sounds. Add the play(Sound) met ...
Creating a Test Class Select the Dependencies tab at the top of the screen, click the + button at the bottom of the dialog, and ...
Chapter 21 Unit Testing and Audio Playback navigate to a test class associated with the class you are looking at. If there is n ...
Setting Up Your Test Figure 21.4 Selecting a destination directory Setting Up Your Test Now to build out your SoundViewModel te ...
Chapter 21 Unit Testing and Audio Playback If you do that in a unit test, though, you create a problem: If BeatBox is broken, t ...
Writing Tests Writing Tests Now that your setUp() method is written, you are ready to write your tests. A test is a method in yo ...
Chapter 21 Unit Testing and Audio Playback on SoundViewModel called onButtonClicked() that calls BeatBox.play(Sound). Write a t ...
Testing object interactions The verify(Object) uses a fluent interface, much like the AlertDialog.Builder class you used earlier ...
Chapter 21 Unit Testing and Audio Playback Rerun your test. This time you should see green, indicating that all your tests pass ...
Data Binding Callbacks Data Binding Callbacks One last step remains to get your buttons working: You need to hook up onButtonCli ...
Chapter 21 Unit Testing and Audio Playback Unloading Sounds The app works, but to be a good citizen you should clean up your So ...
Rotation and Object Continuity Rotation and Object Continuity Now you are a good citizen, which is nice. Unfortunately, your app ...
Chapter 21 Unit Testing and Audio Playback Retaining a fragment Fortunately, fragments have a feature that you can use to keep ...
Rotation and retained fragments Figure 21.9 Default rotation with a UI fragment On the other hand, if retainInstance is true, t ...
Chapter 21 Unit Testing and Audio Playback A retained fragment is not destroyed, but it is detached from the dying activity. Th ...
«
17
18
19
20
21
22
23
24
25
26
»
Free download pdf