“10622ba3cf940c49127a95158e6a6a21c4a2dd98”上不存在“...gserver/git@gitcode.net:s920243400/PaddleDetection.git”
未验证 提交 5d4d1d73 编写于 作者: O openharmony_ci 提交者: Gitee

!18089 新增指定density查询功能

Merge pull request !18089 from zt147369/master
......@@ -640,7 +640,6 @@ getStringArrayValue(resource: Resource): Promise<Array<string>>
}
```
### getMediaContent<sup>9+</sup>
getMediaContent(resId: number, callback: AsyncCallback&lt;Uint8Array&gt;): void
......@@ -680,6 +679,45 @@ getMediaContent(resId: number, callback: AsyncCallback&lt;Uint8Array&gt;): void
}
```
### getMediaContent<sup>10+</sup>
getMediaContent(resId: number, density: number, callback: AsyncCallback&lt;Uint8Array&gt;): void
用户获取指定资源ID对应的指定屏幕密度媒体文件内容,使用callback形式返回字节数组。
**系统能力**:SystemCapability.Global.ResourceManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------- | ---- | ------------------ |
| resId | number | 是 | 资源ID值 |
| [density](#screendensity) | number | 是 | 资源获取需要的屏幕密度,0表示默认屏幕密度 |
| callback | AsyncCallback&lt;Uint8Array&gt; | 是 | 异步回调,用于返回获取的媒体文件内容 |
以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)
**错误码:**
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 9001001 | If the resId invalid. |
| 9001002 | If the resource not found by resId. |
**示例:**
```ts
try {
this.context.resourceManager.getMediaContent($r('app.media.test').id, 120, (error, value) => {
if (error != null) {
console.error(`callback getMediaContent failed, error code: ${error.code}, message: ${error.message}.`);
} else {
let media = value;
}
});
} catch (error) {
console.error(`callback getMediaContent failed, error code: ${error.code}, message: ${error.message}.`)
}
```
### getMediaContent<sup>9+</sup>
......@@ -723,6 +761,49 @@ getMediaContent(resId: number): Promise&lt;Uint8Array&gt;
}
```
### getMediaContent<sup>10+</sup>
getMediaContent(resId: number, density: number): Promise&lt;Uint8Array&gt;
用户获取指定资源ID对应的指定屏幕密度媒体文件内容,使用Promise形式返回字节数组。
**系统能力**:SystemCapability.Global.ResourceManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ------ | ---- | ----- |
| resId | number | 是 | 资源ID值 |
| [density](#screendensity) | number | 是 | 资源获取需要的屏幕密度,0表示默认屏幕密度 |
**返回值:**
| 类型 | 说明 |
| ------------------------- | -------------- |
| Promise&lt;Uint8Array&gt; | 资源ID值对应的媒体文件内容 |
以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)
**错误码:**
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 9001001 | If the resId invalid. |
| 9001002 | If the resource not found by resId. |
**示例:**
```ts
try {
this.context.resourceManager.getMediaContent($r('app.media.test').id, 120).then(value => {
let media = value;
}).catch(error => {
console.error(`promise getMediaContent failed, error code: ${error.code}, message: ${error.message}.`);
});
} catch (error) {
console.error(`promise getMediaContent failed, error code: ${error.code}, message: ${error.message}.`)
}
```
### getMediaContent<sup>9+</sup>
getMediaContent(resource: Resource, callback: AsyncCallback&lt;Uint8Array&gt;): void
......@@ -767,6 +848,51 @@ getMediaContent(resource: Resource, callback: AsyncCallback&lt;Uint8Array&gt;):
}
```
### getMediaContent<sup>10+</sup>
getMediaContent(resource: Resource, density: number, callback: AsyncCallback&lt;Uint8Array&gt;): void
用户获取指定resource对象对应的指定屏幕密度媒体文件内容,使用callback形式返回字节数组。
**系统能力**:SystemCapability.Global.ResourceManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------- | ---- | ------------------ |
| resource | [Resource](#resource9) | 是 | 资源信息 |
| [density](#screendensity) | number | 是 | 资源获取需要的屏幕密度,0表示默认屏幕密度 |
| callback | AsyncCallback&lt;Uint8Array&gt; | 是 | 异步回调,用于返回获取的媒体文件内容 |
以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)
**错误码:**
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 9001001 | If the resId invalid. |
| 9001002 | If the resource not found by resId. |
**示例:**
```ts
let resource = {
bundleName: "com.example.myapplication",
moduleName: "entry",
id: $r('app.media.test').id
};
try {
this.context.resourceManager.getMediaContent(resource, 120, (error, value) => {
if (error != null) {
console.error(`callback getMediaContent failed, error code: ${error.code}, message: ${error.message}.`);
} else {
let media = value;
}
});
} catch (error) {
console.error(`callback getMediaContent failed, error code: ${error.code}, message: ${error.message}.`)
}
```
### getMediaContent<sup>9+</sup>
getMediaContent(resource: Resource): Promise&lt;Uint8Array&gt;
......@@ -814,6 +940,53 @@ getMediaContent(resource: Resource): Promise&lt;Uint8Array&gt;
}
```
### getMediaContent<sup>10+</sup>
getMediaContent(resource: Resource, density: number): Promise&lt;Uint8Array&gt;
用户获取指定resource对象对应的指定屏幕密度媒体文件内容,使用Promise形式返回字节数组。
**系统能力**:SystemCapability.Global.ResourceManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | ---- |
| resource | [Resource](#resource9) | 是 | 资源信息 |
| [density](#screendensity) | number | 是 | 资源获取需要的屏幕密度,0表示默认屏幕密度 |
**返回值:**
| 类型 | 说明 |
| ------------------------- | ------------------- |
| Promise&lt;Uint8Array&gt; | resource对象对应的媒体文件内容 |
以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)
**错误码:**
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 9001001 | If the resId invalid. |
| 9001002 | If the resource not found by resId. |
**示例:**
```ts
let resource = {
bundleName: "com.example.myapplication",
moduleName: "entry",
id: $r('app.media.test').id
};
try {
this.context.resourceManager.getMediaContent(resource, 120).then(value => {
let media = value;
}).catch(error => {
console.error(`promise getMediaContent failed, error code: ${error.code}, message: ${error.message}.`);
});
} catch (error) {
console.error(`promise getMediaContent failed, error code: ${error.code}, message: ${error.message}.`)
}
```
### getMediaContentBase64<sup>9+</sup>
......@@ -854,6 +1027,45 @@ getMediaContentBase64(resId: number, callback: AsyncCallback&lt;string&gt;): voi
}
```
### getMediaContentBase64<sup>10+</sup>
getMediaContentBase64(resId: number, density: number, callback: AsyncCallback&lt;string&gt;): void
用户获取指定资源ID对应的指定屏幕密度图片资源Base64编码,使用callback形式返回字符串。
**系统能力**:SystemCapability.Global.ResourceManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ------------------------ |
| resId | number | 是 | 资源ID值 |
| [density](#screendensity) | number | 是 | 资源获取需要的屏幕密度,0表示默认屏幕密度 |
| callback | AsyncCallback&lt;string&gt; | 是 | 异步回调,用于返回获取的图片资源Base64编码 |
以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)
**错误码:**
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 9001001 | If the resId invalid. |
| 9001002 | If the resource not found by resId. |
**示例:**
```ts
try {
this.context.resourceManager.getMediaContentBase64($r('app.media.test').id, 120, (error, value) => {
if (error != null) {
console.error(`callback getMediaContentBase64 failed, error code: ${error.code}, message: ${error.message}.`);
} else {
let media = value;
}
});
} catch (error) {
console.error(`callback getMediaContentBase64 failed, error code: ${error.code}, message: ${error.message}.`)
}
```
### getMediaContentBase64<sup>9+</sup>
......@@ -897,6 +1109,49 @@ getMediaContentBase64(resId: number): Promise&lt;string&gt;
}
```
### getMediaContentBase64<sup>10+</sup>
getMediaContentBase64(resId: number, density: number): Promise&lt;string&gt;
用户获取指定资源ID对应的指定屏幕密度图片资源Base64编码,使用Promise形式返回字符串。
**系统能力**:SystemCapability.Global.ResourceManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ------ | ---- | ----- |
| resId | number | 是 | 资源ID值 |
| [density](#screendensity) | number | 是 | 资源获取需要的屏幕密度,0表示默认屏幕密度 |
**返回值:**
| 类型 | 说明 |
| --------------------- | -------------------- |
| Promise&lt;string&gt; | 资源ID值对应的图片资源Base64编码 |
以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)
**错误码:**
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 9001001 | If the resId invalid. |
| 9001002 | If the resource not found by resId. |
**示例:**
```ts
try {
this.context.resourceManager.getMediaContentBase64($r('app.media.test').id, 120).then(value => {
let media = value;
}).catch(error => {
console.error(`promise getMediaContentBase64 failed, error code: ${error.code}, message: ${error.message}.`);
});
} catch (error) {
console.error(`promise getMediaContentBase64 failed, error code: ${error.code}, message: ${error.message}.`)
}
```
### getMediaContentBase64<sup>9+</sup>
getMediaContentBase64(resource: Resource, callback: AsyncCallback&lt;string&gt;): void
......@@ -941,6 +1196,51 @@ getMediaContentBase64(resource: Resource, callback: AsyncCallback&lt;string&gt;)
}
```
### getMediaContentBase64<sup>10+</sup>
getMediaContentBase64(resource: Resource, density: number, callback: AsyncCallback&lt;string&gt;): void
用户获取指定resource对象对应的指定屏幕密度图片资源Base64编码,使用callback形式返回字符串。
**系统能力**:SystemCapability.Global.ResourceManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ------------------------ |
| resource | [Resource](#resource9) | 是 | 资源信息 |
| [density](#screendensity) | number | 是 | 资源获取需要的屏幕密度,0表示默认屏幕密度 |
| callback | AsyncCallback&lt;string&gt; | 是 | 异步回调,用于返回获取的图片资源Base64编码 |
以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)
**错误码:**
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 9001001 | If the resId invalid. |
| 9001002 | If the resource not found by resId. |
**示例:**
```ts
let resource = {
bundleName: "com.example.myapplication",
moduleName: "entry",
id: $r('app.media.test').id
};
try {
this.context.resourceManager.getMediaContentBase64(resource, 120, (error, value) => {
if (error != null) {
console.error(`promise getMediaContentBase64 failed, error code: ${error.code}, message: ${error.message}.`);
} else {
let media = value;
}
});
} catch (error) {
console.error(`promise getMediaContentBase64 failed, error code: ${error.code}, message: ${error.message}.`)
}
```
### getMediaContentBase64<sup>9+</sup>
getMediaContentBase64(resource: Resource): Promise&lt;string&gt;
......@@ -988,6 +1288,53 @@ getMediaContentBase64(resource: Resource): Promise&lt;string&gt;
}
```
### getMediaContentBase64<sup>10+</sup>
getMediaContentBase64(resource: Resource, density: number): Promise&lt;string&gt;
用户获取指定resource对象对应的指定屏幕密度图片资源Base64编码,使用Promise形式返回字符串。
**系统能力**:SystemCapability.Global.ResourceManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | ---- |
| resource | [Resource](#resource9) | 是 | 资源信息 |
| [density](#screendensity) | number | 是 | 资源获取需要的屏幕密度,0表示默认屏幕密度 |
**返回值:**
| 类型 | 说明 |
| --------------------- | ------------------------- |
| Promise&lt;string&gt; | resource对象对应的图片资源Base64编码 |
以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)
**错误码:**
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 9001001 | If the resId invalid. |
| 9001002 | If the resource not found by resId. |
**示例:**
```ts
let resource = {
bundleName: "com.example.myapplication",
moduleName: "entry",
id: $r('app.media.test').id
};
try {
this.context.resourceManager.getMediaContentBase64(resource, 120).then(value => {
let media = value;
}).catch(error => {
console.error(`promise getMediaContentBase64 failed, error code: ${error.code}, message: ${error.message}.`);
});
} catch (error) {
console.error(`promise getMediaContentBase64 failed, error code: ${error.code}, message: ${error.message}.`)
}
```
### getConfiguration
......@@ -1789,7 +2136,6 @@ getMediaByName(resName: string, callback: AsyncCallback&lt;Uint8Array&gt;): void
| -------- | ---------------------------------------- |
| 9001003 | If the resName invalid. |
| 9001004 | If the resource not found by resName. |
| 9001006 | If the resource re-ref too much. |
**示例:**
```ts
......@@ -1806,6 +2152,46 @@ getMediaByName(resName: string, callback: AsyncCallback&lt;Uint8Array&gt;): void
}
```
### getMediaByName<sup>10+</sup>
getMediaByName(resName: string, density: number, callback: AsyncCallback&lt;Uint8Array&gt;): void
用户获取指定资源ID对应的指定屏幕密度媒体文件内容,使用callback形式返回字节数组。
**系统能力**:SystemCapability.Global.ResourceManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------- | ---- | ------------------ |
| resName | string | 是 | 资源名称 |
| [density](#screendensity) | number | 是 | 资源获取需要的屏幕密度,0表示默认屏幕密度 |
| callback | AsyncCallback&lt;Uint8Array&gt; | 是 | 异步回调,用于返回获取的媒体文件内容 |
以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)
**错误码:**
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 9001003 | If the resName invalid. |
| 9001004 | If the resource not found by resName. |
**示例:**
```ts
try {
this.context.resourceManager.getMediaByName("test", 120, (error, value) => {
if (error != null) {
console.error(`callback getMediaByName failed, error code: ${error.code}, message: ${error.message}.`);
} else {
let media = value;
}
});
} catch (error) {
console.error(`callback getMediaByName failed, error code: ${error.code}, message: ${error.message}.`)
}
```
### getMediaByName<sup>9+</sup>
getMediaByName(resName: string): Promise&lt;Uint8Array&gt;
......@@ -1834,7 +2220,6 @@ getMediaByName(resName: string): Promise&lt;Uint8Array&gt;
| -------- | ---------------------------------------- |
| 9001003 | If the resName invalid. |
| 9001004 | If the resource not found by resName. |
| 9001006 | If the resource re-ref too much. |
**示例:**
```ts
......@@ -1849,6 +2234,49 @@ getMediaByName(resName: string): Promise&lt;Uint8Array&gt;
}
```
### getMediaByName<sup>10+</sup>
getMediaByName(resName: string, density: number): Promise&lt;Uint8Array&gt;
用户获取指定资源名称对应的指定屏幕密度媒体文件内容,使用Promise形式返回字节数组。
**系统能力**:SystemCapability.Global.ResourceManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | ---- |
| resName | string | 是 | 资源名称 |
| [density](#screendensity) | number | 是 | 资源获取需要的屏幕密度,0表示默认屏幕密度 |
**返回值:**
| 类型 | 说明 |
| ------------------------- | ------------- |
| Promise&lt;Uint8Array&gt; | 资源名称对应的媒体文件内容 |
以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)
**错误码:**
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 9001003 | If the resName invalid. |
| 9001004 | If the resource not found by resName. |
**示例:**
```ts
try {
this.context.resourceManager.getMediaByName("test", 120).then(value => {
let media = value;
}).catch(error => {
console.error(`promise getMediaByName failed, error code: ${error.code}, message: ${error.message}.`);
});
} catch (error) {
console.error(`promise getMediaByName failed, error code: ${error.code}, message: ${error.message}.`)
}
```
### getMediaBase64ByName<sup>9+</sup>
getMediaBase64ByName(resName: string, callback: AsyncCallback&lt;string&gt;): void
......@@ -1872,7 +2300,6 @@ getMediaBase64ByName(resName: string, callback: AsyncCallback&lt;string&gt;): vo
| -------- | ---------------------------------------- |
| 9001003 | If the resName invalid. |
| 9001004 | If the resource not found by resName. |
| 9001006 | If the resource re-ref too much. |
**示例:**
```ts
......@@ -1889,6 +2316,46 @@ getMediaBase64ByName(resName: string, callback: AsyncCallback&lt;string&gt;): vo
}
```
### getMediaBase64ByName<sup>10+</sup>
getMediaBase64ByName(resName: string, density: number, callback: AsyncCallback&lt;string&gt;): void
用户获取指定资源名称对应的指定屏幕密度图片资源Base64编码,使用callback形式返回字符串。
**系统能力**:SystemCapability.Global.ResourceManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ------------------------ |
| resName | string | 是 | 资源名称 |
| [density](#screendensity) | number | 是 | 资源获取需要的屏幕密度,0表示默认屏幕密度 |
| callback | AsyncCallback&lt;string&gt; | 是 | 异步回调,用于返回获取的图片资源Base64编码 |
以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)
**错误码:**
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 9001003 | If the resName invalid. |
| 9001004 | If the resource not found by resName. |
**示例:**
```ts
try {
this.context.resourceManager.getMediaBase64ByName("test", 120, (error, value) => {
if (error != null) {
console.error(`callback getMediaBase64ByName failed, error code: ${error.code}, message: ${error.message}.`);
} else {
let media = value;
}
});
} catch (error) {
console.error(`callback getMediaBase64ByName failed, error code: ${error.code}, message: ${error.message}.`)
}
```
### getMediaBase64ByName<sup>9+</sup>
getMediaBase64ByName(resName: string): Promise&lt;string&gt;
......@@ -1917,7 +2384,6 @@ getMediaBase64ByName(resName: string): Promise&lt;string&gt;
| -------- | ---------------------------------------- |
| 9001003 | If the resName invalid. |
| 9001004 | If the resource not found by resName. |
| 9001006 | If the resource re-ref too much. |
**示例:**
```ts
......@@ -1932,6 +2398,49 @@ getMediaBase64ByName(resName: string): Promise&lt;string&gt;
}
```
### getMediaBase64ByName<sup>10+</sup>
getMediaBase64ByName(resName: string, density: number): Promise&lt;string&gt;
用户获取指定资源名称对应的指定屏幕密度图片资源Base64编码,使用Promise形式返回字符串。
**系统能力**:SystemCapability.Global.ResourceManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | ---- |
| resName | string | 是 | 资源名称 |
| [density](#screendensity) | number | 是 | 资源获取需要的屏幕密度,0表示默认屏幕密度 |
**返回值:**
| 类型 | 说明 |
| --------------------- | ------------------- |
| Promise&lt;string&gt; | 资源名称对应的图片资源Base64编码 |
以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)
**错误码:**
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 9001003 | If the resName invalid. |
| 9001004 | If the resource not found by resName. |
**示例:**
```ts
try {
this.context.resourceManager.getMediaBase64ByName("test", 120).then(value => {
let media = value;
}).catch(error => {
console.error(`promise getMediaBase64ByName failed, error code: ${error.code}, message: ${error.message}.`);
});
} catch (error) {
console.error(`promise getMediaBase64ByName failed, error code: ${error.code}, message: ${error.message}.`)
}
```
### getPluralStringByName<sup>9+</sup>
getPluralStringByName(resName: string, num: number, callback: AsyncCallback&lt;string&gt;): void
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册