Merge startInstaller into constructor
This commit is contained in:
parent
dd7a2fcd98
commit
64a80e763b
2 changed files with 29 additions and 39 deletions
|
@ -36,9 +36,6 @@ public class BInstallerActivity extends Activity {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the activity is first created.
|
||||
*/
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -52,7 +49,6 @@ public class BInstallerActivity extends Activity {
|
|||
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
|
||||
// instantiate our simulation view and set it as the activity's content
|
||||
mBInstallerView = new BInstallerView(this);
|
||||
setContentView(mBInstallerView);
|
||||
}
|
||||
|
@ -72,9 +68,6 @@ public class BInstallerActivity extends Activity {
|
|||
|
||||
myReceiver = new DownloadReceiver();
|
||||
registerReceiver(myReceiver, filter);
|
||||
|
||||
// Start the download manager
|
||||
mBInstallerView.startInstaller();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -35,6 +35,12 @@ public class BInstallerView extends View {
|
|||
private final int imgh;
|
||||
private final float[] testVector = new float[2];
|
||||
private final Matrix matText;
|
||||
private final File baseDir;
|
||||
private final File segmentDir;
|
||||
private final Matrix mat;
|
||||
private final Bitmap bmp;
|
||||
private final float viewscale;
|
||||
private final int[] tileStatus;
|
||||
Paint pnt_1 = new Paint();
|
||||
Paint pnt_2 = new Paint();
|
||||
Paint paint = new Paint();
|
||||
|
@ -44,20 +50,14 @@ public class BInstallerView extends View {
|
|||
float tx, ty;
|
||||
private float lastDownX;
|
||||
private float lastDownY;
|
||||
private Bitmap bmp;
|
||||
private float viewscale;
|
||||
private int[] tileStatus;
|
||||
private boolean tilesVisible = false;
|
||||
private long availableSize;
|
||||
private File baseDir;
|
||||
private File segmentDir;
|
||||
private boolean isDownloading = false;
|
||||
private volatile String currentDownloadOperation = "";
|
||||
private String downloadAction = "";
|
||||
private long totalSize = 0;
|
||||
private long rd5Tiles = 0;
|
||||
private long delTiles = 0;
|
||||
private Matrix mat;
|
||||
|
||||
public BInstallerView(Context context) {
|
||||
super(context);
|
||||
|
@ -76,6 +76,29 @@ public class BInstallerView extends View {
|
|||
|
||||
imgw = (int) (imgwOrig / scaleOrig);
|
||||
imgh = (int) (imghOrig / scaleOrig);
|
||||
|
||||
baseDir = ConfigHelper.getBaseDir(getContext());
|
||||
segmentDir = new File(baseDir, "brouter/segments4");
|
||||
|
||||
try {
|
||||
AssetManager assetManager = getContext().getAssets();
|
||||
InputStream istr = assetManager.open("world.png");
|
||||
bmp = BitmapFactory.decodeStream(istr);
|
||||
istr.close();
|
||||
} catch (IOException io) {
|
||||
throw new RuntimeException("cannot read world.png from assets");
|
||||
}
|
||||
|
||||
tileStatus = new int[72 * 36];
|
||||
scanExistingFiles();
|
||||
|
||||
float scaleX = imgwOrig / ((float) bmp.getWidth());
|
||||
float scaley = imghOrig / ((float) bmp.getHeight());
|
||||
|
||||
viewscale = Math.min(scaleX, scaley);
|
||||
|
||||
mat = new Matrix();
|
||||
mat.postScale(viewscale, viewscale);
|
||||
}
|
||||
|
||||
protected String baseNameForTile(int tileIndex) {
|
||||
|
@ -240,32 +263,6 @@ public class BInstallerView extends View {
|
|||
}
|
||||
}
|
||||
|
||||
public void startInstaller() {
|
||||
|
||||
baseDir = ConfigHelper.getBaseDir(getContext());
|
||||
segmentDir = new File(baseDir, "brouter/segments4");
|
||||
try {
|
||||
AssetManager assetManager = getContext().getAssets();
|
||||
InputStream istr = assetManager.open("world.png");
|
||||
bmp = BitmapFactory.decodeStream(istr);
|
||||
istr.close();
|
||||
} catch (IOException io) {
|
||||
throw new RuntimeException("cannot read world.png from assets");
|
||||
}
|
||||
|
||||
tileStatus = new int[72 * 36];
|
||||
scanExistingFiles();
|
||||
|
||||
float scaleX = imgwOrig / ((float) bmp.getWidth());
|
||||
float scaley = imghOrig / ((float) bmp.getHeight());
|
||||
|
||||
viewscale = Math.min(scaleX, scaley);
|
||||
|
||||
mat = new Matrix();
|
||||
mat.postScale(viewscale, viewscale);
|
||||
tilesVisible = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
super.onSizeChanged(w, h, oldw, oldh);
|
||||
|
|
Loading…
Reference in a new issue