mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2024-11-27 06:10:28 +01:00
Fix potential crash when sharing an image of the board
DroidFish.shareImage() can theoretically be called before the chess board widget measurement has been finished, which would crash the app.
This commit is contained in:
parent
4411b7f8b6
commit
0dd276ba22
|
@ -2391,8 +2391,11 @@ public class DroidFish extends Activity
|
|||
|
||||
private void shareImage() {
|
||||
View v = findViewById(R.id.chessboard);
|
||||
Bitmap b = Bitmap.createBitmap(v.getWidth(), v.getHeight(),
|
||||
Bitmap.Config.ARGB_8888);
|
||||
int w = v.getWidth();
|
||||
int h = v.getHeight();
|
||||
if (w <= 0 || h <= 0)
|
||||
return;
|
||||
Bitmap b = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
|
||||
Canvas c = new Canvas(b);
|
||||
v.draw(c);
|
||||
File imgDir = new File(getFilesDir(), "shared");
|
||||
|
|
Loading…
Reference in New Issue
Block a user