Esempio n. 1
0
  protected void buildMultiPic(final GridLayout gridLayout) {
    gridLayout.setVisibility(View.VISIBLE);
    // 获取当前屏幕尺寸
    DisplayMetrics metrics = new DisplayMetrics();
    WindowManager windowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    windowManager.getDefaultDisplay().getMetrics(metrics);
    // 设置图片的宽度和高度
    int picWidth = metrics.widthPixels / 3 - 48;

    for (int i = 0; i < 9; i++) {
      // 获取View
      SimpleDraweeView simpleDraweeView = (SimpleDraweeView) gridLayout.getChildAt(i);
      // 设置布局参数
      GridLayout.LayoutParams layoutParams = new GridLayout.LayoutParams();
      layoutParams.width = picWidth;
      layoutParams.height = picWidth;
      layoutParams.setMargins(8, 8, 8, 8);
      simpleDraweeView.setLayoutParams(layoutParams);
      // 设置图片数据源
      simpleDraweeView.setImageURI(Uri.parse(Image.imageThumbUrls[i]));
      // 准备传递数据
      final ImageViewPageMessage imageViewPageMessage =
          new ImageViewPageMessage(Image.imageThumbUrls, i);
      simpleDraweeView.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              EventBus.getDefault().postSticky(imageViewPageMessage);
              Intent intent = new Intent(mContext, ImageViewPagerActivity.class);
              mContext.startActivity(intent);
            }
          });
    }
  }
Esempio n. 2
0
  public void playAgain(View view) {
    winningLayout.setTranslationX(-1000f);
    player = 0;
    for (int i = 0; i < 9; i++) {
      spots[i] = 2;
    }
    gameIsActive = true;
    GridLayout gridLayout = (GridLayout) findViewById(R.id.grid);
    for (int i = 0; i < gridLayout.getChildCount(); i++) {

      ((ImageView) gridLayout.getChildAt(i)).setImageResource(0);
    }
  }
Esempio n. 3
0
  public CellButton[] getallcells() {
    int l = 0;
    liCellBut = new CellButton[board.getChildCount()];
    for (int i = 0; i <= board.getChildCount(); i++) {
      View tmpView = (View) board.getChildAt(i);
      // Toast.makeText(getActivity(),tmpView.getClass().getName(),Toast.LENGTH_SHORT).show();
      if (tmpView instanceof CellButton) {

        // Toast.makeText(getActivity(),"CellButt",Toast.LENGTH_SHORT).show();
        liCellBut[l] = (CellButton) tmpView;
        l++;
      }
    }

    return liCellBut;
  }
Esempio n. 4
0
  public void PlayAgain(View view) {

    LinearLayout layout = (LinearLayout) findViewById(R.id.winnerlayout);

    layout.setVisibility(view.INVISIBLE);
    // this.gameState = {2,2,2,2,2,2,2,2,2};

    // 0 = Yellow and 1 = Red;
    activePlayer = 0;
    // 2 means unplayed.

    for (int i = 0; i < gameState.length; i++) {
      gameState[i] = 2;
    }

    // reset the state of the images
    GridLayout gridLayout = (GridLayout) findViewById(R.id.gridLayout);

    for (int i = 0; i < gridLayout.getChildCount(); i++) {

      ((ImageView) gridLayout.getChildAt(i)).setImageResource(0);
    }
  }