提交 4904bc23 编写于 作者: Z z00514981 提交者: ZhengJiangliang

fixed e67888d3 from https://gitee.com/zheng-jiangliang-windowmanager/docs/pulls/20984

bindDialogTarget接口示例代码更新
Signed-off-by: Nz00514981 <zhengjiangliang@huawei.com>
Change-Id: Icd36005256ce0bed86f3f3063ee93aa0afe3b23a
上级 96b5b6c7
...@@ -3063,7 +3063,16 @@ class TestRemoteObject extends rpc.RemoteObject { ...@@ -3063,7 +3063,16 @@ class TestRemoteObject extends rpc.RemoteObject {
} }
let token = new TestRemoteObject('testObject'); let token = new TestRemoteObject('testObject');
let windowClass = null;
let config = {name: "dialogWindow", windowType: window.WindowType.TYPE_DIALOG, ctx: this.context};
try { try {
window.createWindow(config, (err, data) => {
if (err.code) {
console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
return;
}
windowClass = data;
});
windowClass.bindDialogTarget(token, () => { windowClass.bindDialogTarget(token, () => {
console.info('Dialog Window Need Destroy.'); console.info('Dialog Window Need Destroy.');
}, (err) => { }, (err) => {
...@@ -3136,7 +3145,16 @@ class TestRemoteObject extends rpc.RemoteObject { ...@@ -3136,7 +3145,16 @@ class TestRemoteObject extends rpc.RemoteObject {
} }
let token = new TestRemoteObject('testObject'); let token = new TestRemoteObject('testObject');
let windowClass = null;
let config = {name: "dialogWindow", windowType: window.WindowType.TYPE_DIALOG, ctx: this.context};
try { try {
window.createWindow(config, (err, data) => {
if (err.code) {
console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
return;
}
windowClass = data;
});
let promise = windowClass.bindDialogTarget(token, () => { let promise = windowClass.bindDialogTarget(token, () => {
console.info('Dialog Window Need Destroy.'); console.info('Dialog Window Need Destroy.');
}); });
...@@ -3192,7 +3210,16 @@ export default class ServiceExtAbility extends ServiceExtensionAbility { ...@@ -3192,7 +3210,16 @@ export default class ServiceExtAbility extends ServiceExtensionAbility {
onRequest(want, startId) { onRequest(want, startId) {
console.info('onRequest'); console.info('onRequest');
let windowClass = null;
let config = {name: "dialogWindow", windowType: window.WindowType.TYPE_DIALOG, ctx: this.context};
try { try {
window.createWindow(config, (err, data) => {
if (err.code) {
console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
return;
}
windowClass = data;
});
let requestInfo = dialogRequest.getRequestInfo(want) let requestInfo = dialogRequest.getRequestInfo(want)
windowClass.bindDialogTarget(requestInfo, () => { windowClass.bindDialogTarget(requestInfo, () => {
console.info('Dialog Window Need Destroy.'); console.info('Dialog Window Need Destroy.');
...@@ -3204,7 +3231,7 @@ export default class ServiceExtAbility extends ServiceExtensionAbility { ...@@ -3204,7 +3231,7 @@ export default class ServiceExtAbility extends ServiceExtensionAbility {
console.info('Succeeded in binding dialog target.'); console.info('Succeeded in binding dialog target.');
}); });
} catch(err) { } catch(err) {
console.error('getRequestInfo err = ' + JSON.stringify(err)) console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err))
} }
} }
...@@ -3269,7 +3296,16 @@ export default class ServiceExtAbility extends ServiceExtensionAbility { ...@@ -3269,7 +3296,16 @@ export default class ServiceExtAbility extends ServiceExtensionAbility {
onRequest(want, startId) { onRequest(want, startId) {
console.info('onRequest'); console.info('onRequest');
let windowClass = null;
let config = {name: "dialogWindow", windowType: window.WindowType.TYPE_DIALOG, ctx: this.context};
try { try {
window.createWindow(config, (err, data) => {
if (err.code) {
console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
return;
}
windowClass = data;
});
let requestInfo = dialogRequest.getRequestInfo(want) let requestInfo = dialogRequest.getRequestInfo(want)
let promise = windowClass.bindDialogTarget(requestInfo, () => { let promise = windowClass.bindDialogTarget(requestInfo, () => {
console.info('Dialog Window Need Destroy.'); console.info('Dialog Window Need Destroy.');
...@@ -3280,7 +3316,7 @@ export default class ServiceExtAbility extends ServiceExtensionAbility { ...@@ -3280,7 +3316,7 @@ export default class ServiceExtAbility extends ServiceExtensionAbility {
console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err)); console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err));
}); });
} catch(err) { } catch(err) {
console.error('getRequestInfo err = ' + JSON.stringify(err)) console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err))
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册