From f64221a2c06a1515097179f5666db15f36a5b574 Mon Sep 17 00:00:00 2001 From: wangguan Date: Fri, 11 Jun 2021 18:06:45 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E9=A6=96=E6=AC=A1=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/ColorStateList.md | 49 ++++++++++++++++++++++++++++++++++++++ content/ContentResolver.md | 43 +++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 content/ColorStateList.md create mode 100644 content/ContentResolver.md diff --git a/content/ColorStateList.md b/content/ColorStateList.md new file mode 100644 index 0000000..20c62e6 --- /dev/null +++ b/content/ColorStateList.md @@ -0,0 +1,49 @@ + +# ColorStateList +* openharmony API: ohos.agp.components.element.StateElement +* openharmony SDK版本:2.1.1.21 +* IDE版本:2.1.0.501 +* 实现方案: + + +原三方库: + +对TextView设置ColorStateList使其在Normal、Pressed、Focused、Unable四种状态下显示不同的颜色 +``` java + /** 对TextView设置不同状态时其文字颜色。 */ + private ColorStateList createColorStateList(int normal, int pressed, int focused, int unable) { + int[] colors = new int[] { pressed, focused, normal, focused, unable, normal }; + int[][] states = new int[6][]; + states[0] = new int[] { android.R.attr.state_pressed, android.R.attr.state_enabled }; + states[1] = new int[] { android.R.attr.state_enabled, android.R.attr.state_focused }; + states[2] = new int[] { android.R.attr.state_enabled }; + states[3] = new int[] { android.R.attr.state_focused }; + states[4] = new int[] { android.R.attr.state_window_focused }; + states[5] = new int[] {}; + ColorStateList colorList = new ColorStateList(states, colors); + return colorList; +``` + +openharmony: + +需要修改component组件交互效果/背景颜色 +``` java + public Text(Context context, AttrSet attrSet, String styleName) { + super(context, attrSet, styleName); + //通过属性值方式获取 + StateElement backgroudSelector = (StateElement)attrSet.getAttr(styleName).get().getElement(); + + //或者通过以下方式获取 + StateElement backgroudSelector1 = (StateElement)this.getBackgroundElement(); + + Element stateElement1 = backgroudSelector.getStateElement(0); + int[] states1 = backgroudSelector.getStateSet(0); + + Element stateElement2 = backgroudSelector.getStateElement(1); + int[] states2 = backgroudSelector.getStateSet(1); + + StateElement stateElement = new StateElement(); + stateElement.addState(states1,stateElement1); + stateElement.addState(states2,stateElement2); + } +``` \ No newline at end of file diff --git a/content/ContentResolver.md b/content/ContentResolver.md new file mode 100644 index 0000000..a8c75f6 --- /dev/null +++ b/content/ContentResolver.md @@ -0,0 +1,43 @@ + +# ResourceManager +* openharmony API: ohos.global.resource.Resource +* openharmony SDK版本:2.1.1.21 +* IDE版本:2.1.0.501 +* 实现方案: +``` java + public static File readFontFile(Context context,String filePath) { + ResourceManager resManager = context.getResourceManager(); + RawFileEntry rawFileEntry = resManager.getRawFileEntry(filePath); + Resource resource = null; + try { + resource = rawFileEntry.openRawFile(); + } catch (IOException e) { + e.printStackTrace(); + } + StringBuffer fileName = new StringBuffer(filePath); + + File file = new File(context.getExternalFilesDir(Environment.DIRECTORY_PICTURES), fileName.toString()); + OutputStream outputStream = null; + try { + outputStream = new FileOutputStream(file); + int index; + byte[] bytes = new byte[1024]; + while ((index = resource.read(bytes)) != -1) { + outputStream.write(bytes, 0, index); + outputStream.flush(); + } + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + resource.close(); + outputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return file; + } +``` \ No newline at end of file -- Gitee From 964574249aae4038a1f6440b9d5c0d03afdee701 Mon Sep 17 00:00:00 2001 From: wangguan Date: Fri, 11 Jun 2021 19:57:49 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E9=A6=96=E6=AC=A1=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- graphics/BitmapShader.md | 29 +++++++++++++++++++++++++++++ view/onTouchEvent.md | 33 +++++++++++++++++++++++++++++++++ widget/PopupWindow.md | 19 +++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 graphics/BitmapShader.md create mode 100644 view/onTouchEvent.md create mode 100644 widget/PopupWindow.md diff --git a/graphics/BitmapShader.md b/graphics/BitmapShader.md new file mode 100644 index 0000000..8ac2302 --- /dev/null +++ b/graphics/BitmapShader.md @@ -0,0 +1,29 @@ + +# PixelMapShader +* openharmony API: ohos.agp.render.PixelMapShader +* openharmony SDK版本:2.1.1.21 +* IDE版本:2.1.0.501 +* 实现方案: + + +原三方库: + +BitmapShader通过设置给mPaint,然后用这个mPaint绘图时,就会根据你设置的TileMode,对绘制区域进行着色 +``` java + // 渲染图像,使用图像为绘制图形着色 + private BitmapShader mBitmapShader; + // 将bmp作为着色器,就是在指定区域内绘制bmp + mBitmapShader = new BitmapShader(bmp, TileMode.CLAMP, TileMode.CLAMP); + // 设置变换矩阵 + mBitmapShader.setLocalMatrix(mMatrix); + // 设置shader + mBitmapPaint.setShader(mBitmapShader); +``` + +openharmony: + +当您需要绘制的对象大于像素图着色器定义的着色区域时,您可以为像素图指定平铺模式以绘制重复或镜像的像素图。 +``` java + PixelMapShader mShadel; + mShadel = new PixelMapShader(new PixelMapHolder(pixelMap), Shader.TileMode.CLAMP_TILEMODE,Shader.TileMode.CLAMP_TILEMODE); +``` \ No newline at end of file diff --git a/view/onTouchEvent.md b/view/onTouchEvent.md new file mode 100644 index 0000000..6332893 --- /dev/null +++ b/view/onTouchEvent.md @@ -0,0 +1,33 @@ + +# TouchEvent +* openharmony API: ohos.multimodalinput.event.TouchEvent +* openharmony SDK版本:2.1.1.21 +* IDE版本:2.1.0.501 +* 实现方案: + +openharmony: + +实现TouchEventListener接口,重写onTouchEvent方法 +``` java + public class Text extends Component implements Component.TouchEventListener{ + + @Override + public boolean onTouchEvent(Component component, TouchEvent touchEvent) { + int action = touchEvent.getAction(); + MmiPoint point = touchEvent.getPointerPosition(touchEvent.getIndex()); + switch (action){ + case TouchEvent.PRIMARY_POINT_DOWN: + break; + case TouchEvent.POINT_MOVE: + break; + case TouchEvent.PRIMARY_POINT_UP: + break; + case TouchEvent.NONE: + case TouchEvent.CANCEL: + break; + default: + break; + } + return false; + } +``` \ No newline at end of file diff --git a/widget/PopupWindow.md b/widget/PopupWindow.md new file mode 100644 index 0000000..ad10bdf --- /dev/null +++ b/widget/PopupWindow.md @@ -0,0 +1,19 @@ + +# PopupDialog +* openharmony API: ohos.agp.window.dialog.PopupDialog; +* openharmony SDK版本:2.1.1.21 +* IDE版本:2.1.0.501 +* 实现方案: + +openharmony: + +``` java + PopupDialog popupDialog = new PopupDialog(context,null); + popupDialog.setCustomComponent(listView); + popupDialog.setDialogListener(new BaseDialog.DialogListener() { + @Override + public boolean isTouchOutside() { + return true; + } + }); +``` \ No newline at end of file -- Gitee From 3e1056e2e18c72180f8392cf374efc2fe2ae4804 Mon Sep 17 00:00:00 2001 From: wangguan Date: Fri, 11 Jun 2021 20:06:21 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E9=A6=96=E6=AC=A1=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- view/ViewPager.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 view/ViewPager.md diff --git a/view/ViewPager.md b/view/ViewPager.md new file mode 100644 index 0000000..0255410 --- /dev/null +++ b/view/ViewPager.md @@ -0,0 +1,13 @@ + +# PageSlider +* openharmony API: ohos.agp.components.PageSlider +* openharmony SDK版本:2.1.1.21 +* IDE版本:2.1.0.501 +* 实现方案: + +openharmony: + +``` java + bannerView = (PageSlider)findComponentById(ResourceTable.Id_page_slider); + bannerView.setProvider(new TabPagerProvider(this, titles)) +``` \ No newline at end of file -- Gitee From f4da6e6f9e497b2123c3204d3d0c0c4ff5dbf250 Mon Sep 17 00:00:00 2001 From: gaojianming108 Date: Fri, 11 Jun 2021 20:36:03 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=A7=BB=E6=A4=8D?= =?UTF-8?q?=E5=8C=96=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/ContentProvider.md | 109 ++++++++++++++++++++++++++++++ graphics/CornerPathEffect.md | 8 +++ graphics/Matrix.md | 52 ++++++++++++++ graphics/Path.md | 45 ++++++++++++ graphics/PointF.md | 20 ++++++ graphics/PorterDuffXfermode.md | 10 +++ graphics/RectF.md | 70 +++++++++++++++++++ support/v4/widget/DrawerLayout.md | 51 ++++++++++++++ text/TextUtils.md | 25 +++++++ util/SparseArray.md | 59 ++++++++++++++++ 10 files changed, 449 insertions(+) create mode 100644 content/ContentProvider.md create mode 100644 graphics/CornerPathEffect.md create mode 100644 graphics/Matrix.md create mode 100644 graphics/Path.md create mode 100644 graphics/PointF.md create mode 100644 graphics/PorterDuffXfermode.md create mode 100644 graphics/RectF.md create mode 100644 support/v4/widget/DrawerLayout.md create mode 100644 text/TextUtils.md create mode 100644 util/SparseArray.md diff --git a/content/ContentProvider.md b/content/ContentProvider.md new file mode 100644 index 0000000..6f0cc9c --- /dev/null +++ b/content/ContentProvider.md @@ -0,0 +1,109 @@ +### **insert** +>+ openharmony API: ohos.aafwk.ability.DataAbilityHelper.insert +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +DataAbilityHelper helper = DataAbilityHelper.creator(this); + +// 构造插入数据 +ValuesBucket valuesBucket = new ValuesBucket(); +valuesBucket.putString("name", "zhangsan"); +valuesBucket.putInteger("age", 18); +valuesBucket.putFloat("height", 172.0f); +helper.insert(uri, valuesBucket); + +``` + +### **query** +>+ openharmony API: ohos.aafwk.ability.DataAbilityHelper.query +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +DataAbilityHelper helper = DataAbilityHelper.creator(this); + +// 构造查询条件 +DataAbilityPredicates predicates = new DataAbilityPredicates(); +predicates.between("id", 1, 10); + +// 进行查询 +ResultSet resultSet = helper.query(uri, columns, predicates); + +``` + +### **update** +>+ openharmony API: ohos.aafwk.ability.DataAbilityHelper.update +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +DataAbilityHelper helper = DataAbilityHelper.creator(this); + +// 构造更新条件 +DataAbilityPredicates predicates = new DataAbilityPredicates(); +predicates.equalTo("id", 1); + +// 构造更新数据 +ValuesBucket valuesBucket = new ValuesBucket(); +valuesBucket.putString("name", "zhangsan"); +valuesBucket.putInteger("age", 18); +valuesBucket.putFloat("height", 172.0f); +helper.update(uri, valuesBucket, predicates); + +``` + +### **delete** +>+ openharmony API: ohos.aafwk.ability.DataAbilityHelper.delete +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +DataAbilityHelper helper = DataAbilityHelper.creator(this); + +// 构造删除条件 +DataAbilityPredicates predicates = new DataAbilityPredicates(); +predicates.between("id", 1, 10); +helper.delete(uri, predicates); + +``` + +### **bulkInsert** +>+ openharmony API: ohos.aafwk.ability.DataAbilityHelper.batchInsert +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +DataAbilityHelper helper = DataAbilityHelper.creator(this); + +// 构造插入数据 +ValuesBucket[] values = new ValuesBucket[2]; +values[0] = new ValuesBucket(); +values[0].putString("name", "zhangsan"); +values[0].putInteger("age", 18); +values[1] = new ValuesBucket(); +values[1].putString("name", "lisi"); +values[1].putInteger("age", 20); +helper.batchInsert(uri, values); + +``` + +### **applyBatch** +>+ openharmony API: ohos.aafwk.ability.DataAbilityHelper.executeBatch +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +DataAbilityHelper helper = DataAbilityHelper.creator(context, insertUri); + +// 构造批量操作 +ValuesBucket value1 = new ValuesBucket(); +DataAbilityOperation opt1 = DataAbilityOperation.newInsertBuilder(insertUri).withValuesBucket(value1).build(); +ValuesBucket value2 = new ValuesBucket(); +DataAbilityOperation opt2 = DataAbilityOperation.newInsertBuilder(insertUri).withValuesBucket(value2).build(); +List operations = new ArrayList<>(); +operations.add(opt1); +operations.add(opt2); +DataAbilityResult[] result = helper.executeBatch(insertUri, operations); + +``` diff --git a/graphics/CornerPathEffect.md b/graphics/CornerPathEffect.md new file mode 100644 index 0000000..5839a0f --- /dev/null +++ b/graphics/CornerPathEffect.md @@ -0,0 +1,8 @@ +### **CornerPathEffect(float)** +>+ openharmony API: `ohos.agp.render.PathEffect` +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +paint.setPathEffect(new PathEffect(10f)); +``` \ No newline at end of file diff --git a/graphics/Matrix.md b/graphics/Matrix.md new file mode 100644 index 0000000..6746e12 --- /dev/null +++ b/graphics/Matrix.md @@ -0,0 +1,52 @@ +### **setScale** +>+ openharmony API: ohos.agp.utils.Matrix.setScale +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +Matrix matrix = new Matrix(); +// 默认以左上角的点进行缩放矩阵 +matrix.setScale(0.5f, 0.5f); +// 以坐标点(100,100)为枢轴点进行缩放矩阵 +matrix.setScale(0.5f, 0.5f, 100f, 100f); + +``` + +### **setTranslate** +>+ openharmony API: ohos.agp.utils.Matrix.setTranslate +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +Matrix matrix = new Matrix(); +// 平移指定的距离 +matrix.setTranslate(100f, 100f); + +``` + +### **setSkew** +>+ openharmony API: ohos.agp.utils.Matrix.setSkew +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +Matrix matrix = new Matrix(); +// 设置水平错切和垂直错切的值为 0.3 +matrix.setSkew(0.3f, 0.3f); + +``` + +### **setRotate** +>+ openharmony API: ohos.agp.utils.Matrix.setRotate +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +Matrix matrix = new Matrix(); +// 默认以左上角为锚点进行旋转90度 +matrix.setRotate(90); +// 以指定坐标点进行旋转90度 +matrix.setRotate(90, 100f, 100f); + +``` + diff --git a/graphics/Path.md b/graphics/Path.md new file mode 100644 index 0000000..7b803e7 --- /dev/null +++ b/graphics/Path.md @@ -0,0 +1,45 @@ +### **moveTo** +>+ openharmony API: ohos.agp.render.Path.moveTo +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +Path path = new Path(); +path.moveTo(100f, 100f); + +``` + +### **lineTo** +>+ openharmony API: ohos.agp.render.Path.lineTo +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +Path path = new Path(); +path.lineTo(200f, 200f); + +``` + +### **setLastPoint** +>+ openharmony API: ohos.agp.render.Path.setLastPoint +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +Path path = new Path(); +path.setLastPoint(100f, 100f); +// 或者 +path.setLastPoint(new Point(100f, 100f)); + +``` + +### **addRect** +>+ openharmony API: ohos.agp.render.Path.addRect +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +Path path = new Path(); +path.addRect(new RectFloat(0f, 0f, 100f, 100f), Path.Direction.CLOCK_WISE); + +``` diff --git a/graphics/PointF.md b/graphics/PointF.md new file mode 100644 index 0000000..67f3951 --- /dev/null +++ b/graphics/PointF.md @@ -0,0 +1,20 @@ +### **PointF(float, float)** +>+ openharmony API: ohos.agp.utils.Point(float, float) +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +// 直接构建 +Point point = new Point(100f, 100f); +``` + +### **set** +>+ openharmony API: ohos.agp.utils.Point.modify +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +Point point = new Point(); +// 重新修改坐标点 +point.modify(100f, 100f); +``` diff --git a/graphics/PorterDuffXfermode.md b/graphics/PorterDuffXfermode.md new file mode 100644 index 0000000..c20a3dd --- /dev/null +++ b/graphics/PorterDuffXfermode.md @@ -0,0 +1,10 @@ +### **PorterDuffXfermode(PorterDuff.Mode)** +>+ openharmony API: ohos.agp.render.Canvas.PorterDuffMode +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +Canvas canvas = new Canvas(); +// 根据指定的混合模式画指定颜色 +canvas.drawColor(Color.BLUE.getValue(), Canvas.PorterDuffMode.SRC_OVER); +``` \ No newline at end of file diff --git a/graphics/RectF.md b/graphics/RectF.md new file mode 100644 index 0000000..151ceba --- /dev/null +++ b/graphics/RectF.md @@ -0,0 +1,70 @@ +### **RectF** +>+ openharmony API: ohos.agp.utils.RectFloat +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +// 通过坐标点直接构建 +RectFloat rectFloat = new RectFloat(0f, 0f, 100f, 100f); + +// 通过传入一个RectFloat进行构建 +RectFloat rectFloat2 = new RectFloat(new RectFloat(0f, 0f, 100f, 100f)); +``` + +### **width** +>+ openharmony API: ohos.agp.utils.RectFloat.getWidth +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +RectFloat rectFloat = new RectFloat(0f, 0f, 100f, 100f); +rectFloat.getWidth(); +``` + +### **height** +>+ openharmony API: ohos.agp.utils.RectFloat.getHeight +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +RectFloat rectFloat = new RectFloat(0f, 0f, 100f, 100f); +rectFloat.getHeight(); +``` + +### **centerX** +>+ openharmony API: ohos.agp.utils.RectFloat.getHeight +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +RectFloat rectFloat = new RectFloat(0f, 0f, 100f, 100f); +rectFloat.getHorizontalCenter(); +``` + +### **centerY** +>+ openharmony API: ohos.agp.utils.RectFloat.getHeight +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +RectFloat rectFloat = new RectFloat(0f, 0f, 100f, 100f); +rectFloat.getVerticalCenter(); +``` + +### **contains** +>+ openharmony API: ohos.agp.utils.RectFloat.isInclude +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +RectFloat rectFloat = new RectFloat(0f, 0f, 100f, 100f); +// 方式一 +rectFloat.isInclude(50f, 50f); +// 方式二 +rectFloat.isInclude(new Point(50f, 50f)); +// 方式三 +rectFloat.isInclude(new RectFloat(0f, 0f, 50f, 50f)); +// 方式四 +rectFloat.isInclude(0f, 0f, 50f, 50f); +``` + diff --git a/support/v4/widget/DrawerLayout.md b/support/v4/widget/DrawerLayout.md new file mode 100644 index 0000000..f03bf90 --- /dev/null +++ b/support/v4/widget/DrawerLayout.md @@ -0,0 +1,51 @@ +### **closeDrawer** +>+ openharmony API: ohos.agp.components.SlideDrawer.close(closeSmoothly) +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +// 不带动画直接关闭 +slideDrawer.close(); + +// 不带动画向指定方向关闭 +slideDrawer.close(SlideDrawer.SlideDirection.START); + +// 带动画效果的关闭方式 +slideDrawer.closeSmoothly(); + +// 带动画(指定动画时间)效果的关闭方式 +slideDrawer.closeSmoothly(350); + +// 带动画向指定方向关闭 +slideDrawer.closeSmoothly(SlideDrawer.SlideDirection.START); + +// 带动画(指定动画时间)向指定方向关闭 +slideDrawer.closeSmoothly(SlideDrawer.SlideDirection.START, 350); +``` + +### **openDrawer** +>+ openharmony API: ohos.agp.components.SlideDrawer.open(openSmoothly) +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +// 不带动画直接打开 +slideDrawer.open(); + +// 不带动画向指定方向打开 +slideDrawer.open(SlideDrawer.SlideDirection.START); + +// 带动画效果的打开方式 +slideDrawer.openSmoothly(); + +// 带动画(指定动画时间)效果的打开方式 +slideDrawer.openSmoothly(350); + +// 带动画向指定方向打开 +slideDrawer.openSmoothly(SlideDrawer.SlideDirection.START); + +// 带动画(指定动画时间)向指定方向打开 +slideDrawer.openSmoothly(SlideDrawer.SlideDirection.START, 350); +``` + + diff --git a/text/TextUtils.md b/text/TextUtils.md new file mode 100644 index 0000000..614eaff --- /dev/null +++ b/text/TextUtils.md @@ -0,0 +1,25 @@ +### **isEmpty** +>+ openharmony API: ohos.agp.utils.TextTool.isNullOrEmpty +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +String str = ""; +// 判断是否为空或者为null +TextTool.isNullOrEmpty(str); + +``` + +### **equals** +>+ openharmony API: ohos.agp.utils.TextTool.isEqual +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +String strA = "TestA"; +String strB = "TestB"; +// 判断是否相等 +TextTool.isEqual(strA, strB); + +``` + diff --git a/util/SparseArray.md b/util/SparseArray.md new file mode 100644 index 0000000..4ad24a2 --- /dev/null +++ b/util/SparseArray.md @@ -0,0 +1,59 @@ +### **put** +>+ openharmony API: ohos.utils.PlainArray.put +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +PlainArray plainArray = new PlainArray<>(); +plainArray.put(1, "A"); +``` + +### **append** +>+ openharmony API: ohos.utils.PlainArray.append +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +PlainArray plainArray = new PlainArray<>(); +plainArray.append(2,"B"); +``` + +### **remove** +>+ openharmony API: ohos.utils.PlainArray.remove +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +PlainArray plainArray = new PlainArray<>(); +plainArray.remove(1); +``` + +### **removeAt** +>+ openharmony API: ohos.utils.PlainArray.removeAt +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +PlainArray plainArray = new PlainArray<>(); +plainArray.removeAt(0); +``` + +### **contains** +>+ openharmony API: ohos.utils.PlainArray.contains +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +PlainArray plainArray = new PlainArray<>(); +plainArray.contains(1); +``` + +### **clear** +>+ openharmony API: ohos.utils.PlainArray.clear +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +PlainArray plainArray = new PlainArray<>(); +plainArray.clear(); +``` -- Gitee From a4bf2d41adb7e291bec27ee20af37cf5776e8533 Mon Sep 17 00:00:00 2001 From: gaojianming108 Date: Fri, 11 Jun 2021 20:39:14 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=A7=BB=E6=A4=8D?= =?UTF-8?q?=E5=8C=96=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- graphics/RectF.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/graphics/RectF.md b/graphics/RectF.md index 151ceba..2390def 100644 --- a/graphics/RectF.md +++ b/graphics/RectF.md @@ -32,7 +32,7 @@ rectFloat.getHeight(); ``` ### **centerX** ->+ openharmony API: ohos.agp.utils.RectFloat.getHeight +>+ openharmony API: ohos.agp.utils.RectFloat.getHorizontalCenter >+ openharmony SDK版本:2.1.1.21 以上 >+ IDE版本:2.1.0.501 >+ 实现方案:替换使用,使用方法如下: @@ -42,7 +42,7 @@ rectFloat.getHorizontalCenter(); ``` ### **centerY** ->+ openharmony API: ohos.agp.utils.RectFloat.getHeight +>+ openharmony API: ohos.agp.utils.RectFloat.getVerticalCenter >+ openharmony SDK版本:2.1.1.21 以上 >+ IDE版本:2.1.0.501 >+ 实现方案:替换使用,使用方法如下: -- Gitee From 4e390e74dc1d9fed7d97f3eec40ad58b8191df52 Mon Sep 17 00:00:00 2001 From: gaojianming108 Date: Fri, 11 Jun 2021 20:58:09 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=A7=BB=E6=A4=8D?= =?UTF-8?q?=E5=8C=96=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Activity.md | 29 +++++++++++++++++++++++++++++ app/ActivityManager.md | 18 ++++++++++++++++++ os/StatFs.md | 19 +++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 app/Activity.md create mode 100644 app/ActivityManager.md create mode 100644 os/StatFs.md diff --git a/app/Activity.md b/app/Activity.md new file mode 100644 index 0000000..5d7b9ce --- /dev/null +++ b/app/Activity.md @@ -0,0 +1,29 @@ +### **onConfigurationChanged 监听横竖屏切换** +>+ openharmony class:`ohos.aafwk.ability.Ability` +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.1.0.501 +>+ 实现方案: + +步骤一:在 `config.json` 中对 ability 增加属性配置 +```json +"abilities": [ + { + "configChanges": [ + "orientation" + ], + } +``` + +步骤二: 监听方向切换 +```java + @Override +protected void onOrientationChanged(AbilityInfo.DisplayOrientation displayOrientation) { + super.onOrientationChanged(displayOrientation); + if (displayOrientation.name().equals("PORTRAIT")) { + // + } else if (displayOrientation.name().equals("LANDSCAPE")) { + // + } + } + +``` diff --git a/app/ActivityManager.md b/app/ActivityManager.md new file mode 100644 index 0000000..4d3483b --- /dev/null +++ b/app/ActivityManager.md @@ -0,0 +1,18 @@ + +### **MemoryInfo** +>+ openharmony class:`ohos.aafwk.ability.SystemMemoryInfo` +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.1.0.501 +>+ 实现方案: + +* 原库实现 +```java +MemoryInfo memoryInfo = new MemoryInfo() ; +mActivityManager.getMemoryInfo(memoryInfo) ; +``` +* 替换实现 +```java +SystemMemoryInfo systemMemoryInfo = new SystemMemoryInfo(); +context.getAbilityManager().getSystemMemoryInfo(systemMemoryInfo); +``` + diff --git a/os/StatFs.md b/os/StatFs.md new file mode 100644 index 0000000..237b97e --- /dev/null +++ b/os/StatFs.md @@ -0,0 +1,19 @@ + +### **StatFs** +>+ openharmony class:`ohos.data.usage.StatVfs` +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.1.0.501 +>+ 实现方案:查询外置存储器的剩余空间 + +* 原库实现 +```java + File sdcardDir = Environment.getExternalStorageDirectory(); + StatFs sf = new StatFs(sdcardDir.getPath()); + return sf.getAvailableBlocks() * sf.getBlockSize(); +``` + +* 替换实现 +```java + StatVfs statVfs = new StatVfs(context.getExternalCacheDir().getAbsolutePath()); + return statVfs.getAvailableSpace(); +``` \ No newline at end of file -- Gitee