Skip to content

Commit 0641c19

Browse files
committed
ktlint: Fix multi-line if-else violations
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
1 parent 2c808b0 commit 0641c19

8 files changed

Lines changed: 37 additions & 21 deletions

File tree

.editorconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ ktlint_standard_kdoc = disabled
2626
ktlint_standard_max-line-length = disabled
2727
ktlint_standard_mixed-condition-operators = disabled
2828
ktlint_standard_multiline-expression-wrapping = disabled
29-
ktlint_standard_multiline-if-else = disabled
3029
ktlint_standard_no-blank-line-in-list = disabled
3130
ktlint_standard_no-consecutive-comments = disabled
3231
ktlint_standard_no-empty-first-line-in-class-body = disabled

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,13 @@ class FeedViewModel(
7373
.subscribeOn(Schedulers.io())
7474
.observeOn(Schedulers.io())
7575
.map { (event, showPlayedItems, showPartiallyPlayedItems, showFutureItems, notLoadedCount, oldestUpdate) ->
76-
val streamItems = if (event is SuccessResultEvent || event is IdleEvent)
76+
val streamItems = if (event is SuccessResultEvent || event is IdleEvent) {
7777
feedDatabaseManager
7878
.getStreams(groupId, showPlayedItems, showPartiallyPlayedItems, showFutureItems)
7979
.blockingGet(arrayListOf())
80-
else
80+
} else {
8181
arrayListOf()
82+
}
8283

8384
CombineResultDataHolder(event, streamItems, notLoadedCount, oldestUpdate)
8485
}

app/src/main/java/org/schabi/newpipe/player/gesture/BasePlayerGestureListener.kt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ abstract class BasePlayerGestureListener(
8686
// ///////////////////////////////////////////////////////////////////
8787

8888
override fun onDown(e: MotionEvent): Boolean {
89-
if (DEBUG)
89+
if (DEBUG) {
9090
Log.d(TAG, "onDown called with e = [$e]")
91+
}
9192

9293
if (isDoubleTapping && isDoubleTapEnabled) {
9394
doubleTapControls?.onDoubleTapProgressDown(getDisplayPortion(e))
@@ -108,8 +109,9 @@ abstract class BasePlayerGestureListener(
108109
}
109110

110111
override fun onDoubleTap(e: MotionEvent): Boolean {
111-
if (DEBUG)
112+
if (DEBUG) {
112113
Log.d(TAG, "onDoubleTap called with e = [$e]")
114+
}
113115

114116
onDoubleTap(e, getDisplayPortion(e))
115117
return true
@@ -136,17 +138,19 @@ abstract class BasePlayerGestureListener(
136138

137139
private fun startMultiDoubleTap(e: MotionEvent) {
138140
if (!isDoubleTapping) {
139-
if (DEBUG)
141+
if (DEBUG) {
140142
Log.d(TAG, "startMultiDoubleTap called with e = [$e]")
143+
}
141144

142145
keepInDoubleTapMode()
143146
doubleTapControls?.onDoubleTapStarted(getDisplayPortion(e))
144147
}
145148
}
146149

147150
fun keepInDoubleTapMode() {
148-
if (DEBUG)
151+
if (DEBUG) {
149152
Log.d(TAG, "keepInDoubleTapMode called")
153+
}
150154

151155
isDoubleTapping = true
152156
doubleTapHandler.removeCallbacksAndMessages(DOUBLE_TAP)
@@ -161,8 +165,9 @@ abstract class BasePlayerGestureListener(
161165
}
162166

163167
fun endMultiDoubleTap() {
164-
if (DEBUG)
168+
if (DEBUG) {
165169
Log.d(TAG, "endMultiDoubleTap called")
170+
}
166171

167172
isDoubleTapping = false
168173
doubleTapHandler.removeCallbacksAndMessages(DOUBLE_TAP)

app/src/main/java/org/schabi/newpipe/player/gesture/MainPlayerGestureListener.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,18 @@ class MainPlayerGestureListener(
5151
}
5252

5353
override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
54-
if (DEBUG)
54+
if (DEBUG) {
5555
Log.d(TAG, "onSingleTapConfirmed() called with: e = [$e]")
56+
}
5657

57-
if (isDoubleTapping)
58+
if (isDoubleTapping) {
5859
return true
60+
}
5961
super.onSingleTapConfirmed(e)
6062

61-
if (player.currentState != Player.STATE_BLOCKED)
63+
if (player.currentState != Player.STATE_BLOCKED) {
6264
onSingleTap()
65+
}
6366
return true
6467
}
6568

app/src/main/java/org/schabi/newpipe/player/gesture/PopupPlayerGestureListener.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,16 @@ class PopupPlayerGestureListener(
205205
}
206206

207207
override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
208-
if (DEBUG)
208+
if (DEBUG) {
209209
Log.d(TAG, "onSingleTapConfirmed() called with: e = [$e]")
210+
}
210211

211-
if (isDoubleTapping)
212+
if (isDoubleTapping) {
212213
return true
213-
if (player.exoPlayerIsNull())
214+
}
215+
if (player.exoPlayerIsNull()) {
214216
return false
217+
}
215218

216219
onSingleTap()
217220
return true

app/src/main/java/org/schabi/newpipe/player/mediabrowser/MediaBrowserPlaybackPreparer.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,11 @@ class MediaBrowserPlaybackPreparer(
185185
}
186186
val playlistId = path[0].toLong()
187187
val index = path[1].toInt()
188-
return if (playlistType == ID_LOCAL)
188+
return if (playlistType == ID_LOCAL) {
189189
extractLocalPlayQueue(playlistId, index)
190-
else
190+
} else {
191191
extractRemotePlayQueue(playlistId, index)
192+
}
192193
}
193194

194195
ID_URL -> {

app/src/main/java/org/schabi/newpipe/util/potoken/PoTokenException.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ class PoTokenException(message: String) : Exception(message)
66
class BadWebViewException(message: String) : Exception(message)
77

88
fun buildExceptionForJsError(error: String): Exception {
9-
return if (error.contains("SyntaxError"))
9+
return if (error.contains("SyntaxError")) {
1010
BadWebViewException(error)
11-
else
11+
} else {
1212
PoTokenException(error)
13+
}
1314
}

app/src/main/java/org/schabi/newpipe/views/player/PlayerFastSeekOverlay.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ class PlayerFastSeekOverlay(context: Context, attrs: AttributeSet?) :
5252
private var initTap: Boolean = false
5353

5454
override fun onDoubleTapStarted(portion: DisplayPortion) {
55-
if (DEBUG)
55+
if (DEBUG) {
5656
Log.d(TAG, "onDoubleTapStarted called with portion = [$portion]")
57+
}
5758

5859
initTap = false
5960

@@ -64,14 +65,15 @@ class PlayerFastSeekOverlay(context: Context, attrs: AttributeSet?) :
6465
val shouldForward: Boolean =
6566
performListener?.getFastSeekDirection(portion)?.directionAsBoolean ?: return
6667

67-
if (DEBUG)
68+
if (DEBUG) {
6869
Log.d(
6970
TAG,
7071
"onDoubleTapProgressDown called with " +
7172
"shouldForward = [$shouldForward], " +
7273
"wasForwarding = [$wasForwarding], " +
7374
"initTap = [$initTap], "
7475
)
76+
}
7577

7678
/*
7779
* Check if a initial tap occurred or if direction was switched
@@ -97,8 +99,9 @@ class PlayerFastSeekOverlay(context: Context, attrs: AttributeSet?) :
9799
}
98100

99101
override fun onDoubleTapFinished() {
100-
if (DEBUG)
102+
if (DEBUG) {
101103
Log.d(TAG, "onDoubleTapFinished called with initTap = [$initTap]")
104+
}
102105

103106
if (initTap) performListener?.onDoubleTapEnd()
104107
initTap = false

0 commit comments

Comments
 (0)