Fix some AndroidStudio warnings

This commit is contained in:
Manuel Fuhr 2022-04-24 14:33:28 +02:00
parent 1d2809de70
commit fc9deccad7
2 changed files with 75 additions and 90 deletions

View file

@ -14,6 +14,7 @@ import android.os.PowerManager.WakeLock;
import android.os.StatFs; import android.os.StatFs;
import android.widget.EditText; import android.widget.EditText;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat; import androidx.core.app.ActivityCompat;
import androidx.core.os.EnvironmentCompat; import androidx.core.os.EnvironmentCompat;
@ -22,6 +23,7 @@ import java.io.File;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -65,7 +67,7 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
private Set<String> selectedVias; private Set<String> selectedVias;
private List<OsmNodeNamed> nogoList; private List<OsmNodeNamed> nogoList;
private String maptoolDirCandidate; private String maptoolDirCandidate;
private final Set<Integer> dialogIds = new HashSet<Integer>(); private final Set<Integer> dialogIds = new HashSet<>();
private String errorMessage; private String errorMessage;
private String title; private String title;
private int wpCount; private int wpCount;
@ -74,7 +76,6 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
* Called when the activity is first created. * Called when the activity is first created.
*/ */
@Override @Override
@SuppressWarnings("deprecation")
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -94,7 +95,6 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
} }
@Override @Override
@SuppressWarnings("deprecation")
protected Dialog onCreateDialog(int id) { protected Dialog onCreateDialog(int id) {
AlertDialog.Builder builder; AlertDialog.Builder builder;
builder = new AlertDialog.Builder(this); builder = new AlertDialog.Builder(this);
@ -372,11 +372,10 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
private boolean[] getCheckedBooleanArray(int size) { private boolean[] getCheckedBooleanArray(int size) {
boolean[] checked = new boolean[size]; boolean[] checked = new boolean[size];
for (int i = 0; i < checked.length; i++) checked[i] = true; Arrays.fill(checked, true);
return checked; return checked;
} }
@SuppressWarnings("deprecation")
public void selectProfile(String[] items) { public void selectProfile(String[] items) {
availableProfiles = items; availableProfiles = items;
@ -384,7 +383,6 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
showDialog(DIALOG_MAINACTION_ID); showDialog(DIALOG_MAINACTION_ID);
} }
@SuppressWarnings("deprecation")
public void startDownloadManager() { public void startDownloadManager() {
if (!mBRouterView.hasUpToDateLookups()) { if (!mBRouterView.hasUpToDateLookups()) {
showDialog(DIALOG_OLDDATAHINT_ID); showDialog(DIALOG_OLDDATAHINT_ID);
@ -393,19 +391,18 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
} }
} }
@SuppressWarnings("deprecation")
public void selectBasedir(ArrayList<File> items, String defaultBasedir, String message) { public void selectBasedir(ArrayList<File> items, String defaultBasedir, String message) {
this.defaultbasedir = defaultBasedir; this.defaultbasedir = defaultBasedir;
this.message = message; this.message = message;
availableBasedirs = items; availableBasedirs = items;
ArrayList<Long> dirFreeSizes = new ArrayList<Long>(); ArrayList<Long> dirFreeSizes = new ArrayList<>();
for (File f : items) { for (File f : items) {
long size = 0L; long size = 0L;
try { try {
StatFs stat = new StatFs(f.getAbsolutePath()); StatFs stat = new StatFs(f.getAbsolutePath());
size = (long) stat.getAvailableBlocks() * stat.getBlockSize(); size = (long) stat.getAvailableBlocks() * stat.getBlockSize();
} catch (Exception e) { /* ignore */ } } catch (Exception e) { /* ignore */ }
dirFreeSizes.add(Long.valueOf(size)); dirFreeSizes.add(size);
} }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
@ -426,7 +423,6 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
showDialog(DIALOG_SELECTBASEDIR_ID); showDialog(DIALOG_SELECTBASEDIR_ID);
} }
@SuppressWarnings("deprecation")
public void selectRoutingModes(String[] modes, boolean[] modesChecked, String message) { public void selectRoutingModes(String[] modes, boolean[] modesChecked, String message) {
routingModes = modes; routingModes = modes;
routingModesChecked = modesChecked; routingModesChecked = modesChecked;
@ -434,28 +430,23 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
showDialog(DIALOG_ROUTINGMODES_ID); showDialog(DIALOG_ROUTINGMODES_ID);
} }
@SuppressWarnings("deprecation")
public void showModeConfigOverview(String message) { public void showModeConfigOverview(String message) {
this.message = message; this.message = message;
showDialog(DIALOG_MODECONFIGOVERVIEW_ID); showDialog(DIALOG_MODECONFIGOVERVIEW_ID);
} }
@SuppressWarnings("deprecation")
public void selectVias(String[] items) { public void selectVias(String[] items) {
availableVias = items; availableVias = items;
selectedVias = new HashSet<String>(availableVias.length); selectedVias = new HashSet<>(availableVias.length);
for (String via : items) Collections.addAll(selectedVias, items);
selectedVias.add(via);
showDialog(DIALOG_VIASELECT_ID); showDialog(DIALOG_VIASELECT_ID);
} }
@SuppressWarnings("deprecation")
public void selectWaypoint(String[] items) { public void selectWaypoint(String[] items) {
availableWaypoints = items; availableWaypoints = items;
showNewDialog(DIALOG_PICKWAYPOINT_ID); showNewDialog(DIALOG_PICKWAYPOINT_ID);
} }
@SuppressWarnings("deprecation")
public void showWaypointDatabaseHelp() { public void showWaypointDatabaseHelp() {
if (mBRouterView.canAccessSdCard) { if (mBRouterView.canAccessSdCard) {
showNewDialog(DIALOG_SHOW_WP_HELP_ID); showNewDialog(DIALOG_SHOW_WP_HELP_ID);
@ -464,38 +455,33 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
} }
} }
@SuppressWarnings("deprecation")
public void showRepeatTimeoutHelp() { public void showRepeatTimeoutHelp() {
showNewDialog(DIALOG_SHOW_REPEAT_TIMEOUT_HELP_ID); showNewDialog(DIALOG_SHOW_REPEAT_TIMEOUT_HELP_ID);
} }
@SuppressWarnings("deprecation")
public void showWpDatabaseScanSuccess(String bestGuess) { public void showWpDatabaseScanSuccess(String bestGuess) {
maptoolDirCandidate = bestGuess; maptoolDirCandidate = bestGuess;
showNewDialog(DIALOG_SHOW_WP_SCANRESULT_ID); showNewDialog(DIALOG_SHOW_WP_SCANRESULT_ID);
} }
@SuppressWarnings("deprecation")
public void selectNogos(List<OsmNodeNamed> nogoList) { public void selectNogos(List<OsmNodeNamed> nogoList) {
this.nogoList = nogoList; this.nogoList = nogoList;
showDialog(DIALOG_NOGOSELECT_ID); showDialog(DIALOG_NOGOSELECT_ID);
} }
private void showNewDialog(int id) { private void showNewDialog(int id) {
if (dialogIds.contains(Integer.valueOf(id))) { if (dialogIds.contains(id)) {
removeDialog(id); removeDialog(id);
} }
dialogIds.add(Integer.valueOf(id)); dialogIds.add(id);
showDialog(id); showDialog(id);
} }
@SuppressWarnings("deprecation")
public void showErrorMessage(String msg) { public void showErrorMessage(String msg) {
errorMessage = msg; errorMessage = msg;
showNewDialog(DIALOG_EXCEPTION_ID); showNewDialog(DIALOG_EXCEPTION_ID);
} }
@SuppressWarnings("deprecation")
public void showResultMessage(String title, String msg, int wpCount) { public void showResultMessage(String title, String msg, int wpCount) {
errorMessage = msg; errorMessage = msg;
this.title = title; this.title = title;
@ -535,16 +521,18 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
public ArrayList<File> getStorageDirectories() { public ArrayList<File> getStorageDirectories() {
ArrayList<File> list = null; ArrayList<File> list = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
list = new ArrayList<File>(Arrays.asList(getExternalMediaDirs())); list = new ArrayList<>(Arrays.asList(getExternalMediaDirs()));
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
list = new ArrayList<File>(Arrays.asList(getExternalFilesDirs(null))); list = new ArrayList<>(Arrays.asList(getExternalFilesDirs(null)));
} }
ArrayList<File> res = new ArrayList<File>(); ArrayList<File> res = new ArrayList<>();
for (File f : list) { if (list != null) {
if (f != null) { for (File f : list) {
if (getStorageState(f).equals(Environment.MEDIA_MOUNTED)) if (f != null) {
res.add(f); if (getStorageState(f).equals(Environment.MEDIA_MOUNTED))
res.add(f);
}
} }
} }
@ -577,7 +565,7 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
} }
@Override @Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults); super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == 0) { if (requestCode == 0) {
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {

View file

@ -66,7 +66,6 @@ public class BRouterView extends View {
private File tracksDir; private File tracksDir;
private File segmentDir; private File segmentDir;
private File profileDir; private File profileDir;
private String profilePath;
private String profileName; private String profileName;
private String sourceHint; private String sourceHint;
private boolean waitingForSelection = false; private boolean waitingForSelection = false;
@ -109,8 +108,7 @@ public class BRouterView extends View {
// don't ask twice // don't ask twice
String version = "v" + getContext().getString(R.string.app_version); String version = "v" + getContext().getString(R.string.app_version);
File vFile = new File(brd, "profiles2/" + version); File vFile = new File(brd, "profiles2/" + version);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q if (vFile.exists()) {
&& vFile.exists()) {
startSetup(baseDir, false); startSetup(baseDir, false);
return; return;
} }
@ -120,11 +118,10 @@ public class BRouterView extends View {
waitingForSelection = true; waitingForSelection = true;
waitingForMigration = true; waitingForMigration = true;
oldMigrationPath = brd.getAbsolutePath(); oldMigrationPath = brd.getAbsolutePath();
return;
} else { } else {
startSetup(baseDir, false); startSetup(baseDir, false);
return;
} }
return;
} }
} }
String message = baseDir == null ? "(no basedir configured previously)" : "(previous basedir " + baseDir String message = baseDir == null ? "(no basedir configured previously)" : "(previous basedir " + baseDir
@ -212,7 +209,7 @@ public class BRouterView extends View {
wpList = cor.waypoints; wpList = cor.waypoints;
nogoList = cor.nogopoints; nogoList = cor.nogopoints;
nogoVetoList = new ArrayList<OsmNodeNamed>(); nogoVetoList = new ArrayList<>();
sourceHint = "(dev/trgt=" + deviceLevel + "/" + targetSdkVersion + " coordinate-source: " + cor.basedir + cor.rootdir + ")"; sourceHint = "(dev/trgt=" + deviceLevel + "/" + targetSdkVersion + " coordinate-source: " + cor.basedir + cor.rootdir + ")";
@ -248,15 +245,17 @@ public class BRouterView extends View {
} }
String[] fileNames = profileDir.list(); String[] fileNames = profileDir.list();
ArrayList<String> profiles = new ArrayList<String>(); ArrayList<String> profiles = new ArrayList<>();
boolean lookupsFound = false; boolean lookupsFound = false;
for (String fileName : fileNames) { if (fileNames != null) {
if (fileName.endsWith(".brf")) { for (String fileName : fileNames) {
profiles.add(fileName.substring(0, fileName.length() - 4)); if (fileName.endsWith(".brf")) {
profiles.add(fileName.substring(0, fileName.length() - 4));
}
if (fileName.equals("lookups.dat"))
lookupsFound = true;
} }
if (fileName.equals("lookups.dat"))
lookupsFound = true;
} }
// add a "last timeout" dummy profile // add a "last timeout" dummy profile
@ -298,24 +297,26 @@ public class BRouterView extends View {
private void moveFolders(String oldMigrationPath, String basedir) { private void moveFolders(String oldMigrationPath, String basedir) {
File oldDir = new File(oldMigrationPath); File oldDir = new File(oldMigrationPath);
File[] oldFiles = oldDir.listFiles(); File[] oldFiles = oldDir.listFiles();
for (File f : oldFiles) { if (oldFiles != null) {
if (f.isDirectory()) { for (File f : oldFiles) {
int index = f.getAbsolutePath().lastIndexOf("/"); if (f.isDirectory()) {
String tmpdir = basedir + f.getAbsolutePath().substring(index); int index = f.getAbsolutePath().lastIndexOf("/");
moveFolders(f.getAbsolutePath(), tmpdir); String tmpdir = basedir + f.getAbsolutePath().substring(index);
} else { moveFolders(f.getAbsolutePath(), tmpdir);
if (!f.getName().startsWith("v1.6")) { } else {
moveFile(oldMigrationPath, f.getName(), basedir); if (!f.getName().startsWith("v1.6")) {
moveFile(oldMigrationPath, f.getName(), basedir);
}
} }
}
}
} }
} }
private void moveFile(String inputPath, String inputFile, String outputPath) { private void moveFile(String inputPath, String inputFile, String outputPath) {
InputStream in = null; InputStream in;
OutputStream out = null; OutputStream out;
try { try {
//create output directory if it doesn't exist //create output directory if it doesn't exist
@ -334,12 +335,10 @@ public class BRouterView extends View {
out.write(buffer, 0, read); out.write(buffer, 0, read);
} }
in.close(); in.close();
in = null;
// write the output file // write the output file
out.flush(); out.flush();
out.close(); out.close();
out = null;
// delete the original file // delete the original file
new File(inputPath + "/" + inputFile).delete(); new File(inputPath + "/" + inputFile).delete();
@ -365,7 +364,7 @@ public class BRouterView extends View {
} }
public void updateViaList(Set<String> selectedVias) { public void updateViaList(Set<String> selectedVias) {
ArrayList<OsmNodeNamed> filtered = new ArrayList<OsmNodeNamed>(wpList.size()); ArrayList<OsmNodeNamed> filtered = new ArrayList<>(wpList.size());
for (OsmNodeNamed n : wpList) { for (OsmNodeNamed n : wpList) {
String name = n.name; String name = n.name;
if ("from".equals(name) || "to".equals(name) || selectedVias.contains(name)) if ("from".equals(name) || "to".equals(name) || selectedVias.contains(name))
@ -442,7 +441,7 @@ public class BRouterView extends View {
private List<OsmNodeNamed> readWpList(BufferedReader br, boolean isNogo) throws Exception { private List<OsmNodeNamed> readWpList(BufferedReader br, boolean isNogo) throws Exception {
int cnt = Integer.parseInt(br.readLine()); int cnt = Integer.parseInt(br.readLine());
List<OsmNodeNamed> res = new ArrayList<OsmNodeNamed>(cnt); List<OsmNodeNamed> res = new ArrayList<>(cnt);
for (int i = 0; i < cnt; i++) { for (int i = 0; i < cnt; i++) {
OsmNodeNamed wp = OsmNodeNamed.decodeNogo(br.readLine()); OsmNodeNamed wp = OsmNodeNamed.decodeNogo(br.readLine());
wp.isNogo = isNogo; wp.isNogo = isNogo;
@ -471,7 +470,7 @@ public class BRouterView extends View {
rawTrackPath = modesDir + "/remote_rawtrack.dat"; rawTrackPath = modesDir + "/remote_rawtrack.dat";
} }
profilePath = profileDir + "/" + profile + ".brf"; String profilePath = profileDir + "/" + profile + ".brf";
profileName = profile; profileName = profile;
if (needsViaSelection) { if (needsViaSelection) {
@ -490,15 +489,15 @@ public class BRouterView extends View {
} }
if (needsWaypointSelection) { if (needsWaypointSelection) {
String msg; StringBuilder msg;
if (wpList.size() == 0) { if (wpList.size() == 0) {
msg = "Expecting waypoint selection\n" + sourceHint; msg = new StringBuilder("Expecting waypoint selection\n" + sourceHint);
} else { } else {
msg = "current waypoint selection:\n"; msg = new StringBuilder("current waypoint selection:\n");
for (int i = 0; i < wpList.size(); i++) for (int i = 0; i < wpList.size(); i++)
msg += (i > 0 ? "->" : "") + wpList.get(i).name; msg.append(i > 0 ? "->" : "").append(wpList.get(i).name);
} }
((BRouterActivity) getContext()).showResultMessage("Select Action", msg, wpList.size()); ((BRouterActivity) getContext()).showResultMessage("Select Action", msg.toString(), wpList.size());
return; return;
} }
@ -578,7 +577,7 @@ public class BRouterView extends View {
File vtag = new File(path, versionTag); File vtag = new File(path, versionTag);
try { try {
exists = !vtag.createNewFile(); exists = !vtag.createNewFile();
} catch (IOException io) { } catch (IOException ignored) {
} // well.. } // well..
} }
@ -599,7 +598,7 @@ public class BRouterView extends View {
} }
String name = ze.getName(); String name = ze.getName();
File outfile = new File(path, name); File outfile = new File(path, name);
if (!outfile.exists()) { if (!outfile.exists() && outfile.getParentFile() != null) {
outfile.getParentFile().mkdirs(); outfile.getParentFile().mkdirs();
FileOutputStream fos = new FileOutputStream(outfile); FileOutputStream fos = new FileOutputStream(outfile);
@ -647,7 +646,7 @@ public class BRouterView extends View {
int ir = (int) (n.radius * scaleMeter2Pixel); int ir = (int) (n.radius * scaleMeter2Pixel);
if (ir > minradius) { if (ir > minradius) {
Paint paint = new Paint(); Paint paint = new Paint();
paint.setColor(Color.RED); paint.setColor(color);
paint.setStyle(Paint.Style.STROKE); paint.setStyle(Paint.Style.STROKE);
canvas.drawCircle((float) x, (float) y, (float) ir, paint); canvas.drawCircle((float) x, (float) y, (float) ir, paint);
} }
@ -705,7 +704,7 @@ public class BRouterView extends View {
cr = null; cr = null;
try { try {
Thread.sleep(2000); Thread.sleep(2000);
} catch (InterruptedException ie) { } catch (InterruptedException ignored) {
} }
((BRouterActivity) getContext()).showErrorMessage(t.toString()); ((BRouterActivity) getContext()).showErrorMessage(t.toString());
waitingForSelection = true; waitingForSelection = true;
@ -715,7 +714,7 @@ public class BRouterView extends View {
private void showDatabaseScanning(Canvas canvas) { private void showDatabaseScanning(Canvas canvas) {
try { try {
Thread.sleep(100); Thread.sleep(100);
} catch (InterruptedException ie) { } catch (InterruptedException ignored) {
} }
Paint paint1 = new Paint(); Paint paint1 = new Paint();
paint1.setColor(Color.WHITE); paint1.setColor(Color.WHITE);
@ -768,7 +767,7 @@ public class BRouterView extends View {
try { try {
Thread.sleep(sleeptime); Thread.sleep(sleeptime);
} catch (InterruptedException ie) { } catch (InterruptedException ignored) {
} }
lastTs = System.currentTimeMillis(); lastTs = System.currentTimeMillis();
@ -776,9 +775,6 @@ public class BRouterView extends View {
if (cr != null) { if (cr != null) {
if (cr.getErrorMessage() != null) { if (cr.getErrorMessage() != null) {
((BRouterActivity) getContext()).showErrorMessage(cr.getErrorMessage()); ((BRouterActivity) getContext()).showErrorMessage(cr.getErrorMessage());
cr = null;
waitingForSelection = true;
return;
} else { } else {
String memstat = memoryClass + "mb pathPeak " + ((cr.getPathPeak() + 500) / 1000) + "k"; String memstat = memoryClass + "mb pathPeak " + ((cr.getPathPeak() + 500) / 1000) + "k";
String result = "version = BRouter-" + getContext().getString(R.string.app_version) + "\n" + "mem = " + memstat + "\ndistance = " + cr.getDistance() / 1000. + " km\n" + "filtered ascend = " + cr.getAscend() String result = "version = BRouter-" + getContext().getString(R.string.app_version) + "\n" + "mem = " + memstat + "\ndistance = " + cr.getDistance() / 1000. + " km\n" + "filtered ascend = " + cr.getAscend()
@ -796,10 +792,10 @@ public class BRouterView extends View {
title += " / " + cr.getAlternativeIndex() + ". Alternative"; title += " / " + cr.getAlternativeIndex() + ". Alternative";
((BRouterActivity) getContext()).showResultMessage(title, result, rawTrackPath == null ? -1 : -3); ((BRouterActivity) getContext()).showResultMessage(title, result, rawTrackPath == null ? -1 : -3);
cr = null;
waitingForSelection = true;
return;
} }
cr = null;
waitingForSelection = true;
return;
} else if (System.currentTimeMillis() > lastDataTime) { } else if (System.currentTimeMillis() > lastDataTime) {
System.exit(0); System.exit(0);
} }
@ -812,17 +808,18 @@ public class BRouterView extends View {
paintPosition(openSet[si], openSet[si + 1], 0xffffff, 1); paintPosition(openSet[si], openSet[si + 1], 0xffffff, 1);
} }
// paint nogos on top (red) // paint nogos on top (red)
int minradius = 4;
for (int ngi = 0; ngi < nogoList.size(); ngi++) { for (int ngi = 0; ngi < nogoList.size(); ngi++) {
OsmNodeNamed n = nogoList.get(ngi); OsmNodeNamed n = nogoList.get(ngi);
int color = 0xff0000; int color = 0xff0000;
paintPosition(n.ilon, n.ilat, color, 4); paintPosition(n.ilon, n.ilat, color, minradius);
} }
// paint start/end/vias on top (yellow/green/blue) // paint start/end/vias on top (yellow/green/blue)
for (int wpi = 0; wpi < wpList.size(); wpi++) { for (int wpi = 0; wpi < wpList.size(); wpi++) {
OsmNodeNamed n = wpList.get(wpi); OsmNodeNamed n = wpList.get(wpi);
int color = wpi == 0 ? 0xffff00 : wpi < wpList.size() - 1 ? 0xff : 0xff00; int color = wpi == 0 ? 0xffff00 : wpi < wpList.size() - 1 ? 0xff : 0xff00;
paintPosition(n.ilon, n.ilat, color, 4); paintPosition(n.ilon, n.ilat, color, minradius);
} }
canvas.drawBitmap(imgPixels, 0, imgw, (float) 0., (float) 0., imgw, imgh, false, null); canvas.drawBitmap(imgPixels, 0, imgw, (float) 0., (float) 0., imgw, imgh, false, null);
@ -831,10 +828,10 @@ public class BRouterView extends View {
for (int ngi = 0; ngi < nogoList.size(); ngi++) { for (int ngi = 0; ngi < nogoList.size(); ngi++) {
OsmNodeNamed n = nogoList.get(ngi); OsmNodeNamed n = nogoList.get(ngi);
if (n instanceof OsmNogoPolygon) { if (n instanceof OsmNogoPolygon) {
paintPolygon(canvas, (OsmNogoPolygon) n, 4); paintPolygon(canvas, (OsmNogoPolygon) n, minradius);
} else { } else {
int color = 0xff0000; int color = Color.RED;
paintCircle(canvas, n, color, 4); paintCircle(canvas, n, color, minradius);
} }
} }
@ -857,7 +854,7 @@ public class BRouterView extends View {
File basedir = Environment.getExternalStorageDirectory(); File basedir = Environment.getExternalStorageDirectory();
try { try {
File bd2 = new File(basedir, "external_sd"); File bd2 = new File(basedir, "external_sd");
ArrayList<String> basedirGuesses = new ArrayList<String>(); ArrayList<String> basedirGuesses = new ArrayList<>();
basedirGuesses.add(basedir.getAbsolutePath()); basedirGuesses.add(basedir.getAbsolutePath());
if (bd2.exists()) { if (bd2.exists()) {
@ -865,7 +862,7 @@ public class BRouterView extends View {
basedirGuesses.add(basedir.getAbsolutePath()); basedirGuesses.add(basedir.getAbsolutePath());
} }
ArrayList<CoordinateReader> rl = new ArrayList<CoordinateReader>(); ArrayList<CoordinateReader> rl = new ArrayList<>();
for (String bdg : basedirGuesses) { for (String bdg : basedirGuesses) {
rl.add(new CoordinateReaderOsmAnd(bdg)); rl.add(new CoordinateReaderOsmAnd(bdg));
rl.add(new CoordinateReaderLocus(bdg)); rl.add(new CoordinateReaderLocus(bdg));
@ -897,7 +894,7 @@ public class BRouterView extends View {
if (rawTrack != null) { if (rawTrack != null) {
try { try {
rawTrack.writeBinary(rawTrackPath); rawTrack.writeBinary(rawTrackPath);
} catch (Exception e) { } catch (Exception ignored) {
} }
} else { } else {
new File(rawTrackPath).delete(); new File(rawTrackPath).delete();
@ -916,7 +913,7 @@ public class BRouterView extends View {
public void configureService(String[] routingModes, boolean[] checkedModes) { public void configureService(String[] routingModes, boolean[] checkedModes) {
// read in current config // read in current config
TreeMap<String, ServiceModeConfig> map = new TreeMap<String, ServiceModeConfig>(); TreeMap<String, ServiceModeConfig> map = new TreeMap<>();
BufferedReader br = null; BufferedReader br = null;
String modesFile = modesDir + "/serviceconfig.dat"; String modesFile = modesDir + "/serviceconfig.dat";
try { try {
@ -928,12 +925,12 @@ public class BRouterView extends View {
ServiceModeConfig smc = new ServiceModeConfig(line); ServiceModeConfig smc = new ServiceModeConfig(line);
map.put(smc.mode, smc); map.put(smc.mode, smc);
} }
} catch (Exception e) { } catch (Exception ignored) {
} finally { } finally {
if (br != null) if (br != null)
try { try {
br.close(); br.close();
} catch (Exception ee) { } catch (Exception ignored) {
} }
} }
@ -961,12 +958,12 @@ public class BRouterView extends View {
bw.write('\n'); bw.write('\n');
msg.append(smc).append('\n'); msg.append(smc).append('\n');
} }
} catch (Exception e) { } catch (Exception ignored) {
} finally { } finally {
if (bw != null) if (bw != null)
try { try {
bw.close(); bw.close();
} catch (Exception ee) { } catch (Exception ignored) {
} }
} }
((BRouterActivity) getContext()).showModeConfigOverview(msg.toString()); ((BRouterActivity) getContext()).showModeConfigOverview(msg.toString());