Skip to content

Commit

Permalink
version 1.0.8 upcoming
Browse files Browse the repository at this point in the history
cleanup the code for the adapter
  • Loading branch information
amarradi committed Jun 28, 2022
1 parent d8b0ed1 commit 20bc623
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 117 deletions.
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ android {
dependencies {
def preference_version = "1.2.0"

// Java language implementation
implementation "androidx.preference:preference:$preference_version"
implementation 'androidx.appcompat:appcompat:1.4.2'
/*
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
Expand All @@ -47,4 +44,7 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

// Java language implementation
implementation "androidx.preference:preference:$preference_version"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.git.amarradi.palatschinkencounter.models.IngredientsModel;
import com.git.amarradi.palatschinkencounter.models.PreparationModel;
import com.git.amarradi.palatschinkencounter.adapter.RecylerViewRecipeAdapter;
import com.git.amarradi.palatschinkencounter.models.RecipeModel;

import java.util.ArrayList;

public class RecipeActivity extends AppCompatActivity {

ArrayList<IngredientsModel> ingredientsModels = new ArrayList<>();
ArrayList<PreparationModel> preparationModels = new ArrayList<>();
ArrayList<RecipeModel> ingredientsModels = new ArrayList<>();
ArrayList<RecipeModel> preparationModels = new ArrayList<>();

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
Expand All @@ -24,35 +24,35 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {

RecyclerView recyclerView_Ingredients = findViewById(R.id.recyclerView_ingredients);

setupIngredientsModels();
setupRecipeModels();

RecylerIngredientsViewAdapter recylerIngredientsViewAdapter =
new RecylerIngredientsViewAdapter(this,ingredientsModels);
recyclerView_Ingredients.setAdapter(recylerIngredientsViewAdapter);
RecylerViewRecipeAdapter recylerViewIngredientsAdapter =
new RecylerViewRecipeAdapter(this,ingredientsModels);
recyclerView_Ingredients.setAdapter(recylerViewIngredientsAdapter);
recyclerView_Ingredients.setLayoutManager(new LinearLayoutManager(this));


RecyclerView recyclerView_Preparation = findViewById(R.id.RecyclerView_preparation);

setupPreparationModels();
RecylerPreparationViewAdapter recylerPreparationViewAdapter =
new RecylerPreparationViewAdapter(this,preparationModels);
RecylerViewRecipeAdapter recylerViewPreparationAdapter =
new RecylerViewRecipeAdapter(this,preparationModels);
recyclerView_Preparation.setNestedScrollingEnabled(false);
recyclerView_Preparation.setAdapter(recylerPreparationViewAdapter);
recyclerView_Preparation.setAdapter(recylerViewPreparationAdapter);
recyclerView_Preparation.setLayoutManager(new LinearLayoutManager(this));
}

private void setupPreparationModels() {
String[] strings_preparation = getResources().getStringArray(R.array.preparation_array);
for (String s : strings_preparation) {
preparationModels.add(new PreparationModel(s));
preparationModels.add(new RecipeModel(s));
}
}

public void setupIngredientsModels(){
public void setupRecipeModels(){
String[] strings_ingredients = getResources().getStringArray(R.array.ingredients_array);
for (String strings_ingredient : strings_ingredients) {
ingredientsModels.add(new IngredientsModel(strings_ingredient));
ingredientsModels.add(new RecipeModel(strings_ingredient));
}
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.git.amarradi.palatschinkencounter;
package com.git.amarradi.palatschinkencounter.adapter;

import android.content.Context;
import android.util.Log;
Expand All @@ -10,18 +10,19 @@
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.git.amarradi.palatschinkencounter.models.IngredientsModel;
import com.git.amarradi.palatschinkencounter.R;
import com.git.amarradi.palatschinkencounter.models.RecipeModel;

import java.util.ArrayList;

public class RecylerIngredientsViewAdapter extends RecyclerView.Adapter<RecylerIngredientsViewAdapter.MyViewHolder> {
public class RecylerViewRecipeAdapter extends RecyclerView.Adapter<RecylerViewRecipeAdapter.MyViewHolder> {

Context context;
ArrayList<IngredientsModel> ingredientsModels;
ArrayList<RecipeModel> recipeModels;

public RecylerIngredientsViewAdapter(Context context, ArrayList<IngredientsModel> ingredientsModels) {
public RecylerViewRecipeAdapter(Context context, ArrayList<RecipeModel> recipeModels) {
this.context = context;
this.ingredientsModels = ingredientsModels;
this.recipeModels = recipeModels;

}

Expand All @@ -38,23 +39,23 @@ public MyViewHolder(@NonNull View itemView) {

@NonNull
@Override
public RecylerIngredientsViewAdapter.MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
public RecylerViewRecipeAdapter.MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from(context);
View view = inflater.inflate(R.layout.recycler_view_row, parent, false);
return new MyViewHolder(view);
}

@Override
public void onBindViewHolder(@NonNull RecylerIngredientsViewAdapter.MyViewHolder holder, int position) {
public void onBindViewHolder(@NonNull RecylerViewRecipeAdapter.MyViewHolder holder, int position) {

holder.CVtextView.setText(ingredientsModels.get(position).getPreparationLine());
holder.CVtextView.setText(recipeModels.get(position).getRecipeLine());

}

@Override
public int getItemCount() {
Log.d("getItemCount", String.valueOf(ingredientsModels.size()) );
return ingredientsModels.size();
Log.d("getItemCount", String.valueOf(recipeModels.size()) );
return recipeModels.size();
}


Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.git.amarradi.palatschinkencounter.models;

public class RecipeModel {
private final String recipeLine;

public RecipeModel(String recipeLine) {
this.recipeLine = recipeLine;
}

public String getRecipeLine() {
return recipeLine;
}
}

0 comments on commit 20bc623

Please sign in to comment.