From 15504aa627c47b98def2c1ce2506730c9eacbc12 Mon Sep 17 00:00:00 2001 From: chenjianpeng Date: Thu, 27 May 2021 10:22:52 +0800 Subject: [PATCH] =?UTF-8?q?1=EF=BC=8C=E4=BF=AE=E6=94=B9checkstyle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../imageselector/ImageAbility.java | 14 ++++---- .../donkingliang/imageselector/Constant.java | 36 +++++++++++++++++++ .../imageselector/MainAbilityTest.java | 2 +- 3 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 entry/src/ohosTest/java/com/donkingliang/imageselector/Constant.java diff --git a/entry/src/main/java/com/donkingliang/imageselector/ImageAbility.java b/entry/src/main/java/com/donkingliang/imageselector/ImageAbility.java index d639f11..412ed5a 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 0000000..bcc123f --- /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 62eca2e..425097d 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()); -- Gitee