Android Open Source - OpenFoodFinder Restaurant Page Activity






From Project

Back to project page OpenFoodFinder.

License

The source code is released under:

Apache License

If you think the Android project OpenFoodFinder listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.kudos.off;
/*from w w w  . j  a  va2 s  . com*/
import com.kudos.off.R;
import com.google.android.gms.maps.CameraUpdate;
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.model.MarkerOptions;

import android.os.Bundle;
import android.app.Activity;

import android.view.Menu;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class RestaurantPageActivity extends Activity {

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_restaurant_page);

    Bundle b = getIntent().getExtras();
    Place place = b.getParcelable("com.kudos.off.Place");
    setTitle("Open Food Finder");
    TextView textName = (TextView) findViewById(R.id.textName);
    TextView textAddress = (TextView) findViewById(R.id.textAddress);
    ImageView icon = (ImageView) findViewById(R.id.restaurantIcon);

    textName.setText(place.getName());
    textAddress.setText(place.getAddress());

    new DownloadIconTask((ImageView) findViewById(R.id.restaurantIcon))
        .execute(place.getIconURL());

    // all the map related code
    try {
      GoogleMap map = ((MapFragment) getFragmentManager()
          .findFragmentById(R.id.map)).getMap();
      map.addMarker(new MarkerOptions().position(place.getLocation())
          .title(place.getName()));

      map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
      CameraUpdate update = CameraUpdateFactory.newLatLngZoom(
          place.getLocation(), 15);
      map.animateCamera(update);
    } catch (Exception e) {
      Toast.makeText(this, "Error loading map", Toast.LENGTH_SHORT)
          .show();
    }
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.restaurant_page, menu);
    return true;
  }

}




Java Source Code List

com.kudos.off.DownloadIconTask.java
com.kudos.off.GPSLocation.java
com.kudos.off.GooglePlaces.java
com.kudos.off.MainActivity.java
com.kudos.off.Place.java
com.kudos.off.RestaurantPageActivity.java