Skip to content

Commit

Permalink
02_05e
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgassner committed Jul 20, 2020
1 parent 7013528 commit 479109b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/src/main/java/com/example/plainolnotes4/MainViewModel.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
package com.example.plainolnotes4

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.example.plainolnotes4.data.NoteEntity
import com.example.plainolnotes4.data.SampleDataProvider

class MainViewModel : ViewModel() {
// TODO: Implement the ViewModel

val notesList = MutableLiveData<List<NoteEntity>>()
init {
notesList.value = SampleDataProvider.getNotes()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.example.plainolnotes4.data

import java.util.*

class SampleDataProvider {

companion object{
private val sampleText1 = "A simple note"
private val sampleText2 = "A note with\nline feed"
private val sampleText3 = """
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque convallis magna in dolor sodales, tristique efficitur nisl placerat. Proin ultricies pulvinar mauris id imperdiet. Quisque molestie luctus suscipit. Vestibulum suscipit, erat a efficitur imperdiet, erat enim aliquet tortor, ac commodo massa elit convallis sem. Curabitur posuere risus id orci volutpat cursus. Nulla facilisi. Sed eleifend auctor eros, condimentum blandit dolor. In ac viverra metus. Nulla non vestibulum dui. Integer blandit metus nec ipsum venenatis malesuada. Nam sit amet egestas neque. Praesent urna est, lobortis sit amet tincidunt vel, porta sit amet orci. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Suspendisse potenti. Maecenas mattis tempor magna vitae convallis. Sed arcu neque, suscipit blandit finibus at, finibus in odio. Sed a velit vitae purus rhoncus pharetra. Etiam iaculis arcu non purus tristique, ac viverra dui mattis. Morbi scelerisque libero pretium viverra dictum. Duis vestibulum metus venenatis, rutrum augue sit amet, porttitor felis. Etiam viverra ipsum turpis. Sed consequat, nulla vitae sollicitudin condimentum, magna tortor mollis augue, non feugiat erat libero ut magna. Aenean gravida massa vel odio lobortis posuere. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Fusce sed vestibulum eros, quis mollis sapien. Duis mollis vestibulum ullamcorper.
""".trimIndent()

private fun getDate(diff: Long): Date {
return Date(Date().time + diff)
}

fun getNotes() = arrayListOf(
NoteEntity(1, getDate(0), sampleText1),
NoteEntity(2, getDate(1), sampleText1),
NoteEntity(3, getDate(2), sampleText1)
)
}
}

0 comments on commit 479109b

Please sign in to comment.