Commit 721b01f0 authored by Varun Patil's avatar Varun Patil

Follow venue from event page

parent 2b269e05
...@@ -63,4 +63,5 @@ public class Constants { ...@@ -63,4 +63,5 @@ public class Constants {
public static final double MAP_Xn = 19.134417, MAP_Yn = 72.901229, MAP_Zn = 1757, MAP_Zyn = 501; public static final double MAP_Xn = 19.134417, MAP_Yn = 72.901229, MAP_Zn = 1757, MAP_Zyn = 501;
public static final double[] MAP_WEIGHTS_X = {-11.392001766454612, -36.31634553309953, 73.91269388324432, -24.14021153064087, 3.4508817531539115, -0.1462262375477863, 5.532505074667804, -1.542391995870977, 36.14211738142935}; public static final double[] MAP_WEIGHTS_X = {-11.392001766454612, -36.31634553309953, 73.91269388324432, -24.14021153064087, 3.4508817531539115, -0.1462262375477863, 5.532505074667804, -1.542391995870977, 36.14211738142935};
public static final double[] MAP_WEIGHTS_Y = {0.09738953520399705, -4.519868444089616, 62.38493718381985, 16.664561869057696, -2.168377988768651, 0.0919143297622087, 0.32304266159540823, 0.21688067854428716, -12.81393255320748}; public static final double[] MAP_WEIGHTS_Y = {0.09738953520399705, -4.519868444089616, 62.38493718381985, 16.664561869057696, -2.168377988768651, 0.0919143297622087, 0.32304266159540823, 0.21688067854428716, -12.81393255320748};
public static final String MAP_INITIAL_MARKER = "initial_marker";
} }
...@@ -11,6 +11,7 @@ import android.graphics.Point; ...@@ -11,6 +11,7 @@ import android.graphics.Point;
import android.graphics.Rect; import android.graphics.Rect;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.widget.NestedScrollView; import android.support.v4.widget.NestedScrollView;
...@@ -19,6 +20,10 @@ import android.support.v7.widget.RecyclerView; ...@@ -19,6 +20,10 @@ import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.text.Spannable; import android.text.Spannable;
import android.text.SpannableString; import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.text.style.ForegroundColorSpan; import android.text.style.ForegroundColorSpan;
import android.text.style.RelativeSizeSpan; import android.text.style.RelativeSizeSpan;
import android.util.Log; import android.util.Log;
...@@ -189,9 +194,41 @@ public class EventFragment extends BackHandledFragment implements TransitionTarg ...@@ -189,9 +194,41 @@ public class EventFragment extends BackHandledFragment implements TransitionTarg
bodyRecyclerView.setAdapter(bodyAdapter); bodyRecyclerView.setAdapter(bodyAdapter);
bodyRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); bodyRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
// Make the venues clickable
if (!eventVenueName.toString().equals("")) {
// Get the whole string
SpannableString ss = new SpannableString(eventVenueName.toString().substring(2));
if (!eventVenueName.toString().equals("")) // Make each venue clickable
eventVenue.setText(eventVenueName.toString().substring(2)); int i = 0;
for (final Venue venue : event.getEventVenues()) {
int length = venue.getVenueShortName().length();
ClickableSpan cs = new ClickableSpan() {
@Override
public void onClick(@NonNull View widget) {
MapFragment mapFragment = new MapFragment();
Bundle bundle = new Bundle();
bundle.putString(Constants.MAP_INITIAL_MARKER, venue.getVenueName());
mapFragment.setArguments(bundle);
((MainActivity) getActivity()).updateFragment(mapFragment);
}
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
if (getActivity() == null || !isAdded()) return;
ds.setColor(getResources().getColor(R.color.primaryTextColor));
ds.setUnderlineText(false);
}
};
ss.setSpan(cs, i, i + length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
i += length + 2;
}
// Setup the text view
eventVenue.setText(ss);
eventVenue.setMovementMethod(LinkMovementMethod.getInstance());
}
interestedButton.setOnClickListener(getUESOnClickListener(1)); interestedButton.setOnClickListener(getUESOnClickListener(1));
......
...@@ -278,7 +278,9 @@ public class MapFragment extends Fragment implements TextWatcher, ...@@ -278,7 +278,9 @@ public class MapFragment extends Fragment implements TextWatcher,
Locations mLocations = new Locations(venues); Locations mLocations = new Locations(venues);
data = mLocations.data; data = mLocations.data;
markerlist = new ArrayList<com.mrane.data.Marker>(data.values()); markerlist = new ArrayList<com.mrane.data.Marker>(data.values());
setupMap(); if (getArguments() != null) {
setupMap(getArguments().getString(Constants.MAP_INITIAL_MARKER));
}
// Setup locate button // Setup locate button
FloatingActionButton fab = getView().findViewById(R.id.locate_fab); FloatingActionButton fab = getView().findViewById(R.id.locate_fab);
...@@ -308,6 +310,10 @@ public class MapFragment extends Fragment implements TextWatcher, ...@@ -308,6 +310,10 @@ public class MapFragment extends Fragment implements TextWatcher,
} }
private void setupMap() { private void setupMap() {
setupMap(null);
}
private void setupMap(String initalMarkerName) {
if (getView() == null) { if (getView() == null) {
return; return;
} }
...@@ -340,6 +346,7 @@ public class MapFragment extends Fragment implements TextWatcher, ...@@ -340,6 +346,7 @@ public class MapFragment extends Fragment implements TextWatcher,
campusMapView.setImageAsset("map.jpg"); campusMapView.setImageAsset("map.jpg");
campusMapView.setSettingsManager(settingsManager); campusMapView.setSettingsManager(settingsManager);
campusMapView.setData(data); campusMapView.setData(data);
campusMapView.setInitialMarkerName(initalMarkerName);
addMarkerIcon = (ImageButton) getActivity().findViewById(R.id.add_marker_icon); addMarkerIcon = (ImageButton) getActivity().findViewById(R.id.add_marker_icon);
......
...@@ -74,6 +74,7 @@ public class CampusMapView extends SubsamplingScaleImageView { ...@@ -74,6 +74,7 @@ public class CampusMapView extends SubsamplingScaleImageView {
private float density; private float density;
private boolean isFirstLoad = true; private boolean isFirstLoad = true;
private SettingsManager settingsManager; private SettingsManager settingsManager;
private String initialMarkerName = null;
public CampusMapView(Context context) { public CampusMapView(Context context) {
this(context, null); this(context, null);
...@@ -100,6 +101,14 @@ public class CampusMapView extends SubsamplingScaleImageView { ...@@ -100,6 +101,14 @@ public class CampusMapView extends SubsamplingScaleImageView {
RATIO_SHOW_PIN_TEXT = ratio; RATIO_SHOW_PIN_TEXT = ratio;
} }
public String getInitialMarkerName() {
return initialMarkerName;
}
public void setInitialMarkerName(String initialMarkerName) {
this.initialMarkerName = initialMarkerName;
}
private void initialise() { private void initialise() {
displayMetrics = getResources().getDisplayMetrics(); displayMetrics = getResources().getDisplayMetrics();
density = displayMetrics.density; density = displayMetrics.density;
...@@ -119,11 +128,31 @@ public class CampusMapView extends SubsamplingScaleImageView { ...@@ -119,11 +128,31 @@ public class CampusMapView extends SubsamplingScaleImageView {
if (isFirstLoad) { if (isFirstLoad) {
Runnable runnable = new Runnable() { Runnable runnable = new Runnable() {
public void run() { public void run() {
// Center marker on start
Marker centerMarker = null;
// Iterate all markers
if (getInitialMarkerName() != null) {
for (Marker m : markerList) {
if (m.getName().equals(getInitialMarkerName())) {
centerMarker = m;
break;
}
}
}
// If a marker is to be centered
if (centerMarker != null) {
setAndShowResultMarker(centerMarker);
} else {
AnimationBuilder anim; AnimationBuilder anim;
anim = animateScaleAndCenter( anim = animateScaleAndCenter(
getTargetMinScale(), MapFragment.MAP_CENTER); getTargetMinScale(), MapFragment.MAP_CENTER);
anim.withDuration(MapFragment.DURATION_INIT_MAP_ANIM) anim.withDuration(MapFragment.DURATION_INIT_MAP_ANIM)
.start(); .start();
}
// Don't do this again
isFirstLoad = false; isFirstLoad = false;
} }
}; };
......
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