Skip to content

spec and starter code for prog3 - location message board

Notifications You must be signed in to change notification settings

cs160-spring2019/cs160-proj3-spec

 
 

Repository files navigation

cs160 prog3 implementation details

bCourses assignment part 1: https://bcourses.berkeley.edu/courses/1480508/assignments/7967220

bCourses assignment part 2: https://bcourses.berkeley.edu/courses/1480508/assignments/7971063

starter code: https://github.com/cs160-spring2019/prog3-starter

  1. Viewing Landmarks and how far away they are
  2. Accessing a landmark message board
  3. Posting / retrieving comments from a message board using Firebase

Viewing Landmarks and their locations

Requirements

  • display a recycler view with a cell for each landmark in bear_statues.json. Each cell should contain:
    • the landmark name
    • the landmark image: use the bear_images included in the starter code
    • the distance between that landmark and your user's last updated location
  • an "update location" button. when pressed, you should fetch the user's location and update each of the landmark's distances

Getting the user's current location

You can locate your user using android's locationing api's. Since these api's are a part of Google Play Services, you will need to run an emulator with Google Play Services already installed (i.e., Nexus 5 or 5x) or install Google Play Services to an existing emulator.

Tips:

making location updates via the simulator

Accessing a landmark message board

Requirements

  • Users should only be able to access a location's message board if they are within 10 feet of that location.
// returns true if location A is less than 10 meters away from location B
Math.round(locationA.distanceTo(locationB)) < 10

To present the message board, you will need to use an Intent

Intent goToSecondActivityIntent = new Intent(FirstActivity.this, SecondActivity.class);
FirstActivity.this.startActivity(goToSecondActivityIntent);

To pass data through an intent to the next activity, you can use the putExtra and getExtras methods.

FirstActivity.java

String hello = "hello";
goToSecondActivityIntent.putExtra("helloString", hello);

SecondActivity.java

Intent goToSecondActivityIntent = getIntent();
Bundle intentExtras = goToSecondActivityIntent.getExtras();

if(bundle!=null) {
   String helloString =(String) intentExtras.get("helloString");
   // do something with helloString 
}

Creating the message board

We have provided starter code for this part of the assignment. These files are included in the starter code repo:

You will need to:

  • link this provided comment feed to a database

Tip: You can use the Uri class to get a reference to images in your drawable folder. Use this along with ImageView.setImageUri to set an image view's image to that resource image's Uri.

// get the imageUri from a drawable resource file
Uri imageUri = Uri.parse("android.resource://" + [your package name] + "/drawable/" + [your image name]);

// display uri in your image view 
mImageView.setImageURI(imageUri);

Linking the message board to a database

We recommend you use the Firebase Realtime Database for this assignment, since it is built into Android Studio.

Android Studio walks you through most of the process of setting up the database, but here is guide on setting up and reading and writing to your database: https://github.com/cs160-spring2019/cs160-proj3-spec/blob/master/firebase_guide.md. The Firebase documentation online is very extensive, too!

About

spec and starter code for prog3 - location message board

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published