Skip to content

Commit 13186c0

Browse files
authored
Merge pull request #13224 from dustdfg/kotlin_idiomatic
Kotlin misc idiomatic refactor
2 parents 6214ae3 + edfdbe8 commit 13186c0

4 files changed

Lines changed: 8 additions & 16 deletions

File tree

app/src/main/java/org/schabi/newpipe/database/playlist/model/PlaylistRemoteEntity.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,7 @@ data class PlaylistRemoteEntity(
6262
orderingName = playlistInfo.name,
6363
url = playlistInfo.url,
6464
thumbnailUrl = ImageStrategy.imageListToDbUrl(
65-
if (playlistInfo.thumbnails.isEmpty()) {
66-
playlistInfo.uploaderAvatars
67-
} else {
68-
playlistInfo.thumbnails
69-
}
65+
playlistInfo.thumbnails.ifEmpty { playlistInfo.uploaderAvatars }
7066
),
7167
uploader = playlistInfo.uploaderName,
7268
streamCount = playlistInfo.streamCount

app/src/main/java/org/schabi/newpipe/local/feed/FeedViewModel.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ class FeedViewModel(
129129
fun setSaveShowPlayedItems(showPlayedItems: Boolean) {
130130
this.showPlayedItems.onNext(showPlayedItems)
131131
PreferenceManager.getDefaultSharedPreferences(application).edit {
132-
this.putBoolean(application.getString(R.string.feed_show_watched_items_key), showPlayedItems)
133-
this.apply()
132+
putBoolean(application.getString(R.string.feed_show_watched_items_key), showPlayedItems)
134133
}
135134
}
136135

@@ -139,8 +138,7 @@ class FeedViewModel(
139138
fun setSaveShowPartiallyPlayedItems(showPartiallyPlayedItems: Boolean) {
140139
this.showPartiallyPlayedItems.onNext(showPartiallyPlayedItems)
141140
PreferenceManager.getDefaultSharedPreferences(application).edit {
142-
this.putBoolean(application.getString(R.string.feed_show_partially_watched_items_key), showPartiallyPlayedItems)
143-
this.apply()
141+
putBoolean(application.getString(R.string.feed_show_partially_watched_items_key), showPartiallyPlayedItems)
144142
}
145143
}
146144

@@ -149,8 +147,7 @@ class FeedViewModel(
149147
fun setSaveShowFutureItems(showFutureItems: Boolean) {
150148
this.showFutureItems.onNext(showFutureItems)
151149
PreferenceManager.getDefaultSharedPreferences(application).edit {
152-
this.putBoolean(application.getString(R.string.feed_show_future_items_key), showFutureItems)
153-
this.apply()
150+
putBoolean(application.getString(R.string.feed_show_future_items_key), showFutureItems)
154151
}
155152
}
156153

app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupDialog.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ class FeedGroupDialog : DialogFragment(), BackPressable {
327327
groupIcon = feedGroupEntity?.icon
328328
groupSortOrder = feedGroupEntity?.sortOrder ?: -1
329329

330-
val feedGroupIcon = if (selectedIcon == null) icon else selectedIcon!!
330+
val feedGroupIcon = selectedIcon ?: icon
331331
feedGroupCreateBinding.iconPreview.setImageResource(feedGroupIcon.getDrawableRes())
332332

333333
if (feedGroupCreateBinding.groupNameInput.text.isNullOrBlank()) {

app/src/main/java/org/schabi/newpipe/settings/preferencesearch/PreferenceSearchItem.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,13 @@ data class PreferenceSearchItem(
2626
val breadcrumbs: String,
2727
@XmlRes val searchIndexItemResId: Int
2828
) {
29+
val allRelevantSearchFields: List<String>
30+
get() = listOf(title, summary, entries, breadcrumbs)
31+
2932
fun hasData(): Boolean {
3033
return !key.isEmpty() && !title.isEmpty()
3134
}
3235

33-
fun getAllRelevantSearchFields(): MutableList<String?> {
34-
return mutableListOf(title, summary, entries, breadcrumbs)
35-
}
36-
3736
override fun toString(): String {
3837
return "PreferenceItem: $title $summary $key"
3938
}

0 commit comments

Comments
 (0)