This file contains hidden or 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
| // temp |
This file contains hidden or 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 RoomDatabaseMigrationProvider { | |
| public static final Migration MIGRATION_1_2 = new Migration(1, 2) { | |
| @Override | |
| public void migrate(@NonNull SupportSQLiteDatabase database) { | |
| // we have not altered any tables | |
| Log.d("##### 1 - 2 Migration", "started...."); | |
| migrateDatabase_1_2(database); | |
| Log.d("##### 1 - 2 Migration", "completed...."); |
This file contains hidden or 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
| fun EditText.afterTextChanged(afterTextChanged: (String) -> Unit) { | |
| this.addTextChangedListener(object : TextWatcher { | |
| override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) { | |
| } | |
| override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) { | |
| } | |
| override fun afterTextChanged(editable: Editable?) { | |
| afterTextChanged.invoke(editable.toString()) |
This file contains hidden or 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.graphics.Rect | |
| import android.view.View | |
| import androidx.recyclerview.widget.RecyclerView | |
| class MarginItemDecoration(private val spaceHeight: Int) : RecyclerView.ItemDecoration() { | |
| override fun getItemOffsets(outRect: Rect, view: View, | |
| parent: RecyclerView, state: RecyclerView.State) { | |
| with(outRect) { | |
| if (parent.getChildAdapterPosition(view) == 0) { | |
| top = spaceHeight |
This file contains hidden or 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 static final Map<String, String> DATE_FORMAT_REGEXPS; | |
| static { | |
| DATE_FORMAT_REGEXPS = new HashMap<>(); | |
| DATE_FORMAT_REGEXPS.put("^\\d{8}$", "yyyyMMdd"); | |
| DATE_FORMAT_REGEXPS.put("^\\d{1,2}-\\d{1,2}-\\d{4}$", "dd-MM-yyyy"); | |
| DATE_FORMAT_REGEXPS.put("^\\d{4}-\\d{1,2}-\\d{1,2}$", "yyyy-MM-dd"); | |
| DATE_FORMAT_REGEXPS.put("^\\d{1,2}/\\d{1,2}/\\d{4}$", "MM/dd/yyyy"); | |
| DATE_FORMAT_REGEXPS.put("^\\d{4}/\\d{1,2}/\\d{1,2}$", "yyyy/MM/dd"); | |
| DATE_FORMAT_REGEXPS.put("^\\d{1,2}\\s[a-z]{3}\\s\\d{4}$", "dd MMM yyyy"); |
This file contains hidden or 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
| const printA = (target: Object, key: string | symbol, descriptor: TypedPropertyDescriptor<Function>) => { | |
| console.log("A"); | |
| } | |
| const printB = (target: Object, key: string | symbol, descriptor: TypedPropertyDescriptor<Function>) => { | |
| console.log("B"); | |
| } | |
| class Printer { | |
| @printA |
This file contains hidden or 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
| const greaterOrEqual = (n: number) => { | |
| return (target: Object, key: string | symbol) => { | |
| let value = target[key]; | |
| const getter = () => value; | |
| const setter = (val) => { | |
| if (val < n) { | |
| throw new Error(`Value smaller than ${n}`); | |
| } | |
| value = val; |
This file contains hidden or 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
| const log = (target: Object, key: string | symbol) => { | |
| let value = target[key]; | |
| const getter = () => { | |
| console.log("Getting value: ", value); | |
| return value; | |
| }; | |
| const setter = (val) => { | |
| console.log("Setting value: ", val); | |
| value = val; |
This file contains hidden or 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
| const log = (target: Object, key: string | symbol, descriptor: TypedPropertyDescriptor<Function>) => { | |
| return { | |
| value: function( ... args: any[]) { | |
| console.log("Arguments: ", args.join(", ")); | |
| const result = descriptor.value.apply(target, args); | |
| console.log("Result: ", result); | |
| return result; | |
| } | |
| } | |
| } |
This file contains hidden or 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
| const log = <T>(originalConstructor: new(...args: any[]) => T) => { | |
| function newConstructor(... args) { | |
| console.log("Arguments: ", args.join(", ")); | |
| new originalConstructor(args); | |
| } | |
| newConstructor.prototype = originalConstructor.prototype; | |
| return newConstructor; | |
| } | |
| @log |