Android Studio automatic cleanup

This commit is contained in:
Manuel Fuhr 2021-10-19 06:00:04 +02:00
parent 553f064ce0
commit 89ef74f95b
2 changed files with 65 additions and 89 deletions

View file

@ -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<Integer> dialogIds = new HashSet<Integer>();
/**
* Called when the activity is first created.
@ -132,8 +119,6 @@ public class BInstallerActivity extends Activity {
showDialog(DIALOG_CONFIRM_DELETE_ID);
}
private Set<Integer> dialogIds = new HashSet<Integer>();
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);

View file

@ -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++) {