fm/fmapp2/src/com/caf/fmradio/FMRadio.java
@Override
   public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setVolumeControlStream(AudioManager.STREAM_MUSIC);
      mPrefs = new FmSharedPreferences(this);
      mCommandActive = CMD_NONE;
      mCommandFailed = CMD_NONE;

      Log.d(LOGTAG, "onCreate - Height : "+ getWindowManager().getDefaultDisplay().getHeight()
            + " - Width  : "+ getWindowManager().getDefaultDisplay().getWidth());

      mDisplayWidth = getWindowManager().getDefaultDisplay().getWidth();
      DisplayMetrics outMetrics = new DisplayMetrics();
      getWindowManager().getDefaultDisplay().getMetrics(outMetrics );

      setContentView(R.layout.fmradio);
      SavedDataAndState = (LoadedDataAndState)getLastNonConfigurationInstance();

      mPicker = (HorizontalNumberPicker)findViewById(R.id.fm_picker);
      if (mPicker != null) {
          mPicker.setTextSize(mDisplayWidth / TEXTSIZE_PARAMETER_FOR_NUMBER_PICKER);
          mPicker.setDensity(outMetrics.densityDpi);
          mPicker.setOnValueChangedListener(new OnValueChangeListener(){
            @Override
            public void onValueChange(HorizontalNumberPicker picker,
                    int oldVal, int newVal) {
                // TODO Auto-generated method stub
                valueToFrequency(newVal);
                mHandler.post(mRadioChangeFrequency);
            }
        });
      }

      mAnimation = AnimationUtils.loadAnimation(this,
                                                R.anim.preset_select);

      mMuteButton = (ImageView)findViewById(R.id.btn_silent);
      if (mMuteButton != null) {
          mMuteButton.setOnClickListener(mMuteModeClickListener);
      }

      mSpeakerButton = (ImageView)findViewById(R.id.btn_speaker_earphone);
      if (mSpeakerButton != null) {
          mSpeakerButton.setOnClickListener(mSpeakerClickListener);
      }

      mOnOffButton = (ImageView)findViewById(R.id.btn_onoff);
      if (mOnOffButton != null) {
          mOnOffButton.setOnClickListener(mTurnOnOffClickListener);
      }

      mForwardButton = (ImageView)findViewById(R.id.btn_forward);
      if (mForwardButton != null) {
          mForwardButton.setOnClickListener(mForwardClickListener);
          mForwardButton.setOnLongClickListener(mForwardLongClickListener);
      }

      mBackButton = (ImageView)findViewById(R.id.btn_back);
      if (mBackButton != null) {
          mBackButton.setOnClickListener(mBackClickListener);
          mBackButton.setOnLongClickListener(mBackLongClickListener);
      }

      /* 6 Preset Buttons */
      mPresetButtons[0] = (Button)findViewById(R.id.presets_button_1);
      mPresetButtons[1] = (Button)findViewById(R.id.presets_button_2);
      mPresetButtons[2] = (Button)findViewById(R.id.presets_button_3);
      mPresetButtons[3] = (Button)findViewById(R.id.presets_button_4);
      mPresetButtons[4] = (Button)findViewById(R.id.presets_button_5);
      mPresetButtons[5] = (Button)findViewById(R.id.presets_button_6);
      mPresetButtons[6] = (Button)findViewById(R.id.presets_button_7);

      for (int nButton = 0; nButton < MAX_PRESETS_PER_PAGE; nButton++) {
         if (mPresetButtons[nButton] != null) {
             mPresetButtons[nButton]
               .setOnClickListener(mPresetButtonClickListener);
             mPresetButtons[nButton]
               .setOnLongClickListener(mPresetButtonOnLongClickListener);
         }
      }

      mTuneStationFrequencyTV = (TextView)findViewById(R.id.prog_frequency_tv);
      if (mTuneStationFrequencyTV != null) {
         mTuneStationFrequencyTV.setOnLongClickListener(mFrequencyViewClickListener);
      }
      mProgramServiceTV = (TextView)findViewById(R.id.prog_service_tv);
      mStereoTV = (TextView)findViewById(R.id.stereo_text_tv);

      mStationCallSignTV = (TextView)findViewById(R.id.call_sign_tv);
      mProgramTypeTV = (TextView)findViewById(R.id.pty_tv);

      mRadioTextTV = (TextView)findViewById(R.id.radio_text_tv);
      mERadioTextTV = (TextView)findViewById(R.id.eradio_text_tv);
      mSleepMsgTV = (TextView)findViewById(R.id.sleep_msg_tv);
      mRecordingMsgTV = (TextView)findViewById(R.id.record_msg_tv);
      if (mRecordingMsgTV != null) {
          mRecordingMsgTV.setOnClickListener(mRecordButtonListener);
      }
      /* Disable displaying RSSI */
      mRSSI = (ImageView)findViewById(R.id.signal_level);
      if (mRSSI != null) {
          mRSSI.setVisibility(View.INVISIBLE);
      }

      if ((mRadioTextScroller == null) && (mRadioTextTV != null)) {
          mRadioTextScroller = new ScrollerText(mRadioTextTV);
      }

      if ((mERadioTextScroller == null) && (mERadioTextTV != null)) {
          mERadioTextScroller = new ScrollerText(mERadioTextTV);
      }
   }
