View ToDoPresenter.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
package com.manijshrestha.todolist.ui | |
import com.manijshrestha.todolist.data.Task | |
import com.manijshrestha.todolist.data.TaskDao | |
import io.reactivex.Observable | |
import io.reactivex.android.schedulers.AndroidSchedulers | |
import io.reactivex.disposables.CompositeDisposable | |
import io.reactivex.schedulers.Schedulers | |
import javax.inject.Inject |
View ToDoPresenter.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
class ToDoPresenter @Inject constructor(val taskDao: TaskDao) { | |
var tasks = ArrayList<Task>() | |
var presentation: ToDoPresentation? = null | |
fun onCreate(toDoPresentation: ToDoPresentation) { | |
presentation = toDoPresentation | |
loadTasks() | |
} |
View AppModule.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
@Module class AppModule(private val context: Context) { | |
@Provides fun providesAppContext() = context | |
@Provides fun providesAppDatabase(context: Context): AppDatabase = | |
Room.databaseBuilder(context, AppDatabase::class.java, "my-todo-db").allowMainThreadQueries().build() | |
@Provides fun providesToDoDao(database: AppDatabase) = database.taskDao() | |
} |
View AppDatabase.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
@Database(entities = arrayOf(Task::class), version = 1, exportSchema = false) | |
abstract class AppDatabase : RoomDatabase() { | |
abstract fun taskDao(): TaskDao | |
} |
View TaskDao.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
@Dao interface TaskDao { | |
@Query("select * from task") | |
fun getAllTasks(): List<Task> | |
@Query("select * from task where id = :p0") | |
fun findTaskById(id: Long): Task | |
@Insert(onConflict = REPLACE) | |
fun insertTask(task: Task) |
View Task.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
import android.arch.persistence.room.ColumnInfo | |
import android.arch.persistence.room.Entity | |
import android.arch.persistence.room.PrimaryKey | |
@Entity(tableName = "task") | |
data class Task(@ColumnInfo(name = "completed_flag") var completed: Boolean = false, | |
@ColumnInfo(name = "task_desciption") var description: String) { | |
@ColumnInfo(name = "id") | |
@PrimaryKey(autoGenerate = true) var id: Long = 0 | |
} |
View build.gradle
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
dependencies { | |
.... | |
compile "android.arch.persistence.room:runtime:1.0.0-alpha1" | |
kapt "android.arch.persistence.room:compiler:1.0.0-alpha1" | |
... | |
} |
View WeatherDataService.java
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
public class WeatherService { | |
private WeatherListener mListener; | |
public WeatherService(WeatherListener listener) { | |
this.mListener = listener; | |
} | |
public void getWeather(String cityName) { | |
RestAdapter adapter = new RestAdapter.Builder().setEndpoint("http://api.openweathermap.org").build(); |
View build.gradle
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
productFlavors { | |
demo { | |
applicationId = "com.manijshrestha.weatherdemo.demo" | |
resValue "string", "app_name", "Demo App" | |
} | |
full { | |
applicationId = "com.manijshrestha.weatherdemo.full" | |
resValue "string", "app_name", "Full App" | |
} | |
} |
View KioskActivity.java
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
@Override | |
public void onBackPressed() { | |
stopLockTask(); | |
} |
NewerOlder