diff --git a/entry/src/main/java/com/donkingliang/imageselector/ImageAbility.java b/entry/src/main/java/com/donkingliang/imageselector/ImageAbility.java index d639f11da4e0ca78548b06987f4978202a31d9d2..412ed5adaa2b6332ffc80b33abde7751185dee78 100644 --- a/entry/src/main/java/com/donkingliang/imageselector/ImageAbility.java +++ b/entry/src/main/java/com/donkingliang/imageselector/ImageAbility.java @@ -61,28 +61,28 @@ public class ImageAbility extends Ability implements CropResult { public void onStart(Intent intent) { super.onStart(intent); super.setUIContent(ResourceTable.Layout_ability_ucropview); - String urlpath = intent.getStringParam("img"); - - // 网图URI - // 待裁剪图片的URI - Uri uriI = Uri.parse(urlpath); // 本地URI tvLift = (Text) findComponentById(ResourceTable.Id_tv_lift); - Text tvRight = (Text) findComponentById(ResourceTable.Id_tv_right); tvAmplification = (Text) findComponentById(ResourceTable.Id_tv_amplification); tvLessen = (Text) findComponentById(ResourceTable.Id_tv_lessen); - Text tvCrop = (Text) findComponentById(ResourceTable.Id_tv_crop); PixelMap.InitializationOptions options = new PixelMap.InitializationOptions(); options.size = new Size(Constant.IMAGESIZE, Constant.IMAGESIZE); PixelMap pixelmap = PixelMap.create(options); String filename = "test.jpg"; Uri uriPath = saveImage(filename, pixelmap); + String urlpath = intent.getStringParam("img"); + + // 网图URI + // 待裁剪图片的URI + Uri uriI = Uri.parse(urlpath); mUcropView = (UCropView) findComponentById(ResourceTable.Id_ucv_pic); mUcropView.getCropImageView().setImageUri(uriI, uriPath); mUcropView.getOverlayView().setShowCropFrame(true); mUcropView.getOverlayView().setShowCropGrid(true); mUcropView.getOverlayView().setDimmedColor(Color.TRANSPARENT.getValue()); + Text tvRight = (Text) findComponentById(ResourceTable.Id_tv_right); + Text tvCrop = (Text) findComponentById(ResourceTable.Id_tv_crop); // 裁剪Button tvCrop.setClickedListener(component -> cropAndSaveImage()); diff --git a/entry/src/ohosTest/java/com/donkingliang/imageselector/Constant.java b/entry/src/ohosTest/java/com/donkingliang/imageselector/Constant.java new file mode 100644 index 0000000000000000000000000000000000000000..bcc123f02fb716e9099506784e7756d18f3e71d2 --- /dev/null +++ b/entry/src/ohosTest/java/com/donkingliang/imageselector/Constant.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain an copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.donkingliang.imageselector; + +/** + * 常量工具类 + * + * @author: ImageSelecter + * @since 2021-05-25 + */ +public final class Constant { + /** + * TENF 10.0f + */ + public static final float TENF = 10.0f; + /** + * numner 20.0f + */ + public static final float TWOTENT = 20.0f; + + private Constant() { + } +} diff --git a/entry/src/ohosTest/java/com/donkingliang/imageselector/MainAbilityTest.java b/entry/src/ohosTest/java/com/donkingliang/imageselector/MainAbilityTest.java index 62eca2e9c85240ed7a40a492667541458d1545fa..425097dd9f60690eaaaef6041815e6e3abe7ad9b 100644 --- a/entry/src/ohosTest/java/com/donkingliang/imageselector/MainAbilityTest.java +++ b/entry/src/ohosTest/java/com/donkingliang/imageselector/MainAbilityTest.java @@ -38,7 +38,7 @@ public class MainAbilityTest { @Test public void onStart() { HeLog.d("HiLog","单元测试"); - int senSer = AngleUtil.getSensorAngle(10.0f,20.0f); + int senSer = AngleUtil.getSensorAngle(Constant.TENF,Constant.TWOTENT); Assert.assertEquals(0, senSer); ScreenUtils.getScreenHeight(ability.getApplicationContext()); ScreenUtils.getScreenWidth(ability.getApplicationContext());