title: Android TicTacToe - random game endings
body: <p>So today I was making TicTacToe for learning purposes, everything seemed good until i tried playing it myself - at some cases game ends before it should. Let's say this is my tictactoe grid: </p>
  
  <pre><code>1|2|3
  4|5|6
  7|8|9
  </code></pre>
  
  <p>So for example when i place X at 2 and O game suddenly endes concluding that player 2 (O user) won.</p>
  
  <p>Here's my function for finding out if somebody won. I'm probably silly for doing calculations like this, but i don't really know any other methods of finding when somebody won and deciding who is the winner. Just simple 8 if statements on all possible outcomes which includes winner.</p>
  
  <p>(plr1, plr2 - String with values of "X" and "O", text1,2,3 are textviews for X and O and they are arranged same as in grid above)</p>
  
  <pre><code>if(text1.getText().toString() == text2.getText().toString() &amp;&amp; text2.getText().toString() == text3.getText().toString()) {
          if(text1.getText().toString() == plr1) {
              status.setText("Player 1 won!");
              gameRunning = false;
          }
          else if(text1.getText().toString() == plr2){
              status.setText("Player 2 won!");
              gameRunning = false;
          }
      }
      else if(text4.getText().toString() == text5.getText().toString() &amp;&amp; text5.getText().toString() == text6.getText().toString()) {
          if(text4.getText().toString() == plr1) {
              status.setText("Player 1 won!");
              gameRunning = false;
          }
          else if(text1.getText().toString() == plr2){
              status.setText("Player 2 won!");
              gameRunning = false;
          }
      }
      else if(text7.getText().toString() == text8.getText().toString() &amp;&amp; text8.getText().toString() == text9.getText().toString()) {
          if(text1.getText().toString() == plr1) {
              status.setText("Player 1 won!");
              gameRunning = false;
          }
          else if(text1.getText().toString() == plr2){
              status.setText("Player 2 won!");
              gameRunning = false;
          }
      }
      else if(text1.getText().toString() == text4.getText().toString() &amp;&amp; text4.getText().toString() == text7.getText().toString()) {
          if(text1.getText().toString() == plr1) {
              status.setText("Player 1 won!");
              gameRunning = false;
          }
          else if(text1.getText().toString() == plr2){
              status.setText("Player 2 won!");
              gameRunning = false;
          }
      }
      else if(text2.getText().toString() == text5.getText().toString() &amp;&amp; text5.getText().toString() == text8.getText().toString()) {
          if(text1.getText().toString() == plr1) {
              status.setText("Player 1 won!");
              gameRunning = false;
          }
          else if(text1.getText().toString() == plr2){
              status.setText("Player 2 won!");
              gameRunning = false;
          }
      }
      else if(text3.getText().toString() == text6.getText().toString() &amp;&amp; text6.getText().toString() == text9.getText().toString()) {
          if(text1.getText().toString() == plr1) {
              status.setText("Player 1 won!");
              gameRunning = false;
          }
          else if(text1.getText().toString() == plr2){
              status.setText("Player 2 won!");
              gameRunning = false;
          }
      }
      else if(text1.getText().toString() == text5.getText().toString() &amp;&amp; text5.getText().toString() == text9.getText().toString()) {
          if(text7.getText().toString() == plr1) {
              status.setText("Player 1 won!");
              gameRunning = false;
          }
          else if(text7.getText().toString() == plr2){
              status.setText("Player 2 won!");
              gameRunning = false;
          }
      }
      else if(text3.getText().toString() == text5.getText().toString() &amp;&amp; text5.getText().toString() == text7.getText().toString()) {
          if(text1.getText().toString() == plr1) {
              status.setText("Player 1 won!");
              gameRunning = false;
          }
          else if(text1.getText().toString() == plr2){
              status.setText("Player 2 won!");
              gameRunning = false;
          }
      }
  </code></pre>
  
  <p>Problem logically should be at if statements, but for me they seem okay, maybe I'm missing something, because currently is midnight here.</p>