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

Kitchen

parent c0e9b349
...@@ -29,9 +29,9 @@ public final class R { ...@@ -29,9 +29,9 @@ public final class R {
public static final int prelimlogo=0x7f020003; public static final int prelimlogo=0x7f020003;
} }
public static final class id { 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 btnAddMenu=0x7f08001b;
public static final int btnAddToCart=0x7f080038; public static final int btnAddToCart=0x7f080039;
public static final int btnAdmin=0x7f08002e; public static final int btnAdmin=0x7f08002e;
public static final int btnBack=0x7f080037; public static final int btnBack=0x7f080037;
public static final int btnCancel=0x7f08002b; public static final int btnCancel=0x7f08002b;
...@@ -62,9 +62,10 @@ public final class R { ...@@ -62,9 +62,10 @@ public final class R {
public static final int logo=0x7f080007; public static final int logo=0x7f080007;
public static final int logout=0x7f080031; public static final int logout=0x7f080031;
public static final int priceName=0x7f080033; public static final int priceName=0x7f080033;
public static final int tableName=0x7f08003a; public static final int quantity=0x7f080038;
public static final int textView00=0x7f080039; public static final int tableName=0x7f08003b;
public static final int textView01=0x7f08003b; public static final int textView00=0x7f08003a;
public static final int textView01=0x7f08003c;
public static final int textView1=0x7f08001d; public static final int textView1=0x7f08001d;
public static final int textView2=0x7f08001f; public static final int textView2=0x7f08001f;
public static final int textView3=0x7f08002d; public static final int textView3=0x7f08002d;
......
...@@ -123,6 +123,11 @@ ...@@ -123,6 +123,11 @@
android:text="Back" android:text="Back"
android:layout_marginRight="@dimen/button_spacing" android:layout_marginRight="@dimen/button_spacing"
android:onClick="back" /> android:onClick="back" />
<NumberPicker
android:id="@+id/quantity"
android:layout_width="wrap_content"
android:layout_height="200dp" />
<Button <Button
android:id="@+id/btnAddToCart" android:id="@+id/btnAddToCart"
......
...@@ -32,13 +32,16 @@ public class Customer extends Activity { ...@@ -32,13 +32,16 @@ public class Customer extends Activity {
List<String> listDataHeader; List<String> listDataHeader;
List<String> listDataHeaderId; List<String> listDataHeaderId;
HashMap<String, List<String>> listDataChild; HashMap<String, List<String>> listDataChild;
HashMap<String, List<ParseObject>> listDataChildObject;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_customer); setContentView(R.layout.activity_customer);
generateMenu("", true); prepareLists();
//generateMenu("", true);
ListView lv = (ListView)findViewById(R.id.listview1); ListView lv = (ListView)findViewById(R.id.listview1);
lv.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, menu)); lv.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, menu));
...@@ -151,14 +154,14 @@ public class Customer extends Activity { ...@@ -151,14 +154,14 @@ public class Customer extends Activity {
EditText searchString = (EditText) findViewById (R.id.txtSearch); EditText searchString = (EditText) findViewById (R.id.txtSearch);
String criteria = searchString.getText().toString().trim(); String criteria = searchString.getText().toString().trim();
generateMenu(criteria, false); //generateMenu(criteria, false);
} }
public void filterOn (View v) { public void filterOn (View v) {
// toggle to filter items with specified item from item list // toggle to filter items with specified item from item list
EditText searchString = (EditText) findViewById (R.id.txtSearch); EditText searchString = (EditText) findViewById (R.id.txtSearch);
String criteria = searchString.getText().toString().trim(); String criteria = searchString.getText().toString().trim();
generateMenu(criteria, true); //generateMenu(criteria, true);
} }
public void search (View v) { public void search (View v) {
...@@ -175,98 +178,131 @@ public class Customer extends Activity { ...@@ -175,98 +178,131 @@ public class Customer extends Activity {
startActivity (i); startActivity (i);
} }
public void generateMenu(String with, boolean in) { private void prepareLists() {
prepareListData();
listDataHeader = new ArrayList<String>(); ListView lv = (ListView)findViewById(R.id.listview1);
listDataHeaderId = new ArrayList<String>(); lv.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, menu));
listDataChild = new HashMap<String, List<String>>();
getHeaders(with, in);
getChildren();
exp = (ExpandableListView)findViewById(R.id.list); exp = (ExpandableListView)findViewById(R.id.list);
//prepareListData();
epa = new ExpandableAdapter(this, listDataHeader, listDataChild); epa = new ExpandableAdapter(this, listDataHeader, listDataChild);
exp.setAdapter(epa); 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) {}
for(ParseObject po: l) { exp.setOnGroupClickListener(new OnGroupClickListener() {
String name = (String) po.get("ingredient_name");
if(!with.equals("")) { @Override
if(in && name.equals("with")) { public boolean onGroupClick(ExpandableListView parent, View v,
listDataHeader.add(name); int groupPosition, long id) {
listDataHeaderId.add(po.getObjectId()); // Toast.makeText(getApplicationContext(),
listDataChild.put(name, new ArrayList<String>()); // "Group Clicked " + listDataHeader.get(groupPosition),
} // Toast.LENGTH_SHORT).show();
else { return false;
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()); // Listview Group expanded listener
listDataChild.put(name, new ArrayList<String>()); 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();
}
});
// 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);
Toast.makeText(getApplicationContext(),
listDataHeader.get(groupPosition)
+ " : "
+ listDataChild.get(listDataHeader.get(groupPosition)).get(childPosition), Toast.LENGTH_SHORT)
.show();
return false;
}
});
} }
public void getChildren() { private void prepareListData() {
ParseQuery<ParseObject> pq = new ParseQuery<ParseObject>("Menu_Item"); listDataHeader = new ArrayList<String>();
List<String> tempFood = new ArrayList<String>(); listDataChild = new HashMap<String, List<String>>();
List<ParseObject> list = null; listDataChildObject = new HashMap<String, List<ParseObject>>();
// Adding child data
ParseQuery<ParseObject> query1 = ParseQuery.getQuery("Category");
List<ParseObject> listHeaders = null;
try { try {
list = pq.find(); listHeaders = query1.find();
} catch(Exception e) {} } catch(Exception e) {}
for(ParseObject po: list) { for(ParseObject x: listHeaders) {
String name = (String)po.get("item_name"); listDataHeader.add((String)x.get("category_name"));
String ingr = (String)po.get("ingredient_name");
if(listDataHeader.contains(ingr))
listDataChild.get(ingr).add(name);
} }
}
private void prepareListData() {
listDataHeader = new ArrayList<String>();
// Adding child data int n = listDataHeader.size();
listDataHeader.add("MEAT");
listDataHeader.add("SOUP");
listDataHeader.add("FISH");
// Adding child data // Adding child data
List<String> top250 = new ArrayList<String>(); for(int i = 0; i < n; i++) {
top250.add("CRISPY PATA"); String s = listDataHeader.get(i);
top250.add("ADUBA"); ParseObject obj = listHeaders.get(i);
top250.add("PATAATIM"); List<String> list = new ArrayList<String>();
top250.add("SINIGANG"); List<ParseObject> listObject = new ArrayList<ParseObject>();
List<String> nowShowing = new ArrayList<String>(); ParseQuery<ParseObject> query = ParseQuery.getQuery("Menu_Item").whereEqualTo("category", obj);
nowShowing.add("CHICKEN NOODLE SOUP");
nowShowing.add("SINIGANG SA MISO");
nowShowing.add("SPINACH"); List<ParseObject> matches = null;
nowShowing.add("BIRD'S NEST");
try {
matches = query.find();
} catch(Exception e) {}
List<String> comingSoon = new ArrayList<String>(); for(ParseObject a: matches) {
comingSoon.add("TALAKITOK"); // if(isActive(a)) {
comingSoon.add("PAKSIW"); list.add((String) a.get("item_name"));
comingSoon.add("ESCABECHE"); 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");
}
listDataChild.put(listDataHeader.get(0), top250); // Header, Child data prepareLists();
listDataChild.put(listDataHeader.get(1), nowShowing);
listDataChild.put(listDataHeader.get(2), comingSoon);
} }
} }
...@@ -77,4 +77,12 @@ public class Helper { ...@@ -77,4 +77,12 @@ public class Helper {
return p; 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 { ...@@ -32,7 +32,7 @@ public class Kitchen extends Activity {
lv= ( ListView )findViewById( R.id.list ); // List defined in XML ( See Below ) lv= ( ListView )findViewById( R.id.list ); // List defined in XML ( See Below )
/**************** Create Custom Adapter *********/ /**************** Create Custom Adapter *********/
adapter=new KitchenAdapter( CustomListView, CustomListViewValuesArr,res ); adapter=new KitchenAdapter ( CustomListView, CustomListViewValuesArr,res );
lv.setAdapter( adapter ); lv.setAdapter( adapter );
} }
......
...@@ -6,7 +6,10 @@ import android.os.Bundle; ...@@ -6,7 +6,10 @@ import android.os.Bundle;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.EditText;
import android.widget.NumberPicker;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import com.parse.*; import com.parse.*;
...@@ -16,21 +19,28 @@ public class ViewProfile extends Activity { ...@@ -16,21 +19,28 @@ public class ViewProfile extends Activity {
String description = ""; String description = "";
String tags = ""; String tags = "";
double price = 0; double price = 0;
ParseObject obj;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_profile); 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(); Intent i = getIntent();
String name = i.getStringExtra("menu_name"); String name = i.getStringExtra("menu_name");
ParseObject x = null; obj = null;
try{ try{
x = (new ParseQuery("Menu_Item")).whereMatches("item_name", name).getFirst(); obj = (new ParseQuery("Menu_Item")).whereMatches("item_name", name).getFirst();
itemname = x.getString("item_name"); itemname = obj.getString("item_name");
description = x.getString("item_desc"); description = obj.getString("item_desc");
tags = x.getString("ingridient_name"); tags = obj.getString("ingredient_name");
price = x.getDouble("item_price"); price = obj.getDouble("item_price");
}catch(Exception e) {} }catch(Exception e) {}
TextView ax = (TextView) findViewById (R.id.tvName); TextView ax = (TextView) findViewById (R.id.tvName);
...@@ -69,6 +79,17 @@ public class ViewProfile extends Activity { ...@@ -69,6 +79,17 @@ public class ViewProfile extends Activity {
public void addToCart (View v) { public void addToCart (View v) {
// add selected item to Cart // 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() { 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