Example #1
0
 renderScene(route, navigator) {
   let Component = route.component;
   tempNavigator = navigator;
   if (route.name === 'WebViewPage') {
     BackAndroid.removeEventListener('hardwareBackPress', this.goBack);
     isRemoved = true;
   } else if (isRemoved) {
     BackAndroid.addEventListener('hardwareBackPress', this.goBack);
   }
   return (
     <Component navigator={navigator} route={route} />
   );
 }
  render() {

  	_this = this;

 	BackAndroid.addEventListener('hardwareBackPress', function() {
	     if (_this.state.view != 'main') {
	     	_this.setState({view: 'main'});
	     	return true;
	     }

	     BackAndroid.removeEventListener('hardwareBackPress');

	     return false;
  	});

    if(this.state.view == 'main') {
	    return this.renderMainView();
	} else if(this.state.view == 'menu') {
		return this.renderMenuView();
	} else if(this.state.view == 'loading') {
		
		return (
			<View style={{flex: 1, backgroundColor: '#ccc', justifyContent: 'center', alignItems: 'center'}}>
				<Text style={{fontSize: 20}}>Loading...</Text>
			</View>
		);
	} else if(this.state.view == 'scan') {
        return this.renderScannerView();
    } 


    
  }
Example #3
0
 constructor(props) {
   super(props);
   registerApp('wxb24c445773822c79');
   this.renderScene = this.renderScene.bind(this);
   this.goBack = this.goBack.bind(this);
   BackAndroid.addEventListener('hardwareBackPress', this.goBack);
 }
Example #4
0
 componentDidMount() {
   Linking.getInitialURL().then(url => {
     const linkAction = url && BlogApp.actionWithLocation(parseUrlWithPrefix(url, 'navapp:/'));
     AsyncStorage.getItem(APP_STATE_KEY, (err, savedPropsString) => {
       const savedProps = !err && savedPropsString && JSON.parse(savedPropsString);
       if (savedProps && linkAction) {
         this.setState({
           navigationState: BlogApp.navigationReducer(savedProps, linkAction),
         });
       } else if (savedProps) {
         this.setState({
           navigationState: savedProps,
         });
       } else {
         this.setState({
           navigationState: BlogApp.navigationReducer(undefined, BlogApp.Actions.default()),
         })
       }
     });
   });
   Platform.OS !== 'android' &&
     Linking.addEventListener('url', this._handleOpenURL);
   Platform.OS === 'android' &&
     BackAndroid.addEventListener('hardwareBackPress', this._handleBack);
 }
Example #5
0
  componentDidMount() {
    const {dispatch} = this.props
    // init application
    dispatch(init())

    BackAndroid.addEventListener('hardwareBackPress', () => {
      if (this.state.isDrawerOpen === true) {
        this.refs.drawer.closeDrawer()
        return true
      }
      const {prevision, history} = this.props.navigation

      if (history.length > 1) {
        // set active room previous room
        // if (prevision.name === 'room') {
        //   dispatch(selectRoom(prevision.roomId))
        // } else {
        dispatch(selectRoom(''))
        // }
        dispatch(Navigation.goBack())
        return true
      }
      return false
    })
  }
Example #6
0
  componentDidMount() {
    BackAndroid.addEventListener('hardwareBackPress', this.goBack);

    const {dispatch} = this.props;

    InteractionManager.runAfterInteractions(() => {
        dispatch(fetchDetail(programId));
    });

    setTimeout(() => {
        this.setState(
          {
            animPlaying: false
          }
        );
    }, 1000);
    
    if (!mDeviceEventEmitter)
    {
      mDeviceEventEmitter = DeviceEventEmitter.addListener(
              'fullScreenCallback',
              (response) => {
                this.changeToFullScreen(response);
              }
      );
    }
  }
Example #7
0
 componentWillMount()
 {
     // 监听安卓的返回按键
     if (Platform.OS === 'android') {
         BackAndroid.addEventListener('hardwareBackPress', this._onBackAndroid);
     }
 }