/** Called when the activity is first created. */
Called when the activity is first created.
Called when the activity is first created .
@Override
   public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setVolumeControlStream(AudioManager.STREAM_MUSIC);
      mPrefs = new FmSharedPreferences(this);
      mCommandActive = CMD_NONE;
      mCommandFailed = CMD_NONE;
      Log.d(LOGTAG, "onCreate - Height : "+ getWindowManager().getDefaultDisplay().getHeight()
            + " - Width  : "+ getWindowManager().getDefaultDisplay().getWidth());
      mDisplayWidth = getWindowManager().getDefaultDisplay().getWidth();
      DisplayMetrics outMetrics = new DisplayMetrics();
      getWindowManager().getDefaultDisplay().getMetrics(outMetrics );
      setContentView(R.layout.fmradio);
      SavedDataAndState = (LoadedDataAndState)getLastNonConfigurationInstance();
      mPicker = (HorizontalNumberPicker)findViewById(R.id.fm_picker);
      if (mPicker != null) {
          mPicker.setTextSize(mDisplayWidth / TEXTSIZE_PARAMETER_FOR_NUMBER_PICKER);
          mPicker.setDensity(outMetrics.densityDpi);
          mPicker.setOnValueChangedListener(new OnValueChangeListener(){
            @Override
            public void onValueChange(HorizontalNumberPicker picker,
                    int oldVal, int newVal) {
                valueToFrequency(newVal);
                mHandler.post(mRadioChangeFrequency);
            }
        });
      }
      mAnimation = AnimationUtils.loadAnimation(this,
                                                R.anim.preset_select);
      mMuteButton = (ImageView)findViewById(R.id.btn_silent);
      if (mMuteButton != null) {
          mMuteButton.setOnClickListener(mMuteModeClickListener);
      }
      mSpeakerButton = (ImageView)findViewById(R.id.btn_speaker_earphone);
      if (mSpeakerButton != null) {
          mSpeakerButton.setOnClickListener(mSpeakerClickListener);
      }
      mOnOffButton = (ImageView)findViewById(R.id.btn_onoff);
      if (mOnOffButton != null) {
          mOnOffButton.setOnClickListener(mTurnOnOffClickListener);
      }
      mForwardButton = (ImageView)findViewById(R.id.btn_forward);
      if (mForwardButton != null) {
          mForwardButton.setOnClickListener(mForwardClickListener);
          mForwardButton.setOnLongClickListener(mForwardLongClickListener);
      }
      mBackButton = (ImageView)findViewById(R.id.btn_back);
      if (mBackButton != null) {
          mBackButton.setOnClickListener(mBackClickListener);
          mBackButton.setOnLongClickListener(mBackLongClickListener);
      }
      /* 6 Preset Buttons */
      mPresetButtons[0] = (Button)findViewById(R.id.presets_button_1);
      mPresetButtons[1] = (Button)findViewById(R.id.presets_button_2);
      mPresetButtons[2] = (Button)findViewById(R.id.presets_button_3);
      mPresetButtons[3] = (Button)findViewById(R.id.presets_button_4);
      mPresetButtons[4] = (Button)findViewById(R.id.presets_button_5);
      mPresetButtons[5] = (Button)findViewById(R.id.presets_button_6);
      mPresetButtons[6] = (Button)findViewById(R.id.presets_button_7);
      for (int nButton = 0; nButton < MAX_PRESETS_PER_PAGE; nButton++) {
         if (mPresetButtons[nButton] != null) {
             mPresetButtons[nButton]
               .setOnClickListener(mPresetButtonClickListener);
             mPresetButtons[nButton]
               .setOnLongClickListener(mPresetButtonOnLongClickListener);
         }
      }
      mTuneStationFrequencyTV = (TextView)findViewById(R.id.prog_frequency_tv);
      if (mTuneStationFrequencyTV != null) {
         mTuneStationFrequencyTV.setOnLongClickListener(mFrequencyViewClickListener);
      }
      mProgramServiceTV = (TextView)findViewById(R.id.prog_service_tv);
      mStereoTV = (TextView)findViewById(R.id.stereo_text_tv);
      mStationCallSignTV = (TextView)findViewById(R.id.call_sign_tv);
      mProgramTypeTV = (TextView)findViewById(R.id.pty_tv);
      mRadioTextTV = (TextView)findViewById(R.id.radio_text_tv);
      mERadioTextTV = (TextView)findViewById(R.id.eradio_text_tv);
      mSleepMsgTV = (TextView)findViewById(R.id.sleep_msg_tv);
      mRecordingMsgTV = (TextView)findViewById(R.id.record_msg_tv);
      if (mRecordingMsgTV != null) {
          mRecordingMsgTV.setOnClickListener(mRecordButtonListener);
      }
      /* Disable displaying RSSI */
      mRSSI = (ImageView)findViewById(R.id.signal_level);
      if (mRSSI != null) {
          mRSSI.setVisibility(View.INVISIBLE);
      }
      if ((mRadioTextScroller == null) && (mRadioTextTV != null)) {
          mRadioTextScroller = new ScrollerText(mRadioTextTV);
      }
      if ((mERadioTextScroller == null) && (mERadioTextTV != null)) {
          mERadioTextScroller = new ScrollerText(mERadioTextTV);
      }
   }
