Android uygulamamızda arama sayfamızı tasarlayacağız. Arama bölümü 2 kısımdan oluşacak. 1.bölümde daha doğrusu sayfada arama kriterlerini alacağız. Bunları 2. sayfaya gönderip Firebase’den gelen verileri bu kriterler ile filtreleyeceğiz. Her iki sayfada fragmentlardan oluşacak.
İlk önce arama sayfasının layout dosyasını açıyoruz. 3 tane edittext kısmımız olacak. Bu bölümlerden film ismi, yönetmen ismi veya oyuncu isimleri alacağız. Chip’ler sayesinde aranacak filmin konusunu seçtirebileceğiz. En son da FAB sayesinde arama sonucu sayfasına yönlendireceğiz. Chip bölümündeki checkable ile Chip’in seçilip seçilemediğini belirtiyoruz. CheckedIcon ile seçildiği zaman hangi ikonun gösterileceğini belirtiyoruz. 3 farklı relativelayout kullanmamızın sebebi Chip’lerin daha derli toplu görünmesi içindir. Bunlar dışında daha önce bahsettiklerimden farklı bir şey yok.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.core.widget.NestedScrollView
android:focusable="true"
android:focusableInTouchMode="true"
android:clickable="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="100dp">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/InputLayout1"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true"
android:layout_height="wrap_content"
app:boxCornerRadiusBottomEnd="30dp"
app:boxCornerRadiusBottomStart="30dp"
app:boxCornerRadiusTopEnd="30dp"
app:boxCornerRadiusTopStart="30dp"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
app:errorEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/searchedit1"
android:ems="10"
android:inputType="text"
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/aramafilmadi"/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_below="@id/InputLayout1"
android:id="@+id/InputLayout2"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true"
android:layout_height="wrap_content"
app:boxCornerRadiusBottomEnd="30dp"
app:boxCornerRadiusBottomStart="30dp"
app:boxCornerRadiusTopEnd="30dp"
app:boxCornerRadiusTopStart="30dp"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
app:errorEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/searchedit2"
android:ems="10"
android:inputType="text"
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/aramayonetmen"/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_below="@id/InputLayout2"
android:id="@+id/InputLayout3"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true"
android:layout_height="wrap_content"
app:boxCornerRadiusBottomEnd="30dp"
app:boxCornerRadiusBottomStart="30dp"
app:boxCornerRadiusTopEnd="30dp"
app:boxCornerRadiusTopStart="30dp"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
app:errorEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/searchedit3"
android:ems="10"
android:inputType="text"
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/aramaoyuncu"/>
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/addtur"
android:textSize="18sp"
android:layout_below="@id/InputLayout3"
android:layout_marginTop="34dp"
android:id="@+id/searchtur"
android:layout_centerHorizontal="true" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tur1"
android:layout_below="@id/searchtur"
android:layout_marginTop="15dp"
android:layout_centerHorizontal="true">
<com.google.android.material.chip.Chip
app:checkedIcon="@drawable/ic_check"
android:checkable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/turaction"
android:textSize="18sp"
android:id="@+id/searchturaction"/>
<com.google.android.material.chip.Chip
android:layout_width="wrap_content"
android:layout_toEndOf="@id/searchturaction"
android:layout_marginStart="10dp"
android:layout_height="wrap_content"
android:text="@string/turadventure"
android:textSize="18sp"
app:checkedIcon="@drawable/ic_check"
android:checkable="true"
android:id="@+id/searchturadventure"/>
<com.google.android.material.chip.Chip
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_toEndOf="@id/searchturadventure"
android:text="@string/turscience"
app:checkedIcon="@drawable/ic_check"
android:checkable="true"
android:textSize="18sp"
android:id="@+id/searchturscience"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tur2"
android:layout_below="@id/tur1"
android:layout_marginTop="15dp"
android:layout_centerHorizontal="true">
<com.google.android.material.chip.Chip
app:checkedIcon="@drawable/ic_check"
android:checkable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:text="@string/turfantasy"
android:id="@+id/searchturfantasy"/>
<com.google.android.material.chip.Chip
app:checkedIcon="@drawable/ic_check"
android:checkable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:text="@string/turthriller"
android:id="@+id/searchturthriller"
android:layout_toEndOf="@id/searchturfantasy"
android:layout_marginStart="10dp"/>
<com.google.android.material.chip.Chip
app:checkedIcon="@drawable/ic_check"
android:checkable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/turdrama"
android:textSize="18sp"
android:id="@+id/searchturdrama"
android:layout_marginStart="10dp"
android:layout_toEndOf="@id/searchturthriller"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tur3"
android:layout_below="@id/tur2"
android:layout_marginTop="15dp"
android:layout_centerHorizontal="true">
<com.google.android.material.chip.Chip
app:checkedIcon="@drawable/ic_check"
android:checkable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/turcrime"
android:textSize="18sp"
android:id="@+id/searchturcrime"/>
<com.google.android.material.chip.Chip
app:checkedIcon="@drawable/ic_check"
android:checkable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/turmystery"
android:textSize="18sp"
android:id="@+id/searchturmystery"
android:layout_toEndOf="@id/searchturcrime"
android:layout_marginStart="10dp"/>
<com.google.android.material.chip.Chip
app:checkedIcon="@drawable/ic_check"
android:checkable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/turwestern"
android:textSize="18sp"
android:id="@+id/searchturwestern"
android:layout_toEndOf="@id/searchturmystery"
android:layout_marginStart="10dp"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tur3"
android:layout_marginTop="15dp"
android:layout_centerHorizontal="true">
<com.google.android.material.chip.Chip
app:checkedIcon="@drawable/ic_check"
android:checkable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/turwar"
android:textSize="18sp"
android:id="@+id/searchturwar"/>
<com.google.android.material.chip.Chip
app:checkedIcon="@drawable/ic_check"
android:checkable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/turcomedy"
android:layout_toEndOf="@id/searchturwar"
android:layout_marginStart="10dp"
android:textSize="18sp"
android:id="@+id/searchturcomedy"/>
<com.google.android.material.chip.Chip
app:checkedIcon="@drawable/ic_check"
android:checkable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/turhistory"
android:layout_toEndOf="@id/searchturcomedy"
android:layout_marginStart="10dp"
android:textSize="18sp"
android:id="@+id/searchturhistory"/>
</RelativeLayout>
</RelativeLayout>
</androidx.core.widget.NestedScrollView>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:src="@drawable/ic_search"
app:backgroundTint="@color/colorWhite"
app:fabSize="normal"
android:layout_gravity="bottom|end"
android:layout_margin="20dp"
android:layout_alignParentBottom="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/buttonsearch"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Tasarımdan sonra arama sayfasının java dosyasını açıyoruz. Gerekli nesneleri oluşturuyoruz. Edittext’lere key listener ekliyoruz. Böylelikle eğer kullanıcı enter tuşuna basarsa arama yapabiliyoruz. Arama kısmında edittext’ten girilen değerleri string tipinde değişken olarak alıyoruz. Chip’lerin string tipindeki değişkenlerini null yapıyoruz. Chip’lerin seçilip seçilmediğine bakıyoruz. Eğer seçili ise seçili Chip’in değişkenini dolduruyoruz. Eğer seçili değilse null olarak kalıyor. Fragment’dan fragment’ta değer gönderirken bundle kullanıyoruz. Bir bundle oluşturup içine değişkenleri koyuyoruz. Herhangi bir değerin girilip girilmediğine bakıyoruz. Eğer kullanıcı değer girmedi ise kullanıcıya uyarı çıkarıyoruz. Eğer değer girili ise arama sonucu sayfasına yönlendiriyoruz. Burada addtobackstack ile fragment’ın stack’e eklenmesini sağlıyoruz. Bu sayede kullanıcı geri tuşuna bastığı zaman uygulamadan çıkmak yerine arama sayfasına geri gelecektir. Arama kısmının java dosyasında işimiz burada bitiyor.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
public class SearchFragment extends Fragment {
private Chip action,adventure,crime,mystery,drama,thriller,science,fantasy,western,war,comedy,history;
private SearchResultFragment searchResultFragment;
private EditText film_adi,film_yonetmen,film_oyuncu;
private String actionS,adventureS,scienceS,fantasyS,thrillerS,dramaS,crimeS,mysteryS,westernS,warS,comedyS,historyS;
public SearchFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_search, container, false);
FloatingActionButton button = v.findViewById(R.id.buttonsearch);
searchResultFragment=new SearchResultFragment();
action=v.findViewById(R.id.searchturaction);
adventure=v.findViewById(R.id.searchturadventure);
science=v.findViewById(R.id.searchturscience);
fantasy=v.findViewById(R.id.searchturfantasy);
thriller=v.findViewById(R.id.searchturthriller);
drama=v.findViewById(R.id.searchturdrama);
crime=v.findViewById(R.id.searchturcrime);
mystery=v.findViewById(R.id.searchturmystery);
western=v.findViewById(R.id.searchturwestern);
war=v.findViewById(R.id.searchturwar);
comedy=v.findViewById(R.id.searchturcomedy);
history=v.findViewById(R.id.searchturhistory);
film_adi=v.findViewById(R.id.searchedit1);
film_yonetmen=v.findViewById(R.id.searchedit2);
film_oyuncu=v.findViewById(R.id.searchedit3);
film_adi.setOnKeyListener((v1, keyCode, event) -> {
if ((keyCode == KeyEvent.KEYCODE_ENTER)) {
Search();
return true;
}
return false;
});
film_oyuncu.setOnKeyListener((v12, keyCode, event) -> {
if ((keyCode == KeyEvent.KEYCODE_ENTER)) {
Search();
return true;
}
return false;
});
film_yonetmen.setOnKeyListener((v13, keyCode, event) -> {
if ((keyCode == KeyEvent.KEYCODE_ENTER)) {
Search();
return true;
}
return false;
});
button.setOnClickListener(v14 -> Search());
return v;
}
private void Doldurma(){
if(action.isChecked()){
actionS=getResources().getString(R.string.turaction);
}
if(adventure.isChecked()){
adventureS= getResources().getString(R.string.turadventure);
}
if(science.isChecked()){
scienceS= getResources().getString(R.string.turscience);
}
if(fantasy.isChecked()){
fantasyS = getResources().getString(R.string.turfantasy);
}
if(thriller.isChecked()){
thrillerS= getResources().getString(R.string.turthriller);
}
if(drama.isChecked()){
dramaS= getResources().getString(R.string.turdrama);
}
if(crime.isChecked()){
crimeS= getResources().getString(R.string.turcrime);
}
if(mystery.isChecked()){
mysteryS= getResources().getString(R.string.turmystery);
}
if(western.isChecked()){
westernS=getResources().getString(R.string.turwestern);
}
if(war.isChecked()){
warS=getResources().getString(R.string.turwar);
}
if(comedy.isChecked()){
comedyS=getResources().getString(R.string.turcomedy);
}
if(history.isChecked()){
historyS=getResources().getString(R.string.turhistory);
}
}
private void Search(){
String filmadi = film_adi.getText().toString();
String yonetmen = film_yonetmen.getText().toString();
String oyuncu = film_oyuncu.getText().toString();
actionS = null ;
adventureS=null;
scienceS=null;
fantasyS=null;
thrillerS=null;
dramaS=null;
crimeS=null;
mysteryS=null;
westernS=null;
warS=null;
comedyS=null;
historyS=null;
Bundle bundle = new Bundle();
bundle.putString("adi",filmadi);
bundle.putString("yonetmen",yonetmen);
bundle.putString("oyuncu",oyuncu);
Doldurma();
bundle.putString("action",actionS);
bundle.putString("adventure",adventureS);
bundle.putString("science",scienceS);
bundle.putString("fantasy",fantasyS);
bundle.putString("thriller",thrillerS);
bundle.putString("drama",dramaS);
bundle.putString("crime",crimeS);
bundle.putString("mystery",mysteryS);
bundle.putString("western",westernS);
bundle.putString("war",warS);
bundle.putString("comedy",comedyS);
bundle.putString("history",historyS);
searchResultFragment.setArguments(bundle);
if(!TextUtils.isEmpty(filmadi) || !TextUtils.isEmpty(yonetmen) || !TextUtils.isEmpty(oyuncu) || action.isChecked() || adventure.isChecked() || science.isChecked() || fantasy.isChecked()
|| thriller.isChecked() || drama.isChecked() || crime.isChecked() || mystery.isChecked() || western.isChecked()
|| war.isChecked() || comedy.isChecked() || history.isChecked()){
Objects.requireNonNull(getActivity()).getSupportFragmentManager().beginTransaction()
.replace(R.id.main_frame,searchResultFragment,"Result")
.addToBackStack(null).commit();
}
else{
Snackbar.make(Objects.requireNonNull(getView()),getResources().getString(R.string.degergir),Snackbar.LENGTH_LONG).show();
}
}
}
Arama sonucunu göstermek için SearchResultFragment adında bir fragment ve fragmen_searchresult isminde bir layout dosyası oluşturuyoruz. İlk önce layout dosyasını açıyoruz.
Burada herhangi bir sonuç çıkmassa diye bir tane imageview bir tane de text view bulunuyor. Imageview’da arama ikonu textview’da sonuç yok yazısı yazacak. Görünürlük olarak gone seçiyoruz. Gone ile o öge hiç orada yokmuş gibi davranılıyor. Invisible ile o öge orada oluyor ama görünmez oluyor. Sonuçların listeleneceği recyclerview ekleyip tasarımı bitiriyoruz.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="150dp"
android:layout_height="150dp"
android:id="@+id/sonucyok_resim"
android:layout_centerInParent="true"
android:visibility="gone"
android:src="@drawable/ic_search"/>
<TextView
android:layout_width="wrap_content"
android:visibility="gone"
android:layout_height="wrap_content"
android:text="@string/sonucyok"
android:id="@+id/sonucyok_yazi"
android:layout_below="@id/sonucyok_resim"
android:layout_centerHorizontal="true"
android:textSize="20sp"
android:textColor="@color/colorBlack"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/firebaselist"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Arama sonuçlarının gösterileceği sayfanın java dosyasını açıyoruz. Gerekli nesneleri oluşturuyoruz. Gelen değerleri alıp ilgili değişkenlere yüklüyoruz. Eğer Chip’ler boş ise onların değişkenlerini null yapmak yerine boş olacak şekilde ayarlıyoruz. Firebase için referans oluşturuyoruz. Listemizi, adapter’ımızı ve recyclerview’ımızı ayarlıyoruz. Derğişkenlerle beraber verilerin çekileceği methoda gidiyoruz. Burada gelen veriyi ile değişkenleri karşılaştırıyoruz. Eğer aradığımız veri ise listeye ekliyoruz. Eğer değilse hiçbir işlem yapmadan diğer veriye geçiyoruz. En son eğer listemiz boş ise sonuç yok ikon ve yazısını görünür hale getirip işlemleri bitiriyoruz.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
public class SearchResultFragment extends Fragment {
private String adi,yonetmen,oyuncu,action,adventure,science,fantasy,thriller,drama,crime,mystery,western,war,comedy,history,firebase_oyuncu,firebase_turler;
private List<Movies> result;
private FirebaseAdapter adapter;
private ImageView sonucyok_resim;
private TextView sonucyok_text;
private Bundle bundle;
private DatabaseReference reference;
public SearchResultFragment() {
// Required empty public constructor
}
private void getData(){
adi = bundle.getString("adi");
yonetmen = bundle.getString("yonetmen");
oyuncu = bundle.getString("oyuncu");
action=bundle.getString("action");
adventure=bundle.getString("adventure");
science=bundle.getString("science");
fantasy=bundle.getString("fantasy");
thriller=bundle.getString("thriller");
drama=bundle.getString("drama");
crime=bundle.getString("crime");
mystery=bundle.getString("mystery");
western=bundle.getString("western");
war=bundle.getString("war");
comedy=bundle.getString("comedy");
history=bundle.getString("history");
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_search, container, false);
sonucyok_text=v.findViewById(R.id.sonucyok_yazi);
sonucyok_resim=v.findViewById(R.id.sonucyok_resim);
bundle=getArguments();
getData();
if(TextUtils.isEmpty(adi)){
adi="";
}
if(TextUtils.isEmpty(yonetmen)){
yonetmen="";
}
if(TextUtils.isEmpty(oyuncu)){
oyuncu = "";
}
if(TextUtils.isEmpty(action)){
action = "";
}
if(TextUtils.isEmpty(adventure)){
adventure = "";
}
if(TextUtils.isEmpty(science)){
science = "";
}
if(TextUtils.isEmpty(fantasy)){
fantasy = "";
}
if(TextUtils.isEmpty(thriller)){
thriller = "";
}
if(TextUtils.isEmpty(drama)){
drama = "";
}
if(TextUtils.isEmpty(crime)){
crime = "";
}
if(TextUtils.isEmpty(mystery)){
mystery = "";
}
if(TextUtils.isEmpty(western)){
western="";
}
if(TextUtils.isEmpty(war)){
war="";
}
if(TextUtils.isEmpty(comedy)){
comedy="";
}
if(TextUtils.isEmpty(history)){
history="";
}
FirebaseDatabase database = FirebaseDatabase.getInstance();
reference= database.getReference("Filmler");
result =new ArrayList<>();
RecyclerView recyclerView = v.findViewById(R.id.firebaselist);
recyclerView.setHasFixedSize(true);
RecyclerView.LayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(linearLayoutManager);
adapter =new FirebaseAdapter(result,getContext());
recyclerView.setAdapter(adapter);
updateList(adi,yonetmen,oyuncu,action,adventure,science,fantasy,thriller,drama,crime,mystery,western,war,comedy,history);
return v;
}
private void updateList(final String filmadi,final String yonetmen,final String oyuncu,final String action,final String adventure,final String science,
final String fantasy,final String thriller,final String drama,final String crime,final String mystery,final String western,
final String war,final String comedy,final String history){
reference.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(@NonNull DataSnapshot dataSnapshot, String s) {
firebase_oyuncu= Objects.requireNonNull(dataSnapshot.getValue(Movies.class)).getFilm_oyuncular().toLowerCase().replace(",","");
if(Objects.equals(Locale.getDefault().getDisplayLanguage(),"English")){
firebase_turler = Objects.requireNonNull(dataSnapshot.getValue(Movies.class)).getFilm_tur_eng().replace(",","");
}
else{
firebase_turler=Objects.requireNonNull(dataSnapshot.getValue(Movies.class)).getFilm_tur().replace(",","");
}
if(Objects.requireNonNull(dataSnapshot.getValue(Movies.class)).getFilm_ismi().toLowerCase().contains(filmadi.toLowerCase())
&& Objects.requireNonNull(dataSnapshot.getValue(Movies.class)).getFilm_yonetmen().toLowerCase().contains(yonetmen.toLowerCase())
&& firebase_oyuncu.contains(oyuncu.toLowerCase())
&& firebase_turler.contains(action)
&& firebase_turler.contains(adventure)
&& firebase_turler.contains(science)
&& firebase_turler.contains(fantasy)
&& firebase_turler.contains(thriller)
&& firebase_turler.contains(drama)
&& firebase_turler.contains(crime)
&& firebase_turler.contains(mystery)
&& firebase_turler.contains(western)
&& firebase_turler.contains(war)
&& firebase_turler.contains(comedy)
&& firebase_turler.contains(history)){
result.add(dataSnapshot.getValue(Movies.class));
sonucyok_resim.setVisibility(View.GONE);
sonucyok_text.setVisibility(View.GONE);
}
else if(result.isEmpty()) {
sonucyok_text.setVisibility(View.VISIBLE);
sonucyok_resim.setVisibility(View.VISIBLE);
}
adapter.notifyDataSetChanged();
}
@Override
public void onChildChanged(@NonNull DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(@NonNull DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(@NonNull DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
@Override
public void onResume() {
super.onResume();
adapter.notifyItemChanged(adapter.getSira());
}
}
Telefonumuzu bilgisayara bağlayıp kodumuzu test ediyoruz.