Пример #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    context = this;
    setContentView(R.layout.activity_main);
    mHandler.sendEmptyMessageDelayed(0, 1000);
    mColorLayout = (ColorLayout) findViewById(R.id.id_color_panel);

    mShareButton = (Button) findViewById(R.id.id_share_btn);

    mContainer = (LinearLayout) findViewById(R.id.id_ad);
    mPauseBtn = (Button) findViewById(R.id.id_pause_btn);
    mGoOnBtn = (Button) findViewById(R.id.id_goon_btn);
    mScoresTv = (TextView) findViewById(R.id.id_scores_tv);
    mTimeTv = (TextView) findViewById(R.id.id_time_tv);

    mResultPanel = (LinearLayout) findViewById(R.id.id_reslut_panel);
    mResultScoresTv = (TextView) findViewById(R.id.id_result_scores_tv);
    mResultInfoTv = (TextView) findViewById(R.id.id_result_info_tv);

    mColorLayout.setOnClickRightColorListener(
        new ColorLayout.OnClickRightColorListener() {
          @Override
          public void clickRightColor(int score) {
            scores = score;
            mScoresTv.setText(getString(R.string.scores, scores));
          }
        });

    mPauseBtn.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View view) {
            pauseGame();
          }
        });
    mGoOnBtn.setOnClickListener(goonListener);
    mHandler.post(
        new Runnable() {
          @Override
          public void run() {
            RelativeLayout.LayoutParams params =
                new RelativeLayout.LayoutParams(
                    getResources().getDisplayMetrics().widthPixels,
                    getResources().getDisplayMetrics().widthPixels);
            params.addRule(RelativeLayout.CENTER_IN_PARENT);
            mContainer.setLayoutParams(params);
            mContainer.setVisibility(View.INVISIBLE);
          }
        });

    mShareButton.setText(R.string.restart);
    mShareButton.setOnClickListener(restartListener);
  }