Beispiel #1
0
  /** 构造函数,主要对一些对象初始化 */
  public MySurfaceView(Context context) {
    super(context);

    mHolder = this.getHolder(); // 获得SurfaceHolder对象
    mHolder.addCallback(this); // 添加状态监听

    mPaint = new Paint(); // 创建一个画笔对象
    mPaint.setColor(Color.WHITE); // 设置画笔的颜色为白色

    qPaint = new Paint(); // 创建一个画笔对象
    qPaint.setAntiAlias(true); // 消除锯齿
    qPaint.setStyle(Paint.Style.STROKE); // 设置画笔风格为描边
    qPaint.setStrokeWidth(3); // 设置描边的宽度为3
    qPaint.setColor(Color.GREEN); // 设置画笔的颜色为绿色

    // 创建路径对象
    mPath = new Path();
    qPath = new Path();
    tPath = new Path();

    // 设置坐标为50,100
    mX = 50;
    mY = 100;

    // 设置贝塞尔曲线的开始坐标为(10,200)
    qStartX = 10;
    qStartY = 200;

    setFocusable(true); // 设置焦点
  }
Beispiel #2
0
 public MyView(Context context) {
   super(context);
   paint = new Paint();
   paint.setColor(Color.BLUE);
   paint.setStyle(Paint.Style.STROKE); // 设置画笔风格为描边
   paint.setStrokeWidth(10);
   random = new Random();
   setFocusable(true);
   holder = getHolder();
   holder.addCallback(this);
   path = new Path();
 }
Beispiel #3
0
  public FlxGameView(FlxGame game, Context context, AttributeSet attrs) {
    super(context, attrs);

    SurfaceHolder holder = getHolder();
    holder.addCallback(this);

    this.activity = (Activity) context;

    this.game = game;

    this.setFocusable(true);
    this.setFocusableInTouchMode(true);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gatt_services_characteristics);

    final Intent intent = getIntent();
    mDeviceName = intent.getStringExtra(EXTRAS_DEVICE_NAME);
    mDeviceAddress = intent.getStringExtra(EXTRAS_DEVICE_ADDRESS);

    // Sets up UI references.
    mConnectionState = (TextView) findViewById(R.id.connection_state);
    // is serial present?
    isSerial = (TextView) findViewById(R.id.isSerial);

    msgEdit = (EditText) findViewById(R.id.editText);
    returnText = (TextView) findViewById(R.id.returnText);

    sendButton = (Button) findViewById(R.id.sendButton);
    //        timeButton = (Button) findViewById(R.id.timeButton);

    sendButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            if (characteristicReady) {
              StringBuffer sb = new StringBuffer("m");
              sb.append(msgEdit.getText()).append("\n");

              sendMessage(sb.toString());
            }
          }
        });

    //        timeButton.setOnClickListener(new View.OnClickListener() {
    //
    //            @Override
    //            public void onClick(View v) {
    //                if (characteristicReady) {
    //                    StringBuffer sb = new StringBuffer("t");
    //                    Date now = new Date();
    //                    sb.append(DATE_FORMAT.format(now)).append("\n");
    //
    //                    sendMessage(sb.toString());
    //                }
    //            }
    //        });

    infoButton = (ImageView) findViewById(R.id.infoImage);
    infoButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            iascDialog();
          }
        });

    mSurfaceView = (SurfaceView) findViewById(R.id.surfaceView);
    mSurfaceHolder = mSurfaceView.getHolder();
    mSurfaceHolder.addCallback(new MyHolder());

    mPaint = new Paint();
    // 画笔的粗细
    mPaint.setStrokeWidth(5.0f);

    getActionBar().setTitle(mDeviceName);
    getActionBar().setDisplayHomeAsUpEnabled(true);

    Intent gattServiceIntent = new Intent(this, BluetoothLeService.class);
    bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);
  }