This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DayViewHolder(view: View): RecyclerView.ViewHolder(view) { | |
| val title: TextView = itemView.title | |
| fun bind(day: HomeScreenItem.Day) { | |
| title.text = day.title | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public final void bind(@NotNull Day day) { | |
| Intrinsics.checkParameterIsNotNull(day, "day"); | |
| ((TextView)this.itemView.findViewById(id.title)).setText((CharSequence)day.getTitle()); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DayViewHolder(view: View): RecyclerView.ViewHolder(view) { | |
| fun bind(day: HomeScreenItem.Day) { | |
| itemView.title.text = day.title | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DayViewHolder(view: View): RecyclerView.ViewHolder(view) { | |
| fun bind(day: HomeScreenItem.Day) { | |
| itemView.title.text = day.title | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val arduino = Arduino() | |
| arduino.write("H") | |
| Thread.sleep(100) // let Arduino reply | |
| val hello = arduino.read() // hello = "Hello World" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (Serial.available() > 0) { | |
| char command = (char) Serial.read(); | |
| switch (command) { | |
| case 'H': | |
| Serial.write("Hello World"); | |
| break; | |
| } | |
| Serial.flush(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import android.util.Log | |
| import com.google.android.things.pio.PeripheralManagerService | |
| import com.google.android.things.pio.UartDevice | |
| class Arduino(uartDevice: String = "UART0"): AutoCloseable { | |
| private val TAG = "Arduino" | |
| private val uart: UartDevice by lazy { | |
| PeripheralManagerService().openUartDevice(uartDevice).apply { | |
| setBaudrate(115200) | |
| setDataSize(8) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class BooksViewModel extends ViewModel { | |
| private GoogleBooksService service; | |
| public BooksViewModel() { | |
| // Configure Retrofit here | |
| } | |
| private MutableLiveData<List<Book>> books; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // As class member | |
| private BooksViewModel model; | |
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { | |
| // Rest of method removed from example | |
| // Load our BooksViewModel or create a new one | |
| model = ViewModelProviders.of(this).get(BooksViewModel.class); | |
| // Listen for changes on the BooksViewModel |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class BooksViewModel extends ViewModel { | |
| private MutableLiveData<List<Book>> books; | |
| LiveData<List<Book>> getBooks() { | |
| if (books == null) { | |
| books = new MutableLiveData<List<Book>>(); | |
| } | |
| return books; | |
| } |