-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
177 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
catch/src/main/java/uk/ac/masts/sifids/activities/MapActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
package uk.ac.masts.sifids.activities; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.Toolbar; | ||
import android.util.Log; | ||
import android.view.Menu; | ||
import android.view.MenuInflater; | ||
import android.view.MenuItem; | ||
|
||
import com.google.android.gms.maps.CameraUpdateFactory; | ||
import com.google.android.gms.maps.GoogleMap; | ||
import com.google.android.gms.maps.MapFragment; | ||
import com.google.android.gms.maps.OnMapReadyCallback; | ||
import com.google.android.gms.maps.model.MarkerOptions; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import uk.ac.masts.sifids.R; | ||
import uk.ac.masts.sifids.database.CatchDatabase; | ||
import uk.ac.masts.sifids.entities.CatchLocation; | ||
|
||
public class MapActivity extends AppCompatActivity implements OnMapReadyCallback { | ||
|
||
CatchDatabase db; | ||
List<CatchLocation> points; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
|
||
super.onCreate(savedInstanceState); | ||
|
||
setContentView(R.layout.activity_map); | ||
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); | ||
// setSupportActionBar(toolbar); | ||
|
||
db = CatchDatabase.getInstance(getApplicationContext()); | ||
|
||
MapFragment mapFragment = (MapFragment) getFragmentManager() | ||
.findFragmentById(R.id.map); | ||
mapFragment.getMapAsync(this); | ||
|
||
} | ||
|
||
@Override | ||
public boolean onCreateOptionsMenu(Menu menu) { | ||
MenuInflater inflater = getMenuInflater(); | ||
inflater.inflate(R.menu.main_menu, menu); | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
// Handle item selection | ||
Intent intent; | ||
switch (item.getItemId()) { | ||
case R.id.settings: | ||
intent = new Intent(this, SettingsActivity.class); | ||
startActivity(intent); | ||
return true; | ||
case R.id.activity_catch: | ||
intent = new Intent(this, Fish1FormsActivity.class); | ||
startActivity(intent); | ||
return true; | ||
case R.id.activity_map: | ||
intent = new Intent(this, MapActivity.class); | ||
startActivity(intent); | ||
return true; | ||
default: | ||
return super.onOptionsItemSelected(item); | ||
} | ||
} | ||
|
||
@Override | ||
public void onMapReady(GoogleMap map) { | ||
|
||
points = new ArrayList(); | ||
|
||
Runnable r = new Runnable(){ | ||
@Override | ||
public void run() { | ||
points = db.catchDao().getLastLocations(100); | ||
} | ||
}; | ||
|
||
Thread newThread= new Thread(r); | ||
newThread.start(); | ||
try { | ||
newThread.join(); | ||
} | ||
catch (InterruptedException ie) { | ||
|
||
} | ||
|
||
map.setMapType(GoogleMap.MAP_TYPE_TERRAIN); | ||
|
||
boolean first = true; | ||
for (CatchLocation point : points) { | ||
Log.e("Map", "Got " + point.getCoordinates()); | ||
map.addMarker(new MarkerOptions().position(point.getLatLng()).title(point.getCoordinates())); | ||
if (first) { | ||
map.moveCamera(CameraUpdateFactory.newLatLngZoom(point.getLatLng(), (float) 10.0)); | ||
first = false; | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context="uk.ac.masts.sifids.activities.MapActivity"> | ||
|
||
<!--<android.support.design.widget.AppBarLayout--> | ||
<!--android:layout_width="match_parent"--> | ||
<!--android:layout_height="wrap_content"--> | ||
<!--android:theme="@style/AppTheme.AppBarOverlay">--> | ||
|
||
<!--<android.support.v7.widget.Toolbar--> | ||
<!--android:id="@+id/toolbar"--> | ||
<!--android:layout_width="match_parent"--> | ||
<!--android:layout_height="?attr/actionBarSize"--> | ||
<!--android:background="?attr/colorPrimary"--> | ||
<!--app:popupTheme="@style/AppTheme.PopupOverlay" />--> | ||
|
||
<!--</android.support.design.widget.AppBarLayout>--> | ||
|
||
<RelativeLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<fragment xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:name="com.google.android.gms.maps.MapFragment" | ||
android:id="@+id/map" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"/> | ||
|
||
</RelativeLayout> | ||
|
||
</android.support.constraint.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters