83 lines
2.8 KiB
Java
83 lines
2.8 KiB
Java
package com.thebrokenrail.mtudining.activity.menu;
|
|
|
|
import android.text.InputType;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
|
|
import androidx.annotation.NonNull;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
import com.google.android.material.textfield.MaterialAutoCompleteTextView;
|
|
import com.google.android.material.textfield.TextInputEditText;
|
|
import com.google.android.material.textfield.TextInputLayout;
|
|
import com.thebrokenrail.mtudining.R;
|
|
import com.thebrokenrail.mtudining.activity.task.Task;
|
|
import com.thebrokenrail.mtudining.activity.task.TaskAdapter;
|
|
import com.thebrokenrail.mtudining.util.DateUtil;
|
|
import com.thebrokenrail.mtudining.widget.CategoryView;
|
|
|
|
/**
|
|
* Adapter for listing dining halls.
|
|
*/
|
|
class MenuAdapter extends TaskAdapter<MenuData> {
|
|
MenuAdapter(Task<MenuData> task) {
|
|
super(task);
|
|
}
|
|
|
|
@Override
|
|
protected View createItemView(@NonNull ViewGroup parent) {
|
|
// Create View
|
|
CategoryView category = new CategoryView(parent.getContext(), null);
|
|
RecyclerView.LayoutParams layoutParams = new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.WRAP_CONTENT);
|
|
category.setLayoutParams(layoutParams);
|
|
return category;
|
|
}
|
|
|
|
@Override
|
|
protected void bindItemView(View view, int position) {
|
|
/*ListData.Category data = getResult().categories.get(position);
|
|
// Setup View
|
|
CategoryView category = (CategoryView) view;
|
|
category.setup(data.isOpen, data.name, () -> {
|
|
// Open/Close Category
|
|
data.isOpen = !data.isOpen;
|
|
notifyItemChanged(getResult().categories.indexOf(data));
|
|
});
|
|
// Add Locations
|
|
category.clearItems();
|
|
for (ListData.Category.Element location : data.locations) {
|
|
category.addItem(location.name, () -> {
|
|
// Do Something!
|
|
});
|
|
}*/
|
|
}
|
|
|
|
@Override
|
|
protected int getDataSize() {
|
|
return 0;
|
|
}
|
|
|
|
@Override
|
|
protected View createHeader(@NonNull ViewGroup parent) {
|
|
LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());
|
|
return layoutInflater.inflate(R.layout.menu_header, parent, false);
|
|
}
|
|
|
|
@Override
|
|
protected void bindHeader(View view) {
|
|
// Set Date
|
|
MaterialAutoCompleteTextView date = view.findViewById(R.id.menu_date);
|
|
// Retrieve from Task as this must show even when result is not available.
|
|
date.setText(DateUtil.toString(((MenuTask) getTask()).getDate()));
|
|
|
|
// Set Meal
|
|
boolean hasMeal = getResult() != null;
|
|
TextInputLayout meal = view.findViewById(R.id.menu_meal_field);
|
|
meal.setEnabled(hasMeal);
|
|
if (hasMeal) {
|
|
|
|
}
|
|
}
|
|
}
|