Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graded Lab 1 #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions app/src/main/java/pizza/olin/consamables/AdminPageActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import java.util.ArrayList;
import java.util.Date;
import java.util.Locale;

import pizza.olin.consamables.data.FirebaseHandler;
import pizza.olin.consamables.types.GroupOrder;
Expand Down Expand Up @@ -58,6 +59,7 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
public void onClick(View view) {
boolean isActiveOrder = false;
// ^This variable is not used
if (maybeNewestOrder.isPresent()) {
if (maybeNewestOrder.get().isClosed) {
// cool
Expand Down Expand Up @@ -137,10 +139,10 @@ private void updateTimer() {
countDownTimer = new CountDownTimer(timeLeftInOrder, UPDATE_TIMER_MS) {

public void onTick(long millisUntilFinished) {
timeLeft.setText(String.format(
"%02d:%02d",
millisUntilFinished / 1000 / 60,
millisUntilFinished / 1000 % 60));
// To make your code more readable, do this:
long minutes = (millisUntilFinished / 1000) / 60;
long seconds = (millisUntilFinished / 1000) % 60;
timeLeft.setText(String.format(Locale.getDefault(), "%02d:%02d", minutes, seconds));
}

public void onFinish() {
Expand All @@ -152,6 +154,7 @@ public void onFinish() {
countDownTimer.cancel();
}

// "Time's up" needs to be in strings.xml
timeLeft.setText("Time's up!");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public void onCreate(Bundle savedInstanceState) {
orderId = getArguments().getString(ARG_ORDER_ID);
}

// What is this?
if (orderId != null) {

}
Expand All @@ -49,6 +50,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
}

public void onButtonPressed(Uri uri) {
// What is this?
if (mListener != null) {
}
}
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/pizza/olin/consamables/WizardActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public class WizardActivity extends AppCompatActivity
implements HalfOrWholePage.PizzaTypeListener, ToppingSelectPage.ToppingSelectListener,
BeverageSelectPage.BeverageTypeListener, OrderConfirmationPage.OrderConfirmationListener,
FinishedOrderPage.FinishedOrderListener {
private static final String TAG = "WizardActivity";
// This is fine, but consider using WizardActivity.class.getName();
private static final String TAG = WizardActivity.class.getName();
private static final String ANONYMOUS = "anonymous";
private static final int RC_SIGN_IN = 47;
private FirebaseAuth mFirebaseAuth;
Expand All @@ -60,6 +61,8 @@ public class WizardActivity extends AppCompatActivity

@Override
protected void onCreate(Bundle savedInstanceState) {
// This onCreate is huge. Consider refactoring into separate methods like getWizardSteps(),
// and handleEmailVerification()
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_wizard);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public ArrayList<Topping> getToppings() {
return allToppings;
}

// This method doesn't seem to be used
public GroupOrder getCurrentOrder() {
String serializedOrder = prefs.getString("Current Order", "");
GroupOrder order = gson.fromJson(serializedOrder, GroupOrder.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package pizza.olin.consamables.pages;

import android.content.Context;

// Unused import!
import android.net.Uri;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
public class FinishedOrderPage extends Fragment {

private FinishedOrderListener mListener;

// This isn't used
private SharedPrefsHandler prefsHandler;

public FinishedOrderPage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public void setUserVisibleHint(boolean isVisible) {
if (thisOrder.getBeverage() != null) {
beverage.setText(thisOrder.getBeverage().getName());
} else {
// This needs to be in strings.xml
beverage.setText("None");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ public void setUserVisibleHint(boolean isVisible) {
if (isVisible) {
PizzaOrderType pizzaType = mListener.getPizzaType();
ViewGroup parent = (ViewGroup) getView();

// does parent always have at least 1 child?
View currentView = parent.getChildAt(0);

int currentViewId = currentView.getId();
int targetViewId = viewOptions.get(pizzaType);
int layoutId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public String getDisplayName() {

@Override
public String getDisplayDetails() {
// Beautiful
return Stream.of(toppings)
.reduce("", new BiFunction<String, Topping, String>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public String getDisplayName() {

@Override
public String getDisplayDetails() {
// None of these are used
ArrayList<Topping> leftToppings = leftHalf.getToppings();
ArrayList<Topping> rightToppings = rightHalf.getToppings();
int leftMaxLength = getLeftMaxToppingLength();
Expand Down