From 89ef74f95b6c67549309588f1a721b4d52c0e33d Mon Sep 17 00:00:00 2001 From: Manuel Fuhr Date: Tue, 19 Oct 2021 06:00:04 +0200 Subject: [PATCH] Android Studio automatic cleanup --- .../btools/routingapp/BInstallerActivity.java | 29 ++-- .../btools/routingapp/BInstallerView.java | 125 ++++++++---------- 2 files changed, 65 insertions(+), 89 deletions(-) diff --git a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java index 9b58547..e42b3d0 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerActivity.java @@ -28,20 +28,7 @@ public class BInstallerActivity extends Activity { private PowerManager mPowerManager; private WakeLock mWakeLock; private DownloadReceiver myReceiver; - - - public class DownloadReceiver extends BroadcastReceiver { - - @Override - public void onReceive(Context context, Intent intent) { - if (intent.hasExtra("txt")) { - String txt = intent.getStringExtra("txt"); - boolean ready = intent.getBooleanExtra("ready", false); - mBInstallerView.setState(txt, ready); - } - } - } - + private final Set dialogIds = new HashSet(); /** * Called when the activity is first created. @@ -132,8 +119,6 @@ public class BInstallerActivity extends Activity { showDialog(DIALOG_CONFIRM_DELETE_ID); } - private Set dialogIds = new HashSet(); - private void showNewDialog(int id) { if (dialogIds.contains(Integer.valueOf(id))) { removeDialog(id); @@ -142,6 +127,18 @@ public class BInstallerActivity extends Activity { showDialog(id); } + public class DownloadReceiver extends BroadcastReceiver { + + @Override + public void onReceive(Context context, Intent intent) { + if (intent.hasExtra("txt")) { + String txt = intent.getStringExtra("txt"); + boolean ready = intent.getBooleanExtra("ready", false); + mBInstallerView.setState(txt, ready); + } + } + } + static public long getAvailableSpace(String baseDir) { StatFs stat = new StatFs(baseDir); diff --git a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerView.java b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerView.java index 2752b8e..0ba2448 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BInstallerView.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BInstallerView.java @@ -28,50 +28,63 @@ public class BInstallerView extends View { private static final int MASK_DELETED_RD5 = 2; private static final int MASK_INSTALLED_RD5 = 4; private static final int MASK_CURRENT_RD5 = 8; - - private int imgwOrig; - private int imghOrig; - private float scaleOrig; - - private int imgw; - private int imgh; - - private float lastDownX; - private float lastDownY; - - private Bitmap bmp; - - private float viewscale; - - private float[] testVector = new float[2]; - - private int[] tileStatus; - - private boolean tilesVisible = false; - - private long availableSize; - private File baseDir; - private File segmentDir; - - private boolean isDownloading = false; public static boolean downloadCanceled = false; - - private long currentDownloadSize; - private String currentDownloadFile = ""; - private volatile String currentDownloadOperation = ""; - private String downloadAction = ""; - private volatile String newDownloadAction = ""; - - private long totalSize = 0; - private long rd5Tiles = 0; - private long delTiles = 0; - Paint pnt_1 = new Paint(); Paint pnt_2 = new Paint(); Paint paint = new Paint(); - Activity mActivity; + int btnh = 40; + int btnw = 160; + float tx, ty; + private final int imgwOrig; + private final int imghOrig; + private final float scaleOrig; + private final int imgw; + private final int imgh; + private float lastDownX; + private float lastDownY; + private Bitmap bmp; + private float viewscale; + private final float[] testVector = new float[2]; + private int[] tileStatus; + private boolean tilesVisible = false; + private long availableSize; + private File baseDir; + private File segmentDir; + private boolean isDownloading = false; + private long currentDownloadSize; + private final String currentDownloadFile = ""; + private volatile String currentDownloadOperation = ""; + private String downloadAction = ""; + private final String newDownloadAction = ""; + private long totalSize = 0; + private long rd5Tiles = 0; + private long delTiles = 0; + private Matrix mat; + private final Matrix matText; + public BInstallerView(Context context) { + super(context); + mActivity = (Activity) context; + + DisplayMetrics metrics = new DisplayMetrics(); + ((Activity) getContext()).getWindowManager().getDefaultDisplay().getMetrics(metrics); + imgwOrig = metrics.widthPixels; + imghOrig = metrics.heightPixels; + int im = imgwOrig > imghOrig ? imgwOrig : imghOrig; + + scaleOrig = im / 480.f; + + matText = new Matrix(); + matText.preScale(scaleOrig, scaleOrig); + + imgw = (int) (imgwOrig / scaleOrig); + imgh = (int) (imghOrig / scaleOrig); + + totalSize = 0; + rd5Tiles = 0; + delTiles = 0; + } protected String baseNameForTile(int tileIndex) { int lon = (tileIndex % 72) * 5 - 180; @@ -100,7 +113,6 @@ public class BInstallerView extends View { return (ilon + 180) / 5 + 72 * ((ilat + 90) / 5); } - public boolean isDownloadCanceled() { return downloadCanceled; } @@ -167,7 +179,6 @@ public class BInstallerView extends View { deleteRawTracks(); // invalidate raw-tracks after data update } - public void downloadDone(boolean success) { isDownloading = false; if (success) { @@ -234,7 +245,7 @@ public class BInstallerView extends View { availableSize = -1; try { - availableSize = (long) ((BInstallerActivity) getContext()).getAvailableSpace(baseDir.getAbsolutePath()); + availableSize = ((BInstallerActivity) getContext()).getAvailableSpace(baseDir.getAbsolutePath()); //StatFs stat = new StatFs(baseDir.getAbsolutePath ()); //availableSize = (long)stat.getAvailableBlocksLong()*stat.getBlockSizeLong(); } catch (Exception e) { /* ignore */ } @@ -256,9 +267,6 @@ public class BInstallerView extends View { } } - private Matrix mat; - private Matrix matText; - public void startInstaller() { baseDir = ConfigHelper.getBaseDir(getContext()); @@ -285,29 +293,6 @@ public class BInstallerView extends View { tilesVisible = false; } - public BInstallerView(Context context) { - super(context); - mActivity = (Activity) context; - - DisplayMetrics metrics = new DisplayMetrics(); - ((Activity) getContext()).getWindowManager().getDefaultDisplay().getMetrics(metrics); - imgwOrig = metrics.widthPixels; - imghOrig = metrics.heightPixels; - int im = imgwOrig > imghOrig ? imgwOrig : imghOrig; - - scaleOrig = im / 480.f; - - matText = new Matrix(); - matText.preScale(scaleOrig, scaleOrig); - - imgw = (int) (imgwOrig / scaleOrig); - imgh = (int) (imghOrig / scaleOrig); - - totalSize = 0; - rd5Tiles = 0; - delTiles = 0; - } - @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); @@ -411,12 +396,6 @@ public class BInstallerView extends View { } } - int btnh = 40; - int btnw = 160; - - - float tx, ty; - private void drawSelectedTiles(Canvas canvas, Paint pnt, float fw, float fh, int status, int mask, boolean doCount, boolean cntDel, boolean doDraw) { for (int ix = 0; ix < 72; ix++) for (int iy = 0; iy < 36; iy++) {