protected void populateView() {

    TextView textView = (TextView) getView().findViewById(R.id.standings_title);
    textView.setText(getActivity().getString(R.string.league_title, userTeam.getSeriesName()));

    View teamView;
    int realPosition = 0;
    int leagueSize = league.size();
    List<LeagueTeam> standingsLeague;
    if (mainActivity) {
      standingsLeague = new ArrayList<LeagueTeam>();
      realPosition = shrinkLeague(standingsLeague);
      getView().findViewById(R.id.standings_titles).setVisibility(View.GONE);
    } else {
      standingsLeague = league;
      getView().findViewById(R.id.standings_titles).setVisibility(View.VISIBLE);
    }
    ViewGroup standings = (ViewGroup) getView().findViewById(R.id.standings_table);
    int position = 1;
    int max = standings.getChildCount();
    for (LeagueTeam team : standingsLeague) {
      if ((position) < max) {
        // En ese caso la tabla tiene elementos y el de esta posición
        // puede modificarse
        teamView = standings.getChildAt(position);
      } else {
        teamView = inflater.inflate(R.layout.standings_fragment_team, null);
        standings.addView(teamView);
      }
      teamView.setTag(team);
      textView = (TextView) teamView.findViewById(R.id.team_position);
      textView.setText(Integer.toString(realPosition + 1));
      int color = colorPosition(realPosition, leagueSize);
      if (color > 0) {
        textView.setBackgroundColor(getResources().getColor(color));
      }

      textView = (TextView) teamView.findViewById(R.id.team_name);
      textView.setText(team.getTeamName());
      if (team.getTeamId() == userTeam.getTeamId()) {
        textView.setTypeface(Typeface.DEFAULT_BOLD);
      } else {
        textView.setTypeface(Typeface.DEFAULT);
      }

      ((TextView) teamView.findViewById(R.id.team_points))
          .setText(Integer.toString(team.getPoints()));
      position++;
      realPosition++;
    }
    if ((position) < max) {
      // Aún quedan elementos que no deberían estar aquí
      for (int i = position; i < max; i++) {
        standings.removeViewAt(position);
      }
    }
  }
  @Override
  public void reloadFragment(boolean cacheOnly) {
    if (userTeam == null) {
      userTeam = DBAdapter.getInstance(getActivity()).readUserTeam();
    }
    if (userTeam != null) {

      TextView textView = (TextView) getView().findViewById(R.id.standings_title);
      textView.setText(getActivity().getString(R.string.league_title, userTeam.getSeriesName()));

      if (task == null || task.getStatus() == AsyncTask.Status.FINISHED || task.isCancelled()) {
        task = new ReadStandingsTask();
        int cache = cacheOnly ? 1 : 0;
        task.execute(userTeam.getSeriesId(), cache);
      } else {
        CustomLog.info("StandingsFragment", "There are another task running");
      }
    }
  }
 @Override
 public void reloadFragment(boolean cacheOnly) {
   if (userTeam == null) {
     userTeam = DBAdapter.getInstance(getActivity()).readUserTeam();
   }
   if (task == null || task.getStatus() == AsyncTask.Status.FINISHED || task.isCancelled()) {
     task = new ReadMatchesTask();
     int cache = cacheOnly ? 1 : 0;
     task.execute(userTeam.getTeamId(), cache);
   } else {
     Toast.makeText(getActivity(), "Recarga actualmente en ejecución", Toast.LENGTH_SHORT).show();
   }
 }
 private int shrinkLeague(List<LeagueTeam> standingsLeague) {
   int position = 0;
   int playerTeamPos = league.size();
   for (LeagueTeam team : league) {
     standingsLeague.add(team);
     if (team.getTeamId() == userTeam.getTeamId()) {
       playerTeamPos = position;
     } else if ((playerTeamPos + NUM_TEAMS_AFTER) == position) {
       break;
     }
     position++;
   }
   position = 0;
   if (playerTeamPos > NUM_TEAMS_BEFORE) {
     position = playerTeamPos - NUM_TEAMS_BEFORE;
     for (int i = 0; i < playerTeamPos - NUM_TEAMS_BEFORE; i++) {
       standingsLeague.remove(0);
     }
   }
   return position;
 }