Utils.js 944 Bytes
'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}', width)
			.replace('{height}', height);
	}
	return newSrc;
}

export function isEmptyObject(obj) {
  for (var key in obj) {
    return false;
  }
  return true;
}

export function ScrollToIndex(sessionID,list) {

    let index = 0;
    for(var k in list) {
        let name = k;
        if (name == sessionID) {
            break;
        }
        index += 20 + list[k].length * 44;
    }
    return index;
}