Android Open Source - HeadphoneController Select Command Activity






From Project

Back to project page HeadphoneController.

License

The source code is released under:

GNU General Public License

If you think the Android project HeadphoneController listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package ca.mbabic.headphonecontroller;
//from w  w w. j  ava2 s .  c  om
import android.app.ListActivity;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.widget.ListView;
import android.widget.RadioButton;
import ca.mbabic.headphonecontroller.configuration.HCConfigAdapter;
import ca.mbabic.headphonecontroller.models.HCInputSequence;
import ca.mbabic.headphonecontroller.views.CommandAdapter;

public class SelectCommandActivity extends ListActivity {

  public static final String INPUT_SEQUENCE_KEY = "input_sequence_key";
  public static final String[] AVAILABLE_COMMANDS = new String[] {

  "Play/Pause", "Skip Track", "Repeat/Previous Track"

  };

  private String mInputSequence;
  private HCInputSequence mState;

  @Override
  public void onCreate(Bundle savedInstanceState) {

    CommandAdapter viewAdapter;
    HCConfigAdapter configAdapter = new HCConfigAdapter(PreferenceManager.getDefaultSharedPreferences(this), this);
    Bundle args;

    super.onCreate(savedInstanceState);

    setContentView(R.layout.select_command_list_view);

    args = getIntent().getExtras();

    if (args != null) {
      mInputSequence = args.getString(INPUT_SEQUENCE_KEY);
      mState = configAdapter.getState(mInputSequence);
    } else {
      // TODO: Log error? Throw exception? Quit?
    }

    viewAdapter = new CommandAdapter(this, R.layout.select_command_list_view, 
      null);
    
//    adapter = new ArrayAdapter<String>(this,
//        R.layout.select_command_list_item, R.id.command_selection_label,
//        AVAILABLE_COMMANDS) {
//
//      private int mPositionSelected = 0;
//
//      public void setPositionSelected(int newPosition) {
//        mPositionSelected = newPosition;
//      }
//      
//      @Override
//      public View getView(int position, View convertView, 
//          ViewGroup parent) {
//
//        LayoutInflater viewInflater;
//        TextView textView;
//        RadioButton radioButton;
//        View view;
//        
//        view = convertView;
//        
//        if (view == null) {
//          
//          viewInflater = (LayoutInflater) 
//              getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//          
//          view = viewInflater.inflate(
//              R.layout.select_command_list_item, null);
//          
//        }
//        
//        radioButton = (RadioButton) 
//            view.findViewById(R.id.command_selection_button);
//        
//        textView = (TextView) 
//            view.findViewById(R.id.command_selection_label);
//        
//        radioButton.setChecked(position == mPositionSelected);
//        radioButton.setTag(position);
//        radioButton.setOnClickListener(new View.OnClickListener() {
//          
//          @Override
//          public void onClick(View v) {
//            setPositionSelected((int) v.getTag());
//            notifyDataSetInvalidated();
//          }
//        });
//        
//        return view;
//      }
//
//    };
//    
    setListAdapter(viewAdapter);

  }
  
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);
    
    RadioButton radioButton = (RadioButton)
        v.findViewById(R.id.command_selection_button);
    
    radioButton.setChecked(true);
    
  }
  
}




Java Source Code List

ca.mbabic.headphonecontroller.ConfigurationFragment.java
ca.mbabic.headphonecontroller.HCApplication.java
ca.mbabic.headphonecontroller.HomeActivity.java
ca.mbabic.headphonecontroller.SelectCommandActivity.java
ca.mbabic.headphonecontroller.commands.CommandExecutor.java
ca.mbabic.headphonecontroller.commands.HCCommandContext.java
ca.mbabic.headphonecontroller.commands.HCCommandFactory.java
ca.mbabic.headphonecontroller.commands.HCCommand.java
ca.mbabic.headphonecontroller.commands.MuteMusicCommand.java
ca.mbabic.headphonecontroller.commands.NoOpCommand.java
ca.mbabic.headphonecontroller.commands.PlayPauseCommand.java
ca.mbabic.headphonecontroller.commands.PreviousCommand.java
ca.mbabic.headphonecontroller.commands.SkipCommand.java
ca.mbabic.headphonecontroller.configuration.HCConfigAdapter.java
ca.mbabic.headphonecontroller.configuration.HCConfigConstants.java
ca.mbabic.headphonecontroller.db.DbHelper.java
ca.mbabic.headphonecontroller.db.HCCallStateTable.java
ca.mbabic.headphonecontroller.db.HCCommandCallStateTable.java
ca.mbabic.headphonecontroller.db.HCCommandTable.java
ca.mbabic.headphonecontroller.db.HCDbAdapter.java
ca.mbabic.headphonecontroller.db.HCDbHelper.java
ca.mbabic.headphonecontroller.db.HCDbTable.java
ca.mbabic.headphonecontroller.db.HCInputSequenceCommandsTable.java
ca.mbabic.headphonecontroller.db.HCInputSequenceTable.java
ca.mbabic.headphonecontroller.models.HCCmd.java
ca.mbabic.headphonecontroller.models.HCInputSequence.java
ca.mbabic.headphonecontroller.services.MediaButtonListenerService.java
ca.mbabic.headphonecontroller.services.MediaButtonReceiver.java
ca.mbabic.headphonecontroller.services.MediaStateChangeReceiver.java
ca.mbabic.headphonecontroller.statemachine.FourPressState.java
ca.mbabic.headphonecontroller.statemachine.HCStateMachine.java
ca.mbabic.headphonecontroller.statemachine.HCState.java
ca.mbabic.headphonecontroller.statemachine.InactiveState.java
ca.mbabic.headphonecontroller.statemachine.OnePressState.java
ca.mbabic.headphonecontroller.statemachine.ThreePressState.java
ca.mbabic.headphonecontroller.statemachine.TwoPressState.java
ca.mbabic.headphonecontroller.views.CommandAdapter.java