android - Crash getting many data from firebase -


i'm populating recyclerview (not firebaserecyclerview) data coming firebasedatabase. data receive many, users, , can reach many thousands. when receive data app lagges , crashes. know there many data , it's hard work. there way optimize all?

i have errore in logcat

the application may doing work on main thread 

i'm not impressed, ask for possible solutions! thank you

 recyclerview = (recyclerview) findviewbyid(r.id.friend_list2);     //recyclerview.setlayoutmanager(new linearlayoutmanager(getapplicationcontext()));     recyclerview.setlayoutmanager(new gridlayoutmanager(this, 2));      final databasereference mpostreference = firebasedatabase.getinstance().getreference().child("user-profile");     mpostreference.addlistenerforsinglevalueevent(new valueeventlistener() {         @override         public void ondatachange(datasnapshot datasnapshot) {                username = new arraylist<>();             uid = new arraylist<string>();             url = new arraylist<string>();              (datasnapshot data : datasnapshot.getchildren()){                 final frienditem frienditem = data.getvalue(frienditem.class);                 //final string frienditem2 = data.getkey();                    username.add(frienditem);                 //uid.add(frienditem2);                  adapter = new friendholdadapter3(getapplicationcontext(), username, uid, url);                 //adapter.setclicklistener(friendactivity3.this);                 recyclerview.setadapter(adapter);                  /**                 adapter = new friendholdadapter2(friendactivity2.this, username, uid);                 adapter.setclicklistener(friendactivity2.this);                 recyclerview.setadapter(adapter);                  **/                 final list<frienditem> filteredmodellist = filter(username, "        ");                 adapter.setfilter(filteredmodellist);               }         }          @override         public void oncancelled(databaseerror databaseerror) {         }}); 

firebase design network call async, happens inside ondatachange call in on main thread, shift work worker thread asynctask.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -