source stringlengths 14 113 | code stringlengths 10 21.3k |
|---|---|
application-dev\network\net-vpnExtension.md | // Assume that the VNP application is named MyVpnExtAbility. Define it in module.json5.
"extensionAbilities": [
{
"name": "MyVpnExtAbility",
"description": "vpnservice",
"type": "vpn",
"srcEntry": "./ets/serviceextability/MyVpnExtAbility.ts"
}
] |
application-dev\network\net-vpnExtension.md | import { common, Want } from '@kit.AbilityKit';
import { vpnExtension } from '@kit.NetworkKit';
let want: Want = {
deviceId: "",
bundleName: "com.example.myvpndemo",
abilityName: "MyVpnExtAbility",
};
@Entry
@Component
struct Index {
@State message: string = 'Hello World';
build() {
Row() {
Colum... |
application-dev\network\net-vpnExtension.md | import { common, Want } from '@kit.AbilityKit';
import { vpnExtension } from '@kit.NetworkKit';
let want: Want = {
deviceId: "",
bundleName: "com.example.myvpndemo",
abilityName: "MyVpnExtAbility",
};
@Entry
@Component
struct Index {
@State message: string = 'Hello World';
build() {
Row() {
Colum... |
application-dev\network\net-vpnExtension.md | import { vpnExtension, VpnExtensionAbility } from '@kit.NetworkKit';
import { common, Want } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
let context: vpnExtension.VpnExtensionContext;
export default class MyVpnExtAbility extends VpnExtensionAbility {
onDestroy() {
let VpnConnec... |
application-dev\network\net-vpnExtension.md | import { vpnExtension} from '@kit.NetworkKit';
let vpnConfig: vpnExtension.VpnConfig = {
// Configure the IP address of the vNIC.
addresses: [{
address: {
address:'192.x.x.5',
family:1
},
prefixLength:24
}],
// Configure route information.
routes: [{
// Set the name of the vNIC, w... |
application-dev\network\socket-connection.md | import { socket } from '@kit.NetworkKit';
import { BusinessError } from '@kit.BasicServicesKit';
class SocketInfo {
message: ArrayBuffer = new ArrayBuffer(1);
remoteInfo: socket.SocketRemoteInfo = {} as socket.SocketRemoteInfo;
}
// Create a TCP socket connection. A TCPSocket object is returned.
let tcp: socket.TC... |
application-dev\network\socket-connection.md | import { socket } from '@kit.NetworkKit';
import { BusinessError } from '@kit.BasicServicesKit';
// Create a TCP socket server connection. A TCPSocketServer object is returned.
let tcpServer: socket.TCPSocketServer = socket.constructTCPSocketServerInstance();
// Bind the local IP address and port number for listening.... |
application-dev\network\socket-connection.md | import { socket } from '@kit.NetworkKit';
// Create a MulticastSocket object.
let multicast: socket.MulticastSocket = socket.constructMulticastSocketInstance();
let addr : socket.NetAddress = {
address: '239.255.0.1',
port: 32123,
family: 1
}
// Add the MulticastSocket object to a multicast group.
multicast.ad... |
application-dev\network\socket-connection.md | import { socket } from '@kit.NetworkKit';
import { common } from '@kit.AbilityKit';
// Create a local socket connection. A LocalSocket object is returned.
let client: socket.LocalSocket = socket.constructLocalSocketInstance();
client.on('message', (value: socket.LocalSocketMessageInfo) => {
const uintArray = new Uin... |
application-dev\network\socket-connection.md | import { socket } from '@kit.NetworkKit';
import { common } from '@kit.AbilityKit';
// Create a local socket server connection. A LocalSocketServer object is returned.
let server: socket.LocalSocketServer = socket.constructLocalSocketServerInstance();
// Create and bind the local socket file testSocket for listening.
... |
application-dev\network\socket-connection.md | import { socket } from '@kit.NetworkKit';
import { BusinessError } from '@kit.BasicServicesKit';
class SocketInfo {
message: ArrayBuffer = new ArrayBuffer(1);
remoteInfo: socket.SocketRemoteInfo = {} as socket.SocketRemoteInfo;
}
// Create a TLS socket connection (for two-way authentication). A TLSSocketConnection... |
application-dev\network\socket-connection.md | import { socket } from '@kit.NetworkKit';
import { BusinessError } from '@kit.BasicServicesKit';
class SocketInfo {
message: ArrayBuffer = new ArrayBuffer(1);
remoteInfo: socket.SocketRemoteInfo = {} as socket.SocketRemoteInfo;
}
// Create a TCP socket connection. A TCPSocket object is returned.
let tcp: socket.T... |
application-dev\network\socket-connection.md | import { socket } from '@kit.NetworkKit';
import { BusinessError } from '@kit.BasicServicesKit';
let tlsServer: socket.TLSSocketServer = socket.constructTLSSocketServerInstance();
let netAddress: socket.NetAddress = {
address: '192.168.xx.xxx',
port: 8080
}
let tlsSecureOptions: socket.TLSSecureOptions = {
key... |
application-dev\notification\live-view-notification.md | import { notificationManager } from '@kit.NotificationKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { image } from '@kit.ImageKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
const TAG: string = '[PublishOperation]';
const DOMAIN_NUMBER: number = 0xFF00; |
application-dev\notification\live-view-notification.md | let imagePixelMap: image.PixelMap | undefined = undefined; // Obtain the image pixel map information.
let color = new ArrayBuffer(4);
imagePixelMap = await image.createPixelMap(color, {
size: {
height: 1,
width: 1
}
})
if(imagePixelMap !== undefined) {
... |
application-dev\notification\notification-badge.md | import { notificationManager } from '@kit.NotificationKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { BusinessError } from '@kit.BasicServicesKit';
const TAG: string = '[PublishOperation]';
const DOMAIN_NUMBER: number = 0xFF00; |
application-dev\notification\notification-badge.md | let setBadgeNumberCallback = (err: BusinessError): void => {
if (err) {
hilog.error(DOMAIN_NUMBER, TAG, `Failed to set badge number. Code is ${err.code}, message is ${err.message}`);
return;
}
hilog.info(DOMAIN_NUMBER, TAG, `Succeeded in setting badge number.`);
}
let badgeNum... |
application-dev\notification\notification-badge.md | let setBadgeNumberCallback = (err: BusinessError): void => {
if (err) {
hilog.error(DOMAIN_NUMBER, TAG, `Failed to set badge number. Code is ${err.code}, message is ${err.message}`);
return;
}
hilog.info(DOMAIN_NUMBER, TAG, `Succeeded in setting badge number.`);
}
let badgeNum... |
application-dev\notification\notification-badge.md | let badgeNumber: number = 10;
notificationManager.setBadgeNumber(badgeNumber).then(() => {
hilog.info(DOMAIN_NUMBER, TAG, `setBadgeNumber 10 success.`);
});
badgeNumber = 11;
notificationManager.setBadgeNumber(badgeNumber).then(() => {
hilog.info(DOMAIN_NUMBER, TAG, `setBadgeNumber 11 succes... |
application-dev\notification\notification-badge.md | let badgeNumber: number = 10;
notificationManager.setBadgeNumber(badgeNumber).then(() => {
hilog.info(DOMAIN_NUMBER, TAG, `setBadgeNumber 10 success.`);
badgeNumber = 11;
notificationManager.setBadgeNumber(badgeNumber).then(() => {
hilog.info(DOMAIN_NUMBER, TAG, `setBadgeNumber 11 success.... |
application-dev\notification\notification-cancel.md | import { notificationManager } from '@kit.NotificationKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
const TAG: string = '[PublishOperation]';
const DOMAIN_NUMBER: number = 0xFF00; |
application-dev\notification\notification-cancel.md | // After the application is started in the foreground and the message is viewed, call this API to cancel the notification.
notificationManager.cancel(1, (err: BusinessError) => {
if (err) {
hilog.error(DOMAIN_NUMBER, TAG, `Failed to cancel notification. Code is ${err.code}, message is ${err.message}`)... |
application-dev\notification\notification-enable.md | import { notificationManager } from '@kit.NotificationKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { common } from '@kit.AbilityKit';
const TAG: string = '[PublishOperation]';
const DOMAIN_NUMBER: number = 0xFF00; |
application-dev\notification\notification-enable.md | let context = this.getUIContext().getHostContext() as common.UIAbilityContext;
notificationManager.isNotificationEnabled().then((data: boolean) => {
hilog.info(DOMAIN_NUMBER, TAG, "isNotificationEnabled success, data: " + JSON.stringify(data));
if(!data){
notificationManager.requestEnableNotific... |
application-dev\notification\notification-slot.md | import { notificationManager } from '@kit.NotificationKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
const TAG: string = '[PublishOperation]';
const DOMAIN_NUMBER: number = 0xFF00; |
application-dev\notification\notification-slot.md | // addSlot callback
let addSlotCallBack = (err: BusinessError): void => {
if (err) {
hilog.error(DOMAIN_NUMBER, TAG, `addSlot failed, code is ${err.code}, message is ${err.message}`);
} else {
hilog.info(DOMAIN_NUMBER, TAG, `addSlot success`);
}
}
notificationManager.addSlo... |
application-dev\notification\notification-slot.md | // getSlot callback
let getSlotCallback = (err: BusinessError, data: notificationManager.NotificationSlot): void => {
if (err) {
hilog.error(DOMAIN_NUMBER, TAG, `Failed to get slot. Code is ${err.code}, message is ${err.message}`);
} else {
hilog.info(DOMAIN_NUMBER, TAG, `Succeeded in ge... |
application-dev\notification\notification-slot.md | // removeSlot callback
let removeSlotCallback = (err: BusinessError): void => {
if (err) {
hilog.error(DOMAIN_NUMBER, TAG, `removeSlot failed, code is ${JSON.stringify(err.code)}, message is ${JSON.stringify(err.message)}`);
} else {
hilog.info(DOMAIN_NUMBER, TAG, "removeSlot success");
... |
application-dev\notification\notification-subscription.md | import { notificationSubscribe, notificationManager } from '@kit.NotificationKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
const TAG: string = '[SubscribeOperations]';
const DOMAIN_NUMBER: number = 0xFF00; |
application-dev\notification\notification-subscription.md | let subscriber:notificationSubscribe.NotificationSubscriber = {
onConsume: (data:notificationSubscribe.SubscribeCallbackData) => {
let req: notificationManager.NotificationRequest = data.request;
hilog.info(DOMAIN_NUMBER, TAG, `onConsume callback. req.id: ${req.id}`);
},
onCancel: (data:not... |
application-dev\notification\notification-subscription.md | notificationSubscribe.subscribe(subscriber, (err: BusinessError) => { // This API uses an asynchronous callback to return the result.
if (err) {
hilog.error(DOMAIN_NUMBER, TAG, `Failed to subscribe notification. Code is ${err.code}, message is ${err.message}`);
return;
}
}); |
application-dev\notification\notification-update.md | import { notificationManager } from '@kit.NotificationKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
const TAG: string = '[PublishOperation]';
const DOMAIN_NUMBER: number = 0xFF00; |
application-dev\notification\notification-update.md | let notificationRequest: notificationManager.NotificationRequest = {
id: 5,
content: {
notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: 'test_title',
text: 'test_text',
additionalText: 'test_additionalText'
... |
application-dev\notification\notification-update.md | let notificationRequest: notificationManager.NotificationRequest = {
id: 5,
updateOnly: true,
content: {
notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: 'test_title',
text: 'test_text',
additionalText: 'te... |
application-dev\notification\progress-bar-notification.md | import { notificationManager } from '@kit.NotificationKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
const TAG: string = '[PublishOperation]';
const DOMAIN_NUMBER: number = 0xFF00; |
application-dev\notification\progress-bar-notification.md | notificationManager.isSupportTemplate('downloadTemplate').then((data:boolean) => {
hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in supporting download template notification.');
let isSupportTpl: boolean = data; // The value true means that the template of the downloadTemplate type is supported, and false means t... |
application-dev\notification\progress-bar-notification.md | let notificationRequest: notificationManager.NotificationRequest = {
id: 5,
content: {
notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: 'test_title',
text: 'test_text',
additionalText: 'test_additionalText'
... |
application-dev\notification\text-notification.md | import { notificationManager } from '@kit.NotificationKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
const TAG: string = '[PublishOperation]';
const DOMAIN_NUMBER: number = 0xFF00; |
application-dev\notification\text-notification.md | let notificationRequest: notificationManager.NotificationRequest = {
id: 1,
content: {
notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, // Basic notification
normal: {
title: 'test_title',
text: 'test_text',
... |
application-dev\notification\text-notification.md | let notificationRequest: notificationManager.NotificationRequest = {
id: 3,
content: {
notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_MULTILINE, // Multi-line text notification
multiLine: {
title: 'test_title',
text: 'test_text',... |
application-dev\onlyfortest\reference\apis-media-kit\errorcode-media.md | const matches = navigator.userAgent.match(/OpenHarmony (\d+\.?\d*)/);
matches?.length && Number(matches[1]) >= 5; |
application-dev\onlyfortest\reference\apis-media-kit\errorcode-media.md | const isOpenHarmony = () => /OpenHarmony/i.test(navigator.userAgent); |
application-dev\onlyfortest\reference\apis-media-kit\errorcode-media.md | import { taskpool } from '@kit.ArkTS';
@Concurrent
async function testPromiseError() {
await new Promise<number>((resolve, reject) => {
resolve(1);
}).then(()=>{
throw new Error('testPromise Error');
})
}
@Concurrent
async function testPromiseError1() {
await new Promise<string>((resolve, reject) => {... |
application-dev\onlyfortest\reference\apis-media-kit\errorcode-media.md | export function testAdd(arg: number) {
return ++arg;
}
@Sendable
export class MyTestA {
constructor(name: string) {
this.name = name;
}
name: string = 'MyTestA';
}
export class MyTestB {
static nameStr:string = 'MyTestB';
} |
application-dev\onlyfortest\reference\apis-media-kit\errorcode-media.md | import { taskpool } from '@kit.ArkTS';
@Concurrent
function add(num1: number, num2: number): number {
return num1 + num2;
}
async function ConcurrentFunc(): Promise<void> {
try {
let task: taskpool.Task = new taskpool.Task(add, 1, 2);
console.info("taskpool res is: " + await taskpool.execute(task));
} c... |
application-dev\performance\application-performance-analysis.md | import hidebug from '@ohos.hidebug';
// The parameter is the name of the output file. No suffix is required. This parameter is mandatory.
hidebug.startJsCpuProfiling("filename");
// Code block
// ...
// Code block
hidebug.stopJsCpuProfiling("filename"); |
application-dev\performance\arkts-performance-improvement-recommendation.md | @Entry
@Component
struct MyComponent {
@State arr: number[] = Array.from(Array<number>(100), (v:number,k:number) =>k); // Construct an array of 0 to 99.
build() {
List() {
ForEach(this.arr, (item: number) => {
ListItem() {
Text(`item value: ${item}`)
}
}, (item: number) =>... |
application-dev\performance\arkts-performance-improvement-recommendation.md | class BasicDataSource implements IDataSource {
private listeners: DataChangeListener[] = [];
private originDataArray: string[] = [];
public totalCount(): number {
return 0;
}
public getData(index: number): string {
return this.originDataArray[index];
}
registerDataChangeListener(listener: DataC... |
application-dev\performance\arkts-performance-improvement-recommendation.md | class BasicDataSource implements IDataSource {
private listeners: DataChangeListener[] = [];
private originDataArray: string[] = [];
public totalCount(): number {
return 0;
}
public getData(index: number): string {
return this.originDataArray[index];
}
registerDataChangeListener(listener: DataC... |
application-dev\performance\arkts-performance-improvement-recommendation.md | class BasicDataSource implements IDataSource {
private listeners: DataChangeListener[] = [];
private originDataArray: string[] = [];
public totalCount(): number {
return 0;
}
public getData(index: number): string {
return this.originDataArray[index];
}
registerDataChangeListener(listener: DataC... |
application-dev\performance\arkts-performance-improvement-recommendation.md | @Entry
@Component
struct MyComponent {
@State isVisible: Visibility = Visibility.Visible;
build() {
Column() {
Button ("Show/Hide")
.onClick(() => {
if (this.isVisible == Visibility.Visible) {
this.isVisible = Visibility.None
} else {
this.isVisible = V... |
application-dev\performance\arkts-performance-improvement-recommendation.md | @Entry
@Component
struct MyComponent {
@State isVisible: boolean = true;
build() {
Column() {
Button ("Show/Hide")
.onClick(() => {
this.isVisible = !this.isVisible
})
if (this.isVisible) {
Row()
.width(300).height(300).backgroundColor(Color.Pink)
}... |
application-dev\performance\arkts-performance-improvement-recommendation.md | @Entry
@Component
struct MyComponent {
build() {
Flex({ direction: FlexDirection.Column }) {
Flex().width(300).height(200).backgroundColor(Color.Pink)
Flex().width(300).height(200).backgroundColor(Color.Yellow)
Flex().width(300).height(200).backgroundColor(Color.Grey)
}
}
} |
application-dev\performance\arkts-performance-improvement-recommendation.md | @Entry
@Component
struct MyComponent {
build() {
Column() {
Row().width(300).height(200).backgroundColor(Color.Pink)
Row().width(300).height(200).backgroundColor(Color.Yellow)
Row().width(300).height(200).backgroundColor(Color.Grey)
}
}
} |
application-dev\performance\arkts-performance-improvement-recommendation.md | @Entry
@Component
struct MyComponent {
private source: MyDataSource = new MyDataSource();
build() {
List() {
LazyForEach(this.source, (item:string) => {
ListItem() {
Text("Hello" + item)
.fontSize(50)
.onAppear(() => {
console.log("appear:" + item)
... |
application-dev\performance\common-trace-using-instructions.md | // src/main/ets/pages/LazyForEachPage.ets
@Entry
@Component
struct LazyForEachPage {
private iconItemSourceList = new ListData();
aboutToAppear() {
// Add data of 120 icon items.
......
}
build() {
Column() {
Text ('Example of lazy loading')
.fontSize(24)
.fontColor(Color.Bla... |
application-dev\performance\common-trace-using-instructions.md | // src/main/ets/view/IconView.ets
@Component
export struct IconItem {
image: string | Resource = '';
text: string | Resource = '';
build() {
Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.Center, alignContent: FlexAlign.Center }) {
Image(this.image)
.height(40)
.width(40... |
application-dev\performance\component-recycle.md | aboutToReuse?(params: { [key: string]: unknown }): void; |
application-dev\performance\component-recycle.md | aboutToRecycle?(): void; |
application-dev\performance\component-recycle.md | reuseId(id: string); |
application-dev\performance\component-recycle.md | declare const Reusable: ClassDecorator; |
application-dev\performance\component-recycle.md | private dataArray: string[] = [];
private listener: DataChangeListener;
public totalCount(): number {
return this.dataArray.length;
}
public getData(index: number): any {
return this.dataArray[index];
}
public pushData(data: string): void {
this.dataArray.push(data);
}
public reloadListe... |
application-dev\performance\component-recycle.md | LazyForEach(this.GoodDataOne, (item, index) => {
GridItem() {
Column() {
Image(item.img)
.height(item.hei)
.width('100%')
.objectFit(ImageFit.Fill)
Text(item.introduce)
.fontSize(14)
.padding({ left: 5, right: 5 })
.margin({ top: 5 })
Row() {
... |
application-dev\performance\component-recycle.md | LazyForEach(this.GoodDataOne, (item, index) => {
GridItem() {
GoodItems({
boo:item.data.boo,
img:item.data.img,
webimg:item.data.webimg,
hei:item.data.hei,
introduce:item.data.introduce,
price:item.data.price,
numb:item.data.numb,
index:index
})
.reuseId(thi... |
application-dev\performance\improve-application-cold-start-speed.md | // Reduce the number of imported modules.
// import ability from '@ohos.ability.ability';
// import dataUriUtils from '@ohos.ability.dataUriUtils';
// import errorCode from '@ohos.ability.errorCode';
// import featureAbility from '@ohos.ability.featureAbility';
// import particleAbility from '@ohos.ability.particleAbil... |
application-dev\performance\improve-application-cold-start-speed.md | const LARGE_NUMBER = 10000000;
const DELAYED_TIME = 1000;
export default class MyAbilityStage extends AbilityStage {
onCreate(): void {
// Time-consuming operation
// this.computeTask();
this.computeTaskAsync(); // Asynchronous task
}
onAcceptWant(want: Want): string {
// Triggered only for the ... |
application-dev\performance\improve-application-cold-start-speed.md | const LARGE_NUMBER = 10000000;
const DELAYED_TIME = 1000;
export default class EntryAbility extends UIAbility {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
logger.info('Ability onCreate');
// Time-consuming operation
// this.computeTask();
this.computeTaskAsync(); // Asynch... |
application-dev\performance\improve-application-cold-start-speed.md | const LARGE_NUMBER = 10000000;
const DELAYED_TIME = 1000;
@Entry
@Component
struct Index {
@State private text: string = "";
private count: number = 0;
aboutToAppear() {
// Time-consuming operation
// this.computeTask();
this.computeTaskAsync(); // Asynchronous task
let context = getContext(this... |
application-dev\performance\improve-file-upload-and-download-performance.md | import common from '@ohos.app.ability.common';
import fs from '@ohos.file.fs';
import zlib from '@ohos.zlib'; |
application-dev\performance\improve-file-upload-and-download-performance.md | class ZipUpload {
// Storage URI before the task is created.
private waitList: Array<string> = [];
// URIs of the images to upload.
private fileUris: Array<string> = [];
...
} |
application-dev\performance\improve-file-upload-and-download-performance.md | // Compress the images.
async zipUploadFiles(fileUris: Array<string>): Promise<void> {
this.context = getContext(this) as common.UIAbilityContext;
let cacheDir = this.context.cacheDir;
let tempDir = fs.mkdtempSync(`${cacheDir}/XXXXXX`);
// Put the image URIs into the fileUris, and traverse and co... |
application-dev\performance\improve-file-upload-and-download-performance.md | import common from '@ohos.app.ability.common';
import request from '@ohos.request'; |
application-dev\performance\improve-file-upload-and-download-performance.md | class Upload {
// Background task.
private backgroundTask: request.agent.Task | undefined = undefined;
// Storage URI before the task is created.
private waitList: Array<string> = [];
...
} |
application-dev\performance\improve-file-upload-and-download-performance.md | async checkFileExist(fileUri: string): Promise<boolean> {
let httpRequest = http.createHttp();
// Generate an MD5 value.
let md5 = await hash.hash(fileUri, 'md5');
let requestOption: http.HttpRequestOptions = {
method: http.RequestMethod.POST,
extraData: {
'MD5': md5
}
... |
application-dev\performance\improve-file-upload-and-download-performance.md | private config: request.agent.Config = {
action: request.agent.Action.UPLOAD,
headers: HEADER,
url: '',
mode: request.agent.Mode.BACKGROUND,
method: 'POST',
title: 'upload',
network: request.agent.Network.ANY,
data: [],
token: 'UPLOAD_TOKEN'
}
...
// Convert the URI... |
application-dev\performance\improve-file-upload-and-download-performance.md | await this.backgroundTask.start(); |
application-dev\performance\improve-file-upload-and-download-performance.md | async pause() {
if (this.backgroundTask === undefined) {
return;
}
await this.backgroundTask.pause();
} |
application-dev\performance\improve-file-upload-and-download-performance.md | async resume() {
if (this.backgroundTask === undefined) {
return;
}
await this.backgroundTask.resume();
} |
application-dev\performance\improve-file-upload-and-download-performance.md | > // From range-start to the end of the file.
> Range: <unit>=<range-start>-
> // From range-start to range-end.
> Range: <unit>=<range-start>-<range-end>
> // Multiple parts, separated by commas (,).
> Range: <unit>=<range-start>-<range-end>, <range-start>-<range-end>
>
> // Example: The file content after 1024 bytes... |
application-dev\performance\improve-file-upload-and-download-performance.md | import common from '@ohos.app.ability.common';
import request from '@ohos.request'; |
application-dev\performance\improve-file-upload-and-download-performance.md | class Download {
// Storage URI before the task is created.
private waitList: Array<string[]> = [];
// Download task.
private downloadTask: request.agent.Task | undefined = undefined;
// Background task download list.
private backgroundDownloadTaskList: Array<request.agent.Task> = [];
... |
application-dev\performance\improve-file-upload-and-download-performance.md | async createBackgroundTask(downloadList: Array<string[]>) {
let splitUrl = url.split('//')[1].split('/');
let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
let downloadConfig: request.agent.Config = {
action: request.agent.Action.DOWNLOAD,
url: url,
... |
application-dev\performance\improve-file-upload-and-download-performance.md | ...
await downTask.start();
... |
application-dev\performance\improve-file-upload-and-download-performance.md | async pause() {
if (this.backgroundDownloadTaskList.length === 0) {
return;
}
this.backgroundDownloadTaskList.forEach(async task => {
await task.pause();
})
} |
application-dev\performance\improve-file-upload-and-download-performance.md | async resume() {
if (this.backgroundDownloadTaskList.length === 0) {
return;
}
this.backgroundDownloadTaskList.forEach(async task => {
await task.resume();
})
} |
application-dev\performance\improve-file-upload-and-download-performance.md | async deleteAllBackTasks() {
if (this.backgroundDownloadTaskList.length > 0) {
this.backgroundDownloadTaskList.forEach(async task => {
await request.agent.remove(task.tid);
})
this.backgroundDownloadTaskList = [];
}
} |
application-dev\performance\performance-dynamic-import.md | import { pageOne, pageOneData } from './pageOne';
import { pageTwo, pagesTwoData } from './pageTwo';
...
import router from '@ohos.router'; |
application-dev\performance\performance-dynamic-import.md | @Provide('pathInfos') pageInfos: NavPathStack = new NavPathStack();
@Builder
PageMap(name: string) {
if (name === 'pageOne') {
pageOne(new pagesOneData(name, this.pageInfos));
} else if (name === 'pageTwo') {
pageTwo(new pagesTwoData(name, this.pageInfos));
}
...
... |
application-dev\performance\performance-dynamic-import.md | import { pageOne } from './pageOne';
@Builder
export function PageOneLoader() {
pageOne();
} |
application-dev\performance\performance-dynamic-import.md | @BuilderParam PageOneLoader: () => void; |
application-dev\performance\performance-dynamic-import.md | async loadPageOne(key: string){
if (key === "pageOne") {
let PageObj: ESObject = await import("../pages/PageOneLoader");
this.PageOneLoader = PageObj.PageOneLoader;
}
} |
application-dev\performance\performance-dynamic-import.md | private onEntryClick(): void {
try {
this.loadPageOne('pageOne');
this.pageInfos.clear();
this.pageInfos.pushPathByName('pageOne', '');
logger.info('DynamicImport Success');
} catch (error) {
logger.info('DynamicImport Fail');
}
} |
application-dev\performance\performance-dynamic-import.md | @Builder
PageMap(name: string) {
if (name === 'pageOne') {
this.PageOneLoader();
}
} |
application-dev\performance\performance-dynamic-import.md | import router from '@ohos.router';
import { logger } from '../../ets/utils/Logger';
@Entry
@Component
struct DynamicHome {
@Provide('pathInfos') pageInfos: NavPathStack = new NavPathStack();
@State active: boolean = false;
@BuilderParam PageOneLoader: () => void;
@Builder
PageMap(name: string) {
if (nam... |
application-dev\performance\precisely-control-render-scope.md | @Observed
class ClassA {
prop1: number = 0;
prop2: string = "This is Prop2";
}
@Component
struct CompA {
@ObjectLink a: ClassA;
private sizeFont: number = 30; // the private variable does not invoke rendering
private isRenderText() : number {
this.sizeFont++; // the change of sizeFont will not invoke rend... |
application-dev\performance\precisely-control-render-scope.md | @Observed
class UIStyle {
translateX: number = 0;
translateY: number = 0;
scaleX: number = 0.3;
scaleY: number = 0.3;
width: number = 336;
height: number = 178;
posX: number = 10;
posY: number = 50;
alpha: number = 0.5;
borderRadius: number = 24;
imageWidth: number = 78;
imageHeight: number = 78... |
application-dev\performance\precisely-control-render-scope.md | @Observed
class ClassB {
subProp1: number = 100;
}
@Observed
class ClassA {
prop1: number = 0;
prop2: string = "This is Prop2";
prop3: ClassB = new ClassB();
}
@Component
struct CompA {
@ObjectLink a: ClassA;
@ObjectLink b: ClassB; // A new @ObjectLink decorated variable.
private sizeFont: number = 30;
... |
application-dev\performance\precisely-control-render-scope.md | @Observed
class NeedRenderImage { // Properties only used in the same component can be divided into the same new divided class.
public translateImageX: number = 0;
public translateImageY: number = 0;
public imageWidth:number = 78;
public imageHeight:number = 78;
}
@Observed
class NeedRenderScale { // Properties... |
application-dev\performance\precisely-control-render-scope.md | .property(this.needRenderXxx.xxx)
// sample
Text("some text")
.width(this.needRenderSize.width)
.height(this.needRenderSize.height)
.opacity(this.needRenderAlpha.alpha) |
application-dev\performance\precisely-control-render-scope.md | // In parent Component
this.parent.needRenderXxx.xxx = x;
// Example
this.uiStyle.needRenderImage.imageWidth = (this.uiStyle.needRenderImage.imageWidth + 20) % 60; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.