Example #8
0
 _renderScene(route, navigator) {
     thisNavigator = navigator;
     let Component = route.component;
     if (route.name === 'WebViewPage') {
         BackAndroid.removeEventListener('hardwareBackPress', this._goBack);
         isRemoved = true;
     } else {
         if (isRemoved) {
             BackAndroid.addEventListener('hardwareBackPress', this._goBack);
         }
     }
     //const { dispatch } = this.props;
     //const action = bindActionCreators(actions, dispatch);
     //
     return <Component navigator={navigator} {...route.params}/>
 };
Example #9
0
  componentDidMount() {
    BackAndroid.addEventListener('hardwareBackPress', () => {
      const routes = this.props.navigation.routes;
      
    if(routes[routes.length - 1].key === "bread" 
    || routes[routes.length - 1].key === "fruitveg"
    || routes[routes.length - 1].key === "meat"
    || routes[routes.length - 1].key === "milk"
    || routes[routes.length - 1].key === "other"
    || routes[routes.length - 1].key === "sourmilk"
    || routes[routes.length - 1].key === "cheese")
    {

    //  this.props.popRoute(this.props.nacigation.key);
      this.replaceAt(routes[routes.length - 1].key,"recipe");
      return true;
    }
    

      if (routes[routes.length - 1].key === 'home') {
        return false;
      }


      this.props.popRoute(this.props.navigation.key);
      return true;
    });
  }
  constructor(props, context) {
    super(props, context)
    this.state = {
      navigation: {
        index: 0,
        routes: [
          {key: 'screen1'},
        ]
      }
    }
    this._renderScene = this._renderScene.bind(this)
    this._renderHeader = this._renderHeader.bind(this)

    this._goScreen2 = this._navigate.bind(this, {type:'push', key:'screen2'})
    this._goScreen3 = this._navigate.bind(this, {type:'push', key:'screen3'})
    this._goBack = this._navigate.bind(this, {type:'pop'})
    if (Platform.OS === 'android') {
      BackAndroid.addEventListener('hardwareBackPress', () => {
        if (this.state.navigation.index > 0) {
          this._goBack()
          return true
        } else {
          return false
        }
      })
    }
  }
Example #11
0
	/**
	 * 针对android的返回键
	 */
    componentDidMount() {
    	if (Platform.OS === 'android') {
			React.BackAndroid.addEventListener('hardwareBackPress', function() {
				this.onPrev();
			});
		}
    }
Example #12
0
  constructor(props) {
    super(props)

    if (Platform.OS !== 'ios') {
      BackAndroid.addEventListener('hardwareBackPress', this.close)
    }
  }
 componentWillMount(){
   //BackAndroid在iOS平台下是一个空实现,所以理论上不做这个Platform.OS === 'android'判断也是安全的。
   if (Platform.OS === 'android') {
     //监听手机物理返回键
     BackAndroid.addEventListener('hardwareBackPress',this.onBack);
   }
 }
Example #14
0
    componentWillMount() {

        /*
        if (Platform.OS === 'ios') {
            StatusBarIOS.setStyle('light-content');
        }*/


        BackAndroid.addEventListener('hardwareBackPress', () => {

            if (this.refs.nav) {
                if (this.refs.nav.getCurrentRoutes().length === 1) {// 在canEat的home页了
                    if (this.props.nav) {// 在demo中
                        this.props.nav.pop();
                    } else {// 集成了app中
                        BBPageRouterRNM.popModule();
                    }
                } else {
                    this.refs.nav.pop();
                }
            }
            return true;
        });

    }
Example #15
0
  attachListeners = () => {
    Reactotron.log('Attaching listeners!');
    PushNotification.configure({
      onRegister: function(token) {
        Reactotron.log('Notification receiver registered: ' + token.token);
        store.dispatch(gcmRegistered(token.token));
      },
      onNotification: this.onNotification,
      senderID: "304075958563",
      requestPermissions: true,
      popInitialNotification: false
    });
    BackAndroid.addEventListener('hardwareBackPress', this.handleAndroidBackButton);
    //adb shell am start -W -a android.intent.action.VIEW -d "cesar://recover/me@ya.ru/hjdjfshf" com.knopka
    //adb shell am start -W -a android.intent.action.VIEW -d "http://miss-u-mat.cesar.ru/recover/me@ya.ru/hjdjfshf" com.knopka
    Linking.getInitialURL()
      .then(url => {
        if (store.getState().lastInitialURL.url !== url) {
          const parts = url ? url.split('/') : [];
          console.log('Url parts:', parts);
          if (parts.length === 6 && parts[2] === 'miss-u-mat.cesar.ru' && parts[3] === 'recover') {
            console.log('Deep link to password change ', parts[4], parts[5]);
            store.dispatch(setLastInitialURL(url));
            Actions.changePassword({email: parts[4], oldPassword: parts[5]});
            this.hideSplashimmediately();
          }
        }
      })
      .catch(err => console.error('Deep linking error', err));

    this.splashTimeout = setTimeout( () => {
      SplashScreen.hide();
      this.splashHidden = true;
    }, 1000);
  };
