Skip to content

Commit

Permalink
Updated finding location of start and end of trip. Removed Insurance …
Browse files Browse the repository at this point in the history
…info from nav drawer
  • Loading branch information
aaron-weaver committed Mar 21, 2015
1 parent 1e2718e commit f0a2cd3
Show file tree
Hide file tree
Showing 10 changed files with 851 additions and 226 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

942 changes: 749 additions & 193 deletions .idea/workspace.xml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
Expand Down
33 changes: 31 additions & 2 deletions app/src/main/java/andronerds/com/contestapp/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.SharedPreferences;
import android.location.Address;
import android.location.Geocoder;
import android.support.v7.widget.Toolbar;
import android.util.Log;

Expand All @@ -15,8 +17,10 @@
import com.google.android.gms.maps.model.LatLngBounds;
import com.google.android.gms.maps.model.MarkerOptions;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;

import andronerds.com.contestapp.data.Achievements;
import andronerds.com.contestapp.data.Trip;
Expand Down Expand Up @@ -119,15 +123,40 @@ public void openGMaps(Trip trip)
@Override
public void onMapReady(GoogleMap map)
{
Geocoder geocoder = new Geocoder(this, Locale.getDefault());
String startAdd = "";
String endAdd = "";
try
{
List<Address> startAddrList = geocoder.getFromLocation(mTrip.getmTripStartLat(), mTrip.getmTripStartLong(), 1);
Address start = startAddrList.get(0);
startAdd = start.getAddressLine(0);
startAdd = startAdd + "\n" + start.getAddressLine(1);
} catch (IOException e)
{
e.printStackTrace();
}

try
{
List<Address> endAddrList = geocoder.getFromLocation(mTrip.getmTripEndLat(), mTrip.getmTripEndLong(), 1);
Address end = endAddrList.get(0);
endAdd = end.getAddressLine(0);
endAdd = endAdd + "\n" + end.getAddressLine(1);
} catch (IOException e)
{
e.printStackTrace();
}

map.setMapType(GoogleMap.MAP_TYPE_NORMAL);

map.addMarker(new MarkerOptions()
.position(new LatLng(mTrip.getmTripStartLat(), mTrip.getmTripStartLong()))
.title("Start: " + mTrip.getmTripStart()));
.title("Start: " + "\n" + startAdd));

map.addMarker(new MarkerOptions()
.position(new LatLng(mTrip.getmTripEndLat(), mTrip.getmTripEndLong()))
.title("End: " + mTrip.getmTripEnd()));
.title("End: " + "\n" + endAdd));

LatLngBounds.Builder builder = new LatLngBounds.Builder();
builder.include(new LatLng(mTrip.getmTripStartLat(), mTrip.getmTripStartLong()));
Expand Down
35 changes: 33 additions & 2 deletions app/src/main/java/andronerds/com/contestapp/MyTripsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.location.Address;
import android.location.Geocoder;
import android.support.v7.widget.Toolbar;

import com.google.android.gms.maps.CameraUpdate;
Expand All @@ -13,6 +15,10 @@
import com.google.android.gms.maps.model.LatLngBounds;
import com.google.android.gms.maps.model.MarkerOptions;

import java.io.IOException;
import java.util.List;
import java.util.Locale;

