-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrderConfirmationPage.java
More file actions
95 lines (79 loc) · 2.98 KB
/
Copy pathOrderConfirmationPage.java
File metadata and controls
95 lines (79 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package pizza.olin.consamables.pages;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.Spinner;
import android.widget.TextView;
import java.text.DecimalFormat;
import java.util.ArrayList;
import pizza.olin.consamables.BeverageAdapter;
import pizza.olin.consamables.R;
import pizza.olin.consamables.data.SharedPrefsHandler;
import pizza.olin.consamables.types.Beverage;
import pizza.olin.consamables.types.OrderItem;
public class OrderConfirmationPage extends Fragment {
private OrderConfirmationListener mListener;
private OrderItem thisOrder;
private TextView orderType;
private TextView toppings;
private TextView price;
private TextView beverage;
public OrderConfirmationPage() {
// Required empty public constructor
}
public static OrderConfirmationPage newInstance() {
OrderConfirmationPage fragment = new OrderConfirmationPage();
return fragment;
}
@Override
public void setUserVisibleHint(boolean isVisible) {
super.setUserVisibleHint(isVisible);
if (isVisible) {
thisOrder = mListener.getCurrentOrder();
orderType.setText(thisOrder.getDisplayName());
toppings.setText(thisOrder.getDisplayDetails());
String dollarPrice = "$" + new DecimalFormat(".00").format(thisOrder.getPriceCents() / 100.0);
price.setText(dollarPrice);
if (thisOrder.getBeverage() != null) {
beverage.setText(thisOrder.getBeverage().getName());
} else {
// This needs to be in strings.xml
beverage.setText("None");
}
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View myView = inflater.inflate(R.layout.fragment_order_confirmation_page, container, false);
orderType = (TextView) myView.findViewById(R.id.pizza_type);
toppings = (TextView) myView.findViewById(R.id.topping_list);
price = (TextView) myView.findViewById(R.id.default_price);
beverage = (TextView) myView.findViewById(R.id.chosen_beverage);
return myView;
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OrderConfirmationListener) {
mListener = (OrderConfirmationListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OrderConfirmationListener");
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
public interface OrderConfirmationListener {
OrderItem getCurrentOrder();
}
}