Utils.js
933 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'use strict';
import ReactNative from 'react-native';
const {
PixelRatio,
} = ReactNative;
export function getSlicedUrl(src, width, height, mode = 1) {
if (!src) {
return '';
}
width = PixelRatio.getPixelSizeForLayoutSize(width);
height = PixelRatio.getPixelSizeForLayoutSize(height);
let newSrc = src;
if (src.indexOf('imageView') === -1 && src.indexOf('imageMogr') === -1) {
newSrc = src + '?imageView2/' + mode + '/w/' + width + '/h/' + height;
} else {
newSrc = src.replace('{mode}', mode)
.replace(/{width}/g, width)
.replace(/{height}/g, height);
}
return newSrc;
}
export function isEmptyObject(obj) {
for (var key in obj) {
return false;
}
return true;
}
export function ScrollCount(sessionID,list) {
let index = 0;
for(let k in list) {
let name = k;
index += list[k].length;
if (name == sessionID) {
break;
}
}
return index;
}