O'Reilly logo

Hello, Android, 4th Edition by Ed Burnette

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Loose Ends

To finish up the Suggest example, here are a few utility functions used in other places:

suggest/src/main/java/org/example/suggest/MainActivity.java
 
/** Request an update to start after a short delay */
 
private​ ​void​ queueUpdate(​long​ delayMillis) {
 
// Cancel previous update if it hasn't started yet
 
guiThread.removeCallbacks(updateTask);
 
// Start an update if nothing happens after a few milliseconds
 
guiThread.postDelayed(updateTask, delayMillis);
 
}
 
 
/** Modify list on the screen (called from another thread) */
 
public​ ​void​ setSuggestions(​List​<​String​> suggestions) {
 
guiSetList(suggList, suggestions);
 
}
 
 
/** All changes to the GUI must be done in the GUI thread */
 
private​ ​void​ guiSetList(​ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required