Skip to content

Commit f5405c4

Browse files
Refactor: Simplify app rename logic in AppDrawerAdapter
The `activityLabel` variable is now declared once and reused within the app renaming logic in `AppDrawerAdapter.kt`. This avoids repeatedly calculating the same value inside the `onTextChanged` listener, simplifying the code.
1 parent ba8c3c7 commit f5405c4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

app/src/main/java/com/github/codeworkscreativehub/mlauncher/ui/adapter/AppDrawerAdapter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,13 +426,13 @@ class AppDrawerAdapter(
426426
}
427427

428428
appRenameEdit.apply {
429-
text = Editable.Factory.getInstance().newEditable(prefs.getAppAlias(appListItem.activityPackage).takeIf { it.isNotBlank() } ?: appListItem.activityLabel)
429+
val activityLabel = prefs.getAppAlias(appListItem.activityPackage).takeIf { it.isNotBlank() } ?: appListItem.activityLabel
430+
text = Editable.Factory.getInstance().newEditable(activityLabel)
430431
appSaveRename.text = getLocalizedString(R.string.cancel)
431432
addTextChangedListener(object : TextWatcher {
432433
override fun afterTextChanged(s: Editable) {}
433434
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
434435
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
435-
val activityLabel = prefs.getAppAlias(appListItem.activityPackage).takeIf { it.isNotBlank() } ?: appListItem.activityLabel
436436
appSaveRename.text = when {
437437
text.isEmpty() -> getLocalizedString(R.string.reset)
438438
text.toString() == activityLabel -> getLocalizedString(R.string.cancel)

0 commit comments

Comments
 (0)