Example #16
0
  componentWillUnmount() {
    if (Platform.OS === 'ios') {

    }else{
      BackAndroid.removeEventListener('hardwareBackPress', this.onBackAndroid.bind(this));
    }
  }
    componentDidMount() {
        globalNav.navigator = this._navigator;
        // console.log(global.globalNav, "global nav");

        this.props.store.subscribe(() => {
            // console.log("store changed", this.props.store.getState());
            if(this.props.store.getState().drawer.drawerState == 'opened')
                this.openDrawer();

            if(this.props.store.getState().drawer.drawerState == 'closed')
                this._drawer.close();
        });

        BackAndroid.addEventListener('hardwareBackPress', () => {
            var routes = this._navigator.getCurrentRoutes();

            if(routes[routes.length - 1].id == 'home' || routes[routes.length - 1].id == 'login') {
                // CLose the app
                return false;
            }
            else {
                this.popRoute();
                return true;
            }

        });
    }
Example #18
0
  componentDidMount() {
    if (Platform.OS === 'ios') {

    }else {
      BackAndroid.addEventListener('hardwareBackPress', this.onBackAndroid.bind(this));
    }
  }
Example #19
0
 static showActionSheetWithOptions(config: Object, callback: Function) {
   let options = [];
   config.options.forEach((option, i) => {
     i === config.cancelButtonIndex ? (
       options.push(
         <View key={'brace-' + i} style={style.brace} />
       ),
       options.push(
         <TouchableOpacity key={'option-' + i} style={style.close} activeOpacity={0.8} onPress={_closeSheet}>
           <Text style={{color: config.tintColor, fontWeight: 'bold'}}>{option}</Text>
         </TouchableOpacity>
       ) ):
       options.push(
         <TouchableOpacity key={'option-' + i} style={style.row} activeOpacity={0.8} onPress={() => {
           _closeSheet();
           callback(i);
         }}>
           <Text style={{color: i === config.destructiveButtonIndex ? colors.accent : config.tintColor}}>{option}</Text>
         </TouchableOpacity>
       );
   });
   sheet || ( BackAndroid.addEventListener('hardwareBackPress', _androidBack),
     sheet = new RootSiblings(
       <View style={style.container}>
         <TouchableWithoutFeedback onPress={_closeSheet}>
           <View style={style.flex}></View>
         </TouchableWithoutFeedback>
         {options}
       </View>
     )
   );
 }
 componentWillMount()
 {
     if(Platform.OS==='android')
     {
          BackAndroid.addEventListener('hardwareBackPress', this.onBackAndroid.bind(this));
     }
     NetInfo.addEventListener('change',this.handleConnectionInfoChange.bind(this));
     NetInfo.isConnected.addEventListener('change',this.handleConnectivityChange.bind(this));
     //获取网络当前信息
     NetInfo.fetch().done((connectionInfo) => {
         var info=this.switchConnectionInfo(connectionInfo);
         this.props.dispatch(ChangeNetInfo(info));
     });
     //获取网络当前连接状态
     NetInfo.isConnected.fetch().then((isConnected) => {
         this.props.dispatch(ChangeNetConnectStatus(isConnected));
     });
     //获取网络当前连接计费状态
     NetInfo.isConnectionExpensive().then((isConnectionExpensive) => {
         this.props.dispatch(ChangeNetExpensiveStatus(isConnectionExpensive));
     });
            
     Ionicons.getImageSource('ios-arrow-back', 30, '#fff').then((source) => this.setState({ backButtonImage: source }));
     Ionicons.getImageSource('md-menu', 30, '#fff').then((source) => this.setState({ drawerImage: source }));
 }
 RouteMapper(route, navigationOperations, onComponentRef) {
   BackAndroid.addEventListener('hardwareBackPress', function() {
   if (navigationOperations && navigationOperations.getCurrentRoutes().length > 1) {
       navigationOperations.pop();
       return true;
     }
   return false;
   });
   if (route.name === 'home') {
     return (
       <View style={styles.container}>
         <MainScreen navigator={navigationOperations}/>
       </View>
     );
   } else if (route.name === 'story') {
     return (
       <View style={styles.container}>
         <StoryScreen
           style={{flex: 1}}
           navigator={navigationOperations}
           story={route.story} />
       </View>
     );
   }
 }
