Commit b037731f authored by Varun Patil's avatar Varun Patil

Load locations on map from network

parent 76269470
...@@ -13,6 +13,7 @@ import app.insti.data.NewsArticle; ...@@ -13,6 +13,7 @@ import app.insti.data.NewsArticle;
import app.insti.data.PlacementBlogPost; import app.insti.data.PlacementBlogPost;
import app.insti.data.TrainingBlogPost; import app.insti.data.TrainingBlogPost;
import app.insti.data.User; import app.insti.data.User;
import app.insti.data.Venue;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.http.Body; import retrofit2.http.Body;
import retrofit2.http.GET; import retrofit2.http.GET;
...@@ -34,6 +35,9 @@ public interface RetrofitInterface { ...@@ -34,6 +35,9 @@ public interface RetrofitInterface {
@GET("events") @GET("events")
Call<NewsFeedResponse> getNewsFeed(@Header("Cookie") String sessionId); Call<NewsFeedResponse> getNewsFeed(@Header("Cookie") String sessionId);
@GET("locations")
Call<List<Venue>> getAllVenues();
@GET("events") @GET("events")
Call<NewsFeedResponse> getEventsBetweenDates(@Header("Cookie") String sessionId, @Query("start") String start, @Query("end") String end); Call<NewsFeedResponse> getEventsBetweenDates(@Header("Cookie") String sessionId, @Query("start") String start, @Query("end") String end);
......
...@@ -69,6 +69,12 @@ import java.util.Locale; ...@@ -69,6 +69,12 @@ import java.util.Locale;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import app.insti.R; import app.insti.R;
import app.insti.api.RetrofitInterface;
import app.insti.api.ServiceGenerator;
import app.insti.data.Venue;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class MapFragment extends Fragment implements TextWatcher, public class MapFragment extends Fragment implements TextWatcher,
TextView.OnEditorActionListener, AdapterView.OnItemClickListener, View.OnFocusChangeListener, TextView.OnEditorActionListener, AdapterView.OnItemClickListener, View.OnFocusChangeListener,
...@@ -160,12 +166,31 @@ public class MapFragment extends Fragment implements TextWatcher, ...@@ -160,12 +166,31 @@ public class MapFragment extends Fragment implements TextWatcher,
@Override @Override
public void onStart() { public void onStart() {
super.onStart(); super.onStart();
setUpDrawer();
/* Set title */ /* Set title */
Toolbar toolbar = getActivity().findViewById(R.id.toolbar); Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
toolbar.setTitle("InstiMap"); toolbar.setTitle("InstiMap");
RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
retrofitInterface.getAllVenues().enqueue(new Callback<List<Venue>>() {
@Override
public void onResponse(Call<List<Venue>> call, Response<List<Venue>> response) {
if (response.isSuccessful()) {
Locations mLocations = new Locations(response.body());
data = mLocations.data;
markerlist = new ArrayList<com.mrane.data.Marker>(data.values());
setUpDrawer();
setupMap();
}
}
@Override
public void onFailure(Call<List<Venue>> call, Throwable t) { }
});
}
private void setupMap() {
newSmallCard = (LinearLayout) getActivity().findViewById(R.id.new_small_card); newSmallCard = (LinearLayout) getActivity().findViewById(R.id.new_small_card);
slidingLayout = (SlidingUpPanelLayout) getActivity().findViewById(R.id.sliding_layout); slidingLayout = (SlidingUpPanelLayout) getActivity().findViewById(R.id.sliding_layout);
placeNameTextView = (TextView) getActivity().findViewById(R.id.place_name); placeNameTextView = (TextView) getActivity().findViewById(R.id.place_name);
...@@ -177,9 +202,6 @@ public class MapFragment extends Fragment implements TextWatcher, ...@@ -177,9 +202,6 @@ public class MapFragment extends Fragment implements TextWatcher,
slidingLayout.post(setAnchor()); slidingLayout.post(setAnchor());
Locations mLocations = new Locations(getContext());
data = mLocations.data;
markerlist = new ArrayList<com.mrane.data.Marker>(data.values());
initShowDefault(); initShowDefault();
initImageUri(); initImageUri();
...@@ -236,7 +258,6 @@ public class MapFragment extends Fragment implements TextWatcher, ...@@ -236,7 +258,6 @@ public class MapFragment extends Fragment implements TextWatcher,
addMarkerClick(v); addMarkerClick(v);
} }
}); });
} }
private void setUpDrawer() { private void setUpDrawer() {
......
...@@ -9,4 +9,11 @@ public class Building extends Marker { ...@@ -9,4 +9,11 @@ public class Building extends Marker {
this.children = children; this.children = children;
} }
public String[] getChildren() {
return children;
}
public void setChildren(String[] children) {
this.children = children;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment