Skip to content

Commit ac9c720

Browse files
committed
55987-elys
1 parent b28b1d6 commit ac9c720

File tree

14 files changed

+59
-46
lines changed

14 files changed

+59
-46
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ dependencies {
108108
// implementation 'com.jjoe64:graphview:4.2.2'
109109

110110
// https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp
111-
implementation "com.squareup.okhttp3:okhttp:5.2.1"
111+
implementation "com.squareup.okhttp3:okhttp:5.3.0"
112112

113113
// https://developer.android.com/studio/write/java8-support
114114
// https://developer.android.com/studio/write/java8-support-table

app/src/main/java/joshuatee/wx/notifications/NotificationTextProduct.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ object NotificationTextProduct {
6767
if (s != "") {
6868
val textProdChunk = DownloadText.byProduct(context, s)
6969
val textProdFirstLine = if (textProdChunk.length > matchSize) {
70-
textProdChunk.substring(0, matchSize - 2)
70+
textProdChunk.take(matchSize - 2)
7171
} else {
7272
textProdChunk
7373
}

app/src/main/java/joshuatee/wx/objects/LatLon.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class LatLon() {
6363
}
6464

6565
constructor(temp: String) : this() {
66-
xStr = temp.substring(0, 4)
66+
xStr = temp.take(4)
6767
yStr = temp.substring(4, 8)
6868
if (yStr.matches("^0".toRegex())) {
6969
yStr = yStr.replace("^0".toRegex(), "")
@@ -229,7 +229,7 @@ class LatLon() {
229229
val coordinates = html.parseColumn("([0-9]{8}).*?")
230230
var string = ""
231231
coordinates.forEach { temp ->
232-
var xStrTmp = temp.substring(0, 4)
232+
var xStrTmp = temp.take(4)
233233
var yStrTmp = temp.substring(4, 8)
234234
if (yStrTmp.matches("^0".toRegex())) {
235235
yStrTmp = yStrTmp.replace("^0".toRegex(), "")

app/src/main/java/joshuatee/wx/radar/CanvasCreate.kt

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,8 @@ object CanvasCreate {
4141
private const val IMAGE_HEIGHT = 1000
4242
private const val CITY_SIZE = 18
4343

44-
fun layeredImage(context: Context, radarSiteArg: String, product: String): Bitmap {
45-
val radarSite = radarSiteArg
44+
fun layeredImage(context: Context, radarSite: String, product: String): Bitmap {
4645
val scaleType = ProjectionType.WX_RENDER
47-
// if (NexradUtil.isProductTdwr(product)) {
48-
// radarSite = NexradUtil.getTdwrFromRid(radarSite)
49-
// scaleType = ProjectionType.WX_RENDER_48
50-
// }
5146
if (!product.contains("L2")) {
5247
val url = NexradDownload.getRadarFileUrl(radarSite, product)
5348
val inputStream = url.getInputStream()
@@ -94,16 +89,11 @@ object CanvasCreate {
9489

9590
fun layeredImageFromFile(
9691
context: Context,
97-
radarSiteArg: String,
92+
radarSite: String,
9893
product: String,
9994
idxStr: String
10095
): Bitmap {
101-
val radarSite = radarSiteArg
10296
val scaleType = ProjectionType.WX_RENDER
103-
// if (NexradUtil.isProductTdwr(product)) {
104-
// radarSite = NexradUtil.getTdwrFromRid(radarSite)
105-
// scaleType = ProjectionType.WX_RENDER_48
106-
// }
10797
val layers = mutableListOf<Drawable>()
10898
val colorDrawable = RadarPreferences.nexradBackgroundColor.toDrawable()
10999
var bitmapCanvas = createBitmap(IMAGE_WIDTH, IMAGE_HEIGHT)

app/src/main/java/joshuatee/wx/radar/Metar.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,15 @@ internal object Metar {
160160
var windGustInKt = ""
161161
if (windBlob.contains("KT") && windBlob.length == 7) {
162162
validWind = true
163-
windDir = windBlob.substring(0, 3)
163+
windDir = windBlob.take(3)
164164
windInKt = windBlob.substring(3, 5)
165165
val windDirInt = To.int(windDir)
166166
windBlob =
167167
windDir + " (" + UtilityMath.bearingToDirection(windDirInt) + ") " + windInKt + " kt"
168168
} else if (windBlob.contains("KT") && windBlob.length == 10) {
169169
validWind = true
170170
validWindGust = true
171-
windDir = windBlob.substring(0, 3)
171+
windDir = windBlob.take(3)
172172
windInKt = windBlob.substring(3, 5)
173173
windGustInKt = windBlob.substring(6, 8)
174174
val windDirInt = To.int(windDir)

app/src/main/java/joshuatee/wx/radar/WXGLRadarActivityMultiPane.kt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,18 @@ class WXGLRadarActivityMultiPane : VideoRecordActivity(), OnMenuItemClickListene
7474
//
7575
heightDivider =
7676
setupLayout(savedInstanceState, nexradArguments.numberOfPanes, heightDivider)
77-
val widthDivider = if (nexradArguments.numberOfPanes == 4) {
78-
2
79-
} else if (nexradArguments.numberOfPanes == 2 && landScape) {
80-
2
81-
} else {
82-
1
77+
val widthDivider = when (nexradArguments.numberOfPanes) {
78+
4 -> {
79+
2
80+
}
81+
82+
2 if landScape -> {
83+
2
84+
}
85+
86+
else -> {
87+
1
88+
}
8389
}
8490
nexradState = NexradStatePane(
8591
this,

app/src/main/java/joshuatee/wx/radar/WpcFronts.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,11 @@ object WpcFronts {
213213
return if (string.length != 7) {
214214
listOf(0.0, 0.0)
215215
} else {
216-
val latitude = To.double(string.substring(0, 2) + "." + string.substring(2, 3))
216+
val latitude = To.double(string.take(2) + "." + string[2])
217217
val longitude = if (string[3] == '0') {
218-
To.double(string.substring(4, 6) + "." + string.substring(6, 7))
218+
To.double(string.substring(4, 6) + "." + string[6])
219219
} else {
220-
To.double(string.substring(3, 6) + "." + string.substring(6, 7))
220+
To.double(string.substring(3, 6) + "." + string[6])
221221
}
222222
listOf(latitude, longitude)
223223
}

app/src/main/java/joshuatee/wx/settings/SettingsColorPaletteEditor.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,14 @@ class SettingsColorPaletteEditor : BaseActivity(), OnMenuItemClickListener {
156156
errors += "The following lines do not have dbz values in increasing order: " + GlobalVariables.newline + priorValue + " " + list[1] + GlobalVariables.newline
157157
}
158158
priorValue = To.double(list[1])
159-
if (To.double(list[2]) > 255.0 || To.double(list[2]) < 0.0) {
159+
if (To.double(list[2]) !in 0.0..255.0) {
160160
errors =
161161
errors + "Red value must be between 0 and 255: " + GlobalVariables.newline + line + GlobalVariables.newline
162162
}
163-
if (To.double(list[3]) > 255.0 || To.double(list[3]) < 0.0) {
163+
if (To.double(list[3]) !in 0.0..255.0) {
164164
errors += "Green value must be between 0 and 255: " + GlobalVariables.newline + line + GlobalVariables.newline
165165
}
166-
if (To.double(list[4]) > 255.0 || To.double(list[4]) < 0.0) {
166+
if (To.double(list[4]) !in 0.0..255.0) {
167167
errors += "Blue value must be between 0 and 255: " + GlobalVariables.newline + line + GlobalVariables.newline
168168
}
169169
} else {

app/src/main/java/joshuatee/wx/settings/UIPreferences.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,22 +237,22 @@ object UIPreferences {
237237
val res = context.resources
238238
deviceScale = TypedValue.applyDimension(
239239
TypedValue.COMPLEX_UNIT_DIP, 1f,
240-
MyApplication.Companion.dm
240+
MyApplication.dm
241241
)
242242
padding = TypedValue.applyDimension(
243243
TypedValue.COMPLEX_UNIT_DIP,
244244
res.getDimension(R.dimen.padding_dynamic_tv),
245-
MyApplication.Companion.dm
245+
MyApplication.dm
246246
).toInt()
247247
paddingSettings = TypedValue.applyDimension(
248248
TypedValue.COMPLEX_UNIT_DIP,
249249
res.getDimension(R.dimen.padding_dynamic_tv_settings),
250-
MyApplication.Companion.dm
250+
MyApplication.dm
251251
).toInt()
252252
paddingSmall = TypedValue.applyDimension(
253253
TypedValue.COMPLEX_UNIT_DIP,
254254
res.getDimension(R.dimen.padding_dynamic_tv_small),
255-
MyApplication.Companion.dm
255+
MyApplication.dm
256256
).toInt()
257257
lLpadding = res.getDimension(R.dimen.padding_ll)
258258

app/src/main/java/joshuatee/wx/util/DownloadText.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ object DownloadText {
164164
|| prod == "UVICAC"
165165
|| prod == "RWRMX"
166166
|| prod.startsWith("TPT") -> {
167-
val product = prod.substring(0, 3)
167+
val product = prod.take(3)
168168
val site = prod.substring(3)
169169
val url =
170170
"https://forecast.weather.gov/product.php?site=NWS&issuedby=$site&product=$product&format=txt&version=1&glossary=0"
@@ -173,7 +173,7 @@ object DownloadText {
173173
}
174174

175175
prod.startsWith("GLF") -> {
176-
val product = prod.substring(0, 3)
176+
val product = prod.take(3)
177177
val site = prod.substring(3).replace("%", "")
178178
val url =
179179
"https://forecast.weather.gov/product.php?site=NWS&issuedby=$site&product=$product&format=txt&version=1&glossary=0"
@@ -264,7 +264,7 @@ object DownloadText {
264264
}
265265

266266
prod.startsWith("RWR") -> {
267-
val product = prod.substring(0, 3)
267+
val product = prod.take(3)
268268
val location = prod.substring(3).replace("%", "")
269269
val state = WfoSites.getState(location)
270270
val url =
@@ -275,7 +275,7 @@ object DownloadText {
275275
}
276276

277277
prod.startsWith("NSH") || (prod.startsWith("RTP") && prod.length == 6) -> {
278-
val product = prod.substring(0, 3)
278+
val product = prod.take(3)
279279
val location = prod.substring(3).replace("%", "")
280280
val url =
281281
"https://forecast.weather.gov/product.php?site=$location&issuedby=$location&product=$product"
@@ -284,7 +284,7 @@ object DownloadText {
284284
}
285285

286286
prod.startsWith("RTP") && prod.length == 5 -> {
287-
val product = prod.substring(0, 3)
287+
val product = prod.take(3)
288288
val location = prod.substring(3, 5).replace("%", "")
289289
val url =
290290
GlobalVariables.NWS_API_URL + "/products/types/$product/locations/$location"
@@ -312,7 +312,7 @@ object DownloadText {
312312
// Feb 8 2020 Sat
313313
// The NWS API for text products has been unstable Since Wed Feb 5
314314
// resorting to alternatives
315-
val t1 = prod.substring(0, 3)
315+
val t1 = prod.take(3)
316316
val t2 = prod.substring(3).replace("%", "")
317317
if (USE_NWS_API) {
318318
val url = GlobalVariables.NWS_API_URL + "/products/types/$t1/locations/$t2"
@@ -397,7 +397,7 @@ object DownloadText {
397397

398398
fun byProduct(prodF: String, version: Int): String {
399399
val prod = prodF.uppercase(Locale.US)
400-
val t1 = prod.substring(0, 3)
400+
val t1 = prod.take(3)
401401
val t2 = prod.substring(3)
402402
val url =
403403
"https://forecast.weather.gov/product.php?site=NWS&product=$t1&issuedby=$t2&version=$version"

0 commit comments

Comments
 (0)