Merge branch '5.8.0-0.44.0' of http://git.yoho.cn/mobile/YH_RNComponent into 5.8.0-0.44.0
Showing
1 changed file
with
43 additions
and
2 deletions
@@ -16,7 +16,7 @@ import ReactNative, { | @@ -16,7 +16,7 @@ import ReactNative, { | ||
16 | Platform, | 16 | Platform, |
17 | InteractionManager | 17 | InteractionManager |
18 | } from 'react-native'; | 18 | } from 'react-native'; |
19 | -import immutable from 'immutable'; | 19 | +import Immutable from 'immutable'; |
20 | import HotCategoryList from './HotCategoryList'; | 20 | import HotCategoryList from './HotCategoryList'; |
21 | import HotBrandList from './HotBrandList'; | 21 | import HotBrandList from './HotBrandList'; |
22 | import YH_Image from '../../../common/components/YH_Image'; | 22 | import YH_Image from '../../../common/components/YH_Image'; |
@@ -35,10 +35,48 @@ export default class CategoryBList extends Component { | @@ -35,10 +35,48 @@ export default class CategoryBList extends Component { | ||
35 | this.stopPullToRefresh = this.stopPullToRefresh.bind(this); | 35 | this.stopPullToRefresh = this.stopPullToRefresh.bind(this); |
36 | 36 | ||
37 | this.dataSource = new ListView.DataSource({ | 37 | this.dataSource = new ListView.DataSource({ |
38 | - rowHasChanged: (r1, r2) => !immutable.is(r1, r2) | 38 | + rowHasChanged: (r1, r2) => !Immutable.is(r1, r2) |
39 | }); | 39 | }); |
40 | } | 40 | } |
41 | 41 | ||
42 | + shouldComponentUpdate(nextProps){ | ||
43 | + if (Immutable.is(nextProps.categoryList, this.props.categoryList) | ||
44 | + && (nextProps.currentCateId==this.props.currentCateId) | ||
45 | + && (nextProps.currentCateValue==this.props.currentCateValue) | ||
46 | + && (nextProps.currentChannelValue==this.props.currentChannelValue) | ||
47 | + && (Immutable.is(nextProps.currentSubCateData, this.props.currentSubCateData)) | ||
48 | + && (nextProps.contentFetching==this.props.contentFetching)) | ||
49 | + { | ||
50 | + return false; | ||
51 | + } else { | ||
52 | + return true; | ||
53 | + } | ||
54 | + } | ||
55 | + | ||
56 | + componentWillReceiveProps(nextProps) { | ||
57 | + if(nextProps.currentCateId != this.props.currentCateId) { | ||
58 | + try { | ||
59 | + if (Platform.OS === 'ios') { | ||
60 | + if (didTouchTime > 0) { | ||
61 | + let nowTime = (new Date()).valueOf(); | ||
62 | + let time = nowTime - didTouchTime; | ||
63 | + let param = { | ||
64 | + 'eid': nextProps.currentCateId + '', | ||
65 | + 'ts': didTouchTime + '', | ||
66 | + 'cts': time + '', | ||
67 | + }; | ||
68 | + ReactNative.NativeModules.YH_CommonHelper.logPerformanceWithType('CAT_CLK', param); | ||
69 | + } | ||
70 | + didTouchTime = 0; | ||
71 | + } | ||
72 | + } catch (e) { | ||
73 | + | ||
74 | + } finally { | ||
75 | + | ||
76 | + } | ||
77 | + } | ||
78 | + } | ||
79 | + | ||
42 | trigggePullToRefresh(categoryId, categoryValue) { | 80 | trigggePullToRefresh(categoryId, categoryValue) { |
43 | if (Platform.OS === 'ios') { | 81 | if (Platform.OS === 'ios') { |
44 | InteractionManager.runAfterInteractions(() => { | 82 | InteractionManager.runAfterInteractions(() => { |
@@ -181,6 +219,8 @@ export default class CategoryBList extends Component { | @@ -181,6 +219,8 @@ export default class CategoryBList extends Component { | ||
181 | 219 | ||
182 | return ( | 220 | return ( |
183 | <TouchableOpacity activeOpacity={1} onPress={() => { | 221 | <TouchableOpacity activeOpacity={1} onPress={() => { |
222 | + let nowTime = (new Date()).valueOf(); | ||
223 | + didTouchTime = nowTime; | ||
184 | this.refs.subCategoryList && this.refs.subCategoryList.scrollTo({x: 0, y: 0, animated: false}); | 224 | this.refs.subCategoryList && this.refs.subCategoryList.scrollTo({x: 0, y: 0, animated: false}); |
185 | this.props.onSelectCategory && this.props.onSelectCategory(rowData.toJS()); | 225 | this.props.onSelectCategory && this.props.onSelectCategory(rowData.toJS()); |
186 | }}> | 226 | }}> |
@@ -294,6 +334,7 @@ let {width, height} = Dimensions.get('window'); | @@ -294,6 +334,7 @@ let {width, height} = Dimensions.get('window'); | ||
294 | const DEVICE_WIDTH_RATIO = width / 375; | 334 | const DEVICE_WIDTH_RATIO = width / 375; |
295 | let cellWidth = 78 * DEVICE_WIDTH_RATIO; | 335 | let cellWidth = 78 * DEVICE_WIDTH_RATIO; |
296 | let cellPadding = ((width - 102.5 * DEVICE_WIDTH_RATIO) - cellWidth * 3) / 4; | 336 | let cellPadding = ((width - 102.5 * DEVICE_WIDTH_RATIO) - cellWidth * 3) / 4; |
337 | +let didTouchTime = 0; | ||
297 | 338 | ||
298 | let styles = StyleSheet.create({ | 339 | let styles = StyleSheet.create({ |
299 | container: { | 340 | container: { |
-
Please register or login to post a comment