-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7013528
commit 479109b
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
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() | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
app/src/main/java/com/example/plainolnotes4/data/SampleDataProvider.kt
This file contains 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
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) | ||
) | ||
} | ||
} |