Ejemplo n.º 1
0
  private void initViews() {
    imageView = (CropImageView) findViewById(R.id.crop_image);
    imageView.context = this;
    imageView.setRecycler(
        new ImageViewTouchBase.Recycler() {

          @Override
          public void recycle(Bitmap b) {
            b.recycle();
            System.gc();
          }
        });

    findViewById(R.id.btn_cancel)
        .setOnClickListener(
            new View.OnClickListener() {

              public void onClick(View v) {
                setResult(RESULT_CANCELED);
                finish();
              }
            });

    findViewById(R.id.btn_done)
        .setOnClickListener(
            new View.OnClickListener() {

              public void onClick(View v) {
                onSaveClicked();
              }
            });
  }
  private void setupViews() {
    setContentView(R.layout.crop__activity_crop);

    imageView = (CropImageView) findViewById(R.id.crop_image);
    imageView.context = this;
    imageView.setRecycler(
        new ImageViewTouchBase.Recycler() {
          @Override
          public void recycle(Bitmap b) {
            b.recycle();
            System.gc();
          }
        });

    findViewById(R.id.btn_cancel)
        .setOnClickListener(
            new View.OnClickListener() {
              public void onClick(View v) {
                setResult(RESULT_CANCELED);
                finish();
              }
            });

    findViewById(R.id.btn_done)
        .setOnClickListener(
            new View.OnClickListener() {
              public void onClick(View v) {
                onSaveClicked();
              }
            });

    findViewById(R.id.btn_rotate_left)
        .setOnClickListener(
            new View.OnClickListener() {
              public void onClick(View v) {
                Bitmap bitmap = drawableToBitmap(imageView.getDrawable());
                rotateDegreesCounter = rotateDegreesCounter - 90;
                rotateBitmap = new RotateBitmap(bitmap, rotateDegreesCounter);
                if (rotateBitmap != null) {
                  startCrop();
                }
              }
            });

    findViewById(R.id.btn_rotate_right)
        .setOnClickListener(
            new View.OnClickListener() {

              public void onClick(View v) {

                Bitmap bitmap = drawableToBitmap(imageView.getDrawable());
                rotateDegreesCounter = rotateDegreesCounter + 90;
                rotateBitmap = new RotateBitmap(bitmap, rotateDegreesCounter);
                if (rotateBitmap != null) {
                  startCrop();
                }
              }
            });
  }