Android Open Source - EatDudeAndroid Restaurant Search






From Project

Back to project page EatDudeAndroid.

License

The source code is released under:

GNU General Public License

If you think the Android project EatDudeAndroid 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.wileynet.eatdude;
/*www. j  a  va  2 s  . c  o m*/
import java.util.Map;
import java.util.Vector;

import com.wileynet.eatdude.xml.SAXHelper;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

//import android.widget.Toast;

public class RestaurantSearch extends Activity {

  public static Restaurant r;
  public static Vector<String> orders = new Vector<String>();
  private String menu_id;
  public static int dbClear = 0;

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

    // Proguard will rename the onClick method and break it unless you
    // specifically tell it not to,
    // or you can just turn off proguard which is easier.
    // http://forum.xda-developers.com/showthread.php?t=777399

    // I got this error from the xml layout for a ImageButton. I was using
    // api 3 which apparently
    // does not support this attribute. Simply going to api 4 resolved this
    // problem.
    // http://blog.jamesbaca.net/?p=40

    // public void selfDestruct(View view) {
    // Kabloey
    // }

    final Button button = (Button) findViewById(R.id.button01);
    button.setOnClickListener(new View.OnClickListener() {
      Intent i;

      public void onClick(View v) {
        if (loadRestaurantXML()) {
          if (r.getMenu().size() > 1) {
            i = new Intent(RestaurantSearch.this,
                MenuSelection.class);
          } else {
            for (Map.Entry<String, String> entry : r.getMenu()
                .entrySet()) {
              menu_id = "" + entry.getKey();
            }
            i = new Intent(RestaurantSearch.this,
                CategorySelection.class);
            i.putExtra("menu_id", menu_id);
          }
        } else {
          Toast.makeText(button.getContext(),
              "Internet Connection Error", Toast.LENGTH_SHORT)
              .show();
        }

        startActivity(i);
      }
    });

  }

  protected boolean loadRestaurantXML() {

    Boolean success = true;
    try {
      String url = "http://wileynet5.appspot.com/example_xml/23001";
      SAXHelper sh = new SAXHelper();

      sh.parseContent(url);
      r = new Restaurant(sh.restaurant_id, sh.restaurant_name, sh.menu,
          sh.menu_category, sh.menu_item);
      // sh = null;
    } catch (Exception e) {
      success = false;
    }

    return success;
  }

}




Java Source Code List

com.wileynet.eatdude.CategorySelection.java
com.wileynet.eatdude.CitySelection.java
com.wileynet.eatdude.CountrySelection.java
com.wileynet.eatdude.EatDudeSplash.java
com.wileynet.eatdude.HelpHome.java
com.wileynet.eatdude.ItemDisplay.java
com.wileynet.eatdude.ItemSelection.java
com.wileynet.eatdude.MainHome.java
com.wileynet.eatdude.MenuSelection.java
com.wileynet.eatdude.RestaurantSearch.java
com.wileynet.eatdude.RestaurantSelection.java
com.wileynet.eatdude.Restaurant.java
com.wileynet.eatdude.StateSelection.java
com.wileynet.eatdude.db.LoadRestaurant.java
com.wileynet.eatdude.db.RestaurantDbAdapter.java
com.wileynet.eatdude.db.RestaurantDbHelper.java
com.wileynet.eatdude.util.SpinnerData.java
com.wileynet.eatdude.util.StringUtils.java
com.wileynet.eatdude.xml.GeoDefaultHandler.java
com.wileynet.eatdude.xml.GeoSaxHelper.java
com.wileynet.eatdude.xml.MessageDefaultHandler.java
com.wileynet.eatdude.xml.MessageSaxHelper.java
com.wileynet.eatdude.xml.MyDefaultHandler.java
com.wileynet.eatdude.xml.SAXHelper.java