Authored by 孙凯

添加监听频道事件 review by 张丽霞

@@ -49,23 +49,18 @@ export default class ChannelFliter extends React.Component { @@ -49,23 +49,18 @@ export default class ChannelFliter extends React.Component {
49 } 49 }
50 50
51 _renderRow(rowData, sectionID, rowID) { 51 _renderRow(rowData, sectionID, rowID) {
52 -  
53 - let colorStyle = rowID == this.state.selectedIndex ? {color: '#444444',fontFamily: 'HelveticaNeue',fontSize: 17} : {color: '#b0b0b0',fontFamily: 'HelveticaNeue-Bold',fontSize: 14,}; 52 + let colorStyle = rowID == this.props.selectID ? {color: '#444444',fontFamily: 'HelveticaNeue',fontSize: 17} : {color: '#b0b0b0',fontFamily: 'HelveticaNeue-Bold',fontSize: 14,};
54 53
55 return ( 54 return (
56 <TouchableOpacity onPress={() => { 55 <TouchableOpacity onPress={() => {
57 let filters = this.state.filters; 56 let filters = this.state.filters;
58 let filter = this.state.filters[rowID]; 57 let filter = this.state.filters[rowID];
59 - if (this.state.selectedIndex == rowID) { 58 + if (this.props.selectID == rowID) {
60 return; 59 return;
61 } 60 }
62 61
63 filter.isSelect = !filter.isSelect; 62 filter.isSelect = !filter.isSelect;
64 filters[rowID] = filter; 63 filters[rowID] = filter;
65 - this.setState({  
66 - selectedIndex: rowID,  
67 - filters,  
68 - });  
69 this.props.onChannelPressFliter && this.props.onChannelPressFliter(rowID); 64 this.props.onChannelPressFliter && this.props.onChannelPressFliter(rowID);
70 }}> 65 }}>
71 <View key={'row' + rowID} style={styles.rowContainer}> 66 <View key={'row' + rowID} style={styles.rowContainer}>
@@ -58,6 +58,15 @@ class BrandContainer extends Component { @@ -58,6 +58,15 @@ class BrandContainer extends Component {
58 this._onPressBrandSearchItem = this._onPressBrandSearchItem.bind(this); 58 this._onPressBrandSearchItem = this._onPressBrandSearchItem.bind(this);
59 this._setBrandData = this._setBrandData.bind(this); 59 this._setBrandData = this._setBrandData.bind(this);
60 this._setInitialListSize = this._setInitialListSize.bind(this); 60 this._setInitialListSize = this._setInitialListSize.bind(this);
  61 +
  62 +
  63 + this.subscription = NativeAppEventEmitter.addListener(
  64 + 'ChannelDidChangeEvent',
  65 + (reminder) => {
  66 + this._onChannelPressFliter(reminder.channel-1);
  67 + }
  68 + );
  69 +
61 } 70 }
62 71
63 componentDidMount() { 72 componentDidMount() {
@@ -71,6 +80,10 @@ class BrandContainer extends Component { @@ -71,6 +80,10 @@ class BrandContainer extends Component {
71 80
72 } 81 }
73 82
  83 + componentWillUnmount() {
  84 + this.subscription && this.subscription.remove();
  85 + }
  86 +
74 _onPressSlideItem(url){ 87 _onPressSlideItem(url){
75 ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url); 88 ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
76 } 89 }