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
class HomeFragment : StandardFragment() { | |
... | |
} | |
class SpeakersFragment : StandardFragment() { | |
... | |
} |
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
open class StandardFragment:Fragment(),CoroutineScope { | |
private lateinit var job: Job | |
override val coroutineContext: CoroutineContext | |
get() = job + Dispatchers.Main | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
job = Job() |
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
@Database(entities = [Palestrante::class], version = 1) | |
abstract class PalestranteDB: RoomDatabase() { | |
abstract fun dao(): PalestranteDAO | |
companion object { | |
@Volatile | |
private var TALK_INSTANCE: PalestranteDB? = null | |
fun getDatabase(context: Context): PalestranteDB { |
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
@Dao | |
interface PalestranteDAO { | |
@Insert | |
suspend fun salvar(palestrante: Palestrante) | |
@Query("SELECT * FROM tb_palestrante") | |
suspend fun buscarTodos(): List<Palestrante> | |
@Update | |
suspend fun actualizar(palestrante: Palestrante) |
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 = "tb_palestrante") | |
data class Palestrante( | |
@PrimaryKey(autoGenerate = true) | |
var id: Int = 0, | |
@ColumnInfo(name = "nome_palestrante") | |
val palestrante: String, | |
val tecnologia: String, | |
val topico: String | |
):Serializable |
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
apply plugin: 'kotlin-kapt' |
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
implementation "androidx.room:room-ktx:$room_version" | |
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7" |
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
implementation "androidx.room:room-ktx:$room_version" | |
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7" |
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
def room_version = "2.2.5" | |
implementation "androidx.room:room-runtime:$room_version" | |
kapt "androidx.room:room-compiler:$room_version" |
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
class MainActivity : AppCompatActivity() { | |
private lateinit var mNavController: NavController | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
... |