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
| event TypedEventHandler<object, IItemsChangedEventArgs> INotifyItemsChanged.ItemsChanged | |
| { | |
| add { _itemsChanged += value; RefreshPackages(); } // <-- the whole point | |
| remove => _itemsChanged -= value; | |
| } |
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
| process.Start(); | |
| string stdout = process.StandardOutput.ReadToEnd(); | |
| string stderr = process.StandardError.ReadToEnd(); | |
| process.WaitForExit(); // do NOT move this above the reads |
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
| internal sealed partial class ClearAppDataCommand : InvokableCommand | |
| { | |
| private readonly string _packageName; | |
| public ClearAppDataCommand(string packageName) | |
| { | |
| _packageName = packageName; | |
| Name = "Clear App Data"; | |
| } |
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
| buildTypes.release.proguard { | |
| configurationFiles.from("proguard-rules.pro") | |
| } |
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
| Tray( | |
| icon = clockIcon(), | |
| tooltip = "DogeClock", | |
| menu = { | |
| Item(if (isVisible) "Hide" else "Show", onClick = { isVisible = !isVisible }) | |
| Separator() | |
| Item("Exit", onClick = ::exitApplication) | |
| }, | |
| ) |
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
| @Serializable | |
| private data class PositionConfig(val x: Float, val y: Float) | |
| class PositionRepository { | |
| fun loadPosition(): WindowPosition? { | |
| if (!configFile.exists()) return null | |
| return try { | |
| val config = Json.decodeFromString<PositionConfig>(configFile.readText()) | |
| WindowPosition(config.x.dp, config.y.dp) | |
| } catch (e: Exception) { |
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
| val appModule = module { | |
| single<WindowStyleHelper> { | |
| if (System.getProperty("os.name").startsWith("Windows")) { | |
| WindowsWindowStyleHelper() | |
| } else { | |
| // provide macOS or Linux implementations below | |
| } | |
| } | |
| } |
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
| // Define which Windows functions we need | |
| internal interface User32 : Library { | |
| fun FindWindowA(className: String?, windowTitle: String?): Pointer? | |
| fun GetWindowLongA(hwnd: Pointer, index: Int): Int | |
| fun SetWindowLongA(hwnd: Pointer, index: Int, newStyle: Int): Int | |
| } | |
| class WindowsWindowStyleHelper : WindowStyleHelper { | |
| // JNA loads the actual Windows DLL at runtime | |
| val user32 = Native.load("user32", User32::class.java) |
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
| class ClockViewModel : ViewModel() { | |
| // .... | |
| init { | |
| viewModelScope.launch { | |
| while (true) { | |
| delay(60.seconds) | |
| _time.value = LocalTime.now().format(formatter) | |
| } | |
| } | |
| } |
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
| init { | |
| viewModelScope.launch { | |
| while (true) { | |
| delay((60 - LocalTime.now().second) * 1000L) | |
| _time.value = LocalTime.now().format(formatter) | |
| } | |
| } | |
| } |
NewerOlder