예제 #1
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    mColorSpinner = (Spinner) findViewById(R.id.color_spinner);
    ArrayAdapter<CharSequence> colorAdapter =
        ArrayAdapter.createFromResource(
            this, R.array.color_array, android.R.layout.simple_spinner_item);
    colorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mColorSpinner.setAdapter(colorAdapter);
    mColorSpinner.setOnItemSelectedListener(new ColorSelectedListener());

    mTextSizeSpinner = (Spinner) findViewById(R.id.text_size);
    ArrayAdapter<CharSequence> textSizeAdapter =
        ArrayAdapter.createFromResource(
            this, R.array.text_size_array, android.R.layout.simple_spinner_item);
    textSizeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mTextSizeSpinner.setAdapter(textSizeAdapter);
    mTextSizeSpinner.setSelection(3); // 3 is regular text size at startup.
    mTextSizeSpinner.setOnItemSelectedListener(new TextSizeSelectedListener());

    mTextSizeLabel = (TextView) findViewById(R.id.text_size_label);
    mBackgroundColorLabel = (TextView) findViewById(R.id.background_color_label);

    mGetPropertiesButton = (Button) findViewById(R.id.get_properties);
    mGetPropertiesButton.setOnClickListener(new GetPropertiesListener());

    mSetPropertiesButton = (Button) findViewById(R.id.set_properties);
    mSetPropertiesButton.setOnClickListener(new SetPropertiesListener());

    mBackgroundColor = "";
    mTextSize = -1;

    /* Make all AllJoyn calls through a separate handler thread to prevent blocking the UI. */
    HandlerThread busThread = new HandlerThread("BusHandler");
    busThread.start();
    mBusHandler = new BusHandler(busThread.getLooper());

    /* Connect to an AllJoyn object. */
    mBusHandler.sendEmptyMessage(BusHandler.CONNECT);
    mHandler.sendEmptyMessage(MESSAGE_START_PROGRESS_DIALOG);
  }
예제 #2
0
  @Override
  protected void onDestroy() {
    super.onDestroy();

    mBusHandler.sendEmptyMessage(BusHandler.DISCONNECT);
  }