From 40fa30f3cff4d81f7a137d7eec62b851b94bdacb Mon Sep 17 00:00:00 2001 From: xuechangfeng <963779172@qq.com> Date: Wed, 30 Jun 2021 15:48:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sample/slice/MainAbilitySlice.java | 112 +++++++++--------- 1 file changed, 58 insertions(+), 54 deletions(-) diff --git a/entry/src/main/java/com/leinardi/ohos/speeddial/sample/slice/MainAbilitySlice.java b/entry/src/main/java/com/leinardi/ohos/speeddial/sample/slice/MainAbilitySlice.java index b3d1a0e..31db8e3 100644 --- a/entry/src/main/java/com/leinardi/ohos/speeddial/sample/slice/MainAbilitySlice.java +++ b/entry/src/main/java/com/leinardi/ohos/speeddial/sample/slice/MainAbilitySlice.java @@ -313,60 +313,8 @@ public class MainAbilitySlice extends AbilitySlice { @Override public void onClick(Component component) { if (!isAddFloat) { - isOrange = true; - isDelete = false; - isYellow = false; - isFourTopSize = "0"; - isAddFloat = true; - mListContainer.setEnabled(false); - mImageAdd.setVisibility(Component.HIDE); - mImageAddPen.setVisibility(Component.VISIBLE); - if (posDegree == 0) { - mImageAdd.setWidth(90); - mImageAdd.setHeight(90); - animatorPropertyAddPen.rotate(45).setDuration(10); - animatorPropertyAddPen.start(); - } else if (posDegree == 1) { - animatorPropertyAdd.rotate(0).setDuration(1); - animatorPropertyAdd.start(); - mImageAdd.setWidth(90); - mImageAdd.setHeight(90); - animatorPropertyAddPen.rotate(45).setDuration(300); - animatorPropertyAddPen.start(); - } else if (posDegree == 2) { - animatorPropertyAdd.rotate(-45).setDuration(1); - animatorPropertyAdd.start(); - PixelMapElement pixelMapElement = null; - try { - pixelMapElement = new PixelMapElement(mImageAddPen.getResourceManager() - .getResource(ResourceTable.Media_brush1)); - } catch (IOException e) { - e.printStackTrace(); - } catch (NotExistException e) { - e.printStackTrace(); - } - mImageAddPen.setBackground(pixelMapElement); - animatorPropertyAddPen.rotate(90).setDuration(300); - animatorPropertyAddPen.start(); - } else if (posDegree == 3) { - animatorPropertyAdd.rotate(-45).setDuration(1); - animatorPropertyAdd.start(); - - PixelMapElement pixelMapElement = null; - try { - pixelMapElement = new PixelMapElement(mImageAddPen.getResourceManager() - .getResource(ResourceTable.Media_brush2)); - } catch (IOException e) { - e.printStackTrace(); - } catch (NotExistException e) { - e.printStackTrace(); - } - mImageAddPen.setBackground(pixelMapElement); - animatorPropertyAddPen.rotate(180).setDuration(300); - animatorPropertyAddPen.start(); - } + initOne(); initAddPen(); - if (pos == 0) { initIsTop(); } else if (pos == 1) { @@ -854,6 +802,61 @@ public class MainAbilitySlice extends AbilitySlice { }); } + private void initOne() { + isOrange = true; + isDelete = false; + isYellow = false; + isFourTopSize = "0"; + isAddFloat = true; + mListContainer.setEnabled(false); + mImageAdd.setVisibility(Component.HIDE); + mImageAddPen.setVisibility(Component.VISIBLE); + if (posDegree == 0) { + mImageAdd.setWidth(90); + mImageAdd.setHeight(90); + animatorPropertyAddPen.rotate(45).setDuration(10); + animatorPropertyAddPen.start(); + } else if (posDegree == 1) { + animatorPropertyAdd.rotate(0).setDuration(1); + animatorPropertyAdd.start(); + mImageAdd.setWidth(90); + mImageAdd.setHeight(90); + animatorPropertyAddPen.rotate(45).setDuration(300); + animatorPropertyAddPen.start(); + } else if (posDegree == 2) { + animatorPropertyAdd.rotate(-45).setDuration(1); + animatorPropertyAdd.start(); + PixelMapElement pixelMapElement = null; + try { + pixelMapElement = new PixelMapElement(mImageAddPen.getResourceManager() + .getResource(ResourceTable.Media_brush1)); + } catch (IOException e) { + e.printStackTrace(); + } catch (NotExistException e) { + e.printStackTrace(); + } + mImageAddPen.setBackground(pixelMapElement); + animatorPropertyAddPen.rotate(90).setDuration(300); + animatorPropertyAddPen.start(); + } else if (posDegree == 3) { + animatorPropertyAdd.rotate(-45).setDuration(1); + animatorPropertyAdd.start(); + + PixelMapElement pixelMapElement = null; + try { + pixelMapElement = new PixelMapElement(mImageAddPen.getResourceManager() + .getResource(ResourceTable.Media_brush2)); + } catch (IOException e) { + e.printStackTrace(); + } catch (NotExistException e) { + e.printStackTrace(); + } + mImageAddPen.setBackground(pixelMapElement); + animatorPropertyAddPen.rotate(180).setDuration(300); + animatorPropertyAddPen.start(); + } + } + private void initIsTop() { mListContainerCircleLeft.setVisibility(Component.HIDE); mListContainerCircleTop.setVisibility(Component.VISIBLE); @@ -916,7 +919,8 @@ public class MainAbilitySlice extends AbilitySlice { mListItemProviderCircle = new ListItemProviderCircle(listCircle, MainAbilitySlice.this, "bottom"); mListContainerCircleBottom.setItemProvider(mListItemProviderCircle); mListContainerCircleBottom.setOrientation(Component.VERTICAL); - mDSOne.setContentPosition(getDisplayWidthInPx(MainAbilitySlice.this) - vp2px(context, 90), getDisplayHeightInPx(MainAbilitySlice.this) - vp2px(context, 600)); + mDSOne.setContentPosition(getDisplayWidthInPx(MainAbilitySlice.this) - vp2px(context, 90), + getDisplayHeightInPx(MainAbilitySlice.this) - vp2px(context, 630)); } private void initIsRight() { -- Gitee