提交 c23213c4 编写于 作者: H huweiqi

demo update

Signed-off-by: Nhuweiqi <huweiqi1@huawei.com>
Change-Id: I29fe39789981bd5de5b2b2aa71695579c0cb2140
上级 f52b512f
......@@ -446,7 +446,7 @@ async function example() {
let photoType = photoAccessHelper.PhotoType.IMAGE;
let extension = 'jpg';
phAccessHelper.createAsset(photoType, extension, (err, uri) => {
if (photoAsset != undefined) {
if (uri != undefined) {
console.info('createAsset uri' + uri);
console.info('createAsset successfully');
} else {
......@@ -2856,10 +2856,10 @@ getAssets(options: FetchOptions, callback: AsyncCallback&lt;FetchResult&lt;Photo
import dataSharePredicates from '@ohos.data.dataSharePredicates';
async function example() {
console.info('albumGetPhotoAssetsDemoCallback');
console.info('albumGetAssetsDemoCallback');
let predicates = new dataSharePredicates.DataSharePredicates();
let albumFetchOptions = {
fetchColumns: [],
predicates: predicates
};
let fetchOption = {
......@@ -2914,10 +2914,11 @@ getAssets(options: FetchOptions): Promise&lt;FetchResult&lt;PhotoAsset&gt;&gt;;
import dataSharePredicates from '@ohos.data.dataSharePredicates';
async function example() {
console.info('albumGetPhotoAssetsDemoPromise');
console.info('albumGetAssetsDemoPromise');
let predicates = new dataSharePredicates.DataSharePredicates();
let albumFetchOptions = {
fetchColumns: [],
predicates: predicates
};
let fetchOption = {
......@@ -2967,6 +2968,7 @@ async function example() {
console.info('albumCommitModifyDemo');
let predicates = new dataSharePredicates.DataSharePredicates();
let albumFetchOptions = {
fetchColumns: [],
predicates: predicates
};
const albumList = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, albumFetchOptions);
......@@ -3015,6 +3017,7 @@ async function example() {
console.info('albumCommitModifyDemo');
let predicates = new dataSharePredicates.DataSharePredicates();
let albumFetchOptions = {
fetchColumns: [],
predicates: predicates
};
const albumList = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, albumFetchOptions);
......@@ -3496,6 +3499,131 @@ async function example() {
}
```
### setCoverUri
setCoverUri(uri: string, callback: AsyncCallback&lt;void&gt;): void;
设置相册封面,该方法使用callback形式来返回结果。
**注意**:此接口只可修改用户相册封面,不允许修改系统相册封面。
**系统接口**:此接口为系统接口。
**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ---------- |
| uri | string | 是 | 待设置为相册封面文件的uri。 |
| callback | AsyncCallback&lt;void&gt; | 是 | callback返回void。 |
**错误码:**
接口抛出错误码的详细介绍请参见[通用错误码](../errorcodes/errorcode-universal.md)
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 202 | Called by non-system application. |
| 401 | if parameter is invalid. |
**示例:**
```ts
import dataSharePredicates from '@ohos.data.dataSharePredicates';
async function example() {
try {
console.info('setCoverUriDemoCallback');
let predicates = new dataSharePredicates.DataSharePredicates();
let fetchOption = {
fetchColumns: [],
predicates: predicates
};
let albumFetchResult = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
let album = await albumFetchResult.getFirstObject();
let fetchResult = await album.getAssets(fetchOption);
let asset = await fetchResult.getFirstObject();
album.setCoverUri(asset.uri, (err) => {
if (err === undefined) {
console.info('album setCoverUri successfully');
} else {
console.error('album setCoverUri failed with error: ' + err);
}
});
} catch (err) {
console.error('setCoverUriDemoCallback failed with error: ' + err);
}
}
```
### setCoverUri
setCoverUri(uri: string): Promise&lt;void&gt;;
设置相册封面,该方法使用Promise来返回结果。
**注意**:此接口只可修改用户相册封面,不允许修改系统相册封面。
**系统接口**:此接口为系统接口。
**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ---------- |
| uri | string | 是 | 待设置为相册封面文件的uri。 |
**返回值:**
| 类型 | 说明 |
| --------------------------------------- | ----------------- |
|Promise&lt;void&gt; | Promise对象,返回void。 |
**错误码:**
接口抛出错误码的详细介绍请参见[通用错误码](../errorcodes/errorcode-universal.md)
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 202 | Called by non-system application. |
| 401 | if parameter is invalid. |
**示例:**
```ts
import dataSharePredicates from '@ohos.data.dataSharePredicates';
async function example() {
try {
console.info('setCoverUriDemoCallback');
let predicates = new dataSharePredicates.DataSharePredicates();
let fetchOption = {
fetchColumns: [],
predicates: predicates
};
let albumFetchResult = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
let album = await albumFetchResult.getFirstObject();
let fetchResult = await album.getAssets(fetchOption);
let asset = await fetchResult.getFirstObject();
album.setCoverUri(asset.uri, (err) => {
if (err === undefined) {
console.info('album setCoverUri successfully');
} else {
console.error('album setCoverUri failed with error: ' + err);
}
});
} catch (err) {
console.error('setCoverUriDemoCallback failed with error: ' + err);
}
}
```
## MemberType
成员类型。
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册