• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15import MediaLib from '@ohos.multimedia.mediaLibrary';
16import { Log } from '../utils/Log';
17import selectManager from '../manager/SelectManager';
18
19const TAG = "PeerDataItem"
20
21export class PeerDataItem {
22    index: number;
23    uri: string;
24    orientation: number;
25    deviceName: string;
26    count: number;
27    networkId: string;
28    isSelect: boolean;
29
30    constructor(count: number, peer: MediaLib.PeerInfo, fileAsset: MediaLib.FileAsset) {
31        this.uri = fileAsset.uri;
32        this.orientation = fileAsset.orientation;
33        this.deviceName = peer.deviceName;
34        this.count = count;
35        this.networkId = peer.networkId;
36    }
37
38    getHashCode() {
39        return `${this.networkId} ${this.orientation} ${this.isSelect}`;
40    }
41
42    getThumbnail(): string {
43        Log.debug(TAG, `this.uri ${this.uri}`);
44        return this.uri + `/thumbnail/256/256`;
45    }
46
47    setSelect(isSelect: boolean) {
48        this.isSelect = isSelect;
49        selectManager.setSelect(this.uri, this.isSelect);
50    }
51}