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
MyRepository mRepository = new MyRepository(getApplicationContext); |
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
String title = "First note title"; | |
String desc = "First note desc"; | |
mRepository.insert(title, desc); |
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
String newTitle = "New Title"; | |
Stirng descNew = "New Description"; | |
Entity entity = new Entity(); | |
entity.setTitle(newTitle); | |
entity.setContent(newTitle); | |
entity.setWroteAt(AppTools.getCurrentDateTime()); | |
//Updating a row | |
mRepository.update(entity); |
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
@WorkerThread | |
fun search(desc : String) : LiveData<List<DataClass>>{ | |
return myDao.getSearchResults(desc) | |
} |
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
val search = menu.findItem(R.id.searchItems) | |
searchView = search.actionView as androidx.appcompat.widget.SearchView | |
searchView.isSubmitButtonEnabled = true | |
searchView.setOnQueryTextListener(object: androidx.appcompat.widget. | |
SearchView.OnQueryTextListener{ | |
override fun onQueryTextSubmit(query: String?): Boolean { | |
if (query != null) { | |
getItemsFromDb(query) | |
} | |
return true |
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
private fun getItemsFromDb(searchText: String) { | |
var searchText = searchText | |
searchText = "%$searchText%" | |
myViewModel.searchForItems(desc = searchText).observe(this@MainActivity, Observer { list -> | |
list?.let { | |
Log.e("List = ", list.toString()) | |
} | |
}) |
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
# Install R + RStudio on Ubuntu 16.04 | |
sudo apt-key adv –keyserver keyserver.ubuntu.com –recv-keys E084DAB9 | |
# Ubuntu 12.04: precise | |
# Ubuntu 14.04: trusty | |
# Ubuntu 16.04: xenial | |
# Basic format of next line deb https://<my.favorite.cran.mirror>/bin/linux/ubuntu <enter your ubuntu version>/ | |
sudo add-apt-repository 'deb https://ftp.ussg.iu.edu/CRAN/bin/linux/ubuntu xenial/' | |
sudo apt-get update |
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
@Entity(tableName = "word_table") | |
data class Word ( | |
@PrimaryKey | |
@NonNull | |
var name: String, | |
var meaning: String? = null, | |
var audioPath: String? = null | |
) |
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
@Insert(onConflict = OnConflictStrategy.REPLACE) | |
fun insertWord(word: Word) | |
@Query ("Select * from word_table") | |
fun getAllWordsPaged() : DataSource.Factory<Int, Word> | |
@Query("Delete from word_table where name like :name") | |
fun deleteWord(name: String) | |
@Query("Update word_table set name = :name, meaning = :meaning, audioPath = :audiopath where name like :originalName") |
OlderNewer