Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add point count info, assists in debugging #56

Merged
merged 2 commits into from
Mar 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/services/LocationService.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
import BackgroundGeolocation from '@mauron85/react-native-background-geolocation';

var instanceCount = 0
var lastPointCount = 0;

export default class LocationServices {
static start() {
Expand Down Expand Up @@ -60,6 +61,10 @@ export default class LocationServices {
locationData = [];
}

locationData.push(location);
lastPointCount = locationData.length;
console.log('[GPS] Saving point:', lastPointCount)

// Curate the list of points
SetStoreData('LOCATION_DATA', locationData); var nowUTC = new Date().toISOString();
var unixtimeUTC = Date.parse(nowUTC);
Expand Down Expand Up @@ -171,6 +176,11 @@ export default class LocationServices {
// you can also just start without checking for status
// BackgroundGeolocation.start();
}

static getPointCount() {
return lastPointCount;
}

static stop() {
// unregister all event listeners
BackgroundGeolocation.removeAllListeners();
Expand Down
48 changes: 31 additions & 17 deletions app/views/Export.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import React, { Component } from 'react';
import React, {
Component
} from 'react';
import {
SafeAreaView,
StyleSheet,
Expand All @@ -13,9 +15,12 @@ import {
import colors from "../constants/colors";
import WebView from 'react-native-webview';
import Button from "../components/Button";
import { GetStoreData } from '../helpers/General';
import {
GetStoreData
} from '../helpers/General';
import Share from 'react-native-share';
import RNFetchBlob from 'rn-fetch-blob';
import LocationServices from '../services/LocationService';

const base64 = RNFetchBlob.base64

Expand All @@ -29,34 +34,35 @@ class ExportScreen extends Component {
}

onShare = async () => {
try {
const locationArray = await GetStoreData('LOCATION_DATA');
var locationData;

if (locationArray !== null) {
locationData = JSON.parse(locationArray);
} else {
locationData = [];
}

b64Data = base64.encode(JSON.stringify(locationData));
Share.open({
try {
const locationArray = await GetStoreData('LOCATION_DATA');
var locationData;

if (locationArray !== null) {
locationData = JSON.parse(locationArray);
} else {
locationData = [];
}

b64Data = base64.encode(JSON.stringify(locationData));
Share.open({
url: "data:string/txt;base64," + b64Data
}).then(res => {
console.log(res);
})
.catch(err => {
console.log(err.message, err.code);
})
} catch (error) {
console.log(error.message);
} catch (error) {
console.log(error.message);
}
};

backToMain() {
this.props.navigation.navigate('LocationTrackingScreen', {})
}


render() {

return (
Expand All @@ -73,6 +79,7 @@ class ExportScreen extends Component {
<View style={styles.block}>
<Button onPress={this.onShare} title="Share" />
</View>
<Text style={styles.mainText}>Points to be shared: { LocationServices.getPointCount() }</Text>
</View>

</SafeAreaView>
Expand Down Expand Up @@ -121,6 +128,13 @@ const styles = StyleSheet.create({
textAlignVertical: 'center',
padding: 20,
},
smallText: {
fontSize: 10,
lineHeight: 24,
fontWeight: '400',
textAlignVertical: 'center',
padding: 20,
},

headerContainer: {
flexDirection: 'row',
Expand All @@ -140,4 +154,4 @@ const styles = StyleSheet.create({
},
});

export default ExportScreen;
export default ExportScreen;