Skip to content

Commit

Permalink
fix: resolved redundant code, unused code, and reference errors, plus…
Browse files Browse the repository at this point in the history
… updated SubmitBuildingActivity layout
  • Loading branch information
nelsonni committed Mar 16, 2014
1 parent 7631f2d commit c6a8cd7
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 185 deletions.
95 changes: 42 additions & 53 deletions res/layout/activity_submit_building.xml
Original file line number Diff line number Diff line change
@@ -1,66 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

android:layout_height="match_parent" >

<Button
android:id="@+id/submit_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="58dp"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:text="@string/submit" />

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/edit_text_abbreviation"
android:layout_alignTop="@+id/checkBox1"
android:text="@string/wheelchair_accessible"
android:textAppearance="?android:attr/textAppearanceMedium" />

<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/edit_text_abbreviation"
android:layout_marginLeft="33dp"
android:layout_marginTop="36dp"
android:layout_toRightOf="@+id/textView1" />


<EditText
android:id="@+id/edit_text_building_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@+id/checkBox1"
android:layout_alignParentLeft="true"
android:layout_alignStart="@id/submit_button"
android:layout_marginTop="10dp"
android:ems="10"
android:hint="@string/building_name" />

<EditText
android:id="@+id/edit_text_abbreviation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/edit_text_building_name"
android:layout_marginTop="14dp"
android:layout_marginTop="10dp"
android:ems="10"
android:hint="@string/abbreviation" >

<requestFocus />
</EditText>
android:hint="@string/abbreviation" />

<TextView
android:id="@+id/accessible_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below = "@id/edit_text_abbreviation"
android:layout_marginTop="10dp"
android:padding="5dp"
android:ems="10"
android:text="@string/wheelchair_accessible"
android:textAppearance="?android:attr/textAppearanceMedium" />

<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/accessible_text"
android:layout_toRightOf="@+id/accessible_text" />

<!-- Setting MissingPrefix to ignore is only required to circumvent a bug in the Linter linker which is included in the Android SDK.
Further details regarding this bug can be found at: https://code.google.com/p/gmaps-api-issues/issues/detail?id=5002
-->

<fragment
android:id="@+id/submitBuildingMap"
android:id="@+id/submit_map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/submit_button"
android:layout_alignParentLeft="true"
android:layout_below="@+id/checkBox1"
android:layout_marginTop="10dp"
android:layout_below="@id/accessible_text"
tools:ignore="MissingPrefix"
map:cameraTargetLat="44.5657285"
map:cameraTargetLng="-123.2788689"
map:cameraTilt="30"
Expand All @@ -71,23 +77,6 @@
map:uiScrollGestures="true"
map:uiTiltGestures="true"
map:uiZoomControls="false"
map:uiZoomGestures="true"
tools:ignore="MissingPrefix" />

<Button
android:id="@+id/submit_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_alignParentBottom="true"
android:text="@string/submit" />

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="@+id/checkBox1"
android:textAppearance="?android:attr/textAppearanceLarge" />
map:uiZoomGestures="true" />

</RelativeLayout>
16 changes: 8 additions & 8 deletions src/com/example/classlocus/BuildingDetail.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class BuildingDetail extends Activity {
LocationManager manager;
Building building;
GoogleMap map;
BuildingsRepository db;
BuildingsRepository database;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -35,7 +35,7 @@ protected void onCreate(Bundle savedInstanceState) {
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setTitle("Building Detail");

db = new BuildingsRepository(this);
database = new BuildingsRepository(this);

map = ((MapFragment) getFragmentManager().findFragmentById(R.id.details_map)).getMap();
map.setMyLocationEnabled(true);
Expand All @@ -47,7 +47,7 @@ protected void onCreate(Bundle savedInstanceState) {
TextView tv;

if (getIntent().hasExtra("buildingID"))
building = populate(getIntent(), db);
building = populate(getIntent(), database);

//populating fields
if (building != null){
Expand Down Expand Up @@ -98,7 +98,7 @@ public boolean onPrepareOptionsMenu (Menu menu){
inflater.inflate(R.menu.building_detail, menu);

MenuItem fav = menu.findItem(R.id.action_favorites);
if(db.searchFavorites(building) != 0){
if(database.searchFavorites(building) != 0){
fav.setIcon(getResources().getDrawable(R.drawable.ic_action_important));
}
return true;
Expand All @@ -109,12 +109,12 @@ public boolean onOptionsItemSelected(MenuItem item) {
int fid;
switch (item.getItemId()) {
case R.id.action_favorites:
fid = db.searchFavorites(building);
fid = database.searchFavorites(building);
if (fid != 0) {
db.deleteFavorite(fid);
database.deleteFavorite(fid);
item.setIcon(getResources().getDrawable(R.drawable.ic_action_not_important));
} else {
db.saveFavorite(building);
database.saveFavorite(building);
item.setIcon(getResources().getDrawable(R.drawable.ic_action_important));
}
return true;
Expand All @@ -129,7 +129,7 @@ public double buildingDistance(LatLng coord1, LatLng coord2){
}

public void addToFavorites() {
db.saveFavorite(building);
database.saveFavorite(building);
}

public void updateMapPosition(LatLng position) {
Expand Down
2 changes: 0 additions & 2 deletions src/com/example/classlocus/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ protected void onCreate(Bundle savedInstanceState) {

BuildingGenerator.initialDbState(this);
this.setContentView(R.layout.activity_main);


}

@Override
Expand Down
Loading

0 comments on commit c6a8cd7

Please sign in to comment.