import andronerds.com.contestapp.data.Trip;
import andronerds.com.contestapp.fragments.trips.MyTripsFragment;
import andronerds.com.contestapp.navDrawer.NavDrawerActivity;
Expand Down Expand Up @@ -78,15 +84,40 @@ public void openGMaps(Trip trip)
@Override
public void onMapReady(GoogleMap map)
{
Geocoder geocoder = new Geocoder(this, Locale.getDefault());
String startAdd = "";
String endAdd = "";
try
{
List<Address> startAddrList = geocoder.getFromLocation(mTrip.getmTripStartLat(), mTrip.getmTripStartLong(), 1);
Address start = startAddrList.get(0);
startAdd = start.getAddressLine(0);
startAdd = startAdd + "\n" + start.getAddressLine(1);
} catch (IOException e)
{
e.printStackTrace();
}

try
{
List<Address> endAddrList = geocoder.getFromLocation(mTrip.getmTripEndLat(), mTrip.getmTripEndLong(), 1);
Address end = endAddrList.get(0);
endAdd = end.getAddressLine(0);
endAdd = endAdd + "\n" + end.getAddressLine(1);
} catch (IOException e)
{
e.printStackTrace();
}

map.setMapType(GoogleMap.MAP_TYPE_NORMAL);

map.addMarker(new MarkerOptions()
.position(new LatLng(mTrip.getmTripStartLat(), mTrip.getmTripStartLong()))
.title("Start: " + mTrip.getmTripStart()));
.title("Start: " + "\n" + startAdd));

map.addMarker(new MarkerOptions()
.position(new LatLng(mTrip.getmTripEndLat(), mTrip.getmTripEndLong()))
.title("End: " + mTrip.getmTripEnd()));
.title("End: " + "\n" + endAdd));

LatLngBounds.Builder builder = new LatLngBounds.Builder();
builder.include(new LatLng(mTrip.getmTripStartLat(), mTrip.getmTripStartLong()));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package andronerds.com.contestapp.cards;

import android.content.Context;
import android.location.Address;
import android.location.Geocoder;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
Expand All @@ -11,6 +13,10 @@
import com.google.android.gms.maps.GoogleMapOptions;
import com.squareup.picasso.Picasso;

import java.io.IOException;
import java.util.List;
import java.util.Locale;

import andronerds.com.contestapp.R;
import andronerds.com.contestapp.data.Trip;
import butterknife.ButterKnife;
Expand Down Expand Up @@ -51,8 +57,34 @@ public void setupInnerViewElements(ViewGroup parent, View view)

//mTripMapView.setImageDrawable(getContext().getResources().getDrawable(R.drawable.map_placeholder));

mFromText.setText(mTrip.getmTripStart());
mToText.setText(mTrip.getmTripEnd());
Geocoder geocoder = new Geocoder(getContext(), Locale.getDefault());
String startAdd = "";
String endAdd = "";
try
{
List<Address> startAddrList = geocoder.getFromLocation(mTrip.getmTripStartLat(), mTrip.getmTripStartLong(), 1);
Address start = startAddrList.get(0);
startAdd = start.getAddressLine(1);
} catch (IOException e)
{
e.printStackTrace();
}

try
{
List<Address> endAddrList = geocoder.getFromLocation(mTrip.getmTripEndLat(), mTrip.getmTripEndLong(), 1);
Address end = endAddrList.get(0);
endAdd = end.getAddressLine(1);
} catch (IOException e)
{
e.printStackTrace();
}

startAdd = startAdd.replaceAll("\\d","");
endAdd = endAdd.replaceAll("\\d","");

mFromText.setText(startAdd);
mToText.setText(endAdd);


Picasso.with(this.getContext())
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
<item>Trips</item>
<item>MY PROFILE</item>
<item>Profile</item>
<item>Insurance Info</item>
<item>Emergency</item>
<item>Settings</item>
</string-array>
Expand All @@ -47,7 +46,6 @@
<item>Activity</item>
<item>Activity</item>
<item>Activity</item>
<item>Activity</item>
</string-array>

<string-array name="achievement_description">
Expand Down
21 changes: 0 additions & 21 deletions contest_app.iml

This file was deleted.

4 changes: 2 additions & 2 deletions local.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Fri Mar 20 19:47:22 CDT 2015
sdk.dir=D\:\\ProgramFiles\\AndroidSDK
#Fri Mar 20 20:56:57 CDT 2015
sdk.dir=/home/weava/Applications/android-studio/sdk

0 comments on commit f0a2cd3

Please sign in to comment.