Ejemplo n.º 1
0
  @SuppressWarnings("unchecked")
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mainActivity = getActivity().getClass().equals(MainActivity.class);

    userTeam = DBAdapter.getInstance(getActivity()).readUserTeam();

    if (userTeam == null) {
      if (!mainActivity) {
        getActivity().finish();
      }
      return;
    }

    if (savedInstanceState != null) {
      league = (List<LeagueTeam>) savedInstanceState.getSerializable(LEAGUE_STATE);
    }

    if (league == null) {
      reloadFragment(mainActivity);
    } else {
      populateView();
    }
  }
Ejemplo n.º 2
0
  @SuppressWarnings("unchecked")
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    formatter = new SimpleDateFormat("dd/MM/yyyy - HH:mm");

    mainApp = getActivity().getClass().equals(MainActivity.class);

    played = true;
    if (getView() != null && getView().getTag() != null) {
      played = getString(R.string.tag_matches_next).equals(getView().getTag());
    } else {
      if (getArguments().containsKey(TAG_MATCHES)) {
        String param = getArguments().getString(TAG_MATCHES);
        played = getString(R.string.tag_matches_next).equals(param);
      }
    }

    userTeam = DBAdapter.getInstance(getActivity()).readUserTeam();

    if (userTeam == null) {
      if (mainApp) {
        return;
      } else {
        getActivity().finish();
      }
    }

    if (savedInstanceState != null) {
      matches = (List<Match>) savedInstanceState.getSerializable(MATCH_STATE);
    }

    if (mainApp) {
      int title;
      if (played) {
        title = R.string.played_match;
      } else {
        title = R.string.next_match;
      }
      ((TextView) getView().findViewById(R.id.matches_title)).setText(title);
    } else {
      getView().findViewById(R.id.matches_title).setVisibility(View.GONE);
    }

    setListAdapter(new MatchesAdapter());
    ListView listView = getListView();
    listView.setVerticalScrollBarEnabled(false);

    if (matches == null) {
      reloadFragment(false);
    }
  }
Ejemplo n.º 3
0
 @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();
   }
 }
Ejemplo n.º 4
0
  @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");
      }
    }
  }