@Override public void onClick(View v) { switch (v.getId()) { case R.id.btn_save_auto: String frequencyStr = mFrequencyEditText.getText().toString(); String symbolRateStr = mSymbolRateEditText.getText().toString(); mDefaultTransponder.setFrequency(Integer.parseInt(frequencyStr) * 1000); mDefaultTransponder.setSymbolRate(Integer.parseInt(symbolRateStr)); // 点击保存后设置频点信息到bundle 返回搜索时带着频点数据 Intent resultIntent = new Intent(); Bundle mBundle = new Bundle(); mBundle.putInt(MODULATION, mDefaultTransponder.getModulation()); mBundle.putInt(FREQUENCY, Integer.parseInt(frequencyStr) * 1000); mBundle.putInt(SYMBOLRATE, Integer.parseInt(symbolRateStr)); resultIntent.putExtras(mBundle); setResult(AUTOSEARCH_RESPONSECODE, resultIntent); // 保存tp信息到sp if (SearchMainActivity.FULLSEARCH.equals(stringExtra)) { log.D("save mainTP"); TransponderUtil.saveDefaultTransponer( this, DefaultParameter.DefaultTransponderType.DEFAULT_TRANSPONDER_TYPE_MAINTP, mDefaultTransponder); } else { log.D("save autoTp"); TransponderUtil.saveDefaultTransponer( this, DefaultParameter.DefaultTransponderType.DEFAULT_TRANSPONDER_TYPE_AUTO, mDefaultTransponder); } finish(); break; case R.id.btn_cancle_auto: finish(); break; } }
private void setupViews() { mSaveButton.setOnClickListener(this); mCancleButton.setOnClickListener(this); stringExtra = getIntent().getStringExtra(SEARCHTYPE); if (SearchMainActivity.FULLSEARCH.equals(stringExtra)) { mDefaultTransponder = TransponderUtil.getDefaultTransponder( this, DefaultParameter.DefaultTransponderType.DEFAULT_TRANSPONDER_TYPE_MAINTP); mAutoSearchTitle.setText(R.string.full_search_advanced_title); } else { mDefaultTransponder = TransponderUtil.getDefaultTransponder( this, DefaultParameter.DefaultTransponderType.DEFAULT_TRANSPONDER_TYPE_AUTO); } mFrequencyEditText.setText("" + mDefaultTransponder.getFrequency() / 1000); mSymbolRateEditText.setText("" + mDefaultTransponder.getSymbolRate()); switch (mDefaultTransponder.getModulation()) { case DefaultParameter.ModulationType.MODULATION_64QAM: mSpinner.setSelection(0); break; case DefaultParameter.ModulationType.MODULATION_128QAM: mSpinner.setSelection(1); break; case DefaultParameter.ModulationType.MODULATION_256QAM: mSpinner.setSelection(2); break; default: break; } mFrequencyEditText.setRange( DefaultParameter.SearchParameterRange.FREQUENCY_MIN, DefaultParameter.SearchParameterRange.FREQUENCY_MAX); mSymbolRateEditText.setRange( DefaultParameter.SearchParameterRange.SYMBOLRATE_MIN, DefaultParameter.SearchParameterRange.SYMBOLRATE_MAX); mFrequencyEditText.setOnInputDataErrorListener( new OnInputDataErrorListener() { public void onInputDataError(int errorType) { switch (errorType) { case MyEditText.INPUT_DATA_ERROR_TYPE_NULL: // 弹出对话框提示输入错误。 // // SearchAdvancedSettingActivity.this.showDialog(DialogId.DIALOG_ALERT_FREQUENCY_NULL); AdapterViewSelectionUtil.showToast( SearchAdvancedSettingActivity.this, R.string.frequency_null); mFrequencyEditText.setText("" + mDefaultTransponder.getFrequency() / 1000); break; case MyEditText.INPUT_DATA_ERROR_TYPE_OUT: // // SearchAdvancedSettingActivity.this.showDialog(DialogId.DIALOG_ALERT_FREQUENCY); AdapterViewSelectionUtil.showToast( SearchAdvancedSettingActivity.this, R.string.frequency_out_of_range); mFrequencyEditText.setText("" + mDefaultTransponder.getFrequency() / 1000); break; case MyEditText.INPUT_DATA_ERROR_TYPE_NORMAL: break; } } }); mSymbolRateEditText.setText("" + mDefaultTransponder.getSymbolRate()); mSymbolRateEditText.setOnInputDataErrorListener( new OnInputDataErrorListener() { public void onInputDataError(int errorType) { switch (errorType) { case MyEditText.INPUT_DATA_ERROR_TYPE_NULL: AdapterViewSelectionUtil.showToast( SearchAdvancedSettingActivity.this, R.string.symbol_rate_null); mSymbolRateEditText.setText("" + mDefaultTransponder.getSymbolRate()); break; case MyEditText.INPUT_DATA_ERROR_TYPE_OUT: AdapterViewSelectionUtil.showToast( SearchAdvancedSettingActivity.this, R.string.symbol_rate_out_of_range); mSymbolRateEditText.setText("" + mDefaultTransponder.getSymbolRate()); break; case MyEditText.INPUT_DATA_ERROR_TYPE_NORMAL: break; } } }); }