Skip to content

Instantly share code, notes, and snippets.

@gokmenbayram
gokmenbayram / AllowOnlyLettersAndNoConsecutiveSpaces.kt
Last active March 20, 2024 15:06
AllowOnlyLettersAndNoConsecutiveSpaces
fun EditText.allowOnlyLettersAndNoConsecutiveSpaces() {
filters = arrayOf(InputFilter { enteredText, start, end, dest, dstart, dend ->
if (enteredText.toString().matches("[a-zA-ZğüşıöçĞÜŞİÖÇ ]*".toRegex())) {
when {
//If the first character is entered as empty
enteredText.isBlank() && dest.isEmpty() -> ""
//If the entered character is empty and entered as empty at the first index
enteredText.isBlank() && dend == 0 -> ""
import androidx.compose.foundation.Image
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.layout.wrapContentWidth
// You can thoroughly monitor the events you send to Firebase Analytics with the commands you enter in the Android Studio terminal.
adb shell setprop log.tag.FA VERBOSE
adb shell setprop log.tag.FA-SVC VERBOSE
adb logcat -v time -s FA FA-SVC
@gokmenbayram
gokmenbayram / ManualMigration_5
Created November 14, 2022 07:57
Manual Migration
Room.databaseBuilder(
context,
RoomDatabase::class.java, "DB_NAME")
.addMigrations(MIGRATION_1_2, MIGRATION_2_3)
.build())
@gokmenbayram
gokmenbayram / ManualMigration_4.kt
Created November 14, 2022 07:51
Manual Migration
val MIGRATION_2_3 = object : Migration(2, 3) {
override fun migrate(database: SupportSQLiteDatabase) {
// Yeni tablo oluştur
database.execSQL("CREATE TABLE USER_NEW (userid TEXT, username TEXT, age INTEGER, PRIMARY KEY(userid))")
// Eski tablodan verileri kopyala
database.execSQL("INSERT INTO USER_NEW (userid, username, age) SELECT userid, username, age FROM USER")
// Eski tabloyu sil
@gokmenbayram
gokmenbayram / ManualMigration_3.kt
Created November 14, 2022 07:25
Manual Migration
@Database(
entities = [],
version = 2, // upgrade db version on any change
exportSchema = true
)
@gokmenbayram
gokmenbayram / ManualMigration_2.kt
Created November 14, 2022 07:10
Manual Migration
Room.databaseBuilder(
context,
RoomDatabase::class.java, "DB_NAME")
.addMigrations(MIGRATION_1_2)
.build())
@gokmenbayram
gokmenbayram / ManualMigration_1.kt
Last active November 14, 2022 07:06
Manual Migration
val MIGRATION_1_2 = object : Migration(1, 2) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("ALTER TABLE User ADD COLUMN age INTEGER")
}
}
@gokmenbayram
gokmenbayram / AutoMatedMigration_3.kt
Created November 11, 2022 10:49
AutoMigrationSpec
@Database(
version = 2,
entities = [ User.class ],
autoMigrations = [
AutoMigration (
from = 1,
to = 2,
spec = UserDatabase.UserAutoMigration::class
)
]
@gokmenbayram
gokmenbayram / AutomatedMigration_2.kt
Created November 11, 2022 08:56
AutomatedMigration
@Database(
- version = 2, // old version
+ version = 3, // upgraded version
entities = [ User.class ],
autoMigrations = [
AutoMigration (from = 1, to = 2),
+ AutoMigration (from = 2, to = 3)
]
)
abstract class UserDatabase : RoomDatabase { }