|
1 | 1 | package com.example.teamtrackingapptest2;
|
2 | 2 |
|
3 | 3 | import android.content.Context;
|
| 4 | +import android.os.Build; |
| 5 | +import android.os.VibrationEffect; |
| 6 | +import android.os.Vibrator; |
4 | 7 | import android.view.LayoutInflater;
|
5 | 8 | import android.view.View;
|
6 | 9 | import android.view.ViewGroup;
|
|
17 | 20 |
|
18 | 21 | public class Adapter_name extends RecyclerView.Adapter<Adapter_name.ViewHolder> implements Filterable {
|
19 | 22 | private Context context;
|
| 23 | + Vibrator vibrator; |
20 | 24 | private ArrayList<Student> students;
|
21 | 25 | private ArrayList<Student> studentsfull;
|
22 | 26 | public String studentName;
|
23 | 27 | public TextView textView;
|
24 | 28 | public SearchView searchView;
|
25 | 29 |
|
26 |
| - public Adapter_name(Context context, ArrayList<Student> students, TextView textView, SearchView searchView) { |
| 30 | + public Adapter_name(Context context, ArrayList<Student> students, TextView textView, SearchView searchView, Vibrator vibrator) { |
27 | 31 | this.context = context;
|
28 | 32 | this.students = students;
|
| 33 | + this.vibrator=vibrator; |
29 | 34 | this.searchView=searchView;
|
30 | 35 | studentsfull=new ArrayList<>(students);
|
31 | 36 | studentName="";
|
@@ -53,6 +58,14 @@ public void onClick(View v) {
|
53 | 58 | searchView.setQuery(studentName,false);
|
54 | 59 | searchView.clearFocus();
|
55 | 60 | textView.setText(studentName);
|
| 61 | + if(Build.VERSION.SDK_INT>=26) |
| 62 | + { |
| 63 | + vibrator.vibrate(VibrationEffect.createOneShot(50,30)); |
| 64 | + } |
| 65 | + else |
| 66 | + { |
| 67 | + vibrator.vibrate(50); |
| 68 | + } |
56 | 69 |
|
57 | 70 | }
|
58 | 71 | });
|
|
0 commit comments