Skip to content
Snippets Groups Projects
Commit f416ffce authored by Shawn Kauenhofen (sak330)'s avatar Shawn Kauenhofen (sak330)
Browse files

Restaurants missing google reviews, events crash

parent b599c2f2
No related branches found
No related tags found
No related merge requests found
...@@ -69,13 +69,12 @@ public class MainActivity extends AppCompatActivity implements CustomAdapter.Ite ...@@ -69,13 +69,12 @@ public class MainActivity extends AppCompatActivity implements CustomAdapter.Ite
mUser.addTag("Fine Arts"); mUser.addTag("Fine Arts");
pModel = new PersistentModel();
mModel = new Model(this.getApplication(), mUser, pModel);
pModel.setUser(mUser); pModel.setUser(mUser);
popAdapter = new CustomAdapter(this, mModel.getPopList()); popAdapter = new CustomAdapter(this, mModel.getPopList());
curAdapter = new CustomAdapter(this, mModel.getCurList()); curAdapter = new CustomAdapter(this, mModel.getCurList());
pinAdapter = new CustomAdapter(this, mModel.getPinList()); pinAdapter = new CustomAdapter(this, mModel.getPinList());
......
...@@ -10,8 +10,6 @@ import androidx.annotation.NonNull; ...@@ -10,8 +10,6 @@ import androidx.annotation.NonNull;
import androidx.core.content.res.ResourcesCompat; import androidx.core.content.res.ResourcesCompat;
import com.android.volley.BuildConfig;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -32,7 +30,6 @@ public class Model { ...@@ -32,7 +30,6 @@ public class Model {
private EventRestoList curList; private EventRestoList curList;
private EventRestoList pinList; private EventRestoList pinList;
private ViewEvent viewEvent;
private Map<String, Review[]> resReviews; private Map<String, Review[]> resReviews;
private Map<String, Review[]> eventReviews; private Map<String, Review[]> eventReviews;
...@@ -46,7 +43,6 @@ public class Model { ...@@ -46,7 +43,6 @@ public class Model {
public Model(@NonNull Application app, User u, PersistentModel pModel) { public Model(@NonNull Application app, User u, PersistentModel pModel) {
user = u; user = u;
application = app; application = app;
...@@ -61,8 +57,6 @@ public class Model { ...@@ -61,8 +57,6 @@ public class Model {
pinList = pinController.getPinnedEvents(); pinList = pinController.getPinnedEvents();
callGoogle(); callGoogle();
} }
public void setPopAdapter(CustomAdapter adapter) { this.popAdapter = adapter; } public void setPopAdapter(CustomAdapter adapter) { this.popAdapter = adapter; }
...@@ -181,7 +175,7 @@ public class Model { ...@@ -181,7 +175,7 @@ public class Model {
PlacesInterface apiInterface = RetrofitClient.getClient().create(PlacesInterface.class); PlacesInterface apiInterface = RetrofitClient.getClient().create(PlacesInterface.class);
// Initiate call and map it to the serialized objects // Initiate call and map it to the serialized objects
Call<QuerySerialization.PlacesNearbySearchResponse> call = apiInterface.queryPlaces(type, location, keyword, "distance", BuildConfig.GOOGLE_PLACES_API_KEY); Call<QuerySerialization.PlacesNearbySearchResponse> call = apiInterface.queryPlaces(type, location, keyword, "distance", BuildConfig.GOOGLE_PLACE_API_KEY);
call.enqueue(new Callback<QuerySerialization.PlacesNearbySearchResponse>() { call.enqueue(new Callback<QuerySerialization.PlacesNearbySearchResponse>() {
@Override @Override
public void onResponse(@NonNull Call<QuerySerialization.PlacesNearbySearchResponse> call, @NonNull Response<QuerySerialization.PlacesNearbySearchResponse> response) { public void onResponse(@NonNull Call<QuerySerialization.PlacesNearbySearchResponse> call, @NonNull Response<QuerySerialization.PlacesNearbySearchResponse> response) {
...@@ -202,7 +196,7 @@ public class Model { ...@@ -202,7 +196,7 @@ public class Model {
// Perform detail query to get hours // Perform detail query to get hours
PlacesInterface apiInterface = RetrofitClient.getClient().create(PlacesInterface.class); PlacesInterface apiInterface = RetrofitClient.getClient().create(PlacesInterface.class);
Call<DetailSerialization.PlaceDetailsResponse> call2 = apiInterface.queryDetails(returnedList.get(i).placeId, BuildConfig.GOOGLE_PLACES_API_KEY); Call<DetailSerialization.PlaceDetailsResponse> call2 = apiInterface.queryDetails(returnedList.get(i).placeId, BuildConfig.GOOGLE_PLACE_API_KEY);
call2.enqueue(new Callback<DetailSerialization.PlaceDetailsResponse>() { call2.enqueue(new Callback<DetailSerialization.PlaceDetailsResponse>() {
@Override @Override
......
package com.example.event36;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;
import androidx.annotation.NonNull;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
public class PersistentModel implements Parcelable {
private List<Restaurant> restaurants = new ArrayList<>();
private List<Event> events = new ArrayList<>();
private User user;
public PersistentModel(){
}
protected PersistentModel(Parcel in) {
Gson gson = new Gson();
String userJson = in.readString();
user = gson.fromJson(userJson, User.class);
String eventsJson = in.readString();
Type listOfEventType = new TypeToken<ArrayList<Event>>() {}.getType();
events = gson.fromJson(eventsJson , listOfEventType);
String restaurantsJson = in.readString();
Type listOfRestaurantType = new TypeToken<ArrayList<Restaurant>>() {}.getType();
restaurants = gson.fromJson(restaurantsJson , listOfRestaurantType);
}
public static final Creator<PersistentModel> CREATOR = new Creator<PersistentModel>() {
@Override
public PersistentModel createFromParcel(Parcel in) {
return new PersistentModel(in);
}
@Override
public PersistentModel[] newArray(int size) {
return new PersistentModel[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
Gson gson = new Gson();
String userJson = gson.toJson(user);
dest.writeString(userJson);
String eventsJson = gson.toJson(events);
dest.writeString(eventsJson);
String restaurantJson = gson.toJson(restaurants);
dest.writeString(restaurantJson);
}
public void addEvent(Event e){
events.add(e);
}
public void addRestaurant(Restaurant res){
restaurants.add(res);
}
public void addRestaurants(List<Restaurant> restaurants){
this.restaurants.addAll(restaurants);
Log.d("PersistentModelR", "Current number of restaurants: " + this.restaurants.size());
}
//getter and setter for user
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public Restaurant getRestaurantById(String resId) {
for (Restaurant item : restaurants) {
if ( item.getId().equals(resId)) {
return item;
}
}
return null;
}
public List<Restaurant> getRestaurants() {
return restaurants;
}
}
...@@ -32,7 +32,7 @@ public class ReviewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> ...@@ -32,7 +32,7 @@ public class ReviewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
* by RecyclerView. * by RecyclerView.
*/ */
ReviewAdapter(Context context, Context baseContext, EventRestoSuperClass place) { ReviewAdapter(Context context, Context baseContext, EventRestoSuperClass place) {
Log.d("ReviewAdapter place_type", place.getPlaceType().toString()); //Log.d("ReviewAdapter place_type", place.getPlaceType().toString());
this.mInflater = LayoutInflater.from(context); this.mInflater = LayoutInflater.from(context);
this.baseContext = baseContext; this.baseContext = baseContext;
this.place = place; this.place = place;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment