Commit 68c7e7e2 authored by Nina Sanchez's avatar Nina Sanchez

Kitchen

parent c0e9b349
......@@ -29,9 +29,9 @@ public final class R {
public static final int prelimlogo=0x7f020003;
}
public static final class id {
public static final int action_settings=0x7f08003c;
public static final int action_settings=0x7f08003d;
public static final int btnAddMenu=0x7f08001b;
public static final int btnAddToCart=0x7f080038;
public static final int btnAddToCart=0x7f080039;
public static final int btnAdmin=0x7f08002e;
public static final int btnBack=0x7f080037;
public static final int btnCancel=0x7f08002b;
......@@ -62,9 +62,10 @@ 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=0x7f08003a;
public static final int textView00=0x7f080039;
public static final int textView01=0x7f08003b;
public static final int quantity=0x7f080038;
public static final int tableName=0x7f08003b;
public static final int textView00=0x7f08003a;
public static final int textView01=0x7f08003c;
public static final int textView1=0x7f08001d;
public static final int textView2=0x7f08001f;
public static final int textView3=0x7f08002d;
......
......@@ -124,6 +124,11 @@
android:layout_marginRight="@dimen/button_spacing"
android:onClick="back" />
<NumberPicker
android:id="@+id/quantity"
android:layout_width="wrap_content"
android:layout_height="200dp" />
<Button
android:id="@+id/btnAddToCart"
android:layout_width="wrap_content"
......
......@@ -32,13 +32,16 @@ public class Customer extends Activity {
List<String> listDataHeader;
List<String> listDataHeaderId;
HashMap<String, List<String>> listDataChild;
HashMap<String, List<ParseObject>> listDataChildObject;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_customer);
generateMenu("", true);
prepareLists();
//generateMenu("", true);
ListView lv = (ListView)findViewById(R.id.listview1);
lv.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, menu));
......@@ -151,14 +154,14 @@ public class Customer extends Activity {
EditText searchString = (EditText) findViewById (R.id.txtSearch);
String criteria = searchString.getText().toString().trim();
generateMenu(criteria, false);
//generateMenu(criteria, false);
}
public void filterOn (View v) {
// toggle to filter items with specified item from item list
EditText searchString = (EditText) findViewById (R.id.txtSearch);
String criteria = searchString.getText().toString().trim();
generateMenu(criteria, true);
//generateMenu(criteria, true);
}
public void search (View v) {
......@@ -175,98 +178,131 @@ public class Customer extends Activity {
startActivity (i);
}
public void generateMenu(String with, boolean in) {
private void prepareLists() {
prepareListData();
listDataHeader = new ArrayList<String>();
listDataHeaderId = new ArrayList<String>();
listDataChild = new HashMap<String, List<String>>();
getHeaders(with, in);
getChildren();
ListView lv = (ListView)findViewById(R.id.listview1);
lv.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, menu));
exp = (ExpandableListView)findViewById(R.id.list);
//prepareListData();
epa = new ExpandableAdapter(this, listDataHeader, listDataChild);
exp.setAdapter(epa);
}
public void getHeaders(String with, boolean in) {
ParseQuery<ParseObject> pq = new ParseQuery("Ingredient");
List<ParseObject> l = null;
try{
l = pq.find();
} catch(Exception e) {}
exp.setOnGroupClickListener(new OnGroupClickListener() {
for(ParseObject po: l) {
String name = (String) po.get("ingredient_name");
if(!with.equals("")) {
if(in && name.equals("with")) {
listDataHeader.add(name);
listDataHeaderId.add(po.getObjectId());
listDataChild.put(name, new ArrayList<String>());
}
else {
if(name.equals("with")) continue;
listDataHeader.add(name);
listDataHeaderId.add(po.getObjectId());
listDataChild.put(name, new ArrayList<String>());
}
}
else {
listDataHeader.add(name);
listDataHeaderId.add(po.getObjectId());
listDataChild.put(name, new ArrayList<String>());
@Override
public boolean onGroupClick(ExpandableListView parent, View v,
int groupPosition, long id) {
// Toast.makeText(getApplicationContext(),
// "Group Clicked " + listDataHeader.get(groupPosition),
// Toast.LENGTH_SHORT).show();
return false;
}
});
// Listview Group expanded listener
exp.setOnGroupExpandListener(new OnGroupExpandListener() {
@Override
public void onGroupExpand(int groupPosition) {
Toast.makeText(getApplicationContext(),
listDataHeader.get(groupPosition) + " Expanded",
Toast.LENGTH_SHORT).show();
}
});
// Listview Group collasped listener
exp.setOnGroupCollapseListener(new OnGroupCollapseListener() {
@Override
public void onGroupCollapse(int groupPosition) {
Toast.makeText(getApplicationContext(),
listDataHeader.get(groupPosition) + " Collapsed",
Toast.LENGTH_SHORT).show();
}
});
public void getChildren() {
ParseQuery<ParseObject> pq = new ParseQuery<ParseObject>("Menu_Item");
List<String> tempFood = new ArrayList<String>();
List<ParseObject> list = null;
try {
list = pq.find();
} catch(Exception e) {}
// Listview on child click listener
exp.setOnChildClickListener(new OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
// TODO Auto-generated method stub
//editMenu(listDataHeader.get(groupPosition), childPosition);
String cat = listDataHeader.get(groupPosition);
String name = ((String) ( (ParseObject) listDataChildObject.get(cat).get(childPosition)).get("item_name"));
Intent i = new Intent(getApplicationContext(), ViewProfile.class);
i.putExtra("menu_name", name);
startActivity(i);
for(ParseObject po: list) {
String name = (String)po.get("item_name");
String ingr = (String)po.get("ingredient_name");
if(listDataHeader.contains(ingr))
listDataChild.get(ingr).add(name);
Toast.makeText(getApplicationContext(),
listDataHeader.get(groupPosition)
+ " : "
+ listDataChild.get(listDataHeader.get(groupPosition)).get(childPosition), Toast.LENGTH_SHORT)
.show();
return false;
}
});
}
private void prepareListData() {
listDataHeader = new ArrayList<String>();
listDataChild = new HashMap<String, List<String>>();
listDataChildObject = new HashMap<String, List<ParseObject>>();
// Adding child data
listDataHeader.add("MEAT");
listDataHeader.add("SOUP");
listDataHeader.add("FISH");
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"));
}
int n = listDataHeader.size();
// Adding child data
List<String> top250 = new ArrayList<String>();
top250.add("CRISPY PATA");
top250.add("ADUBA");
top250.add("PATAATIM");
top250.add("SINIGANG");
List<String> nowShowing = new ArrayList<String>();
nowShowing.add("CHICKEN NOODLE SOUP");
nowShowing.add("SINIGANG SA MISO");
nowShowing.add("SPINACH");
nowShowing.add("BIRD'S NEST");
List<String> comingSoon = new ArrayList<String>();
comingSoon.add("TALAKITOK");
comingSoon.add("PAKSIW");
comingSoon.add("ESCABECHE");
listDataChild.put(listDataHeader.get(0), top250); // Header, Child data
listDataChild.put(listDataHeader.get(1), nowShowing);
listDataChild.put(listDataHeader.get(2), comingSoon);
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);
List<ParseObject> matches = null;
try {
matches = query.find();
} catch(Exception e) {}
for(ParseObject a: matches) {
// if(isActive(a)) {
list.add((String) a.get("item_name"));
listObject.add(a);
// }
}
listDataChild.put(s, list);
listDataChildObject.put(s, listObject);
}
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, getIntent());
if(resultCode==RESULT_OK && requestCode==1){
System.out.println("RESULT :D");
}
prepareLists();
}
}
......@@ -77,4 +77,12 @@ public class Helper {
return p;
}
public static void addOrder(ParseObject item, int table_num, int qty) {
ParseObject order = new ParseObject("Order");
order.put("item_id", item);
//order.put("table_id", table_num); // get pointer
order.put("quantity", qty);
order.saveInBackground();
}
}
......@@ -32,7 +32,7 @@ public class Kitchen extends Activity {
lv= ( ListView )findViewById( R.id.list ); // List defined in XML ( See Below )
/**************** Create Custom Adapter *********/
adapter=new KitchenAdapter( CustomListView, CustomListViewValuesArr,res );
adapter=new KitchenAdapter ( CustomListView, CustomListViewValuesArr,res );
lv.setAdapter( adapter );
}
......
......@@ -6,7 +6,10 @@ import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.NumberPicker;
import android.widget.TextView;
import android.widget.Toast;
import com.parse.*;
......@@ -16,21 +19,28 @@ public class ViewProfile extends Activity {
String description = "";
String tags = "";
double price = 0;
ParseObject obj;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_profile);
NumberPicker np = (NumberPicker) findViewById(R.id.quantity);
np.setMinValue(1);
np.setMaxValue(20);
np.setWrapSelectorWheel(true);
np.setValue(1);
Intent i = getIntent();
String name = i.getStringExtra("menu_name");
ParseObject x = null;
obj = null;
try{
x = (new ParseQuery("Menu_Item")).whereMatches("item_name", name).getFirst();
itemname = x.getString("item_name");
description = x.getString("item_desc");
tags = x.getString("ingridient_name");
price = x.getDouble("item_price");
obj = (new ParseQuery("Menu_Item")).whereMatches("item_name", name).getFirst();
itemname = obj.getString("item_name");
description = obj.getString("item_desc");
tags = obj.getString("ingredient_name");
price = obj.getDouble("item_price");
}catch(Exception e) {}
TextView ax = (TextView) findViewById (R.id.tvName);
......@@ -69,6 +79,17 @@ public class ViewProfile extends Activity {
public void addToCart (View v) {
// add selected item to Cart
NumberPicker np = (NumberPicker) findViewById(R.id.quantity);
int qty = np.getValue();
Helper.addOrder(obj, 0, qty); // change table num
Toast.makeText(getApplicationContext(),
"Ordered " + qty + " " + itemname,
Toast.LENGTH_SHORT).show();
finish();
}
public void onBackPressed() {
......
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