brew install profanity
- The latest build available today via homebrew is 0.4.7, and it does not support desktop notifications.
import UIKit | |
class ProductsTableViewController: UITableViewController { | |
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
return 5 | |
} | |
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
let cell = tableView.dequeueReusableCell(withIdentifier: "ProductCell", for: indexPath) |
class EditTaskViewModel(val taskId: String? = null) { | |
/** | |
* Initialises this view model by loading the given task from the repository | |
* and binding it to the UI. | |
*/ | |
fun loadTask() {} | |
/** | |
* Commits the modified or new task to the repository. |
class EditTaskViewModel(val taskId: String? = null) : BaseObservable() { | |
@get:Bindable | |
var task: Task = Task() | |
set(value) { | |
field = value | |
notifyPropertyChanged(BR.task) | |
} | |
/** |
class EditTaskViewModel(val taskId: String? = null, | |
private val repository: TaskRepository, | |
private val listener: EditTaskListener? = null, | |
private val logger: Logger? = null) : BaseObservable() { | |
@get:Bindable | |
var task: Task = Task() // setter left out for brevity | |
fun loadTask() { | |
if (taskId == null) { |
interface EditTaskListener { | |
/** | |
* Called when the task has been comitted. | |
*/ | |
fun onTaskCommitted() | |
/** | |
* Called when there was a non-recoverable error. | |
* | |
* Usually removing the view bound to this view model is the appropriate reaction. |
fun commit() { | |
if (task.title.isBlank()) { | |
logger?.e("Trying to commit a task with an empty title.") | |
listener?.onFatalError(R.string.add_task_empty_title) | |
return | |
} | |
repository.commitTask(task, taskId) | |
listener?.onTaskCommitted() |
<?xml version="1.0" encoding="utf-8"?> | |
<layout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto"> | |
<data> | |
<variable | |
name="viewModel" | |
type="com.ubuntudroid.toddler.tasks.edit.EditTaskViewModel" /> | |
</data> |