chore: lint project (#3395)

* chore: format swift code
* chore: format clang code
* chore: format kotlin code
* refactor: rename folder "API" to "api"
This commit is contained in:
Krzysztof Moch
2023-12-07 08:47:40 +01:00
committed by GitHub
parent 72679a7d63
commit 800aee09de
43 changed files with 1407 additions and 1364 deletions

View File

@@ -1,6 +1,6 @@
[*.{kt,kts}]
indent_style=space
indent_size=2
indent_size=4
continuation_indent_size=4
insert_final_newline=true
max_line_length=160

View File

@@ -1,4 +1,4 @@
package com.brentvatne.common.API
package com.brentvatne.common.api
import androidx.annotation.IntDef
import java.lang.annotation.Retention
@@ -29,10 +29,11 @@ internal object ResizeMode {
* Keeps the aspect ratio but takes up the view's size.
*/
const val RESIZE_MODE_CENTER_CROP = 4
@JvmStatic
@Mode
fun toResizeMode(ordinal: Int): Int {
return when (ordinal) {
fun toResizeMode(ordinal: Int): Int =
when (ordinal) {
RESIZE_MODE_FIXED_WIDTH -> RESIZE_MODE_FIXED_WIDTH
RESIZE_MODE_FIXED_HEIGHT -> RESIZE_MODE_FIXED_HEIGHT
RESIZE_MODE_FILL -> RESIZE_MODE_FILL
@@ -40,7 +41,6 @@ internal object ResizeMode {
RESIZE_MODE_FIT -> RESIZE_MODE_FIT
else -> RESIZE_MODE_FIT
}
}
@Retention(RetentionPolicy.SOURCE)
@IntDef(
@@ -51,4 +51,4 @@ internal object ResizeMode {
RESIZE_MODE_CENTER_CROP
)
annotation class Mode
}
}

View File

@@ -1,4 +1,4 @@
package com.brentvatne.common.API
package com.brentvatne.common.api
import com.brentvatne.common.toolbox.ReactBridgeUtils
import com.facebook.react.bridge.ReadableMap
@@ -24,6 +24,7 @@ class SubtitleStyle private constructor() {
private const val PROP_PADDING_TOP = "paddingTop"
private const val PROP_PADDING_LEFT = "paddingLeft"
private const val PROP_PADDING_RIGHT = "paddingRight"
@JvmStatic
fun parse(src: ReadableMap?): SubtitleStyle {
val subtitleStyle = SubtitleStyle()
@@ -35,4 +36,4 @@ class SubtitleStyle private constructor() {
return subtitleStyle
}
}
}
}

View File

@@ -1,4 +1,4 @@
package com.brentvatne.common.API
package com.brentvatne.common.api
/*
* class to handle timedEvent retrieved from the stream
@@ -7,4 +7,4 @@ package com.brentvatne.common.API
class TimedMetadata(_identifier: String? = null, _value: String? = null) {
var identifier: String? = _identifier
var value: String? = _value
}
}

View File

@@ -1,4 +1,4 @@
package com.brentvatne.common.API
package com.brentvatne.common.api
/*
* internal representation of audio & text tracks
@@ -8,7 +8,8 @@ class Track {
var mimeType: String? = null
var language: String? = null
var isSelected = false
// in bps available only on audio tracks
var bitrate = 0
var index = 0
}
}

View File

@@ -1,4 +1,4 @@
package com.brentvatne.common.API
package com.brentvatne.common.api
/*
* internal representation of audio & text tracks
@@ -12,4 +12,4 @@ class VideoTrack {
var id = -1
var trackId = ""
var isSelected = false
}
}

View File

@@ -4,9 +4,9 @@ import androidx.annotation.StringDef;
import android.view.View;
import com.brentvatne.common.API.TimedMetadata;
import com.brentvatne.common.API.Track;
import com.brentvatne.common.API.VideoTrack;
import com.brentvatne.common.api.TimedMetadata;
import com.brentvatne.common.api.Track;
import com.brentvatne.common.api.VideoTrack;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.WritableArray;

View File

@@ -12,8 +12,10 @@ import java.lang.Exception
object DebugLog {
// log level to display
private var level = Log.WARN
// enable thread display in logs
private var displayThread = true
// add a common prefix for easy filtering
private const val TAG_PREFIX = "RNV"
@@ -24,16 +26,15 @@ object DebugLog {
}
@JvmStatic
private fun getTag(tag: String): String {
return TAG_PREFIX + tag
}
private fun getTag(tag: String): String = TAG_PREFIX + tag
@JvmStatic
private fun getMsg(msg: String): String {
return if (displayThread) {
private fun getMsg(msg: String): String =
if (displayThread) {
"[" + Thread.currentThread().name + "] " + msg
} else msg
}
} else {
msg
}
@JvmStatic
fun v(tag: String, msg: String) {
@@ -92,4 +93,4 @@ object DebugLog {
wtf(tag, "------------------------>" + getMsg(msg))
}
}
}
}

View File

@@ -1,8 +1,8 @@
package com.brentvatne.common.toolbox
import com.facebook.react.bridge.Dynamic
import com.facebook.react.bridge.ReadableMap
import com.facebook.react.bridge.ReadableArray
import com.facebook.react.bridge.ReadableMap
import java.util.HashMap
/*
@@ -53,17 +53,19 @@ object ReactBridgeUtils {
@JvmStatic
fun safeGetInt(map: ReadableMap?, key: String?): Int {
return safeGetInt(map, key, 0);
return safeGetInt(map, key, 0)
}
@JvmStatic
fun safeGetDouble(map: ReadableMap?, key: String?, fallback: Double): Double {
return if (map != null && map.hasKey(key!!) && !map.isNull(key)) map.getDouble(key) else fallback
}
@JvmStatic
fun safeGetDouble(map: ReadableMap?, key: String?): Double {
return safeGetDouble(map, key, 0.0);
return safeGetDouble(map, key, 0.0)
}
/**
* toStringMap converts a [ReadableMap] into a HashMap.
*
@@ -116,17 +118,16 @@ object ReactBridgeUtils {
if (str1 == null || str2 == null) return false // only 1 is null
if (str1.size != str2.size) return false // only 1 is null
for (i in str1.indices) {
if (str1[i] == str2[i]) // standard check
if (str1[i] == str2[i]) {
// standard check
return false
}
}
return true
}
@JvmStatic
fun safeStringMapEquals(
first: Map<String?, String?>?,
second: Map<String?, String?>?
): Boolean {
fun safeStringMapEquals(first: Map<String?, String?>?, second: Map<String?, String?>?): Boolean {
if (first == null && second == null) return true // both are null
if (first == null || second == null) return false // only 1 is null
if (first.size != second.size) {

View File

@@ -19,7 +19,7 @@ import android.content.Context;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import com.brentvatne.common.API.ResizeMode;
import com.brentvatne.common.api.ResizeMode;
/**
* A {@link FrameLayout} that resizes itself to match a specified aspect ratio.

View File

@@ -25,8 +25,8 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import com.brentvatne.common.API.ResizeMode;
import com.brentvatne.common.API.SubtitleStyle;
import com.brentvatne.common.api.ResizeMode;
import com.brentvatne.common.api.SubtitleStyle;
import java.util.List;

View File

@@ -91,11 +91,11 @@ import androidx.media3.extractor.metadata.id3.Id3Frame;
import androidx.media3.extractor.metadata.id3.TextInformationFrame;
import androidx.media3.ui.LegacyPlayerControlView;
import com.brentvatne.common.API.ResizeMode;
import com.brentvatne.common.API.SubtitleStyle;
import com.brentvatne.common.API.TimedMetadata;
import com.brentvatne.common.API.Track;
import com.brentvatne.common.API.VideoTrack;
import com.brentvatne.common.api.ResizeMode;
import com.brentvatne.common.api.SubtitleStyle;
import com.brentvatne.common.api.TimedMetadata;
import com.brentvatne.common.api.Track;
import com.brentvatne.common.api.VideoTrack;
import com.brentvatne.common.react.VideoEventEmitter;
import com.brentvatne.common.toolbox.DebugLog;
import com.brentvatne.react.R;

View File

@@ -10,8 +10,8 @@ import androidx.media3.common.util.Util;
import androidx.media3.datasource.RawResourceDataSource;
import androidx.media3.exoplayer.DefaultLoadControl;
import com.brentvatne.common.API.ResizeMode;
import com.brentvatne.common.API.SubtitleStyle;
import com.brentvatne.common.api.ResizeMode;
import com.brentvatne.common.api.SubtitleStyle;
import com.brentvatne.common.react.VideoEventEmitter;
import com.brentvatne.common.toolbox.DebugLog;
import com.brentvatne.common.toolbox.ReactBridgeUtils;