From e4e61f2d883dbeb164c2567d2ab58792ae4126c0 Mon Sep 17 00:00:00 2001 From: rustie Date: Mon, 21 Jan 2019 09:33:11 -0800 Subject: [PATCH] shhh (#116) --- .../asucmobile/fragments/MapsFragment.java | 31 +++++++++++++++++-- .../asuc/asucmobile/main/LiveBusActivity.java | 3 ++ .../utilities/NavigationGenerator.java | 8 ----- app/src/main/res/layout/credits_dialog.xml | 15 +++------ 4 files changed, 36 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/com/asuc/asucmobile/fragments/MapsFragment.java b/app/src/main/java/com/asuc/asucmobile/fragments/MapsFragment.java index bf0780c5..09de293f 100644 --- a/app/src/main/java/com/asuc/asucmobile/fragments/MapsFragment.java +++ b/app/src/main/java/com/asuc/asucmobile/fragments/MapsFragment.java @@ -7,6 +7,7 @@ import android.content.SharedPreferences; import android.content.pm.PackageManager; +import android.graphics.Bitmap; import android.graphics.Color; import android.icu.text.SimpleDateFormat; import android.icu.util.TimeZone; @@ -41,6 +42,7 @@ import com.asuc.asucmobile.R; import com.asuc.asucmobile.controllers.Controller; import com.asuc.asucmobile.controllers.LiveBusController; +import com.asuc.asucmobile.main.CreditsDialog; import com.asuc.asucmobile.main.LiveBusActivity; import com.asuc.asucmobile.main.PopUpActivity; import com.asuc.asucmobile.main.RouteSelectActivity; @@ -110,6 +112,8 @@ public class MapsFragment extends Fragment private GoogleMap mMap; Gson gson = new Gson(); final LatLng BERKELEY = new LatLng(37.8716, -122.2727); + final LatLng EGG = new LatLng(37.8266,-122.3236); + final String GO_BEARS = "go bears!"; private GoogleApiClient googleApiClient; double longitude; double latitude; @@ -382,7 +386,6 @@ public void onClick(View v) { } }); - /** * Manipulates the map once available. * This callback is triggered when the map is ready to be used. @@ -518,6 +521,10 @@ public void onMapClick(LatLng latLng) { bmService.callIconList().enqueue(new retrofit2.Callback() { @Override public void onResponse(Call call, Response response) { + + if (response.body() == null) + return; + mapHash.put("Microwave", response.body().getMicrowaves()); mapHash.put("Water Fountain", response.body().getWaterFountains()); mapHash.put("Nap Pod", response.body().getNapPods()); @@ -534,6 +541,8 @@ public void onFailure(Call call, Throwable t) { liveTrack(); + shh(); + } private void updateLocation(View v) { @@ -561,11 +570,19 @@ private void updateLocation(View v) { @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) public boolean onMarkerClick(final Marker marker) { + Log.d("HELLOOO", "MARKER CLICKED"); if (marker.getTag() == null) { return true; //If the live busIcon is selected, dont' do anything. } + // shhh + if (marker.getTitle().equals(GO_BEARS)) { + Intent i = new Intent(getActivity(), CreditsDialog.class); + startActivity(i); + return true; + } + Intent popUp; clearFocus(); //marker.setIcon(icon); @@ -608,7 +625,7 @@ private void loadMarkers(HashMap> items) { ArrayList sleepPods = items.get("Nap Pod"); BitmapDescriptor microwaveIcon = BitmapDescriptorFactory.fromResource(R.drawable.microwave_map_icon); BitmapDescriptor waterBottleIcon = BitmapDescriptorFactory.fromResource(R.drawable.waterbottle_map_icon); - BitmapDescriptor sleepPodIcon =BitmapDescriptorFactory.fromResource(R.drawable.sleeppod_map_icon); + BitmapDescriptor sleepPodIcon = BitmapDescriptorFactory.fromResource(R.drawable.sleeppod_map_icon); if (microwaves != null && microwaves.size() != 0) { for (CategoryLoc loc : microwaves) { @@ -662,7 +679,17 @@ private void loadMarkers(HashMap> items) { } } + } + private void shh() { + BitmapDescriptor bearIcon = BitmapDescriptorFactory.fromResource(R.drawable.bearmarker); + MarkerOptions singleMarkerOption = new MarkerOptions() + .position(EGG) + .icon(bearIcon) + .visible(true) + .title(GO_BEARS); + Marker singleMarker = mMap.addMarker(singleMarkerOption); + singleMarker.setTag(false); } public String getDistance(double lat, double lng) { diff --git a/app/src/main/java/com/asuc/asucmobile/main/LiveBusActivity.java b/app/src/main/java/com/asuc/asucmobile/main/LiveBusActivity.java index 804a628b..d7b91caf 100755 --- a/app/src/main/java/com/asuc/asucmobile/main/LiveBusActivity.java +++ b/app/src/main/java/com/asuc/asucmobile/main/LiveBusActivity.java @@ -157,6 +157,9 @@ public void onResponse(Call call, Response response) { failCount = 0; } + if (response.body() == null) + return; + List buses = LiveBusController.parse(response.body()); HashSet lines = new HashSet<>(); diff --git a/app/src/main/java/com/asuc/asucmobile/utilities/NavigationGenerator.java b/app/src/main/java/com/asuc/asucmobile/utilities/NavigationGenerator.java index 83e3c264..4da44157 100644 --- a/app/src/main/java/com/asuc/asucmobile/utilities/NavigationGenerator.java +++ b/app/src/main/java/com/asuc/asucmobile/utilities/NavigationGenerator.java @@ -159,14 +159,6 @@ public static void openMenu(@NonNull final Activity activity) { DrawerLayout drawerLayout = (DrawerLayout) activity.findViewById(R.id.drawer_layout); if (drawerLayout != null) { drawerLayout.openDrawer(Gravity.LEFT); - View v = drawerLayout.findViewById(R.id.drawer_header); - v.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Intent i = new Intent(activity, CreditsDialog.class); - activity.startActivity(i); - } - }); } } diff --git a/app/src/main/res/layout/credits_dialog.xml b/app/src/main/res/layout/credits_dialog.xml index 905ff8e3..374df538 100644 --- a/app/src/main/res/layout/credits_dialog.xml +++ b/app/src/main/res/layout/credits_dialog.xml @@ -28,7 +28,7 @@ @@ -36,7 +36,7 @@ @@ -44,7 +44,7 @@ @@ -52,18 +52,11 @@ -