Example #22
0
    init() {

        this._queryMsg();
        this._startQueryMsg();

        BackAndroid.addEventListener('hardwareBackPress', () => {

            if (this.getRefs().nav) {

                let routes = this.getRefs().nav.getCurrentRoutes();

                if (routes.length === 1) {// 在home页了
                    if (this.getProps().nav) {// 在demo中
                        this.getProps().nav.pop();
                    } else {// 集成了app中
                        BBPageRouterRNM.popModule();
                    }
                } else {

                    if (routes[routes.length - 1].backIsClose === true) {
                        BBPageRouterRNM.popModule();
                    } else {
                        this.getRefs().nav.pop();
                    }

                }
            }
            return true;
        });
    }
Example #23
0
 componentDidMount(){
     SplashScreen.hide()
     BackAndroid.addEventListener('hardwareBackPress', function () {
         BackAndroid.exitApp(0)
         return true
     })
 }
Example #24
0
  componentDidMount() {
    Service.isLoggedIn().then(bool => {
      this.setState({loggedIn: bool});
    });

    BackAndroid.addEventListener('hardwareBackPress', this.handleBackButton);
  }
  showActionSheetWithOptions(options, onSelect) {
    if (this.state.isVisible) {
      return;
    }

    this.setState({
      options,
      onSelect,
      isVisible: true,
      isAnimating: true,
      isWaitingForSheetHeight: true,
    });

    this.state.overlayOpacity.setValue(0);
    this.state.sheetY.setValue(-this.state.sheetHeight);

    Animated.timing(this.state.overlayOpacity, {
      toValue: 0.3,
      easing: Easing.in(Easing.linear),
      duration: OPACITY_ANIMATION_TIME,
    }).start();

    if (options.cancelButtonIndex) {
      this._backAndroidEventListener = BackAndroid.addEventListener('actionSheetHardwareBackPress', this._onCancel);
    }
  }
Example #26
0
 componentWillUnMount() {
   BackAndroid.removeEventListener('hardwareBackPress');
   NetInfo.isConnected.removeEventListener(
     'change',
     this._handleConnectivityChange
   );
 }
componentDidMount(){
     setTimeout(()=>{this.setState({splashed:true});
                      },4000);
     if (Platform.OS === 'android') {
        BackAndroid.addEventListener('hardwareBackPress',()=>this.onBackAndroid());
    };
}
Example #28
0
 componentWillMount() {
   Orientation.lockToPortrait();
   if (Platform.OS === 'android') {
     Orientation.registerOnOrientationChanged();
     BackAndroid.addEventListener('hardwareBackPress', this.onBackAndroid);
   }
 }
    _animateOut() {
        if (this.state.isAnimating) {
            return false;
        }

        BackAndroid.removeEventListener('actionSheetHardwareBackPress', this._animateOut);

        this.setState({
            isAnimating: true,
        });

        Animated.timing(this.state.overlayOpacity, {
            toValue: 0,
            easing: Easing.in(Easing.linear),
            duration: OPACITY_ANIMATION_TIME,
        }).start(result => {
            if (result.finished) {
                this.setState({
                    isVisible: false,
                    isAnimating: false,
                });
            }
        });

        Animated.timing(this.state.sheetY, {
            toValue: -this.state.sheetHeight,
            easing: Easing.inOut(Easing.ease),
            duration: Y_ANIMATION_TIME,
        }).start();

        return true;
    }
Example #30
0
  componentDidMount() {
    if(Platform.OS === 'android'){
      BackAndroid.addEventListener('hardwareBackPress', this.onBackPress);
    }

    this.getLatestNews();
  }