Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 558d915

Browse files
Change some functions to property syntax
1 parent 8f993ed commit 558d915

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

‎app/src/main/java/tk/superl2/xwifi/MainActivity.kt‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,12 @@ class MainActivity: AppCompatActivity() {
130130
// Returns Filter object
131131
override fun getFilter() = object: Filter() {
132132
// Filters the wifiEntries ArrayList with the qeury from the SearchView, and sets the results.
133-
override fun performFiltering(constraint: CharSequence): FilterResults {
134-
return FilterResults().apply {
135-
values = ArrayList<WifiEntry>().apply {
136-
wifiEntries.filterTo(this) { it.title.contains(constraint, true) }
133+
override fun performFiltering(constraint: CharSequence) =
134+
FilterResults().apply {
135+
values = ArrayList<WifiEntry>().apply {
136+
wifiEntries.filterTo(this) { it.title.contains(constraint, true) }
137+
}
137138
}
138-
}
139-
}
140139

141140
// Publishes the filtered results
142141
override fun publishResults(constraint: CharSequence, results: FilterResults) {

‎app/src/main/java/tk/superl2/xwifi/Utils.kt‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@ fun setThemeFromSharedPrefs(prefs: SharedPreferences) {
1616
}
1717

1818
// Returns night mode constant from string
19-
fun getThemeFromPreferenceString(value: String): Int {
20-
return when (value) {
21-
"Light" -> AppCompatDelegate.MODE_NIGHT_NO
22-
"Dark" -> AppCompatDelegate.MODE_NIGHT_YES
23-
"System" -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
24-
else -> {
25-
Log.w(TAG, "Invalid theme set in shared preferences! Using system theme.")
26-
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
27-
}
28-
}
29-
}
19+
fun getThemeFromPreferenceString(value: String) =
20+
when (value) {
21+
"Light" -> AppCompatDelegate.MODE_NIGHT_NO
22+
"Dark" -> AppCompatDelegate.MODE_NIGHT_YES
23+
"System" -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
24+
else -> {
25+
Log.w(TAG, "Invalid theme set in shared preferences! Using system theme.")
26+
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
27+
}
28+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /