Esempio n. 1
0
  // sets up database on first open
  // or initialize stone positions based on database data
  private void initializeStones() {
    if (dbHandler.isEmpty()) {
      Log.d("V", "filling up table");
      FrameLayout b0 = (FrameLayout) findViewById(R.id.b0);
      FrameLayout t1 = (FrameLayout) findViewById(R.id.t1);
      FrameLayout t2 = (FrameLayout) findViewById(R.id.t2);
      FrameLayout t3 = (FrameLayout) findViewById(R.id.t3);
      FrameLayout b4 = (FrameLayout) findViewById(R.id.b4);
      FrameLayout b5 = (FrameLayout) findViewById(R.id.b5);
      FrameLayout t6 = (FrameLayout) findViewById(R.id.t6);
      FrameLayout t7 = (FrameLayout) findViewById(R.id.t7);
      FrameLayout t8 = (FrameLayout) findViewById(R.id.t8);
      FrameLayout b9 = (FrameLayout) findViewById(R.id.b9);
      FrameLayout b10 = (FrameLayout) findViewById(R.id.b10);
      FrameLayout t11 = (FrameLayout) findViewById(R.id.t11);
      FrameLayout t12 = (FrameLayout) findViewById(R.id.t12);
      FrameLayout t13 = (FrameLayout) findViewById(R.id.t13);
      FrameLayout b14 = (FrameLayout) findViewById(R.id.b14);
      dbHandler.addStone("" + b0.getId());
      dbHandler.addStone("" + t1.getId());
      dbHandler.addStone("" + t2.getId());
      dbHandler.addStone("" + t3.getId());
      dbHandler.addStone("" + b4.getId());
      dbHandler.addStone("" + b5.getId());
      dbHandler.addStone("" + t6.getId());
      dbHandler.addStone("" + t7.getId());
      dbHandler.addStone("" + t8.getId());
      dbHandler.addStone("" + b9.getId());
      dbHandler.addStone("" + b10.getId());
      dbHandler.addStone("" + t11.getId());
      dbHandler.addStone("" + t12.getId());
      dbHandler.addStone("" + t13.getId());
      dbHandler.addStone("" + b14.getId());
    }

    for (int i = 1; i <= numofstones; i++) {
      String ispot = dbHandler.getSpot(i);
      int spotid = Integer.parseInt(ispot);
      FrameLayout spot = (FrameLayout) findViewById(spotid);
      ImageView currentStone = allStones[i - 1];
      FrameLayout parent = (FrameLayout) currentStone.getParent();
      parent.removeView(currentStone);
      spot.addView(currentStone);
      currentStone.setVisibility(View.VISIBLE);
    }
  }