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
//setup | |
// dir for script to work in | |
String DIR = "/your/project/dir"; | |
// character that have to occur before target variable | |
List<Character> charactersBeforeVariable = Arrays.asList( | |
' ', | |
'(', | |
'.', | |
'!', |
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
value = value; |
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
mValue = value; |
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
this.value = value; |
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’ | |
android { | |
--- | |
} | |
dependencies { | |
// RxKotlin and RxAndroid | |
compile "io.reactivex.rxjava2:rxkotlin:2.0.0" | |
compile "io.reactivex.rxjava2:rxandroid:2.0.1" |
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 ItemDao { | |
@Query("SELECT name, place, description, date_added_ms FROM items") | |
fun getAllItems(): Flowable<List<Item>> | |
@Query("SELECT name FROM items WHERE place = :arg0") | |
fun getItemsAt(place: String): Flowable<List<Item>> | |
@Insert(onConflict = OnConflictStrategy.REPLACE) | |
fun insertItem(item: Item) |
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 database = Room.databaseBuilder(applicationContext, ItemsDatabase::class.java, "cleverDatabaseName").build() |
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 onGetItems() = database.itemDao().getAllItems() | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribe(view::showData, { | |
throwable -> | |
view.showLoadingDataError(throwable.localizedMessage) | |
}) |
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(Item::class), version = 1) | |
abstract class ItemsDatabase : RoomDatabase() { | |
abstract fun itemDao(): ItemDao | |
} |
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 = "items") | |
data class Item( | |
@PrimaryKey | |
@ColumnInfo(name = "name") var name: String = "", | |
@ColumnInfo(name = "place") var place: String = "", | |
@ColumnInfo(name = "quantity") var quantity: String = "", | |
@ColumnInfo(name = "description") var description: String = "", | |
@ColumnInfo(name = "tags") var tags: String = "", | |
@ColumnInfo(name = "date_added_ms") var dateMS: Long = Calendar.getInstance().timeInMillis | |
) |