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 androidx.compose.foundation.Canvas | |
import androidx.compose.foundation.background | |
import androidx.compose.foundation.border | |
import androidx.compose.foundation.layout.Box | |
import androidx.compose.foundation.layout.Row | |
import androidx.compose.foundation.layout.fillMaxHeight | |
import androidx.compose.foundation.layout.fillMaxWidth | |
import androidx.compose.foundation.layout.height | |
import androidx.compose.foundation.layout.offset | |
import androidx.compose.foundation.layout.padding |
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
@Entity | |
data class Note(/* properties declaradas */) |
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 NoteListActivity : AppCompatActivity() { | |
private var adapter: NoteListAdapter? = null | |
private var recyclerView: RecyclerView? = null | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_note_list) | |
adapter = NoteListAdapter(notes(), this) | |
recyclerView = note_list_recyclerview |
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
// others plugins | |
apply plugin: 'kotlin-kapt' | |
android { | |
// Android project configuration | |
} | |
dependencies { | |
// others dependencies |
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
package br.com.alexf.ceepws.service | |
import br.com.alexf.ceepws.model.Note | |
import br.com.alexf.ceepws.repository.NoteRepository | |
class NoteService( | |
private val noteRepository: NoteRepository) { | |
fun all(): List<Note> { | |
return noteRepository.findAll().toList() |
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
<?xml version="1.0" encoding="utf-8"?> | |
<android.support.constraint.ConstraintLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<ImageView |
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
fun alter(note: Note, | |
preExecute: () -> Unit = {}, | |
finished: () -> Unit = {}, | |
altered: (alteredNote: Note) -> Unit) { | |
titleField.setText(note.title) | |
descriptionField.setText(note.description) | |
AlertDialog.Builder(context) | |
.setTitle("Alter note") | |
.setView(createdView) | |
.setPositiveButton("Save") { _, _ -> |
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
fun <T> Response<T>?.defaultResponse(success: (t: T) -> Unit) { | |
this?.body()?.let { success(it) } | |
} | |
fun Throwable?.defaultFailure(failure: (throwable: Throwable) -> Unit) { | |
this?.let { | |
failure(it) | |
} | |
} |
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
fun list(preExecute: () -> Unit, | |
finished: () -> Unit, | |
success: (notes: List<Note>) -> Unit, | |
failure: (throwable: Throwable) -> Unit) { | |
val call = RetrofitInitializer().noteService().list() | |
call.enqueue( | |
callback( | |
response = { response -> | |
response?.body()?.let { | |
success(it) |
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
fun <T> callback(preExecute: () -> Unit = {}, | |
finished: () -> Unit = {}, | |
response: (response: Response<T>?) -> Unit = {}, | |
failure: (throwable: Throwable?) -> Unit = {}): Callback<T> { | |
preExecute() | |
return object : Callback<T> { | |
override fun onResponse(call: Call<T>?, response: Response<T>?) { | |
response(response) | |
finished() | |
} |
NewerOlder