@Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == RESULT_OK) {
      switch (requestCode) {
        case REQUEST_CUT_PHOTO: // 发送本地图片
          if (data != null) {
            if (Build.VERSION.SDK_INT < 23 || new File(cuttedPicturePath).exists() == false) {
              Bundle bundle = data.getExtras();
              if (bundle != null) {
                Bitmap photo = bundle.getParcelable("data");
                // photo.
                if (photo != null) {
                  // 照片的路径
                  setCuttedPicturePath();
                  cuttedPicturePath =
                      CommonUtil.savePhotoToSDCard(
                          cuttedPicturePath, cuttedPictureName, "jpg", photo);
                }
              }
            }
            setResult(RESULT_OK, new Intent().putExtra(RESULT_PICTURE_PATH, cuttedPicturePath));
          }
          break;
        default:
          break;
      }
    }

    finish();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    intent = getIntent();

    originalPicturePath = intent.getStringExtra(INTENT_ORIGINAL_PICTURE_PATH);
    cuttedWidth = intent.getIntExtra(INTENT_CUT_WIDTH, 0);
    cuttedHeight = intent.getIntExtra(INTENT_CUT_HEIGHT, 0);
    if (cuttedWidth <= 0) {
      cuttedWidth = cuttedHeight;
    }
    if (cuttedHeight <= 0) {
      cuttedHeight = cuttedWidth;
    }

    if (StringUtil.isNotEmpty(originalPicturePath, true) == false || cuttedWidth <= 0) {
      Log.e(
          TAG,
          "onCreate  StringUtil.isNotEmpty(originalPicturePath, true)"
              + " == false || cuttedWidth <= 0 >> finish(); return;");
      showShortToast("图片不存在,请先选择图片");
      finish();
      return;
    }

    // 功能归类分区方法,必须调用<<<<<<<<<<
    initData();
    initView();
    initEvent();
    // 功能归类分区方法,必须调用>>>>>>>>>>

  }
Exemple #3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.demo_main_activity);
    // 类相关初始化,必须使用<<<<<<<<<<<<<<<<
    context = this;
    isAlive = true;
    // 类相关初始化,必须使用>>>>>>>>>>>>>>>>

    // 功能归类分区方法,必须调用<<<<<<<<<<
    initView();
    initData();
    initListener();
    // 功能归类分区方法,必须调用>>>>>>>>>>

  }
Exemple #4
0
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode != RESULT_OK) {
      return;
    }
    switch (requestCode) {
      case REQUEST_TO_SELECT_PICTURE:
        if (data != null) {
          cutPicture(data.getStringExtra(SelectPictureActivity.RESULT_PICTURE_PATH));
        }
        break;
      case REQUEST_TO_CUT_PICTURE: // 返回的结果
        if (data != null) {
          setPicture(data.getStringExtra(CutPictureActivity.RESULT_PICTURE_PATH));
        }
        break;
      case REQUEST_TO_EDIT_TEXT_INFO:
        if (data != null) {
          svDemoMain.smoothScrollTo(0, 0);
          tvDemoMainHeadName.setText(
              StringUtil.getTrimedString(data.getStringExtra(EditTextInfoWindow.RESULT_VALUE)));
        }
        break;
      case REQUEST_TO_SERVER_SETTING:
        if (data != null) {
          // TODO
        }
        break;
      case REQUEST_TO_TOP_MENU:
        if (data != null) {
          switch (data.getIntExtra(TopMenuWindow.RESULT_POSITION, -1)) {
            case 0:
              showItemOnlyDialog();
              break;
            case 1:
              selectPicture();
              break;
            default:
              break;
          }
        }
        break;
      case REQUEST_TO_BOTTOM_MENU:
        if (data != null) {
          int selectedPosition = data.getIntExtra(BottomMenuWindow.RESULT_ITEM_ID, -1);
          if (selectedPosition >= 0 && selectedPosition < topbarColorResIds.length) {
            rlDemoMainTopbar.setBackgroundResource(topbarColorResIds[selectedPosition]);
          }
        }
        break;
      case REQUEST_TO_DATE_PICKER:
        if (data != null) {
          //					List<Integer> selectedPositionList = data.getIntegerArrayListExtra(
          //							GridPickerWindow.RESULT_SELECTED_POSITIONS);
          //					showShortToast("selectedPositionList.size() = " + (selectedPositionList == null
          //							? "null" : selectedPositionList.size()));

          ArrayList<Integer> dateList =
              data.getIntegerArrayListExtra(DatePickerWindow.RESULT_DATE_DETAIL_LIST);
          if (dateList != null && dateList.size() >= 3) {
            showShortToast(
                "选择的日期为" + dateList.get(0) + "-" + (dateList.get(1) + 1) + "-" + dateList.get(2));
          }
        }
        break;
      case REQUEST_TO_PLACE_PICKER:
        if (data != null) {
          ArrayList<String> placeList =
              data.getStringArrayListExtra(PlacePickerWindow.RESULT_PLACE_LIST);
          if (placeList != null) {
            String place = "";
            for (String s : placeList) {
              place += StringUtil.getTrimedString(s);
            }
            showShortToast("选择的地区为: " + place);
          }
        }
        break;
      default:
        break;
    }
  }
 @Override
 public void finish() {
   exitAnim = enterAnim = R.anim.null_anim;
   super.finish();
 }
 @Override
 public void initEvent() { // 必须调用
   super.initEvent();
 }
  @Override
  public void initData() { // 必须调用
    super.initData();

    startPhotoZoom(originalPicturePath, cuttedWidth, cuttedHeight);
  }
 @Override
 public void initView() { // 必须调用
   super.initView();
 }