Skip to content

Instantly share code, notes, and snippets.

View miquelbeltran's full-sized avatar

Miguel Beltran miquelbeltran

View GitHub Profile
class DayViewHolder(view: View): RecyclerView.ViewHolder(view) {
val title: TextView = itemView.title
fun bind(day: HomeScreenItem.Day) {
title.text = day.title
}
}
public final void bind(@NotNull Day day) {
Intrinsics.checkParameterIsNotNull(day, "day");
((TextView)this.itemView.findViewById(id.title)).setText((CharSequence)day.getTitle());
}
class DayViewHolder(view: View): RecyclerView.ViewHolder(view) {
fun bind(day: HomeScreenItem.Day) {
itemView.title.text = day.title
}
}
class DayViewHolder(view: View): RecyclerView.ViewHolder(view) {
fun bind(day: HomeScreenItem.Day) {
itemView.title.text = day.title
}
}
val arduino = Arduino()
arduino.write("H")
Thread.sleep(100) // let Arduino reply
val hello = arduino.read() // hello = "Hello World"
if (Serial.available() > 0) {
char command = (char) Serial.read();
switch (command) {
case 'H':
Serial.write("Hello World");
break;
}
Serial.flush();
}
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)
class BooksViewModel extends ViewModel {
private GoogleBooksService service;
public BooksViewModel() {
// Configure Retrofit here
}
private MutableLiveData<List<Book>> books;
// 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
class BooksViewModel extends ViewModel {
private MutableLiveData<List<Book>> books;
LiveData<List<Book>> getBooks() {
if (books == null) {
books = new MutableLiveData<List<Book>>();
}
return books;
}