days, long timestamp, boolean showHeader)
{
- if(days == null || days.size() <= 0)
+ if(days == null || days.size() == 0)
return null;
StringBuilder sb = new StringBuilder();
@@ -2325,7 +2317,6 @@ private String getCode(String icon)
{
return switch (icon)
{
- case "clearsky_day" -> "01d";
case "clearsky_night" -> "01n";
case "clearsky_polartwilight" -> "01m";
case "fair_day" -> "02d";
@@ -2479,7 +2470,7 @@ String[] processWZ(String data, boolean showHeader)
day.day = tmp[0];
}
- if (tmp.length <= 1)
+ if (tmp.length == 1)
continue;
String[] mybits = tmp[1].split("
");
@@ -2685,6 +2676,8 @@ String[] processYahoo(String data, boolean showHeader)
void SendIntents()
{
+ getWeather();
+ getForecast();
Intent intent = new Intent();
intent.setAction(Common.UPDATE_INTENT);
context.sendBroadcast(intent);
diff --git a/app/src/main/java/com/odiousapps/weewxweather/Forecast.java b/app/src/main/java/com/odiousapps/weewxweather/Forecast.java
index 36b6d26..2546a7a 100644
--- a/app/src/main/java/com/odiousapps/weewxweather/Forecast.java
+++ b/app/src/main/java/com/odiousapps/weewxweather/Forecast.java
@@ -154,11 +154,13 @@ private void loadWebView()
int height = Math.round((float) Resources.getSystem().getDisplayMetrics().widthPixels / sd * 0.955f);
int width = Math.round((float) Resources.getSystem().getDisplayMetrics().heightPixels / sd * 0.955f);
- String html = "\n" +
- "\n" +
- " \n" +
- " \n" +
- " \n";
+ String html = """
+
+
+
+
+
+ """;
if (dark_theme == 1)
html += "";
@@ -443,140 +445,121 @@ private void generateForecast()
return;
}
- switch(fctype.toLowerCase(Locale.ENGLISH))
+ switch (fctype.toLowerCase(Locale.ENGLISH))
{
- case "yahoo":
+ case "yahoo" ->
{
String[] content = common.processYahoo(data, true);
- if(content != null && content.length >= 2)
+ if (content != null && content.length >= 2)
updateForecast(content[0], content[1]);
- break;
}
- case "weatherzone":
+ case "weatherzone" ->
{
String[] content = common.processWZ(data, true);
- if(content != null && content.length >= 2)
+ if (content != null && content.length >= 2)
updateForecast(content[0], content[1]);
- break;
}
- case "yr.no":
+ case "yr.no" ->
{
String[] content = common.processYR(data, true);
- if(content != null && content.length >= 2)
+ if (content != null && content.length >= 2)
updateForecast(content[0], content[1]);
- break;
}
- case "met.no":
+ case "met.no" ->
{
String[] content = common.processMetNO(data, true);
- if(content != null && content.length >= 2)
+ if (content != null && content.length >= 2)
updateForecast(content[0], content[1]);
- break;
}
- case "bom.gov.au":
+ case "bom.gov.au" ->
{
String[] content = common.processBOM(data, true);
- if(content != null && content.length >= 2)
+ if (content != null && content.length >= 2)
updateForecast(content[0], content[1]);
- break;
}
- case "wmo.int":
+ case "wmo.int" ->
{
String[] content = common.processWMO(data, true);
- if(content != null && content.length >= 2)
+ if (content != null && content.length >= 2)
updateForecast(content[0], content[1]);
- break;
}
- case "weather.gov":
+ case "weather.gov" ->
{
String[] content = common.processWGOV(data, true);
- if(content != null && content.length >= 2)
+ if (content != null && content.length >= 2)
updateForecast(content[0], content[1]);
- break;
}
- case "weather.gc.ca":
+ case "weather.gc.ca" ->
{
String[] content = common.processWCA(data, true);
- if(content != null && content.length >= 2)
+ if (content != null && content.length >= 2)
updateForecast(content[0], content[1]);
- break;
}
- case "weather.gc.ca-fr":
+ case "weather.gc.ca-fr" ->
{
String[] content = common.processWCAF(data, true);
- if(content != null && content.length >= 2)
+ if (content != null && content.length >= 2)
updateForecast(content[0], content[1]);
- break;
}
- case "metoffice.gov.uk":
+ case "metoffice.gov.uk" ->
{
String[] content = common.processMET(data, true);
- if(content != null && content.length >= 2)
+ if (content != null && content.length >= 2)
updateForecast(content[0], content[1]);
- break;
}
- case "bom2":
+ case "bom2" ->
{
String[] content = common.processBOM2(data, true);
- if(content != null && content.length >= 2)
+ if (content != null && content.length >= 2)
updateForecast(content[0], content[1]);
- break;
}
- case "bom3":
+ case "bom3" ->
{
String[] content = common.processBOM3(data, true);
- if(content != null && content.length >= 2)
+ if (content != null && content.length >= 2)
updateForecast(content[0], content[1]);
- break;
}
- case "aemet.es":
+ case "aemet.es" ->
{
String[] content = common.processAEMET(data, true);
- if(content != null && content.length >= 2)
+ if (content != null && content.length >= 2)
updateForecast(content[0], content[1]);
- break;
}
- case "dwd.de":
+ case "dwd.de" ->
{
String[] content = common.processDWD(data, true);
- if(content != null && content.length >= 2)
+ if (content != null && content.length >= 2)
updateForecast(content[0], content[1]);
- break;
}
- case "metservice.com":
+ case "metservice.com" ->
{
String[] content = common.processMetService(data, true);
- if(content != null && content.length >= 2)
+ if (content != null && content.length >= 2)
updateForecast(content[0], content[1]);
- break;
}
- case "openweathermap.org":
+ case "openweathermap.org" ->
{
String[] content = common.processOWM(data, true);
- if(content != null && content.length >= 2)
+ if (content != null && content.length >= 2)
updateForecast(content[0], content[1]);
- break;
}
- case "weather.com":
+ case "weather.com" ->
{
String[] content = common.processWCOM(data, true);
- if(content != null && content.length >= 2)
+ if (content != null && content.length >= 2)
updateForecast(content[0], content[1]);
- break;
}
- case "met.ie":
+ case "met.ie" ->
{
String[] content = common.processMETIE(data, true);
- if(content != null && content.length >= 2)
+ if (content != null && content.length >= 2)
updateForecast(content[0], content[1]);
- break;
}
- case "tempoitalia.it":
+ case "tempoitalia.it" ->
{
String[] content = common.processTempoItalia(data, true);
- if(content != null && content.length >= 2)
+ if (content != null && content.length >= 2)
updateForecast(content[0], content[1]);
- break;
}
}
@@ -624,90 +607,64 @@ private void updateForecast(final String bits, final String desc)
switch (common.GetStringPref("fctype", "yahoo").toLowerCase(Locale.ENGLISH))
{
- case "yahoo":
- im.setImageResource(R.drawable.purple);
- break;
- case "weatherzone":
- im.setImageResource(R.drawable.wz);
- break;
- case "yr.no":
- im.setImageResource(R.drawable.yrno);
- break;
- case "met.no":
- im.setImageResource(R.drawable.met_no);
- break;
- case "bom.gov.au":
+ case "yahoo" -> im.setImageResource(R.drawable.purple);
+ case "weatherzone" -> im.setImageResource(R.drawable.wz);
+ case "yr.no" -> im.setImageResource(R.drawable.yrno);
+ case "met.no" -> im.setImageResource(R.drawable.met_no);
+ case "bom.gov.au" ->
+ {
im.setImageResource(R.drawable.bom);
- if(dark_theme == 1)
+ if (dark_theme == 1)
im.setColorFilter(new ColorMatrixColorFilter(Common.NEGATIVE));
else
im.setColorFilter(null);
- break;
- case "wmo.int":
- im.setImageResource(R.drawable.wmo);
- break;
- case "weather.gov":
- im.setImageResource(R.drawable.wgov);
- break;
- case "weather.gc.ca":
- case "weather.gc.ca-fr":
- im.setImageResource(R.drawable.wca);
- break;
- case "metoffice.gov.uk":
- im.setImageResource(R.drawable.met);
- break;
- case "bom2":
- case "bom3":
+ }
+ case "wmo.int" -> im.setImageResource(R.drawable.wmo);
+ case "weather.gov" -> im.setImageResource(R.drawable.wgov);
+ case "weather.gc.ca", "weather.gc.ca-fr" -> im.setImageResource(R.drawable.wca);
+ case "metoffice.gov.uk" -> im.setImageResource(R.drawable.met);
+ case "bom2", "bom3" ->
+ {
im.setImageResource(R.drawable.bom);
- if(dark_theme == 1)
+ if (dark_theme == 1)
{
im.setColorFilter(new ColorMatrixColorFilter(Common.NEGATIVE));
- } else {
+ } else
+ {
im.setColorFilter(null);
}
- break;
- case "aemet.es":
- im.setImageResource(R.drawable.aemet);
- break;
- case "dwd.de":
- im.setImageResource(R.drawable.dwd);
- break;
- case "metservice.com":
+ }
+ case "aemet.es" -> im.setImageResource(R.drawable.aemet);
+ case "dwd.de" -> im.setImageResource(R.drawable.dwd);
+ case "metservice.com" ->
+ {
im.setImageResource(R.drawable.metservice);
- if(dark_theme == 1)
+ if (dark_theme == 1)
im.setColorFilter(new ColorMatrixColorFilter(Common.NEGATIVE));
else
im.setColorFilter(null);
- break;
- case "meteofrance.com":
- im.setImageResource(R.drawable.mf);
- break;
- case "openweathermap.org":
- im.setImageResource(R.drawable.owm);
- break;
- case "apixu.com":
+ }
+ case "meteofrance.com" -> im.setImageResource(R.drawable.mf);
+ case "openweathermap.org" -> im.setImageResource(R.drawable.owm);
+ case "apixu.com" ->
+ {
im.setImageResource(R.drawable.apixu);
- if(dark_theme == 1)
+ if (dark_theme == 1)
im.setColorFilter(new ColorMatrixColorFilter(Common.NEGATIVE));
else
im.setColorFilter(null);
- break;
- case "weather.com":
- im.setImageResource(R.drawable.weather_com);
- break;
- case "met.ie":
+ }
+ case "weather.com" -> im.setImageResource(R.drawable.weather_com);
+ case "met.ie" ->
+ {
im.setImageResource(R.drawable.met_ie);
- if(dark_theme == 1)
+ if (dark_theme == 1)
im.setColorFilter(new ColorMatrixColorFilter(Common.NEGATIVE));
else
im.setColorFilter(null);
- break;
- case "ilmeteo.it":
- im.setImageResource(R.drawable.ilmeteo_it);
- break;
- case "tempoitalia.it":
- im.setImageResource(R.drawable.tempoitalia_it);
- break;
+ }
+ case "ilmeteo.it" -> im.setImageResource(R.drawable.ilmeteo_it);
+ case "tempoitalia.it" -> im.setImageResource(R.drawable.tempoitalia_it);
}
});
}
diff --git a/app/src/main/java/com/odiousapps/weewxweather/MainActivity.java b/app/src/main/java/com/odiousapps/weewxweather/MainActivity.java
index cdfc6c9..8d5b959 100644
--- a/app/src/main/java/com/odiousapps/weewxweather/MainActivity.java
+++ b/app/src/main/java/com/odiousapps/weewxweather/MainActivity.java
@@ -622,13 +622,15 @@ private void processSettings()
{
switch (fctype.toLowerCase(Locale.ENGLISH))
{
- case "yahoo":
+ case "yahoo" ->
+ {
Common.LogMessage("forecast=" + forecast);
Common.LogMessage("fctype=" + fctype);
- if(!forecast.startsWith("http"))
+ if (!forecast.startsWith("http"))
{
common.SetStringPref("lastError", "Yahoo API recently changed, you need to update your settings.");
- runOnUiThread(() -> {
+ runOnUiThread(() ->
+ {
b1.setEnabled(true);
b2.setEnabled(true);
dialog.dismiss();
@@ -641,27 +643,23 @@ private void processSettings()
});
return;
}
- break;
- case "weatherzone":
+ }
+ case "weatherzone" ->
+ {
forecast = "https://rss.weatherzone.com.au/?u=12994-1285<=aploc&lc=" + forecast + "&obs=0&fc=1&warn=0";
Common.LogMessage("forecast=" + forecast);
Common.LogMessage("fctype=" + fctype);
- break;
- case "yr.no":
- case "met.no":
- case "weather.gc.ca":
- case "weather.gc.ca-fr":
- case "metoffice.gov.uk":
- case "bom2":
- case "aemet.es":
- case "dwd.de":
- case "tempoitalia.it":
+ }
+ case "yr.no", "met.no", "weather.gc.ca", "weather.gc.ca-fr", "metoffice.gov.uk", "bom2", "aemet.es", "dwd.de", "tempoitalia.it" ->
+ {
Common.LogMessage("forecast=" + forecast);
Common.LogMessage("fctype=" + fctype);
- break;
- case "bom.gov.au":
+ }
+ case "bom.gov.au" ->
+ {
common.SetStringPref("lastError", "Forecast type " + fctype + " is no longer supported due to ftp support being dropped in Android. Use bom2 forecasts instead, check the wiki for details.");
- runOnUiThread(() -> {
+ runOnUiThread(() ->
+ {
b1.setEnabled(true);
b2.setEnabled(true);
dialog.dismiss();
@@ -673,83 +671,91 @@ private void processSettings()
}).show();
});
return;
- case "wmo.int":
- if(!forecast.startsWith("http"))
+ }
+ case "wmo.int" ->
+ {
+ if (!forecast.startsWith("http"))
forecast = "https://worldweather.wmo.int/en/json/" + forecast.trim() + "_en.xml";
Common.LogMessage("forecast=" + forecast);
Common.LogMessage("fctype=" + fctype);
- break;
- case "weather.gov":
+ }
+ case "weather.gov" ->
+ {
String lat = "", lon = "";
-
- if(forecast.contains("?"))
+ if (forecast.contains("?"))
forecast = forecast.split("\\?", 2)[1].trim();
-
- if(forecast.contains("lat") && forecast.contains("lon"))
+ if (forecast.contains("lat") && forecast.contains("lon"))
{
String[] tmp = forecast.split("&");
- for(String line : tmp)
+ for (String line : tmp)
{
- if(line.split("=", 2)[0].equals("lat"))
+ if (line.split("=", 2)[0].equals("lat"))
lat = line.split("=", 2)[1].trim();
- if(line.split("=", 2)[0].equals("lon"))
+ if (line.split("=", 2)[0].equals("lon"))
lon = line.split("=", 2)[1].trim();
}
- } else {
+ } else
+ {
lat = forecast.split(",")[0].trim();
lon = forecast.split(",")[1].trim();
}
-
forecast = "https://forecast.weather.gov/MapClick.php?lat=" + lat + "&lon=" + lon + "&unit=0&lg=english&FcstType=json";
Common.LogMessage("forecast=" + forecast);
Common.LogMessage("fctype=" + fctype);
- break;
- case "bom3":
+ }
+ case "bom3" ->
+ {
forecast = "https://api.weather.bom.gov.au/v1/locations/" + forecast.trim() + "/forecasts/daily";
Common.LogMessage("forecast=" + forecast);
Common.LogMessage("fctype=" + fctype);
- break;
- case "metservice.com":
+ }
+ case "metservice.com" ->
+ {
forecast = "https://www.metservice.com/publicData/localForecast" + forecast;
Common.LogMessage("forecast=" + forecast);
Common.LogMessage("fctype=" + fctype);
- break;
- case "openweathermap.org":
- if(metric_forecasts.isChecked())
+ }
+ case "openweathermap.org" ->
+ {
+ if (metric_forecasts.isChecked())
forecast += "&units=metric";
else
forecast += "&units=imperial";
forecast += "&lang=" + Locale.getDefault().getLanguage();
Common.LogMessage("forecast=" + forecast);
Common.LogMessage("fctype=" + fctype);
- break;
- case "weather.com":
+ }
+ case "weather.com" ->
+ {
forecast = "https://api.weather.com/v3/wx/forecast/daily/5day?geocode=" + forecast + "&format=json&apiKey=d522aa97197fd864d36b418f39ebb323";
- if(metric_forecasts.isChecked())
+ if (metric_forecasts.isChecked())
forecast += "&units=m";
else
forecast += "&units=e";
forecast += "&language=" + Locale.getDefault().getLanguage() + "-" + Locale.getDefault().getCountry();
Common.LogMessage("forecast=" + forecast);
Common.LogMessage("fctype=" + fctype);
- break;
- case "met.ie":
+ }
+ case "met.ie" ->
+ {
metierev = "https://prodapi.metweb.ie/location/reverse/" + forecast.replaceAll(",", "/");
forecast = "https://prodapi.metweb.ie/weather/daily/" + forecast.replaceAll(",", "/") + "/10";
- if(common.GetStringPref("metierev", "").equals("") || !forecast.equals(oldforecast))
+ if (common.GetStringPref("metierev", "").equals("") || !forecast.equals(oldforecast))
{
metierev = common.downloadForecast(fctype, metierev, null);
- JSONObject jobj= new JSONObject(metierev);
+ JSONObject jobj = new JSONObject(metierev);
metierev = jobj.getString("city") + ", Ireland";
common.SetStringPref("metierev", metierev);
}
Common.LogMessage("forecast=" + forecast);
Common.LogMessage("fctype=" + fctype);
Common.LogMessage("metierev=" + metierev);
- break;
- default:
+ }
+ default ->
+ {
common.SetStringPref("lastError", String.format(getString(R.string.forecast_type_is_invalid), fctype));
- runOnUiThread(() -> {
+ runOnUiThread(() ->
+ {
b1.setEnabled(true);
b2.setEnabled(true);
dialog.dismiss();
@@ -761,6 +767,7 @@ private void processSettings()
}).show();
});
return;
+ }
}
} catch (Exception e) {
common.SetStringPref("lastError", e.toString());
diff --git a/app/src/main/java/com/odiousapps/weewxweather/SplashScreen.java b/app/src/main/java/com/odiousapps/weewxweather/SplashScreen.java
index a900248..67c8b0a 100644
--- a/app/src/main/java/com/odiousapps/weewxweather/SplashScreen.java
+++ b/app/src/main/java/com/odiousapps/weewxweather/SplashScreen.java
@@ -1,12 +1,9 @@
package com.odiousapps.weewxweather;
import android.annotation.SuppressLint;
-import android.app.AlarmManager;
-import android.content.Context;
import android.content.Intent;
-import android.net.Uri;
-import android.os.Build;
import android.os.Bundle;
+
import androidx.appcompat.app.AppCompatActivity;
@SuppressLint("CustomSplashScreen")
@@ -40,16 +37,6 @@ protected void onResume()
private void startApp()
{
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
- {
- AlarmManager alarms = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
- if(!alarms.canScheduleExactAlarms())
- {
- startActivity(new Intent(android.provider.Settings.ACTION_REQUEST_SCHEDULE_EXACT_ALARM, Uri.parse("package:" + getPackageName())));
- finish();
- }
- }
-
Intent intent = new Intent(SplashScreen.this, MainActivity.class);
startActivity(intent);
}
diff --git a/app/src/main/java/com/odiousapps/weewxweather/Stats.java b/app/src/main/java/com/odiousapps/weewxweather/Stats.java
index 9f44334..48da83c 100644
--- a/app/src/main/java/com/odiousapps/weewxweather/Stats.java
+++ b/app/src/main/java/com/odiousapps/weewxweather/Stats.java
@@ -331,7 +331,7 @@ private void updateFields()
if(bits.length > 205 && !bits[205].equals(""))
{
stmp = " | " + bits[205] + "UVI | " + convert(bits[206]) +
- " | " + convert(bits[208]) + " | " + bits[207] + "W/m\u00B2 | |
";
+ "" + convert(bits[208]) + " | " + bits[207] + "W/m² | | ";
sb.append(stmp);
}
@@ -391,7 +391,7 @@ private void updateFields()
if(bits.length > 209 && !bits[209].equals(""))
{
stmp = " | " + bits[209] + "UVI | " + convert(bits[210]) +
- " | " + convert(bits[212]) + " | " + bits[211] + "W/m\u00B2 | |
";
+ "" + convert(bits[212]) + " | " + bits[211] + "W/m² | | ";
sb.append(stmp);
}
@@ -452,7 +452,7 @@ private void updateFields()
if(bits.length > 213 && !bits[213].equals(""))
{
stmp = " | " + bits[213] + "UVI | " + getTime(bits[214]) +
- " | " + getTime(bits[216]) + " | " + bits[215] + "W/m\u00B2 | |
";
+ "" + getTime(bits[216]) + " | " + bits[215] + "W/m² | | ";
sb.append(stmp);
}
@@ -501,7 +501,7 @@ private void updateFields()
if(bits.length > 217 && !bits[217].equals(""))
{
stmp = " | " + bits[217] + "UVI | " + getTime(bits[218]) +
- " | " + getTime(bits[220]) + " | " + bits[219] + "W/m\u00B2 | |
";
+ "" + getTime(bits[220]) + " | " + bits[219] + "W/m² | | ";
sb.append(stmp);
}
@@ -550,7 +550,7 @@ private void updateFields()
if(bits.length > 221 && !bits[221].equals(""))
{
stmp = " | " + bits[221] + "UVI | " + getTime(bits[222]) +
- " | " + getTime(bits[224]) + " | " + bits[223] + "W/m\u00B2 | |
";
+ "" + getTime(bits[224]) + " | " + bits[223] + "W/m² | | ";
sb.append(stmp);
}
diff --git a/app/src/main/java/com/odiousapps/weewxweather/UpdateCheck.java b/app/src/main/java/com/odiousapps/weewxweather/UpdateCheck.java
index 4e11b36..e92cbcd 100644
--- a/app/src/main/java/com/odiousapps/weewxweather/UpdateCheck.java
+++ b/app/src/main/java/com/odiousapps/weewxweather/UpdateCheck.java
@@ -9,7 +9,7 @@ public class UpdateCheck extends BroadcastReceiver
@Override
public void onReceive(final Context c, Intent i)
{
- Common.LogMessage("UpdateCheck.java started.");
+ Common.LogMessage("UpdateCheck.java started.", true);
if(c == null)
{
Common.LogMessage("UpdateCheck.java failed, c == null");
@@ -21,12 +21,12 @@ public void onReceive(final Context c, Intent i)
if(!common.checkConnection())
{
- Common.LogMessage("Skipping update due to wifi setting.");
+ Common.LogMessage("Skipping update due to wifi setting.", true);
return;
}
common.getWeather();
common.getForecast();
- Common.LogMessage("UpdateCheck.java finished.");
+ Common.LogMessage("UpdateCheck.java finished.", true);
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/odiousapps/weewxweather/Weather.java b/app/src/main/java/com/odiousapps/weewxweather/Weather.java
index 8685cba..079c33f 100644
--- a/app/src/main/java/com/odiousapps/weewxweather/Weather.java
+++ b/app/src/main/java/com/odiousapps/weewxweather/Weather.java
@@ -174,7 +174,7 @@ public boolean onConsoleMessage(ConsoleMessage cm)
sb.append(stmp);
stmp = " | " + bits[45] + "UVI | " +
- "" + bits[43] + "W/m\u00B2 | |
";
+ "" + bits[43] + "W/m² | | ";
sb.append(stmp);
if(bits.length > 202 && common.GetBoolPref("showIndoor", false))
@@ -255,7 +255,7 @@ private void loadWebView()
{
switch (common.GetStringPref("radtype", "image"))
{
- case "image":
+ case "image" ->
{
String radar = common.context.getFilesDir() + "/radar.gif";
@@ -263,30 +263,35 @@ private void loadWebView()
Common.LogMessage("myFile == " + myFile.getAbsolutePath());
Common.LogMessage("myFile.exists() == " + myFile.exists());
- if(!myFile.exists() || common.GetStringPref("RADAR_URL", "").equals(""))
+ if (!myFile.exists() || common.GetStringPref("RADAR_URL", "").equals(""))
{
sb.append("").append(getString(R.string.radar_url_not_set)).append("");
- } else {
- sb.append("\n" +
- "\n" +
- " \n" +
- " \n" +
- " \n");
+ } else
+ {
+ sb.append("""
+
+
+
+
+
+ """);
if (dark_theme == 1)
sb.append("");
try
{
File f = new File(radar);
- try(FileInputStream imageInFile = new FileInputStream(f))
+ try (FileInputStream imageInFile = new FileInputStream(f))
{
byte[] imageData = new byte[(int) f.length()];
if (imageInFile.read(imageData) > 0)
radar = "data:image/jpeg;base64," + Base64.encodeToString(imageData, Base64.DEFAULT);
- } catch (Exception e2) {
+ } catch (Exception e2)
+ {
e2.printStackTrace();
}
- } catch (Exception e) {
+ } catch (Exception e)
+ {
e.printStackTrace();
}
@@ -305,7 +310,8 @@ private void loadWebView()
});
return;
}
- case "webpage":
+ case "webpage" ->
+ {
mHandler.post(() ->
{
String radar_url = common.GetStringPref("RADAR_URL", "");
@@ -314,12 +320,14 @@ private void loadWebView()
swipeLayout.setRefreshing(false);
});
return;
- default:
+ }
+ default ->
+ {
sb.append("");
if (dark_theme == 1)
sb.append("");
sb.append("Radar URL not set or is still downloading. You can go to settings to change.");
- break;
+ }
}
mHandler.post(() ->
@@ -343,10 +351,10 @@ private void loadWebView()
switch (fctype.toLowerCase(Locale.ENGLISH))
{
- case "yahoo":
+ case "yahoo" ->
{
String[] content = common.processYahoo(data);
- if (content == null || content.length <= 0)
+ if (content == null || content.length == 0)
{
stopRefreshing();
return;
@@ -361,12 +369,11 @@ private void loadWebView()
sb.append(tmp);
tmp = "" + logo + content[0] + "";
sb.append(tmp);
- break;
}
- case "weatherzone":
+ case "weatherzone" ->
{
String[] content = common.processWZ(data);
- if (content == null || content.length <= 0)
+ if (content == null || content.length == 0)
{
stopRefreshing();
return;
@@ -381,12 +388,11 @@ private void loadWebView()
sb.append(tmp);
tmp = "" + logo + content[0] + "";
sb.append(tmp);
- break;
}
- case "yr.no":
+ case "yr.no" ->
{
String[] content = common.processYR(data);
- if (content == null || content.length <= 0)
+ if (content == null || content.length == 0)
{
stopRefreshing();
return;
@@ -401,12 +407,11 @@ private void loadWebView()
sb.append(tmp);
tmp = "" + logo + content[0] + "";
sb.append(tmp);
- break;
}
- case "met.no":
+ case "met.no" ->
{
String[] content = common.processMetNO(data);
- if (content == null || content.length <= 0)
+ if (content == null || content.length == 0)
{
stopRefreshing();
return;
@@ -421,12 +426,11 @@ private void loadWebView()
sb.append(tmp);
tmp = "" + logo + content[0] + "";
sb.append(tmp);
- break;
}
- case "bom.gov.au":
+ case "bom.gov.au" ->
{
String[] content = common.processBOM(data);
- if (content == null || content.length <= 0)
+ if (content == null || content.length == 0)
{
stopRefreshing();
return;
@@ -444,12 +448,11 @@ private void loadWebView()
tmp = "" + logo + content[0] + "";
sb.append(tmp);
- break;
}
- case "wmo.int":
+ case "wmo.int" ->
{
String[] content = common.processWMO(data);
- if (content == null || content.length <= 0)
+ if (content == null || content.length == 0)
{
stopRefreshing();
return;
@@ -464,12 +467,11 @@ private void loadWebView()
sb.append(tmp);
tmp = "" + logo + content[0] + "";
sb.append(tmp);
- break;
}
- case "weather.gov":
+ case "weather.gov" ->
{
String[] content = common.processWGOV(data);
- if (content == null || content.length <= 0)
+ if (content == null || content.length == 0)
{
stopRefreshing();
return;
@@ -484,12 +486,11 @@ private void loadWebView()
sb.append(tmp);
tmp = "" + logo + content[0] + "";
sb.append(tmp);
- break;
}
- case "weather.gc.ca":
+ case "weather.gc.ca" ->
{
String[] content = common.processWCA(data);
- if (content == null || content.length <= 0)
+ if (content == null || content.length == 0)
{
stopRefreshing();
return;
@@ -504,12 +505,11 @@ private void loadWebView()
sb.append(tmp);
tmp = "" + logo + content[0] + "";
sb.append(tmp);
- break;
}
- case "weather.gc.ca-fr":
+ case "weather.gc.ca-fr" ->
{
String[] content = common.processWCAF(data);
- if (content == null || content.length <= 0)
+ if (content == null || content.length == 0)
{
stopRefreshing();
return;
@@ -524,12 +524,11 @@ private void loadWebView()
sb.append(tmp);
tmp = "" + logo + content[0] + "