Skip to content

Commit 32e6f27

Browse files
authored
Merge pull request #11 from ONatanT/addPopUp
Add pop up
2 parents a05c81a + 5835868 commit 32e6f27

4 files changed

Lines changed: 70 additions & 5 deletions

File tree

app/src/main/java/com/example/firsthitmonday/CustomeAdapter.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.example.firsthitmonday;
22

3+
import android.app.Dialog;
34
import android.view.LayoutInflater;
45
import android.view.View;
56
import android.view.ViewGroup;
67
import android.widget.ImageView;
78
import android.widget.TextView;
9+
import android.widget.Toast;
810

911
import androidx.annotation.NonNull;
1012
import androidx.recyclerview.widget.RecyclerView;
@@ -16,6 +18,7 @@
1618
public class CustomeAdapter extends RecyclerView.Adapter<CustomeAdapter.MyViewHolder> {
1719

1820
ArrayList<DataModel> dataset;
21+
Dialog myDialog;
1922
public CustomeAdapter(ArrayList<DataModel> dataSet) {
2023
this.dataset = dataSet;
2124
}
@@ -43,6 +46,22 @@ public CustomeAdapter.MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent,
4346

4447
MyViewHolder myViewHolder = new MyViewHolder(view);
4548

49+
myDialog = new Dialog(view.getContext());
50+
myDialog.setContentView(R.layout.popup_character);
51+
52+
53+
myViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
54+
@Override
55+
public void onClick(View view) {
56+
TextView dialog_name = (TextView) myDialog.findViewById(R.id.dialog_name_id);
57+
ImageView dialog_image = (ImageView) myDialog.findViewById(R.id.dialog_imageview_id);
58+
dialog_name.setText(dataset.get(myViewHolder.getAdapterPosition()).getName());
59+
dialog_image.setImageResource(dataset.get(myViewHolder.getAdapterPosition()).getImage());
60+
myDialog.show();
61+
62+
}
63+
});
64+
4665
return myViewHolder;
4766
}
4867

@@ -57,6 +76,7 @@ public void onBindViewHolder(@NonNull CustomeAdapter.MyViewHolder holder, int po
5776
textViewVersion.setText((dataset.get(position).getVersion()));
5877
imageView.setImageResource(dataset.get(position).getImage());
5978

79+
6080
}
6181

6282
@Override

app/src/main/java/com/example/firsthitmonday/MyData.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
public class MyData {
66

7-
static String[] nameArray = {"Dark", "Jonas", "marta", "Noah", "Hannah", "Ulrich", "Mikkel","Bartosh", "Alex", "Charlotte", "Helge"};
8-
static String[] textArray = {"Netflix tv show", "The main character", "Jonas' girlfriend", "The scary priest who kidnapped children", "Jonas's mother", "Marta's father, cheats on his wife with Jonas' mother", "The son of ulrich and marta's brother, was kidnapped by the priest", "Jonas's best friend", "Bartosh's father and the manager of the nuclear power plant", "The director of the police station who investigates the abduction of the children","A mysterious old man whom everyone suspects of kidnapping the children"};
7+
static String[] nameArray = {"Jonas", "marta", "Noah", "Hannah", "Ulrich", "Mikkel","Bartosh", "Alex", "Charlotte", "Helge"};
8+
static String[] textArray = {"The main character", "Jonas' girlfriend", "The scary priest who kidnapped children", "Jonas's mother", "Marta's father, cheats on his wife with Jonas' mother", "The son of ulrich and marta's brother, was kidnapped by the priest", "Jonas's best friend", "Bartosh's father and the manager of the nuclear power plant", "The director of the police station who investigates the abduction of the children","A mysterious old man whom everyone suspects of kidnapping the children"};
99

10-
static Integer[] drawableArray = {R.drawable.dark, R.drawable.jonas, R.drawable.marta,
10+
static Integer[] drawableArray = {R.drawable.jonas, R.drawable.marta,
1111
R.drawable.noah, R.drawable.hannah, R.drawable.ulrich, R.drawable.mikkel,
1212
R.drawable.bartosh, R.drawable.alex, R.drawable.charlotte,R.drawable.helge};
1313

app/src/main/res/layout/activity_main.xml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@
1010
android:orientation="vertical"
1111
tools:context=".MainActivity">
1212

13+
<TextView
14+
android:id="@+id/textView3"
15+
android:layout_width="match_parent"
16+
android:layout_height="wrap_content"
17+
android:background="#FFFFFF"
18+
android:text="Dark"
19+
android:gravity="bottom|center"
20+
android:textSize="30sp"
21+
android:textColor="@color/black"
22+
android:textStyle="bold" />
23+
1324
<Button
1425
android:id="@+id/search_button"
1526
android:layout_width="match_parent"
@@ -39,6 +50,5 @@
3950
<androidx.recyclerview.widget.RecyclerView
4051
android:id="@+id/res"
4152
android:layout_width="match_parent"
42-
android:layout_height="match_parent"
43-
/>
53+
android:layout_height="match_parent" />
4454
</LinearLayout>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="350dp"
4+
android:layout_height="wrap_content"
5+
android:layout_gravity="center">
6+
7+
8+
<LinearLayout
9+
android:layout_width="match_parent"
10+
android:layout_height="wrap_content"
11+
android:orientation="vertical"
12+
android:background="#232323"
13+
android:gravity="center_horizontal">
14+
15+
16+
<TextView
17+
android:id="@+id/dialog_name_id"
18+
android:layout_width="wrap_content"
19+
android:layout_height="wrap_content"
20+
android:gravity="center|top"
21+
android:text="Character Name"
22+
android:textColor="@color/white"
23+
android:textSize="24sp"
24+
android:textStyle="bold" />
25+
26+
<ImageView
27+
android:id="@+id/dialog_imageview_id"
28+
android:layout_width="120dp"
29+
android:layout_height="120dp"
30+
android:padding="10dp" />
31+
32+
33+
</LinearLayout>
34+
35+
</RelativeLayout>

0 commit comments

Comments
 (0)