Skip to content

Commit

Permalink
Add missing files to vcs
Browse files Browse the repository at this point in the history
  • Loading branch information
joshliberty committed Jun 22, 2014
1 parent ee7ee73 commit cf79a09
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 35 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
local.properties
.idea
out
gen
Binary file added lib/retrofit-1.5.1-javadoc.jar
Binary file not shown.
Binary file added lib/retrofit-1.5.1-sources.jar
Binary file not shown.
Binary file added lib/retrofit-1.5.1.jar
Binary file not shown.
39 changes: 4 additions & 35 deletions src/com/joshliberty/veganfriendly/MapActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private void getRestaurants(){
Log.d(MapActivity.class.getSimpleName(), "Trying to get restaurants");
long lastUpdate = App.getPreferences(this).getLong(LAST_UPDATE, 0);
long timeDelta = new Date().getTime() - lastUpdate;
if(timeDelta > 604800){
if(timeDelta > 604800000){ // update weekly in any case todo add gcm receiver to receive push updates
RestAdapter restAdapter = new RestAdapter.Builder().setEndpoint(ApiService.API_SERVER).build();
ApiService service = restAdapter.create(ApiService.class);
service.getRestaurants(mapCenter.target.latitude, mapCenter.target.longitude, this);
Expand Down Expand Up @@ -180,41 +180,10 @@ public void onConnectionFailed(ConnectionResult connectionResult) {
// Location Updates Listener
private class OurCameraChangedListener implements GoogleMap.OnCameraChangeListener {

long lastMovedTime;
boolean taskRunning = false;
CameraPosition currentPosition;

@Override
public void onCameraChange(CameraPosition cameraPosition) {
currentPosition = cameraPosition;

if(cameraPosition.zoom > 13){
lastMovedTime = new Date().getTime();
if(!taskRunning){
taskRunning = true;
new AsyncTask<Void, Void, Void>(){
@Override
protected Void doInBackground(Void... params) {
long current = new Date().getTime();
long timePassed = current - lastMovedTime;
if(timePassed < 1000){
try {
Thread.sleep(150l);
doInBackground();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
taskRunning = false;
return null;
}
@Override
protected void onPostExecute(Void result){
Log.d(MapActivity.class.getSimpleName(), "Enough time has passed. Refreshing restaurants.");
showRestaurantsOnMap();
}
}.execute();
}
public void onCameraChange(final CameraPosition cameraPosition) {
if(cameraPosition.zoom > 12){
showRestaurantsOnMap();
}
}

Expand Down
18 changes: 18 additions & 0 deletions src/com/joshliberty/veganfriendly/api/ApiService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.joshliberty.veganfriendly.api;

import com.joshliberty.veganfriendly.models.Restaurant;
import retrofit.Callback;
import retrofit.http.GET;
import retrofit.http.Path;

import java.util.List;

/**
* Created bv by caligula on 09/06/14.
* This file is part of VeganFriendly.
*/
public interface ApiService {
public static String API_SERVER = "http://10.0.0.9:5000";
@GET("/restaurants/{latitude}/{longitude}")
void getRestaurants(@Path("latitude") double latitude, @Path("longitude") double longitude, Callback<List<Restaurant>> cb);
}

0 comments on commit cf79a09

Please sign in to comment.