use of com.example.ezmeal.FindRecipes.FindRecipesModels.CategoryFragmentChildHorizontalRecyclerModel in project EZMeal by Jake-Sokol2.
the class CategoryFragmentAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
final int itemType = getItemViewType(position);
if (position == 6) {
db = FirebaseFirestore.getInstance();
// todo: RecipesRating
dbRecipes = db.collection("Recipes");
StaggeredGridLayoutManager.LayoutParams staggeredLayout = (StaggeredGridLayoutManager.LayoutParams) holder.itemView.getLayoutParams();
staggeredLayout.setFullSpan(true);
holder.itemView.setLayoutParams(staggeredLayout);
HorizontalViewHolder horizontalHolder = (HorizontalViewHolder) holder;
horizontalHolder.horizontalRecipes.setBackgroundColor(Color.parseColor("#ffffffff"));
RecyclerView.LayoutManager horizontalManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
horizontalHolder.childHorizontalRecyclerView.setHasFixedSize(true);
horizontalHolder.childHorizontalRecyclerView.setLayoutManager(horizontalManager);
EZMealDatabase sqlDb = Room.databaseBuilder(holder.itemView.getContext(), EZMealDatabase.class, "user").allowMainThreadQueries().fallbackToDestructiveMigration().build();
CategoryFragmentChildHorizontalRecyclerModel horizontalModel;
horizontalModel = new CategoryFragmentChildHorizontalRecyclerModel(popularRecipesTitleList, popularRecipesImageList, avgPopularRatingList);
CategoryFragmentChildHorizontalRecylerAdapter highRatedRecipesAdapter = new CategoryFragmentChildHorizontalRecylerAdapter(horizontalLists.get(0));
/*CategoryFragmentChildHorizontalRecylerAdapter highRatedRecipesAdapter = new CategoryFragmentChildHorizontalRecylerAdapter(horizontalModel.getRecipeList(),
horizontalModel.getUriList(), horizontalHolder.childHorizontalRecyclerView.getContext(), horizontalModel.getAvgRatingList());*/
highRatedRecipesAdapter.setOnItemClickListener(new CategoryFragmentChildHorizontalRecylerAdapter.MainAdapterListener() {
@Override
public void onItemClick(int position) {
Intent intent = new Intent(holder.itemView.getContext(), RecipeActivity.class);
Bundle bundle = new Bundle();
// highRatedRecipeIdList.get(position));
bundle.putString("id", horizontalLists.get(0).get(position).getRecipeId());
intent.putExtras(bundle);
holder.itemView.getContext().startActivity(intent);
}
});
horizontalHolder.childHorizontalRecyclerView.setAdapter(highRatedRecipesAdapter);
} else {
MainViewHolder verticalHolder = (MainViewHolder) holder;
StaggeredGridLayoutManager.LayoutParams staggeredLayout = (StaggeredGridLayoutManager.LayoutParams) holder.itemView.getLayoutParams();
staggeredLayout.setFullSpan(false);
holder.itemView.setLayoutParams(staggeredLayout);
String recipeTitle = verticalRecipes.get(position).getTitle();
uri = verticalRecipes.get(position).getImage();
verticalHolder.txtTitle.setText(recipeTitle);
Glide.with(verticalHolder.itemView.getContext()).load(uri).into(verticalHolder.recipeImage);
Double avgRatingDouble = verticalRecipes.get(position).getAvgRating();
float avgRatingFloat = avgRatingDouble.floatValue();
if (verticalRecipes.get(position).getTotalCountOfRatings() >= COUNT_THRESHOLD_TO_SHOW_RECIPES) {
// todo: there is an underlying issue here - we shouldn't need to set this to VISIBLE as it should never be set INVISIBLE. For some reason the recyclerview sets it invisible anyway
verticalHolder.ratingBar.setVisibility(View.VISIBLE);
verticalHolder.ratingBar.setRating(avgRatingFloat);
} else {
verticalHolder.ratingBar.setVisibility(View.INVISIBLE);
}
}
}
use of com.example.ezmeal.FindRecipes.FindRecipesModels.CategoryFragmentChildHorizontalRecyclerModel in project EZMeal by Jake-Sokol2.
the class CategoryFragmentFeaturedRecyclerAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
final int itemType = getItemViewType(position);
db = FirebaseFirestore.getInstance();
// todo: RecipesRating
dbRecipes = db.collection("Recipes");
StaggeredGridLayoutManager.LayoutParams staggeredLayout = (StaggeredGridLayoutManager.LayoutParams) holder.itemView.getLayoutParams();
staggeredLayout.setFullSpan(true);
holder.itemView.setLayoutParams(staggeredLayout);
HorizontalViewHolder horizontalHolder = (HorizontalViewHolder) holder;
horizontalHolder.horizontalRecipes.setBackgroundColor(Color.parseColor("#ffffffff"));
RecyclerView.LayoutManager horizontalManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
horizontalHolder.childHorizontalRecyclerView.setHasFixedSize(true);
horizontalHolder.childHorizontalRecyclerView.setLayoutManager(horizontalManager);
EZMealDatabase sqlDb = Room.databaseBuilder(holder.itemView.getContext(), EZMealDatabase.class, "user").allowMainThreadQueries().fallbackToDestructiveMigration().build();
CategoryFragmentChildHorizontalRecyclerModel horizontalModel;
horizontalModel = new CategoryFragmentChildHorizontalRecyclerModel(popularRecipesTitleList, popularRecipesImageList, avgPopularRatingList);
// CategoryFragmentChildHorizontalRecylerAdapter highRatedRecipesAdapter = new CategoryFragmentChildHorizontalRecylerAdapter(horizontalModel.getRecipeList(),
// horizontalModel.getUriList(), horizontalHolder.childHorizontalRecyclerView.getContext(), horizontalModel.getAvgRatingList());
horizontalHolder.txtTitle.setText(verticalTitleList.get(position));
if (horizontalLists.size() > 0) {
Log.i("active categories", "horizontalLists size > 0 inside vertical recyclerAdapter");
Log.i("active categories", "size in vertical adapter - " + String.valueOf(horizontalLists.size()));
for (int i = 0; i < horizontalLists.size(); i++) {
Log.i("active categories", "looping list inside vertical adapter");
Log.i("active categories", "\t" + i + ": " + String.valueOf(horizontalLists.get(i)));
}
CategoryFragmentChildHorizontalRecylerAdapter highRatedRecipesAdapter = new CategoryFragmentChildHorizontalRecylerAdapter(horizontalLists.get(position));
highRatedRecipesAdapter.setOnItemClickListener(new CategoryFragmentChildHorizontalRecylerAdapter.MainAdapterListener() {
@Override
public void onItemClick(int position) {
Intent intent = new Intent(holder.itemView.getContext(), RecipeActivity.class);
Bundle bundle = new Bundle();
// highRatedRecipeIdList.get(position));
bundle.putString("id", horizontalLists.get(0).get(position).getRecipeId());
intent.putExtras(bundle);
holder.itemView.getContext().startActivity(intent);
}
});
horizontalHolder.childHorizontalRecyclerView.setAdapter(highRatedRecipesAdapter);
/*if (position == 0)
{
final int itemType = getItemViewType(position);
db = FirebaseFirestore.getInstance();
// todo: RecipesRating
dbRecipes = db.collection("RecipesRatingBigInt");
StaggeredGridLayoutManager.LayoutParams staggeredLayout = (StaggeredGridLayoutManager.LayoutParams) holder.itemView.getLayoutParams();
staggeredLayout.setFullSpan(true);
holder.itemView.setLayoutParams(staggeredLayout);
HorizontalViewHolder horizontalHolder = (HorizontalViewHolder) holder;
horizontalHolder.horizontalRecipes.setBackgroundColor(Color.parseColor("#ffffffff"));
RecyclerView.LayoutManager horizontalManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
horizontalHolder.childHorizontalRecyclerView.setHasFixedSize(true);
horizontalHolder.childHorizontalRecyclerView.setLayoutManager(horizontalManager);
EZMealDatabase sqlDb = Room.databaseBuilder(holder.itemView.getContext(), EZMealDatabase.class, "user")
.allowMainThreadQueries().fallbackToDestructiveMigration().build();
CategoryFragmentChildHorizontalRecyclerModel horizontalModel;
horizontalModel = new CategoryFragmentChildHorizontalRecyclerModel(popularRecipesTitleList, popularRecipesImageList, avgPopularRatingList);
//CategoryFragmentChildHorizontalRecylerAdapter highRatedRecipesAdapter = new CategoryFragmentChildHorizontalRecylerAdapter(horizontalModel.getRecipeList(),
// horizontalModel.getUriList(), horizontalHolder.childHorizontalRecyclerView.getContext(), horizontalModel.getAvgRatingList());
horizontalHolder.txtTitle.setText(verticalTitleList.get(position));
if (horizontalLists.size() > 0)
{
Log.i("active categories", "horizontalLists size > 0 inside vertical recyclerAdapter");
Log.i("active categories", "size in vertical adapter - " + String.valueOf(horizontalLists.size()));
CategoryFragmentChildHorizontalRecylerAdapter highRatedRecipesAdapter = new CategoryFragmentChildHorizontalRecylerAdapter(horizontalLists.get(position));
highRatedRecipesAdapter.setOnItemClickListener(new CategoryFragmentChildHorizontalRecylerAdapter.MainAdapterListener()
{
@Override
public void onItemClick(int position)
{
Intent intent = new Intent(holder.itemView.getContext(), RecipeActivity.class);
Bundle bundle = new Bundle();
//bundle.putString("id", highRatedRecipeIdList.get(position));
//intent.putExtras(bundle);
//holder.itemView.getContext().startActivity(intent);
}
});
horizontalHolder.childHorizontalRecyclerView.setAdapter(highRatedRecipesAdapter);*/
// }
} else {
CategoryFragmentChildHorizontalRecylerAdapter highRatedRecipesAdapter = new CategoryFragmentChildHorizontalRecylerAdapter(horizontalLists.get(position));
highRatedRecipesAdapter.setOnItemClickListener(new CategoryFragmentChildHorizontalRecylerAdapter.MainAdapterListener() {
@Override
public void onItemClick(int position) {
Intent intent = new Intent(holder.itemView.getContext(), RecipeActivity.class);
Bundle bundle = new Bundle();
// bundle.putString("id", highRatedRecipeIdList.get(position));
// intent.putExtras(bundle);
// holder.itemView.getContext().startActivity(intent);
}
});
horizontalHolder.childHorizontalRecyclerView.setAdapter(highRatedRecipesAdapter);
}
}
Aggregations