예제 #1
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
      case SELECT_PICTURE:
        if (resultCode == RESULT_OK) {
          Uri selectedImage = data.getData();
          String[] filePathColumn = {MediaStore.Images.Media.DATA};

          Cursor cursor =
              getContentResolver().query(selectedImage, filePathColumn, null, null, null);
          cursor.moveToFirst();

          int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
          String filePath = cursor.getString(columnIndex);
          cursor.close();

          Bitmap bkgImg = BitmapFactory.decodeFile(filePath);
          Display disp = getWindowManager().getDefaultDisplay();
          int w = disp.getWidth();
          int h = disp.getHeight();

          double scaleX = (w * 1.0) / bkgImg.getWidth();
          double scaleY = (h * 1.0) / bkgImg.getHeight();

          double scale = Math.min(scaleX, scaleY);

          double sw = w * scaleX;
          double sh = h * scaleY;
          // System.out.println("Scale X ["+scaleX+"] - Scale Y ["+scaleY+"] - Scale ["+scale+"]");

          bkgImg = Bitmap.createBitmap(bkgImg, 0, 0, w, h);
          pinTableFrag.setBackground(bkgImg);
        }
    }
  }
예제 #2
0
  /**
   * ************************************************
   *
   * <p>CallBack methods
   *
   * <p>************************************************
   */
  @Override
  public void onPinSelected(int pinId) {

    pinTableFrag.setCurrentPin(pinId);
    closeMenu();
  }