Skip to content

Commit f189b78

Browse files
committed
Only create the game board on layout once.
1 parent d238ec8 commit f189b78

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/com/tackmobile/GameboardView.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class GameboardView extends RelativeLayout implements OnTouchListener {
1717
protected Rect gameboardRect;
1818
protected HashSet<GameTile> tiles;
1919
protected GameTile emptyTile;
20+
private boolean boardCreated;
2021

2122
public GameboardView(Context context, AttributeSet attrSet) {
2223
super(context, attrSet);
@@ -26,8 +27,11 @@ public GameboardView(Context context, AttributeSet attrSet) {
2627
@Override
2728
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
2829
super.onLayout(changed, left, top, right, bottom);
29-
determineGameboardSizes();
30-
placeTiles();
30+
if (!boardCreated) {
31+
determineGameboardSizes();
32+
placeTiles();
33+
boardCreated = true;
34+
}
3135
}
3236

3337
protected void placeTiles() {

0 commit comments

Comments
 (0)