Пример #1
0
        @Override
        public boolean handleResponse(ServiceResponse response) {
          if (response.getHttpCode() == 200) {
            Game game = new Gson().fromJson(response.getJsonResponse(), Game.class);
            if (game != null && game.getTeam().size() != 0) {

              setContentView(R.layout.activity_choose_team);

              ImageButton red = (ImageButton) findViewById(R.id.ibCtmRed);
              red.setOnClickListener(onRed);

              ImageButton blue = (ImageButton) findViewById(R.id.ibCtmBlue);
              blue.setOnClickListener(onBlue);

              SessionManager.getInstance(getApplicationContext()).createSession(game, "game");
              redTeam = game.getTeam().get(0);
              blueTeam = game.getTeam().get(1);

              redView = (TextView) findViewById(R.id.textViewTeamREd);
              blueView = (TextView) findViewById(R.id.textViewTeamBlue);

              redView.setText(redTeam.getName());
              blueView.setText(blueTeam.getName());

              red.setEnabled(true);
              blue.setEnabled(true);

              return true;
            } else {
              Toast.makeText(
                      getApplicationContext(),
                      "There is no team found for code " + code,
                      Toast.LENGTH_LONG)
                  .show();
              finish();
            }
          } else {
            Toast.makeText(
                    getApplicationContext(), "Failed to fetch teams for match!", Toast.LENGTH_LONG)
                .show();
            finish();
          }
          return false;
        }
Пример #2
0
 @Override
 public boolean handleResponse(ServiceResponse response) {
   if (response.getHttpCode() == 200) {
     Intent intent = new Intent(getApplicationContext(), MatchInfoActivity.class);
     intent.putExtra("code", code);
     startActivity(intent);
     finish();
     return true;
   } else {
     Toast.makeText(getApplicationContext(), "Please try again!", Toast.LENGTH_LONG).show();
     return false;
   }
 }