Skip to content

Instantly share code, notes, and snippets.

View manuelernesto's full-sized avatar
🟣

Manuel Ernesto manuelernesto

🟣
View GitHub Profile
etName_firestore_update.text.append(personExtra.name)
etEmail_firestore_update.text.append(personExtra.email)
etPhone_firestore_update.text.append(personExtra.phone)
val person = Person(
null,
etName_firestore_update.text.toString(),
etEmail_firestore_update.text.toString(),
etPhone_firestore_update.text.toString())
db.collection("Person").document(personExtra.id!!).set(person)
.addOnSuccessListener {
"Updated Successful.".toast(this@UpdateFirestoreActivity)
finish()
db.collection("Person").document(personExtra.id!!)
.update("name",etName_firestore_update.text)
.addOnSuccessListener {
"Updated Successful.".toast(this@UpdateFirestoreActivity)
finish()
startActivity(Intent(this, FirestoreListActivity::class.java))
progressBarStyle.visibility = ProgressBar.INVISIBLE
}.addOnFailureListener { exception ->
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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"
tools:context=".MainActivity">
<TextView
<style name="AppTheme" parent="Theme.AppCompat.DayNight">
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight">
private fun chooseThemeDialog() {
val builder = AlertDialog.Builder(this)
builder.setTitle(getString(R.string.choose_theme_text))
val styles = arrayOf("Light","Dark","System default")
val checkedItem = 0
builder.setSingleChoiceItems(styles, checkedItem) { dialog, which ->
private fun chooseThemeDialog() {
val builder = AlertDialog.Builder(this)
builder.setTitle(getString(R.string.choose_theme_text))
val styles = arrayOf("Light","Dark","System default")
val checkedItem = 0
builder.setSingleChoiceItems(styles, checkedItem) { dialog, which ->
when (which) {
implementation "androidx.preference:preference-ktx:1.1.1"
class MyPreferences(context: Context?) {
companion object {
private const val DARK_STATUS = "io.github.manuelernesto.DARK_STATUS"
}
private val preferences = PreferenceManager.getDefaultSharedPreferences(context)
var darkMode = preferences.getInt(DARK_STATUS, 0)
set(value) = preferences.edit().putInt(DARK_STATUS, value).apply()