Authored by 孙凯

整理代码 review by zhanglixia

... ... @@ -2,6 +2,7 @@
import React from 'react';
import ReactNative from 'react-native';
import {getSlicedUrl} from '../../utils/Utils';
const {
AppRegistry,
... ... @@ -23,31 +24,13 @@ export default class BannerReourceList extends React.Component {
});
}
static 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;
}
_pressRow(rowData){
this.props.onPressBrandItem(rowData.url)
}
renderRow(rowData,sectionID,rowID,highlightRow) {
let newSrc = BannerReourceList.getSlicedUrl(rowData.src, itemWidth, itemWidth, 1);
let newSrc = getSlicedUrl(rowData.src, itemWidth, itemWidth, 1);
return (
<TouchableOpacity activeOpacity={0.5} onPress={() => {
this.props.onPressBrandItem && this.props.onPressBrandItem(rowData.url);
... ...
... ... @@ -2,6 +2,7 @@
import React from 'react';
import ReactNative from 'react-native';
import {getSlicedUrl} from '../../utils/Utils';
const {
StyleSheet,
... ... @@ -18,27 +19,9 @@ export default class NewHotBannerListCell extends React.Component {
super(props);
}
static 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;
}
render() {
let rowData = this.props.rowData;
let newSrc = NewHotBannerListCell.getSlicedUrl(rowData.brand_ico, width, height, 1);
let newSrc = getSlicedUrl(rowData.brand_ico, width, height, 1);
return (
<TouchableOpacity activeOpacity={0.5} onPress={() => {
// this.props.onPressRecommendItem && this.props.onPressRecommendItem(rowData.get('url'));
... ...
'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;
}
... ...