Skip to content

Commit

Permalink
chore: set indent to 4
Browse files Browse the repository at this point in the history
  • Loading branch information
KrzysztofMoch committed Dec 6, 2023
1 parent e98a2c0 commit 12bba63
Show file tree
Hide file tree
Showing 31 changed files with 3,362 additions and 3,358 deletions.
2 changes: 1 addition & 1 deletion android/.editorconfig
Original file line number Diff line number Diff line change
@@ -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
Expand Down
92 changes: 46 additions & 46 deletions android/src/main/java/com/brentvatne/common/API/ResizeMode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,50 @@ import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy

internal object ResizeMode {
/**
* Either the width or height is decreased to obtain the desired aspect ratio.
*/
const val RESIZE_MODE_FIT = 0

/**
* The width is fixed and the height is increased or decreased to obtain the desired aspect ratio.
*/
const val RESIZE_MODE_FIXED_WIDTH = 1

/**
* The height is fixed and the width is increased or decreased to obtain the desired aspect ratio.
*/
const val RESIZE_MODE_FIXED_HEIGHT = 2

/**
* The height and the width is increased or decreased to fit the size of the view.
*/
const val RESIZE_MODE_FILL = 3

/**
* 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 =
when (ordinal) {
RESIZE_MODE_FIXED_WIDTH -> RESIZE_MODE_FIXED_WIDTH
RESIZE_MODE_FIXED_HEIGHT -> RESIZE_MODE_FIXED_HEIGHT
RESIZE_MODE_FILL -> RESIZE_MODE_FILL
RESIZE_MODE_CENTER_CROP -> RESIZE_MODE_CENTER_CROP
RESIZE_MODE_FIT -> RESIZE_MODE_FIT
else -> RESIZE_MODE_FIT
}

@Retention(RetentionPolicy.SOURCE)
@IntDef(
RESIZE_MODE_FIT,
RESIZE_MODE_FIXED_WIDTH,
RESIZE_MODE_FIXED_HEIGHT,
RESIZE_MODE_FILL,
RESIZE_MODE_CENTER_CROP
)
annotation class Mode
/**
* Either the width or height is decreased to obtain the desired aspect ratio.
*/
const val RESIZE_MODE_FIT = 0

/**
* The width is fixed and the height is increased or decreased to obtain the desired aspect ratio.
*/
const val RESIZE_MODE_FIXED_WIDTH = 1

/**
* The height is fixed and the width is increased or decreased to obtain the desired aspect ratio.
*/
const val RESIZE_MODE_FIXED_HEIGHT = 2

/**
* The height and the width is increased or decreased to fit the size of the view.
*/
const val RESIZE_MODE_FILL = 3

/**
* 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 =
when (ordinal) {
RESIZE_MODE_FIXED_WIDTH -> RESIZE_MODE_FIXED_WIDTH
RESIZE_MODE_FIXED_HEIGHT -> RESIZE_MODE_FIXED_HEIGHT
RESIZE_MODE_FILL -> RESIZE_MODE_FILL
RESIZE_MODE_CENTER_CROP -> RESIZE_MODE_CENTER_CROP
RESIZE_MODE_FIT -> RESIZE_MODE_FIT
else -> RESIZE_MODE_FIT
}

@Retention(RetentionPolicy.SOURCE)
@IntDef(
RESIZE_MODE_FIT,
RESIZE_MODE_FIXED_WIDTH,
RESIZE_MODE_FIXED_HEIGHT,
RESIZE_MODE_FILL,
RESIZE_MODE_CENTER_CROP
)
annotation class Mode
}
52 changes: 26 additions & 26 deletions android/src/main/java/com/brentvatne/common/API/SubtitleStyle.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,33 @@ import com.facebook.react.bridge.ReadableMap
* Helper file to parse SubtitleStyle prop and build a dedicated class
*/
class SubtitleStyle private constructor() {
var fontSize = -1
private set
var paddingLeft = 0
private set
var paddingRight = 0
private set
var paddingTop = 0
private set
var paddingBottom = 0
private set
var fontSize = -1
private set
var paddingLeft = 0
private set
var paddingRight = 0
private set
var paddingTop = 0
private set
var paddingBottom = 0
private set

companion object {
private const val PROP_FONT_SIZE_TRACK = "fontSize"
private const val PROP_PADDING_BOTTOM = "paddingBottom"
private const val PROP_PADDING_TOP = "paddingTop"
private const val PROP_PADDING_LEFT = "paddingLeft"
private const val PROP_PADDING_RIGHT = "paddingRight"
companion object {
private const val PROP_FONT_SIZE_TRACK = "fontSize"
private const val PROP_PADDING_BOTTOM = "paddingBottom"
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()
subtitleStyle.fontSize = ReactBridgeUtils.safeGetInt(src, PROP_FONT_SIZE_TRACK, -1)
subtitleStyle.paddingBottom = ReactBridgeUtils.safeGetInt(src, PROP_PADDING_BOTTOM, 0)
subtitleStyle.paddingTop = ReactBridgeUtils.safeGetInt(src, PROP_PADDING_TOP, 0)
subtitleStyle.paddingLeft = ReactBridgeUtils.safeGetInt(src, PROP_PADDING_LEFT, 0)
subtitleStyle.paddingRight = ReactBridgeUtils.safeGetInt(src, PROP_PADDING_RIGHT, 0)
return subtitleStyle
@JvmStatic
fun parse(src: ReadableMap?): SubtitleStyle {
val subtitleStyle = SubtitleStyle()
subtitleStyle.fontSize = ReactBridgeUtils.safeGetInt(src, PROP_FONT_SIZE_TRACK, -1)
subtitleStyle.paddingBottom = ReactBridgeUtils.safeGetInt(src, PROP_PADDING_BOTTOM, 0)
subtitleStyle.paddingTop = ReactBridgeUtils.safeGetInt(src, PROP_PADDING_TOP, 0)
subtitleStyle.paddingLeft = ReactBridgeUtils.safeGetInt(src, PROP_PADDING_LEFT, 0)
subtitleStyle.paddingRight = ReactBridgeUtils.safeGetInt(src, PROP_PADDING_RIGHT, 0)
return subtitleStyle
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ package com.brentvatne.common.api
*/

class TimedMetadata(_identifier: String? = null, _value: String? = null) {
var identifier: String? = _identifier
var value: String? = _value
var identifier: String? = _identifier
var value: String? = _value
}
14 changes: 7 additions & 7 deletions android/src/main/java/com/brentvatne/common/API/Track.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ package com.brentvatne.common.api
* internal representation of audio & text tracks
*/
class Track {
var title: String? = null
var mimeType: String? = null
var language: String? = null
var isSelected = false
var title: String? = null
var mimeType: String? = null
var language: String? = null
var isSelected = false

// in bps available only on audio tracks
var bitrate = 0
var index = 0
// in bps available only on audio tracks
var bitrate = 0
var index = 0
}
14 changes: 7 additions & 7 deletions android/src/main/java/com/brentvatne/common/API/VideoTrack.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ package com.brentvatne.common.api
*/

class VideoTrack {
var width = 0
var height = 0
var bitrate = 0
var codecs = ""
var id = -1
var trackId = ""
var isSelected = false
var width = 0
var height = 0
var bitrate = 0
var codecs = ""
var id = -1
var trackId = ""
var isSelected = false
}
150 changes: 75 additions & 75 deletions android/src/main/java/com/brentvatne/common/toolbox/DebugLog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,87 +10,87 @@ 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"

@JvmStatic
fun setConfig(_level: Int, _displayThread: Boolean) {
level = _level
displayThread = _displayThread
}

@JvmStatic
private fun getTag(tag: String): String = TAG_PREFIX + tag

@JvmStatic
private fun getMsg(msg: String): String =
if (displayThread) {
"[" + Thread.currentThread().name + "] " + msg
} else {
msg
// 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"

@JvmStatic
fun setConfig(_level: Int, _displayThread: Boolean) {
level = _level
displayThread = _displayThread
}

@JvmStatic
private fun getTag(tag: String): String = TAG_PREFIX + tag

@JvmStatic
private fun getMsg(msg: String): String =
if (displayThread) {
"[" + Thread.currentThread().name + "] " + msg
} else {
msg
}

@JvmStatic
fun v(tag: String, msg: String) {
if (level <= Log.VERBOSE) Log.v(getTag(tag), getMsg(msg))
}

@JvmStatic
fun d(tag: String, msg: String) {
if (level <= Log.DEBUG) Log.d(getTag(tag), getMsg(msg))
}

@JvmStatic
fun i(tag: String, msg: String) {
if (level <= Log.INFO) Log.i(getTag(tag), getMsg(msg))
}

@JvmStatic
fun w(tag: String, msg: String) {
if (level <= Log.WARN) Log.w(getTag(tag), getMsg(msg))
}

@JvmStatic
fun e(tag: String, msg: String) {
if (level <= Log.ERROR) Log.e(getTag(tag), getMsg(msg))
}

@JvmStatic
fun v(tag: String, msg: String) {
if (level <= Log.VERBOSE) Log.v(getTag(tag), getMsg(msg))
}

@JvmStatic
fun d(tag: String, msg: String) {
if (level <= Log.DEBUG) Log.d(getTag(tag), getMsg(msg))
}

@JvmStatic
fun i(tag: String, msg: String) {
if (level <= Log.INFO) Log.i(getTag(tag), getMsg(msg))
}

@JvmStatic
fun w(tag: String, msg: String) {
if (level <= Log.WARN) Log.w(getTag(tag), getMsg(msg))
}

@JvmStatic
fun e(tag: String, msg: String) {
if (level <= Log.ERROR) Log.e(getTag(tag), getMsg(msg))
}

@JvmStatic
fun wtf(tag: String, msg: String) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
Log.wtf(getTag(tag), "--------------->" + getMsg(msg))
} else {
Log.e(getTag(tag), "--------------->" + getMsg(msg))
@JvmStatic
fun wtf(tag: String, msg: String) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
Log.wtf(getTag(tag), "--------------->" + getMsg(msg))
} else {
Log.e(getTag(tag), "--------------->" + getMsg(msg))
}
printCallStack()
}
printCallStack()
}

@JvmStatic
fun printCallStack() {
if (level <= Log.VERBOSE) {
val e = Exception()
e.printStackTrace()

@JvmStatic
fun printCallStack() {
if (level <= Log.VERBOSE) {
val e = Exception()
e.printStackTrace()
}
}
}

// Additionnal thread safety checkers
@JvmStatic
fun checkUIThread(tag: String, msg: String) {
if (Thread.currentThread().name != "main") {
wtf(tag, "------------------------>" + getMsg(msg))
// Additionnal thread safety checkers
@JvmStatic
fun checkUIThread(tag: String, msg: String) {
if (Thread.currentThread().name != "main") {
wtf(tag, "------------------------>" + getMsg(msg))
}
}
}

@JvmStatic
fun checkNotUIThread(tag: String, msg: String) {
if (Thread.currentThread().name == "main") {
wtf(tag, "------------------------>" + getMsg(msg))
@JvmStatic
fun checkNotUIThread(tag: String, msg: String) {
if (Thread.currentThread().name == "main") {
wtf(tag, "------------------------>" + getMsg(msg))
}
}
}
}
Loading

0 comments on commit 12bba63

Please sign in to comment.