Skip to content

Commit

Permalink
Fix issue with Late Night hours and issue with empty menus
Browse files Browse the repository at this point in the history
  • Loading branch information
knosseir committed Sep 29, 2017
1 parent da38623 commit e78a268
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 21 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
android:name="com.knosseir.admin.bruinfeed.DiningHallInfoActivity"
android:label="@string/title_activity_dining_hall_info"
android:parentActivityName="com.knosseir.admin.bruinfeed.MainActivity"
android:theme="@style/AppTheme.NoActionBar">
android:theme="@style/AppTheme">
</activity>

<activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public class DatabaseHandler extends SQLiteOpenHelper {

private static final int DATABASE_VERSION = 6;
private static final int DATABASE_VERSION = 7;

// Database Name
private static String DATABASE_NAME = "mealItemManager";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ protected void onCreate(Bundle savedInstanceState) {

// TODO: CHOOSE MEAL BASED ON DINING PERIODS FOR EACH DINING HALL

selectedDiningHall = getIntent().getStringExtra("SelectedDiningHall");
// selectedDiningHall = getIntent().getStringExtra("SelectedDiningHall");
activityLevel = getIntent().getIntExtra("ActivityLevel", 0);
activityLevelProgressBar = findViewById(R.id.activityLevel);

Expand Down Expand Up @@ -339,6 +339,8 @@ public void filterMenuItems() {

@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
selectedDiningHall = getIntent().getStringExtra("SelectedDiningHall");

switch (item.getItemId()) {
case R.id.bottom_breakfast_button:
getMeals(selectedDiningHall, "Breakfast");
Expand Down Expand Up @@ -382,6 +384,10 @@ public void getMeals(String selectedDiningHall, String meal) {
originalMenuItems = new ArrayList<>(menuItems);
originalSections = new ArrayList<>(sections);

if (menuItems.isEmpty() && sections.isEmpty()) {
Snackbar.make(findViewById(R.id.menuRecyclerView), getResources().getString(R.string.no_items_loaded), Snackbar.LENGTH_SHORT).show();
}

updateRecyclerView();
}

Expand Down
23 changes: 11 additions & 12 deletions app/src/main/java/com/knosseir/admin/bruinfeed/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,15 @@ public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);

MenuItem hoursButton = menu.findItem(R.id.main_hours_button);
hoursButton.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
Intent hoursIntent = new Intent(getBaseContext(), DiningHallHoursActivity.class);
startActivity(hoursIntent);
return false;
}
});
// MenuItem hoursButton = menu.findItem(R.id.main_hours_button);
// hoursButton.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
// @Override
// public boolean onMenuItemClick(MenuItem menuItem) {
// Intent hoursIntent = new Intent(getBaseContext(), DiningHallHoursActivity.class);
// startActivity(hoursIntent);
// return false;
// }
// });

// MenuItem searchButton = menu.findItem(R.id.main_action_search);

Expand Down Expand Up @@ -547,7 +547,6 @@ public boolean getHours() {
dinnerClosingHours.put(diningHall, closeTime);
break;
default:
return false;
}
}
}
Expand Down Expand Up @@ -724,7 +723,7 @@ public void onClick(View v) {
holder.footer.setTextColor(Color.RED);
}
}
else if (lunchOpen == 0 && lunchClose == 0 && currentHour < 17) {
else if (lunchOpen == 0 && lunchClose == 0 && brunchOpen == 0 && brunchClose == 0 && currentHour < 17) {
holder.footer.setText("Closed for lunch");
holder.footer.setTextColor(Color.RED);
} else if (dinnerOpen == 0 && dinnerClose == 0) {
Expand All @@ -735,7 +734,7 @@ else if (lunchOpen == 0 && lunchClose == 0 && currentHour < 17) {
else if (currentHour < breakfastOpen ||
(currentHour <= breakfastOpen && currentMinute < breakfastOpeningHours.get(diningHall).get(Calendar.MINUTE))) {
Calendar breakfastOpenCal = breakfastOpeningHours.get(diningHall);
String period = ((int) breakfastOpenCal.get(Calendar.AM_PM) == 0) ? "AM" : "PM"; // cast to int is redundant but a bug in Android Studio makes it throw errors otherwise
String period = ((int) breakfastOpenCal.get(Calendar.AM_PM) == 0) ? "AM" : "PM";
String minute = ((int) breakfastOpenCal.get(Calendar.MINUTE) == 0) ? "00" : Integer.toString(breakfastOpenCal.get(Calendar.MINUTE));
holder.footer.setText("Opening for breakfast at " + breakfastOpenCal.get(Calendar.HOUR) + ":" + minute + " " + period);
holder.footer.setTextColor(Color.RED);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/src/main/res/layout/dining_hall_row.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
android:layout_alignParentRight="true"
android:layout_marginTop="4dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:src="@drawable/ic_map_black_24dp" />
android:src="@drawable/ic_location_on_black_24dp" />

</RelativeLayout>
4 changes: 2 additions & 2 deletions app/src/main/res/menu/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<!--
<item
android:id="@+id/main_hours_button"
android:icon="@drawable/ic_access_time_black_24dp"
android:title="Search"
android:title="Hours"
app:showAsAction="always" />
<!--
<item
android:id="@+id/main_action_search"
android:icon="@drawable/ic_search_black_24dp"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/menu/search_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

<item
android:id="@+id/dining_map_button"
android:icon="@drawable/ic_map_black_24dp"
android:title="Map"
android:icon="@drawable/ic_location_on_black_24dp"
android:title="Location"
app:showAsAction="always" />

<item
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<string name="no_internet">Your device is offline.</string>
<string name="no_description">No description available</string>
<string name="connection_timeout">Your connection timed out.</string>
<string name="no_items_loaded">No items were loaded. Please try again.</string>
<string name="no_items_loaded">The selected menu is empty.</string>
<string name="initial_boot_load_message">Please wait while we cache future meal data...</string>

<string name="empty_menu">The selected menu is empty.</string>
Expand Down

0 comments on commit e78a268

Please sign in to comment.