Slavchikk 1 an în urmă
părinte
comite
8c68900406

+ 13 - 1
app/src/main/java/com/example/recipeproj/AdapterRecipe.java

@@ -45,14 +45,26 @@ public class AdapterRecipe  extends BaseAdapter {
         TextView fullRec = v.findViewById(R.id.txtFull);
         TextView nameRec = v.findViewById(R.id.txtName);
         ImageView imageView = v.findViewById(R.id.imageView2);
-
+        TextView caloryText = v.findViewById(R.id.txtCalory);
+        TextView timeText = v.findViewById(R.id.txtTime);
         Recipe recipe = recipeList.get(position);
 
+        caloryText.setText(recipe.getCalory());
+        timeText.setText(recipe.getTimeGot());
+
         fullRec.setText(recipe.getFullRecipe());
         nameRec.setText(recipe.getNameRecipe());
         DecodeImage dcd = new DecodeImage(mContext);
         imageView.setImageBitmap(dcd.getUserImage(recipe.getImage()));
 
+        v.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                Intent intent = new Intent(mContext, ViewRecipe.class);
+                intent.putExtra(Recipe.class.getSimpleName(), recipe);
+                mContext.startActivity(intent);
+            }
+        });
 
         return v;
     }

+ 3 - 1
app/src/main/java/com/example/recipeproj/MainActivity.java

@@ -68,7 +68,9 @@ public class MainActivity extends AppCompatActivity {
                             prodJson.getInt("idRecipe"),
                             prodJson.getString("fullRecipe"),
                             prodJson.getString("nameRecipe"),
-                            prodJson.getString("image")
+                            prodJson.getString("image"),
+                            prodJson.getString("calory"),
+                            prodJson.getString("timeGot")
 
 
                     );

+ 14 - 5
app/src/main/java/com/example/recipeproj/Recipe.java

@@ -15,12 +15,14 @@ public class Recipe implements Parcelable {
     public String nameRecipe;
 
     public String image;
-
-    public Recipe(Integer idRecipe, String fullRecipe, String nameRecipe,String image) {
+    public String calory;
+    public String timeGot;
+    public Recipe(Integer idRecipe, String fullRecipe, String nameRecipe,String image,String calory,String timeGot) {
         this.idRecipe = idRecipe;
         this.fullRecipe = fullRecipe;
         this.nameRecipe = nameRecipe;
-
+        this.calory = calory;
+        this.timeGot = timeGot;
         this.image = image;
     }
 
@@ -29,7 +31,8 @@ public class Recipe implements Parcelable {
         idRecipe = in.readInt();
         fullRecipe = in.readString();
         nameRecipe = in.readString();
-
+        calory = in.readString();
+        timeGot = in.readString();
         image = in.readString();
     }
 
@@ -38,7 +41,8 @@ public class Recipe implements Parcelable {
         dest.writeInt(idRecipe);
         dest.writeString(fullRecipe);
         dest.writeString(nameRecipe);
-
+        dest.writeString(calory);
+        dest.writeString(timeGot);
         dest.writeString(image);
     }
 
@@ -59,9 +63,14 @@ public class Recipe implements Parcelable {
         }
     };
 
+    public String getCalory() {return calory;}
+    public String getTimeGot() {return timeGot;}
+
     public Integer getIdRecipe() {
         return idRecipe;
     }
+    public  void setCalory(String calory) {this.calory = calory;}
+    public  void setTimeGot(String timeGot) {this.timeGot = timeGot;}
 
     public void setIdRecipe(Integer idRecipe) {
         this.idRecipe = idRecipe;

+ 28 - 8
app/src/main/res/layout/activity_recipe.xml

@@ -27,23 +27,43 @@
 
         <TextView
             android:id="@+id/txtFull"
-            android:layout_width="96dp"
-            android:layout_height="49dp"
+            android:layout_width="80dp"
+            android:layout_height="80dp"
             android:layout_alignParentTop="true"
             android:layout_alignParentEnd="true"
-            android:layout_marginTop="240dp"
-            android:layout_marginEnd="264dp"
+            android:layout_marginTop="246dp"
+            android:layout_marginEnd="314dp"
+            android:text="TextView" />
+
+        <TextView
+            android:id="@+id/txtCalory"
+            android:layout_width="80dp"
+            android:layout_height="80dp"
+            android:layout_alignParentTop="true"
+            android:layout_alignParentEnd="true"
+            android:layout_marginTop="247dp"
+            android:layout_marginEnd="221dp"
+            android:text="TextView" />
+
+        <TextView
+            android:id="@+id/txtTime"
+            android:layout_width="80dp"
+            android:layout_height="80dp"
+            android:layout_alignParentTop="true"
+            android:layout_alignParentEnd="true"
+            android:layout_marginTop="246dp"
+            android:layout_marginEnd="24dp"
             android:text="TextView" />
 
         <TextView
             android:id="@+id/txtName"
 
-            android:layout_width="96dp"
-            android:layout_height="49dp"
+            android:layout_width="80dp"
+            android:layout_height="80dp"
             android:layout_alignParentTop="true"
             android:layout_alignParentEnd="true"
-            android:layout_marginTop="242dp"
-            android:layout_marginEnd="92dp"
+            android:layout_marginTop="246dp"
+            android:layout_marginEnd="117dp"
             android:text="TextView" />