@@ -50,12 +50,67 @@ protected void onCreate(Bundle savedInstanceState) {
50
50
myadapter =new MyCustomAdapter (listnewsData );
51
51
ListView lsNews =(ListView )findViewById (R .id .listView );
52
52
lsNews .setAdapter (myadapter );//intisal with data
53
- Refesh ();
53
+ // Refesh();
54
54
}
55
55
56
56
void Refesh (){
57
57
listnewsData .clear ();
58
-
58
+ databaseReference .child ("Users" ).child (GlobalInfo .PhoneNumber ).
59
+ child ("Finders" ).addValueEventListener (new ValueEventListener () {
60
+ @ Override
61
+ public void onDataChange (DataSnapshot dataSnapshot ) {
62
+
63
+ Map <String , Object > td = (HashMap <String , Object >) dataSnapshot .getValue ();
64
+
65
+ listnewsData .clear ();
66
+ if (td == null ) //no one allow you to find him
67
+ {
68
+ listnewsData .add (new AdapterItems ("NoTicket" , "no_desc" ));
69
+ myadapter .notifyDataSetChanged ();
70
+ return ;
71
+ }
72
+ // List<Object> values = td.values();
73
+
74
+
75
+ // get all contact to list
76
+ ArrayList <AdapterItems > list_contact = new ArrayList <AdapterItems >();
77
+ Cursor cursor = getContentResolver ().query (ContactsContract .CommonDataKinds .Phone .CONTENT_URI , null , null , null , null );
78
+ while (cursor .moveToNext ()) {
79
+ String name = cursor .getString (cursor .getColumnIndex (ContactsContract .CommonDataKinds .Phone .DISPLAY_NAME ));
80
+
81
+ String phoneNumber = cursor .getString (cursor .getColumnIndex (ContactsContract .CommonDataKinds .Phone .NUMBER ));
82
+ list_contact .add (new AdapterItems ( name ,GlobalInfo .FormatPhoneNumber (phoneNumber )
83
+ ));
84
+
85
+
86
+ }
87
+
88
+
89
+ // if the name is save chane his text
90
+ // case who find me
91
+ String tinfo ;
92
+ for ( String Numbers : td .keySet ()) {
93
+ for (AdapterItems cs : list_contact ) {
94
+
95
+ //IsFound = SettingSaved.WhoIFindIN.get(cs.Detals); // for case who i could find list
96
+ if (cs .PhoneNumber .length () > 0 )
97
+ if (Numbers .contains (cs .PhoneNumber )) {
98
+ listnewsData .add (new AdapterItems (cs .UserName , cs .PhoneNumber ));
99
+ break ;
100
+ }
101
+
102
+ }
103
+
104
+ }
105
+ myadapter .notifyDataSetChanged ();
106
+ }
107
+
108
+ @ Override
109
+ public void onCancelled (DatabaseError error ) {
110
+ // Failed to read value
111
+ // Log.w(TAG, "Failed to read value.", error.toException());
112
+ }
113
+ });
59
114
60
115
61
116
@@ -165,19 +220,25 @@ public long getItemId(int position) {
165
220
}
166
221
167
222
@ Override
168
- public View getView (int position , View convertView , ViewGroup parent )
169
- {
223
+ public View getView (int position , View convertView , ViewGroup parent ) {
170
224
LayoutInflater mInflater = getLayoutInflater ();
171
- View myView = mInflater .inflate (R .layout .single_row_conact , null );
172
225
173
- final AdapterItems s = listnewsDataAdpater .get (position );
226
+ final AdapterItems s = listnewsDataAdpater .get (position );
227
+ if (s .UserName .equals ("NoTicket" )) {
228
+ View myView = mInflater .inflate (R .layout .news_ticket_no_news , null );
229
+
230
+ return myView ;
174
231
175
- TextView tv_user_name =( TextView )myView .findViewById (R .id .tv_user_name );
176
- tv_user_name .setText (s .UserName );
177
- TextView tv_phone =( TextView )myView .findViewById (R .id .tv_phone );
178
- tv_phone .setText (s .PhoneNumber );
232
+ } else {
233
+ View myView = mInflater .inflate (R .layout .single_row_conact , null );
179
234
180
- return myView ;
235
+ TextView tv_user_name = (TextView ) myView .findViewById (R .id .tv_user_name );
236
+ tv_user_name .setText (s .UserName );
237
+ TextView tv_phone = (TextView ) myView .findViewById (R .id .tv_phone );
238
+ tv_phone .setText (s .PhoneNumber );
239
+
240
+ return myView ;
241
+ }
181
242
}
182
243
183
244
}
0 commit comments