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
/** | |
* Custom EditText that paints a bottom line and the text or | |
* a filled circle if it is a password | |
*/ | |
class PinEntryEditText : AppCompatEditText { | |
private var mSpace = 24f //24 dp by default, space between the lines | |
private var mNumChars = 4f | |
private var mLineSpacing = 8f //8dp by default, height of the text from our lines |
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
ProcessLifecycleOwner.get().lifecycle.addObserver(ApplicationOwner()) |
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 fun onResume() { | |
super.onResume() | |
MyApplication.activityResumed() | |
} | |
override void onPause() { | |
super.onPause() | |
MyApplication.activityPaused() | |
} |
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 = [ProductEntity::class], version = SharedContentDataBase.VERSION) | |
abstract class SharedContentDataBase : RoomDatabase() { | |
companion object { | |
const val VERSION = 2 | |
val migrationRoom: Migration = object : Migration(1, 2) { | |
override fun migrate(database: SupportSQLiteDatabase) { | |
val queryForDatabase = """ | |
CREATE TABLE IF NOT EXISTS UpdatedTableProduct (idProduct TEXT PRIMARY KEY NOT NULL, name TEXT, nameClean TEXT, |
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 addIndex = """ | |
CREATE INDEX IF NOT EXISTS index_Product_idProduct_skuId ON Product(idProduct, skuId) | |
""" | |
database.execSQL(addIndex) |
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 queryForDatabase = """ | |
CREATE TABLE IF NOT EXISTS UpdatedTableProduct (idProduct TEXT PRIMARY KEY NOT NULL, name TEXT, nameClean TEXT, | |
description TEXT, discount INT, skuId TEXT, hasAddedToCart INT, opened INT, notified INT, | |
FOREIGN KEY (idProduct) REFERENCES Image(imageId) ON UPDATE NO ACTION ON DELETE NO ACTION, | |
FOREIGN KEY (skuId) REFERENCES Prices(idProduct) ON UPDATE NO ACTION ON DELETE NO ACTION """" | |
database.execSQL(queryForDatabase) |
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 queryForDatabase = """ | |
CREATE TABLE IF NOT EXISTS UpdatedTableProduct (idProduct TEXT PRIMARY KEY NOT NULL, name TEXT, nameClean TEXT, | |
description TEXT, discount INT, skuId TEXT, hasAddedToCart INT, opened INT, notified INT""" | |
database.execSQL(queryForDatabase) | |
val queryCopyDataBase = """ | |
INSERT OR REPLACE INTO UpdatedTableProduct (idProduct, name, nameClean, description, discount, | |
skuId, hasAddedToCart, opened, notified) | |
SELECT idProduct, name, nameClean, description, discount, | |
skuId, hasAddedToCart, opened, notified FROM Product""" |
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.execSQL("ALTER TABLE Product ADD COLUMN hasAddedToCart INT") |
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 = [ProductEntity::class], version = SharedContentDataBase.VERSION) | |
abstract class SharedContentDataBase : RoomDatabase() { | |
companion object { | |
const val VERSION = 2 | |
val migrationRoom: Migration = object : Migration(1, 2) { | |
override fun migrate(database: SupportSQLiteDatabase) { | |
//This is where the magic happends |
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 = "Products", | |
foreignKeys = [ForeignKey(entity = ImagesEntity::class, | |
parentColumns = arrayOf("imageId"), childColumns = arrayOf("cityId")), | |
ForeignKey(entity = PricesEntity::class, | |
parentColumns = arrayOf("skuId"), childColumns = arrayOf("idProduct"))], | |
indices = [Index(value = ["idProduct", "skuId"])]) | |
data class ProductEntity ( | |
@PrimaryKey(autoGenerate = false) | |
@ColumnInfo(name = "idProduct") |