Пример #1
0
  @Override
  public void setUserVisibleHint(boolean isVisibleToUser) {

    // metodo che viene eseguito quando il fragment è a video \o/
    super.setUserVisibleHint(isVisibleToUser);
    if (isVisibleToUser) {

      View fab = getActivity().findViewById(R.id.add_info);
      if (fab.getVisibility() == View.VISIBLE) {

        fab.startAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.fadeout));
        fab.setVisibility(View.GONE);
      }

      int a, b, c;
      a = survey.getAmountOfSkipped();
      b = survey.getAmountOfIncomplete();
      c = survey.getSize() - a - b;
      tCom.setText(String.valueOf(c));
      tSki.setText(String.valueOf(a));
      tInc.setText(String.valueOf(b));
      if (survey.isCompleted()) {
        btnInvio.setVisibility(View.VISIBLE);
        btnInvio.setEnabled(true);
      } else {
        btnInvio.setEnabled(false);
      }

      btnInvio.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {

              Intent intent = new Intent(getActivity(), SurveyService.class);
              intent.putExtra("survey", survey);
              intent.putExtra("user", getArguments().getParcelable("user"));
              intent.putExtra("OP", "POST");
              btnInvio.setVisibility(View.GONE);
              wait.setVisibility(View.VISIBLE);
              getActivity().startService(intent);
            }
          });
    }
  }
Пример #2
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    Bundle args = getArguments();
    survey = args.getParcelable("survey");
    assert survey != null;
    boolean hasExtra = survey.hasExtra();

    int layout = hasExtra ? R.layout.survey_summary_withextra : R.layout.survey_summary;

    View rootView = inflater.inflate(layout, container, false);
    tCom = (TextView) rootView.findViewById(R.id.n_completate);
    tSki = (TextView) rootView.findViewById(R.id.n_omesse);
    tInc = (TextView) rootView.findViewById(R.id.n_incomplete);
    btnInvio = (Button) rootView.findViewById(R.id.btnInvio);
    wait = (ProgressBar) rootView.findViewById(R.id.waitForSave);

    if (hasExtra) {
      // todo: binding delle extra info, TBD
    }

    return rootView;
  }