コード例 #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);
  }
コード例 #2
0
  @Override
  public void onBackPressed() {
    long sizeFrom = -1, sizeTo = -1;

    if (sizeFromText.getText().length() > 0) {
      long units = Long.parseLong(sizeFromText.getText().toString());
      long measure = spinnerFrom.getSelectedItemPosition();
      sizeFrom = GetSize(units, measure);
    }

    if (sizeToText.getText().length() > 0) {
      long units = Long.parseLong(sizeToText.getText().toString());
      long measure = spinnerTo.getSelectedItemPosition();
      sizeTo = GetSize(units, measure);
    }

    fltParams.SetSize(sizeFrom, sizeTo);

    String filter = editFilter.getText().toString();
    String names[] = filter.split(";");

    if (names.length > 0) {
      ArrayList<String> list = new ArrayList<String>();
      for (int i = 0; i < names.length; i++) {
        list.add(names[i]);
      }
      fltParams.AddNames(list);
    }

    fltParams.SetUseFilter(useFilter.isChecked());

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

    finish();
  }
コード例 #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());
  }