Exemplo n.º 1
0
  @Override
  protected void onResume() {
    super.onResume();

    intent.putExtra("size_from", fltParams.GetSizeFrom());
    intent.putExtra("size_to", fltParams.GetSizeTo());
    intent.putExtra("time_from", fltParams.GetTimeFrom());
    intent.putExtra("time_to", fltParams.GetTimeTo());
    intent.putStringArrayListExtra("names", fltParams.GetNames());
    intent.putExtra("use_filter", fltParams.IsUseFilter());

    setResult(RESULT_CANCELED, intent);
  }
Exemplo n.º 2
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == RESULT_CANCELED) {
      if (requestCode == TIME_FROM) {
        long time = data.getLongExtra("time", -1);
        fltParams.SetTime(time, fltParams.GetTimeTo());
        intent.putExtra("time_from", fltParams.GetTimeFrom());
        if (time != -1) {
          timeFromText.setText(TimeToStr(time));
        } else timeFromText.setText("");
      } else if (requestCode == TIME_TO) {
        long time = data.getLongExtra("time", -1);
        fltParams.SetTime(fltParams.GetTimeFrom(), time);
        intent.putExtra("time_to", fltParams.GetTimeTo());
        if (time != -1) {
          timeToText.setText(TimeToStr(time));
        } else timeToText.setText("");
      }
    }
  }
Exemplo n.º 3
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.settings_filter);

    Intent i = getIntent();
    fltParams.SetSize(i.getLongExtra("size_from", -1), i.getLongExtra("size_to", -1));
    fltParams.SetTime(i.getLongExtra("time_from", -1), i.getLongExtra("time_to", -1));
    fltParams.AddNames(i.getStringArrayListExtra("names"));
    fltParams.SetUseFilter(i.getBooleanExtra("use_filter", false));

    ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, spinnerSizes);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    spinnerFrom = (Spinner) findViewById(R.id.spinner_from_kb);
    spinnerFrom.setAdapter(adapter);
    spinnerFrom.setSelection(1);

    spinnerTo = (Spinner) findViewById(R.id.spinner_to_kb);
    spinnerTo.setAdapter(adapter);
    spinnerTo.setSelection(1);

    sizeFromText = (TextView) findViewById(R.id.edit_size_from);
    if (fltParams.GetSizeFrom() != -1) {
      long measure[] = GetMeasure(fltParams.GetSizeFrom());
      sizeFromText.setText(String.valueOf(measure[0]));
      spinnerFrom.setSelection((int) measure[1]);
    }

    sizeToText = (TextView) findViewById(R.id.edit_size_to);
    if (fltParams.GetSizeTo() != -1) {
      long measure[] = GetMeasure(fltParams.GetSizeTo());
      sizeToText.setText(String.valueOf(measure[0]));
      spinnerTo.setSelection((int) measure[1]);
    }

    timeFromText = (TextView) findViewById(R.id.edit_date_from);
    if (fltParams.GetTimeFrom() != -1) {
      timeFromText.setText(TimeToStr(fltParams.GetTimeFrom()));
    }

    timeToText = (TextView) findViewById(R.id.edit_date_to);
    if (fltParams.GetTimeTo() != -1) {
      timeToText.setText(TimeToStr(fltParams.GetTimeTo()));
    }

    timeFromText.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Context context = v.getContext();
            Intent intent = new Intent(context, DateTime.class);
            intent.putExtra("time", fltParams.GetTimeFrom());
            ((Activity) context).startActivityForResult(intent, TIME_FROM);
          }
        });

    timeToText.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Context context = v.getContext();
            Intent intent = new Intent(context, DateTime.class);
            intent.putExtra("time", fltParams.GetTimeFrom());
            ((Activity) context).startActivityForResult(intent, TIME_TO);
          }
        });

    editFilter = (TextView) findViewById(R.id.edit_filter);

    if (fltParams.GetNames().size() > 0) {
      String filter = "";
      for (String name : fltParams.GetNames()) {
        filter += name + ";";
      }
      editFilter.setText(filter);
    }

    useFilter = (CheckBox) findViewById(R.id.check_use_filter);
    useFilter.setChecked(fltParams.IsUseFilter());
  }