Commit b6b275fb authored by Nina Sanchez's avatar Nina Sanchez

Revert "Helper and fixed menu"

This reverts commit 155cd3a7.
parent 0d1c6c7e
<?xml version="1.0" encoding="UTF-8"?>
<manifest android:versionCode="1" android:versionName="1.0"
package="com.cs123grpE.restaurantorderingsystem" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="21"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application android:allowBackup="true"
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cs123grpE.restaurantorderingsystem"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:screenOrientation="landscape" android:theme="@style/AppTheme">
<activity android:label="@string/app_name" android:name=".Login"/>
<activity android:label="@string/title_activity_select_account" android:name=".SelectAccount"/>
<activity android:label="@string/title_activity_register" android:name=".Register"/>
<activity android:label="@string/title_activity_settings" android:name=".Settings"/>
<activity android:label="@string/title_activity_admin" android:name=".Admin"/>
<activity android:label="@string/title_activity_customer" android:name=".Customer"/>
<activity android:label="@string/title_activity_edit_bill" android:name=".EditBill"/>
<activity android:label="@string/title_activity_edit_menu" android:name=".EditMenu"/>
<activity
android:label="@string/title_activity_add_edit_profile" android:name=".AddEditProfile"/>
<activity android:label="@string/title_activity_view_profile" android:name=".ViewProfile"/>
<activity android:label="@string/app_name" android:name=".MainActivity">
android:screenOrientation="landscape"
android:theme="@style/AppTheme" >
<activity
android:name=".Login"
android:label="@string/app_name" >
</activity>
<activity
android:name=".SelectAccount"
android:label="@string/title_activity_select_account" >
</activity>
<activity
android:name=".Register"
android:label="@string/title_activity_register" >
</activity>
<activity
android:name=".Settings"
android:label="@string/title_activity_settings" >
</activity>
<activity
android:name=".Admin"
android:label="@string/title_activity_admin" >
</activity>
<activity
android:name=".Customer"
android:label="@string/title_activity_customer" >
</activity>
<activity
android:name=".EditBill"
android:label="@string/title_activity_edit_bill" >
</activity>
<activity
android:name=".EditMenu"
android:label="@string/title_activity_edit_menu" >
</activity>
<activity
android:name=".AddEditProfile"
android:label="@string/title_activity_add_edit_profile" >
</activity>
<activity
android:name=".ViewProfile"
android:label="@string/title_activity_view_profile" >
</activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:label="@string/title_activity_cart" android:name=".Cart"/>
<activity android:label="@string/title_activity_kitchen" android:name=".Kitchen"/>
<!--created by ADT ext plugin at 2015-12-02 23:40:55-->
<activity android:name=".KitchenAdapter"/>
<!--created by ADT ext plugin at 2015-12-02 23:42:23-->
<activity android:name=".OrderModel"/>
<activity
android:name=".Cart"
android:label="@string/title_activity_cart" >
</activity>
<activity
android:name=".Kitchen"
android:label="@string/title_activity_kitchen" >
</activity>
</application>
</manifest>
<?xml version="1.0" encoding="UTF-8"?>
<manifest android:versionCode="1" android:versionName="1.0"
package="com.cs123grpE.restaurantorderingsystem" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="21"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application android:allowBackup="true"
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cs123grpE.restaurantorderingsystem"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:screenOrientation="landscape" android:theme="@style/AppTheme">
<activity android:label="@string/app_name" android:name=".Login"/>
<activity android:label="@string/title_activity_select_account" android:name=".SelectAccount"/>
<activity android:label="@string/title_activity_register" android:name=".Register"/>
<activity android:label="@string/title_activity_settings" android:name=".Settings"/>
<activity android:label="@string/title_activity_admin" android:name=".Admin"/>
<activity android:label="@string/title_activity_customer" android:name=".Customer"/>
<activity android:label="@string/title_activity_edit_bill" android:name=".EditBill"/>
<activity android:label="@string/title_activity_edit_menu" android:name=".EditMenu"/>
<activity
android:label="@string/title_activity_add_edit_profile" android:name=".AddEditProfile"/>
<activity android:label="@string/title_activity_view_profile" android:name=".ViewProfile"/>
<activity android:label="@string/app_name" android:name=".MainActivity">
android:screenOrientation="landscape"
android:theme="@style/AppTheme" >
<activity
android:name=".Login"
android:label="@string/app_name" >
</activity>
<activity
android:name=".SelectAccount"
android:label="@string/title_activity_select_account" >
</activity>
<activity
android:name=".Register"
android:label="@string/title_activity_register" >
</activity>
<activity
android:name=".Settings"
android:label="@string/title_activity_settings" >
</activity>
<activity
android:name=".Admin"
android:label="@string/title_activity_admin" >
</activity>
<activity
android:name=".Customer"
android:label="@string/title_activity_customer" >
</activity>
<activity
android:name=".EditBill"
android:label="@string/title_activity_edit_bill" >
</activity>
<activity
android:name=".EditMenu"
android:label="@string/title_activity_edit_menu" >
</activity>
<activity
android:name=".AddEditProfile"
android:label="@string/title_activity_add_edit_profile" >
</activity>
<activity
android:name=".ViewProfile"
android:label="@string/title_activity_view_profile" >
</activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:label="@string/title_activity_cart" android:name=".Cart"/>
<activity android:label="@string/title_activity_kitchen" android:name=".Kitchen"/>
<!--created by ADT ext plugin at 2015-12-02 23:40:55-->
<activity android:name=".KitchenAdapter"/>
<!--created by ADT ext plugin at 2015-12-02 23:42:23-->
<activity android:name=".OrderModel"/>
<activity
android:name=".Cart"
android:label="@string/title_activity_cart" >
</activity>
<activity
android:name=".Kitchen"
android:label="@string/title_activity_kitchen" >
</activity>
</application>
</manifest>
......@@ -29,7 +29,7 @@ public final class R {
public static final int prelimlogo=0x7f020003;
}
public static final class id {
public static final int action_settings=0x7f08003d;
public static final int action_settings=0x7f08003b;
public static final int btnAddMenu=0x7f08001b;
public static final int btnAddToCart=0x7f080038;
public static final int btnAdmin=0x7f08002e;
......@@ -55,7 +55,6 @@ public final class R {
public static final int btnSave=0x7f080006;
public static final int btnSearch=0x7f080015;
public static final int checkRem=0x7f080021;
public static final int foodName=0x7f08003a;
public static final int list=0x7f080016;
public static final int listCart=0x7f08000d;
public static final int listKitchen=0x7f08001c;
......@@ -63,9 +62,8 @@ public final class R {
public static final int logo=0x7f080007;
public static final int logout=0x7f080031;
public static final int priceName=0x7f080033;
public static final int tableName=0x7f08003b;
public static final int textView00=0x7f080039;
public static final int textView01=0x7f08003c;
public static final int textView01=0x7f08003a;
public static final int textView1=0x7f08001d;
public static final int textView2=0x7f08001f;
public static final int textView3=0x7f08002d;
......
......@@ -5,17 +5,10 @@
android:orientation="vertical" >
<TextView
android:id="@+id/foodName"
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/tableName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
\ No newline at end of file
</LinearLayout>
......@@ -13,7 +13,6 @@ import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
public class AddEditProfile extends Activity {
private String mode;
private ParseObject obj;
......@@ -27,7 +26,7 @@ public class AddEditProfile extends Activity {
mode = i.getStringExtra("mode");
if(mode.equals("Edit")) {
String name = i.getStringExtra("object");
obj = Helper.findObject("Menu_Item", name);
obj = findMenuItem(name);
fillInText();
}
}
......@@ -83,14 +82,14 @@ public class AddEditProfile extends Activity {
EditText cat = (EditText) findViewById (R.id.txtCategory);
if(mode.equals("Add")) {
Helper.addMenuItem(nm.getText().toString(), Double.parseDouble(price.getText().toString()),
addMenuItem(nm.getText().toString(), Double.parseDouble(price.getText().toString()),
des.getText().toString(), tag.getText().toString(), cat.getText().toString());
Toast.makeText (this, "Item is added to menu.", Toast.LENGTH_SHORT).show();
finish();
}
else {
Helper.editMenuItem(obj, nm.getText().toString(), Double.parseDouble(price.getText().toString()),
editMenuItem(obj, nm.getText().toString(), Double.parseDouble(price.getText().toString()),
des.getText().toString(), tag.getText().toString(), cat.getText().toString());
Toast.makeText (this, "Item is edited.", Toast.LENGTH_SHORT).show();
......@@ -100,6 +99,45 @@ public class AddEditProfile extends Activity {
}
private void addMenuItem(String name, double price, String desc, String tag, String cat) {
ParseObject item = new ParseObject("Menu_Item");
item.put("item_name", name);
item.put("item_price", price);
item.put("item_desc", desc);
item.put("active", true);
item.put("category", cat);
item.saveInBackground();
}
private void editMenuItem(ParseObject item, String name, double price, String desc, String tag, String cat) {
item.put("item_name", name);
item.put("item_price", price);
item.put("item_desc", desc);
item.put("active", true);
item.put("category", cat);
item.saveInBackground();
}
private ParseObject findMenuItem(String nameOfItem) {
ParseQuery<ParseObject> query = ParseQuery.getQuery("Menu_Item").whereMatches("item_name", nameOfItem);
List<ParseObject> list = null;
try {
list = query.find();
} catch(Exception e) {}
for(ParseObject a: list) {
if(isActive(a)) return a;
}
return null;
}
private boolean isActive(ParseObject p) {
// Date currDate = Calendar.getInstance().getTime();
// Date activeFrom = (Date) p.get("active_from");
// Date activeUntil = (Date) p.get("active_from");
return p.getBoolean("active");
}
public void onBackPressed() {
// go back to the menu
......
......@@ -78,7 +78,30 @@ public class EditMenu extends Activity {
}
private ParseObject findMenuItem(String nameOfItem) {
ParseQuery<ParseObject> query = ParseQuery.getQuery("Menu_Item").whereMatches("item_name", nameOfItem);
List<ParseObject> list = null;
try {
list = query.find();
} catch(Exception e) {}
for(ParseObject a: list) {
if(isActive(a)) return a;
}
return null;
}
private boolean isActive(ParseObject p) {
// Date currDate = Calendar.getInstance().getTime();
// Date activeFrom = (Date) p.get("active_from");
// Date activeUntil = (Date) p.get("active_from");
return p.getBoolean("active");
}
private void prepareLists() {
prepareListData();
......@@ -149,47 +172,45 @@ public class EditMenu extends Activity {
listDataChildObject = new HashMap<String, List<ParseObject>>();
// Adding child data
ParseQuery<ParseObject> query1 = ParseQuery.getQuery("Category");
List<ParseObject> listHeaders = null;
try {
listHeaders = query1.find();
} catch(Exception e) {}
for(ParseObject x: listHeaders) {
listDataHeader.add((String)x.get("category_name"));
}
listDataHeader.add("Appetizer");
listDataHeader.add("Main");
listDataHeader.add("Dessert");
listDataHeader.add("Beverage");
int n = listDataHeader.size();
// Adding child data
for(int i = 0; i < n; i++) {
String s = listDataHeader.get(i);
ParseObject obj = listHeaders.get(i);
List<String> list = new ArrayList<String>();
List<ParseObject> listObject = new ArrayList<ParseObject>();
ParseQuery<ParseObject> query = ParseQuery.getQuery("Menu_Item").whereEqualTo("category", obj);
//gameQuery.whereEqualTo("cate", ParseUser.getCurrentUser());
ParseQuery<ParseObject> query = ParseQuery.getQuery("Menu_Item").whereMatches("category", s);
List<ParseObject> matches = null;
try {
matches = query.find();
} catch(Exception e) {}
for(ParseObject a: matches) {
// if(isActive(a)) {
//if(isActive(a)) {
list.add((String) a.get("item_name"));
listObject.add(a);
// }
//}
}
listDataChild.put(s, list);
listDataChildObject.put(s, listObject);
}
}
private void addMenuItem(String name, double price, String desc, String tag, String cat) {
ParseObject item = new ParseObject("Menu_Item");
item.put("item_name", name);
item.put("item_price", price);
item.put("item_desc", desc);
item.put("active", true);
item.put("category", cat);
item.saveInBackground();
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, getIntent());
if(resultCode==RESULT_OK && requestCode==1){
......
package com.cs123grpE.restaurantorderingsystem;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnChildClickListener;
import android.widget.ExpandableListView.OnGroupClickListener;
import android.widget.ExpandableListView.OnGroupCollapseListener;
import android.widget.ExpandableListView.OnGroupExpandListener;
import com.parse.*;
import java.util.*;
public class Helper {
public static boolean isActive(ParseObject p) {
// Date currDate = Calendar.getInstance().getTime();
// Date activeFrom = (Date) p.get("active_from");
// Date activeUntil = (Date) p.get("active_from");
return p.getBoolean("active");
}
public static ParseObject findObject(String className, String itemName) {
ParseQuery<ParseObject> query = ParseQuery.getQuery(className).whereMatches("item_name", itemName);
List<ParseObject> list = null;
try {
list = query.find();
} catch(Exception e) {
return null;
}
for(ParseObject a: list) {
if(isActive(a)) return a;
}
return null;
}
public static void addMenuItem(String name, double price, String desc, String tag, String cat) {
ParseObject item = new ParseObject("Menu_Item");
item.put("item_name", name);
item.put("item_price", price);
item.put("item_desc", desc);
item.put("active", true);
ParseObject obj = findObject("Category", cat);
if(obj==null) obj = addCategory(cat);
item.put("category", obj);
item.saveInBackground();
}
public static void editMenuItem(ParseObject item, String name, double price, String desc, String tag, String cat) {
item.put("item_name", name);
item.put("item_price", price);
item.put("item_desc", desc);
item.put("active", true);
ParseObject obj = findObject("Category", cat);
if(obj==null) obj = addCategory(cat);
item.put("category", obj);
item.saveInBackground();
}
public static ParseObject addCategory(String cat) {
ParseObject p = new ParseObject("Category");
p.put("category_name", cat);
p.saveInBackground();
return p;
}
}
package com.cs123grpE.restaurantorderingsystem;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ListView;
import android.widget.Toast;
public class Kitchen extends Activity {
ListView lv;
KitchenAdapter adapter;
public Kitchen CustomListView = null;
public ArrayList<OrderModel> CustomListViewValuesArr = new ArrayList<OrderModel>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_kitchen);
CustomListView = this;
/******** Take some data in Arraylist ( CustomListViewValuesArr ) ***********/
setListData();
Resources res =getResources();
lv= ( ListView )findViewById( R.id.list ); // List defined in XML ( See Below )
/**************** Create Custom Adapter *********/
adapter=new KitchenAdapter( CustomListView, CustomListViewValuesArr,res );
lv.setAdapter( adapter );
}
@Override
......@@ -59,26 +37,4 @@ public class Kitchen extends Activity {
Intent i = new Intent (this, SelectAccount.class);
startActivity(i);
}
public void setListData()
{
for (int i = 0; i < 11; i++) {
final OrderModel sched = new OrderModel();
/******* Firstly take data in model object ******/
sched.setFoodName(""+i);
sched.setTableNumber("Table Number: "+i);
/******** Take Model Object in ArrayList **********/
CustomListViewValuesArr.add( sched );
}
}
public void onItemClick(int mPosition)
{
CustomListViewValuesArr.remove(mPosition);
adapter.notifyDataSetChanged();
}
}
\ No newline at end of file
}
package com.cs123grpE.restaurantorderingsystem;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.res.Resources;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
public class KitchenAdapter extends BaseAdapter implements OnClickListener{
private Activity activity;
private ArrayList data;
private static LayoutInflater inflater=null;
public Resources res;
OrderModel tempValues=null;
int i=0;
public KitchenAdapter(Activity a, ArrayList d,Resources resLocal) {
/********** Take passed values **********/
activity = a;
data=d;
res = resLocal;
/*********** Layout inflator to call external xml layout () ***********/
inflater = ( LayoutInflater )activity.
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
if(data.size()<=0)
return 1;
return data.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View vi = convertView;
ViewHolder holder;
if(convertView==null){
/****** Inflate tabitem.xml file for each row ( Defined below ) *******/
vi = inflater.inflate(R.layout.menu_item, null);
/****** View Holder Object to contain tabitem.xml file elements ******/
holder = new ViewHolder();
holder.text = (TextView) vi.findViewById(R.id.foodName);
holder.text1=(TextView)vi.findViewById(R.id.tableName);
/************ Set holder with LayoutInflater ************/
vi.setTag( holder );
}
else
holder=(ViewHolder)vi.getTag();
if(data.size()<=0)
{
holder.text.setText("No Data");
}
else
{
/***** Get each Model object from Arraylist ********/
tempValues=null;
tempValues = ( OrderModel ) data.get( position );
/************ Set Model values in Holder elements ***********/
holder.text.setText( tempValues.getFoodName() );
holder.text1.setText( tempValues.getTableNumber() );
/******** Set Item Click Listner for LayoutInflater for each row *******/
vi.setOnClickListener((android.view.View.OnClickListener) new OnItemClickListener( position ));
}
return vi;
}
@Override
public void onClick(DialogInterface arg0, int arg1) {
}
public void onClick(View v) {
}
public static class ViewHolder{
public TextView text;
public TextView text1;
}
private class OnItemClickListener implements OnClickListener{
private int mPosition;
OnItemClickListener(int position){
mPosition = position;
}
public void onClick(View v) {
Kitchen sct = (Kitchen)activity;
/**** Call onItemClick Method inside CustomListViewAndroidExample Class ( See Below )****/
sct.onItemClick(mPosition);
}
public void onClick(DialogInterface arg0, int arg1) {
// TODO Auto-generated method stub
}
}
}
\ No newline at end of file
package com.cs123grpE.restaurantorderingsystem;
public class OrderModel {
private String foodName="";
private String tableNumber="";
public String getFoodName() {
return foodName;
}
public void setFoodName(String foodName) {
this.foodName = foodName;
}
public String getTableNumber() {
return tableNumber;
}
public void setTableNumber(String tableNumber) {
this.tableNumber = tableNumber;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment