HustleTime Development: New Feature and bug fixes

Now that I’m back working on my mac, and an xCode that seems to be far more responsive to the machinations of ReactNative than it’s counterpart, Android Studio, I can get back to work.

One of the things I’ve done is now completely implements the 2 versions of the <ArrivalNotification />

This is going to be very useful to all the folks who need to see the last stop on a train. It’s a work in progress, however, as I need to continue to look for oddball train terminals that aren’t part of the default set of stations. What I mean, is that if a train ending service at some random station, HustleTime might not know what to do with it, until I add that station to the list of possible terminal stations.

It’s an imperfect system, but essentially it derives from the fact the MTA GTFS doesn’t include the last stop field, and instead, I’m reduced to some heavy lifting as hustletime-api sorts through all the stops in a current route and then gets the last entry in that array, stores it to a variable, and then includes that in the JSON for each arrival.

I’ve added a little searching indicator so you see when HustleTime is looking for data from the server . This is helpful when you’re underground, and/or don’t have a great signal, so you’ll see that HustleTime is working to get you up-to-the-minute info for arrivals.

I’ve also gone into the code and tried to eliminate some unnecessary API calls to the server. This is mainly accomplished by setting redux store to have an additional key called appReady.

  appReady: {
    featuresLoaded: false,
    mapLoaded: false,
    located: false,
  }

as parts of the app load, it will hit the reducer and change the values in the store, only when all 3 are true, will the app load data from the MTA. One disadvantage of this is that Location Services do indeed need to be enabled for the app to function, where in the past, I had set a default location. My next step is to set a default location if indeed location services are denied.

That involves adding a callback function to the second field in the navigator.geolocation.getCurrentPosition function.

getLocation = () => {
  navigator.geolocation.getCurrentPosition(currentPosition => {
    this.props.dispatchedNewCenter({
      latitude: currentPosition.coords.latitude,
      longitude:currentPosition.coords.longitude}),
    this.props.dispatchedCircleCenter({
      latitude: currentPosition.coords.latitude,
      longitude:currentPosition.coords.longitude})
    }, error => {
      this.setDefaultLocation()
    }
  )
  .then( x => this.props.dispatchedAppReady({located: true}))
}

setDefaultLocation = () => {
  this.props.dispatchedNewCenter({
    latitude: 40.6931111,
    longitude: -73.9913111}),
  this.props.dispatchedCircleCenter({
    latitude: 40.6931111,
    longitude: -73.9913111})
}

When Ios rejects the location request due to a permission not being enabled, it’ll call the setDefaultLocation function, and set lat and lng for somewhere in Boerum Hill.

I’m excited for this latest version of HustleTime, and I’m fairly confident that this will be the last real round of functional updates before I get into the two next big pieces:

  1. refactoring code for readability and efficiency
  2. cosmetic upgrades

Look for this new version (2.1) on the AppStore in the next few days!

as always,
You can get HustleTime on both Android and iPhone free!

HustleTime Development: Delays on Android

With so many of my friends being Android users, I had aimed to keep Android and Ios released in sync, so that all features were available concurrently.

But it’s been 3 weeks since my last post here, and that’s because Android, as usual, is giving me a ton of problems, and I’ve decided not to move forward with new Android releases until I can finish out the build on Ios.

The problems are two-fold. One stems from a strange issue I’m having with react-native-maps library and the component hierarchy, the other has to do with how react-native-maps handles displaying markers over the map.

The <MapView> is particularly finicky, and renders on top of everything, except for components in the same level. For example:

<MapView
  style={{zIndex: -1}}
/>
<Marker
  style={{zIndex: 1}}
/>

works fine, rendering the Marker over the map. The larger issue is when I am rending within HustleTime’s hierarchy, which looks like this:

App<<Home<<MapContainer<<Markers

In this structure, <MapContainer/> renders on top of everything rendered in <App/> and <Home/>, and since zIndex only cares about elements in the same file, and because <App/> and <Home/> both render things to the screen (alerts and buttons respectively) I’ve needed to compress the entire Home component into <MapContainer/>, and move a number of functions from <App/> into <MapContainer/>. This is bad.

My theory is that with this structure, when the <MapContainer/> is re-rendering, it’s doing a lot more work, and it’s slowing things down significantly.

Another major problem I’m having is with the <DefaultMarker /> component. <DefaultMarker /> displays smaller, grayed out markers over stations outside your search radius.

On the bottom right of the screen you can see several stations on the map, giving a user a guide so that they can move the map around to other stations. This is a fairly important feature, and for some reason, in Android, rendering these 497 markers can take up to 3 minutes. That’s unacceptable.

I’ve managed to prevent them from having to re-render, but the initial render is a major lag, and it’s preventing the app from working properly.

There’s a larger solution that involves some math and the map, and rendering only those markers that are viewable on the screen, but that solution is also rife with issues, I’m afraid that when the map is dragged, there won’t be markers to home in on.

So, considering these major issues, until I can figure out what the hell is going on, I’m going to have to put the Android implementation on hold.

There’s a basic working app there now (though it’s got its problems) and I just can’t spin my wheels trying to figure out Android right now. If anyone is willing to help, I’d gladly take it.

Thanks, and sorry android users.

Download HustleTime on android or iPhone free!