Skip to content

Instantly share code, notes, and snippets.

View vprabhu's full-sized avatar

Vignesh Prabhu vprabhu

View GitHub Profile
@vprabhu
vprabhu / DrawerLayoutDemo_.idea_.name
Created February 1, 2014 16:56
Eyas Unfledged Drawer Layout
DrawerLayoutDemo
DrawerLayoutDemo
LoadersDemo
@vprabhu
vprabhu / kotlin_toplevelfunction.csv
Last active March 21, 2018 10:26
TopLevelFunction in Kotlin
Java Kotlin
Keywords used : public & static no keywords
Class Instance is required to call a method No class instance is required to call a function
compile "android.arch.persistence.room:runtime:1.0.0"
annotationProcessor "android.arch.persistence.room:compiler:1.0.0"
@Entity(tableName = "todotasks")
class TodoTask(@field:PrimaryKey(autoGenerate = true)
var id: Int, var name: String?, @field:ColumnInfo(name = "due_date")
var dueDate: Date?)
@Dao
interface TodoTaskDao {
@Query("select * from todotasks order by id")
fun getallTasks(): List<TodoTask>
@Insert
fun insertTodoTask(todoTask: TodoTask)
@Update(onConflict = OnConflictStrategy.REPLACE)
object DateConverter {
@TypeConverter
fun toDate(timestamp: Long?): Date? {
return if (timestamp == null) null else Date(timestamp)
}
@TypeConverter
fun toTimestamp(date: Date?): Long? {
return date?.time