Skip to content

Commit

Permalink
Final review
Browse files Browse the repository at this point in the history
  • Loading branch information
aditmodhvadia committed Nov 22, 2018
1 parent 02d847a commit 990eb8f
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@
public class MenuDisplayAdapter extends BaseAdapter {

ArrayList<String> itemName,itemPrice, itemRating;
ArrayList<Integer> colors;
Context context;
LayoutInflater inflater;

TextView itemNameTextView, itemPriceTextView, itemRatingTextView;

public MenuDisplayAdapter(ArrayList<String> itemName, ArrayList<String> itemPrice, ArrayList<String> itemRating, Context context) {
public MenuDisplayAdapter(ArrayList<String> itemName, ArrayList<String> itemPrice, ArrayList<String> itemRating, ArrayList<Integer> colors, Context context) {
this.itemName = itemName;
this.itemPrice = itemPrice;
this.itemRating = itemRating;
this.colors = colors;
this.context = context;
this.inflater = LayoutInflater.from(context);
}
Expand Down Expand Up @@ -55,11 +57,11 @@ public View getView(int i, View view, ViewGroup viewGroup) {
itemPriceTextView.setText(String.format("₹ %s", itemPrice.get(i)));
itemRatingTextView.setText(itemRating.get(i));
if(Float.valueOf(itemRating.get(i))<2.0){
itemRatingTextView.setTextColor(Color.RED);
itemRatingTextView.setTextColor(colors.get(2));
} else if(Float.valueOf(itemRating.get(i))<3.5){
itemRatingTextView.setTextColor(Color.YELLOW);
itemRatingTextView.setTextColor(colors.get(1));
} else{
itemRatingTextView.setTextColor(Color.GREEN);
itemRatingTextView.setTextColor(colors.get(0));
}

return vi;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class ChineseFragment extends Fragment {
private DatabaseReference rootFood;
ProgressDialog progressDialog;
ArrayList<String> itemName, itemPrice, itemRating;
ArrayList<Integer> colors;

Button alertPlus, alertMinus;
TextView quantitySetTV;
Expand All @@ -55,6 +56,11 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
itemName = new ArrayList<>();
itemPrice = new ArrayList<>();
itemRating = new ArrayList<>();
colors = new ArrayList<>();

colors.add(getResources().getColor(R.color.colorGoodRating));
colors.add(getResources().getColor(R.color.colorMediumRating));
colors.add(getResources().getColor(R.color.colorBadRating));

chineseDisplayListView = v.findViewById(R.id.chineseDisplayListView);
final String CATEGORY = "Chinese";
Expand All @@ -75,7 +81,7 @@ public void onDataChange(DataSnapshot dataSnapshot) {
itemRating.add(dsp.child("Rating").getValue().toString());
}
}
displayAdapter = new MenuDisplayAdapter(itemName, itemPrice, itemRating, getContext());
displayAdapter = new MenuDisplayAdapter(itemName, itemPrice, itemRating, colors, getContext());
chineseDisplayListView.setAdapter(displayAdapter);

// progressDialog.hide();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class PizzaSandwichFragment extends Fragment {
ProgressDialog progressDialog;
private String CATEGORY = "Pizza Sandwich";
ArrayList<String> itemName, itemPrice, itemRating;
ArrayList<Integer> colors;

Button alertPlus, alertMinus;
TextView quantitySetTV;
Expand All @@ -56,6 +57,11 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
itemName = new ArrayList<>();
itemPrice = new ArrayList<>();
itemRating = new ArrayList<>();
colors = new ArrayList<>();

colors.add(getResources().getColor(R.color.colorGoodRating));
colors.add(getResources().getColor(R.color.colorMediumRating));
colors.add(getResources().getColor(R.color.colorBadRating));
pizzaSandwichDisplayListView = v.findViewById(R.id.pizzaSandwichDisplayListView);
// display progress dialog till data is fetched
// progressDialog.setTitle("Please Wait..");
Expand All @@ -79,7 +85,7 @@ public void onDataChange(DataSnapshot dataSnapshot) {
itemRating.add(dsp.child("Rating").getValue().toString());
}
}
displayAdapter = new MenuDisplayAdapter(itemName, itemPrice, itemRating, getContext());
displayAdapter = new MenuDisplayAdapter(itemName, itemPrice, itemRating, colors, getContext());
pizzaSandwichDisplayListView.setAdapter(displayAdapter);
// progressDialog.hide();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class SouthIndianFragment extends Fragment {
ProgressDialog progressDialog;
private String CATEGORY = "South Indian";
ArrayList<String> itemName, itemPrice, itemRating;
ArrayList<Integer> colors;

Button alertPlus, alertMinus;
TextView quantitySetTV;
Expand All @@ -54,6 +55,10 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
itemName = new ArrayList<>();
itemPrice = new ArrayList<>();
itemRating = new ArrayList<>();
colors = new ArrayList<>();
colors.add(getResources().getColor(R.color.colorGoodRating));
colors.add(getResources().getColor(R.color.colorMediumRating));
colors.add(getResources().getColor(R.color.colorBadRating));
southIndianDisplayListView = v.findViewById(R.id.southIndianDisplayListView);
// display progress dialog till data is fetched
// progressDialog.setTitle("Please Wait..");
Expand All @@ -78,7 +83,7 @@ public void onDataChange(DataSnapshot dataSnapshot) {
}
}

displayAdapter = new MenuDisplayAdapter(itemName, itemPrice, itemRating, getContext());
displayAdapter = new MenuDisplayAdapter(itemName, itemPrice, itemRating, colors, getContext());
southIndianDisplayListView.setAdapter(displayAdapter);


Expand Down
23 changes: 13 additions & 10 deletions app/src/main/res/layout/cart_display_customlistview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
android:id="@+id/itemQuantityTextView"
android:layout_width="36dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="64dp"
android:layout_marginStart="4dp"
android:layout_marginBottom="20dp"
android:text="0"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="#000"
app:layout_constraintStart_toEndOf="@+id/decreaseButton"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/decreaseButton" />

<TextView
android:id="@+id/itemPriceTextView"
Expand All @@ -66,28 +66,31 @@
style="?android:attr/borderlessButtonStyle"
android:layout_width="36dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="48dp"
android:layout_marginStart="4dp"
android:layout_marginTop="40dp"
android:layout_marginBottom="8dp"
android:padding="5dp"
android:scaleType="center"
android:src="@drawable/ic_add"
android:tint="#2c3e50"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/itemQuantityTextView"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0" />

<ImageButton
android:id="@+id/decreaseButton"
style="?android:attr/borderlessButtonStyle"
android:layout_width="36dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp"
android:padding="5dp"
android:scaleType="center"
android:src="@drawable/ic_remove"
android:tint="#2c3e50"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/itemNameTextView" />
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />

<ImageView
android:id="@+id/imageView"
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/layout/food_menu_display_custom_listview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:textStyle="bold"
android:layout_marginEnd="24dp"
android:layout_weight="1"
android:text="TextView"
Expand Down Expand Up @@ -54,6 +55,7 @@
android:layout_width="16sp"
android:layout_height="16sp"
android:layout_marginStart="16dp"
android:tint="#bdc3c7"
android:layout_marginTop="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/itemNameTextView"
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@
<color name="colorPrimaryText">#828282</color>
<color name="colorDisableButton">#f1b9b9</color>
<color name="colorMediumRating">#e67e22</color>
<color name="colorGoodRating">#27ae60</color>
<color name="colorBadRating">#e74c3c</color>
</resources>

0 comments on commit 990eb8f

Please sign in to comment.