@ Override public void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ) ; setVolumeControlStream ( AudioManager . STREAM_MUSIC ) ; mPrefs = new FmSharedPreferences ( this ) ; mCommandActive = CMD_NONE ; mCommandFailed = CMD_NONE ; Log . d ( LOGTAG , "onCreate - Height : " + getWindowManager ( ) . getDefaultDisplay ( ) . getHeight ( ) + " - Width  : " + getWindowManager ( ) . getDefaultDisplay ( ) . getWidth ( ) ) ; mDisplayWidth = getWindowManager ( ) . getDefaultDisplay ( ) . getWidth ( ) ; DisplayMetrics outMetrics = new DisplayMetrics ( ) ; getWindowManager ( ) . getDefaultDisplay ( ) . getMetrics ( outMetrics ) ; setContentView ( R . layout . fmradio ) ; SavedDataAndState = ( LoadedDataAndState ) getLastNonConfigurationInstance ( ) ; mPicker = ( HorizontalNumberPicker ) findViewById ( R . id . fm_picker ) ; if ( mPicker != null ) { mPicker . setTextSize ( mDisplayWidth / TEXTSIZE_PARAMETER_FOR_NUMBER_PICKER ) ; mPicker . setDensity ( outMetrics . densityDpi ) ; mPicker . setOnValueChangedListener ( new OnValueChangeListener ( ) { @ Override public void onValueChange ( HorizontalNumberPicker picker , int oldVal , int newVal ) { valueToFrequency ( newVal ) ; mHandler . post ( mRadioChangeFrequency ) ; } } ) ; } mAnimation = AnimationUtils . loadAnimation ( this , R . anim . preset_select ) ; mMuteButton = ( ImageView ) findViewById ( R . id . btn_silent ) ; if ( mMuteButton != null ) { mMuteButton . setOnClickListener ( mMuteModeClickListener ) ; } mSpeakerButton = ( ImageView ) findViewById ( R . id . btn_speaker_earphone ) ; if ( mSpeakerButton != null ) { mSpeakerButton . setOnClickListener ( mSpeakerClickListener ) ; } mOnOffButton = ( ImageView ) findViewById ( R . id . btn_onoff ) ; if ( mOnOffButton != null ) { mOnOffButton . setOnClickListener ( mTurnOnOffClickListener ) ; } mForwardButton = ( ImageView ) findViewById ( R . id . btn_forward ) ; if ( mForwardButton != null ) { mForwardButton . setOnClickListener ( mForwardClickListener ) ; mForwardButton . setOnLongClickListener ( mForwardLongClickListener ) ; } mBackButton = ( ImageView ) findViewById ( R . id . btn_back ) ; if ( mBackButton != null ) { mBackButton . setOnClickListener ( mBackClickListener ) ; mBackButton . setOnLongClickListener ( mBackLongClickListener ) ; } /* 6 Preset Buttons */ mPresetButtons [ 0 ] = ( Button ) findViewById ( R . id . presets_button_1 ) ; mPresetButtons [ 1 ] = ( Button ) findViewById ( R . id . presets_button_2 ) ; mPresetButtons [ 2 ] = ( Button ) findViewById ( R . id . presets_button_3 ) ; mPresetButtons [ 3 ] = ( Button ) findViewById ( R . id . presets_button_4 ) ; mPresetButtons [ 4 ] = ( Button ) findViewById ( R . id . presets_button_5 ) ; mPresetButtons [ 5 ] = ( Button ) findViewById ( R . id . presets_button_6 ) ; mPresetButtons [ 6 ] = ( Button ) findViewById ( R . id . presets_button_7 ) ; for ( int nButton = 0 ; nButton < MAX_PRESETS_PER_PAGE ; nButton ++ ) { if ( mPresetButtons [ nButton ] != null ) { mPresetButtons [ nButton ] . setOnClickListener ( mPresetButtonClickListener ) ; mPresetButtons [ nButton ] . setOnLongClickListener ( mPresetButtonOnLongClickListener ) ; } } mTuneStationFrequencyTV = ( TextView ) findViewById ( R . id . prog_frequency_tv ) ; if ( mTuneStationFrequencyTV != null ) { mTuneStationFrequencyTV . setOnLongClickListener ( mFrequencyViewClickListener ) ; } mProgramServiceTV = ( TextView ) findViewById ( R . id . prog_service_tv ) ; mStereoTV = ( TextView ) findViewById ( R . id . stereo_text_tv ) ; mStationCallSignTV = ( TextView ) findViewById ( R . id . call_sign_tv ) ; mProgramTypeTV = ( TextView ) findViewById ( R . id . pty_tv ) ; mRadioTextTV = ( TextView ) findViewById ( R . id . radio_text_tv ) ; mERadioTextTV = ( TextView ) findViewById ( R . id . eradio_text_tv ) ; mSleepMsgTV = ( TextView ) findViewById ( R . id . sleep_msg_tv ) ; mRecordingMsgTV = ( TextView ) findViewById ( R . id . record_msg_tv ) ; if ( mRecordingMsgTV != null ) { mRecordingMsgTV . setOnClickListener ( mRecordButtonListener ) ; } /* Disable displaying RSSI */ mRSSI = ( ImageView ) findViewById ( R . id . signal_level ) ; if ( mRSSI != null ) { mRSSI . setVisibility ( View . INVISIBLE ) ; } if ( ( mRadioTextScroller == null ) && ( mRadioTextTV != null ) ) { mRadioTextScroller = new ScrollerText ( mRadioTextTV ) ; } if ( ( mERadioTextScroller == null ) && ( mERadioTextTV != null ) ) { mERadioTextScroller = new ScrollerText ( mERadioTextTV ) ; } }
Called when the activity is first created.
Called when the activity is first created .
// TODO Auto-generated method stub