Skip to content

Commit 684e6a8

Browse files
committed
merge
1 parent 3c08a95 commit 684e6a8

File tree

7 files changed

+123
-271
lines changed

7 files changed

+123
-271
lines changed
Binary file not shown.

.idea/workspace.xml

Lines changed: 11 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/example/offlinemaps/MapsActivity.java

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import java.util.List;
3838

3939

40-
4140
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback,
4241
GoogleApiClient.OnConnectionFailedListener {
4342

@@ -158,22 +157,22 @@ public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
158157

159158
}
160159

161-
private void init(){
160+
private void init() {
162161
Log.d(TAG, "init: initializing");
163162

164163
mGoogleApiClient = new GoogleApiClient
165164
.Builder(this)
166165
.addApi(Places.GEO_DATA_API)
167166
.addApi(Places.PLACE_DETECTION_API)
168-
.enableAutoManage(this,this)
167+
.enableAutoManage(this, this)
169168
.build();
170169

171170

172171
}
173172

174173

175174
public double toRadians(double deg) {
176-
return deg*Math.PI/180;
175+
return deg * Math.PI / 180;
177176
}
178177

179178
public double calcDist(LatLng latLng1, LatLng latLng2) {
@@ -188,19 +187,16 @@ public double calcDist(LatLng latLng1, LatLng latLng2) {
188187
double lat2R = toRadians(lat2);
189188
double lon2R = toRadians(lon2);
190189

191-
double a = Math.pow( Math.sin((lat2R-lat1R)/2),2) + Math.cos(lat1R) * Math.cos(lat2R)*Math.pow(Math.sin((lon2R-lon1R)/2),2);
192-
double c = 2 * Math.atan2(Math.sqrt(a),Math.sqrt(1-a));
190+
double a = Math.pow(Math.sin((lat2R - lat1R) / 2), 2) + Math.cos(lat1R) * Math.cos(lat2R) * Math.pow(Math.sin((lon2R - lon1R) / 2), 2);
191+
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
193192
double R = 6371.0;
194-
dist = R*c;
193+
dist = R * c;
195194
return dist;
196195
}
197196

198197

199-
200-
201-
202-
private void moveCamera(LatLng latLng, float zoom, String title){
203-
Log.d(TAG, "moveCamera: moving the camera to: lat: " + latLng.latitude + ", lng: " + latLng.longitude );
198+
private void moveCamera(LatLng latLng, float zoom, String title) {
199+
Log.d(TAG, "moveCamera: moving the camera to: lat: " + latLng.latitude + ", lng: " + latLng.longitude);
204200
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, zoom));
205201

206202
MarkerOptions options = new MarkerOptions()
@@ -210,13 +206,10 @@ private void moveCamera(LatLng latLng, float zoom, String title){
210206
}
211207

212208
/**
213-
*
214209
* CalcDist between two pars of lat-lon
215-
*
216210
*/
217211

218212

219-
220213
LocationCallback mLocationCallback = new LocationCallback() {
221214
@Override
222215
public void onLocationResult(LocationResult locationResult) {
@@ -268,7 +261,7 @@ public void onClick(DialogInterface dialogInterface, int i) {
268261
//Prompt the user once explanation has been shown
269262
ActivityCompat.requestPermissions(MapsActivity.this,
270263
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
271-
MY_PERMISSIONS_REQUEST_LOCATION );
264+
MY_PERMISSIONS_REQUEST_LOCATION);
272265
}
273266
})
274267
.create()
@@ -279,7 +272,7 @@ public void onClick(DialogInterface dialogInterface, int i) {
279272
// No explanation needed, we can request the permission.
280273
ActivityCompat.requestPermissions(this,
281274
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
282-
MY_PERMISSIONS_REQUEST_LOCATION );
275+
MY_PERMISSIONS_REQUEST_LOCATION);
283276
}
284277
}
285278
}
@@ -318,5 +311,4 @@ public void onRequestPermissionsResult(int requestCode,
318311
}
319312

320313

321-
322314
}

firebase.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"functions": {
33
"predeploy": [
44
"npm --prefix \"$RESOURCE_DIR\" run lint"
5-
]
5+
],
6+
"source": "functions"
67
}
78
}

functions/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,15 @@ return null;
4646
exports.doubleVIPpoints = functions.database.ref("/users/{userID}").onCreate((snap, context) => {
4747
console.log(snap.val(), "written by", context.auth.uid);
4848
});
49+
50+
51+
// Send notifications
52+
exports.sendNotification = functions.firestore.document("Users/{user_id}/Notification/{notification_id}").onWrite(event =>{
53+
54+
const user_id = event.params.user_id;
55+
const notification_id = event.params.notification_id;
56+
57+
console.log("User ID: " + user_id + " | Notification ID :" + notification_id);
58+
59+
60+
});

0 commit comments

Comments
 (0)