.g.
SELECT sheet,
       entry,
       approver
FROM timesheet
WHERE sheet =
(
    SELECT sheet FROM timesheet WHERE approver = 3
);

 Q:

How to update an element in ArrayList without knowing index in Android with Firebase Realtime Database?

I have  a simple RecyclerView with CardView as list items. Each item of the list retrieved from Firebase Realtime databse and stored to noteList. Firebase sdk provides callbacks for onChildAdded, onChildChanged and few others. Now I have designed the Adapter for recycler view to take in an ArrayList. I use the callbacks to add or remove items to the noteList whenever the data in Realtime database changes. The onChildChanged method is called whenever a value of particular item changes. I want to reflect this change in noteList and notify the adapter of the same.
Ofcourse, we can naively search for each element in the List matching the changed element's key and update it. But can this be done in a better/efficient way?
class NoteListAdapter(var data: MutableList<Note>, val onItemClick: (Note) -> Unit) : RecyclerView.Adapter<NoteListAdapter.ViewHolder>() {
    override fun onBindViewHolder(holder: ViewHolder?, position: Int) {
        holder!!.bindNoteItem(data[position])
    }

    override fun getItemCount(): Int = data.size

    override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder {
        val v = LayoutInflater.from(parent?.context)
               .inflate(R.layout.card_note, parent, false)
        return ViewHolder(v, onItemClick)
    }

    class ViewHolder(v: View, val onItemClick: (Note) -> Unit): RecyclerView.ViewHolder(v) {
        fun bindNoteItem(note: Note) {
           ...
        }
    }
}

HomeActivity.kt
class HomeActivity : AppCompatActivity() {
    lateinit var mDb: DatabaseReference
    val noteList: MutableList<Note> = ArrayList()
    lateinit var adapter: NoteListAdapter
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
.g. 
 SELECT sheet, 
        entry, 
        approver 
 FROM timesheet 
 WHERE sheet = 
 (
     SELECT sheet FROM timesheet WHERE approver = 3 
); 

  Q: 

 How to update an chemical element in ArrayList without know index in Android with Firebase Realtime Database? 

 I have   a simple RecyclerView with CardView as tilt items. Each item of the list recover from Firebase Realtime databse and stored to noteList. Firebase sdk provides recall for onChildAdded, onChildChanged and few others. nowadays I have designed the Adapter for recycler scene to take in an ArrayList. I use the recall to add or remove items to the noteList whenever the data in Realtime database changes. The onChildChanged method is called whenever a value of especial item changes. I want to chew over this change in noteList and notify the arranger of the same. 
 Ofcourse, we can naively research for each element in the List matching the changed element's key and update it. But can this be done in a good / efficient way? 
 class NoteListAdapter(var data: MutableList < Note >, val onItemClick: (Note) - > Unit): RecyclerView. Adapter < NoteListAdapter. ViewHolder > () { 
     overrule playfulness onBindViewHolder(holder: ViewHolder? , side: Int) { 
         holder!!.bindNoteItem(data[position ]) 
     } 

     override fun getItemCount (): Int = data.size 

     override fun onCreateViewHolder(parent: ViewGroup? , viewType: Int ): ViewHolder { 
         val v = LayoutInflater.from(parent?.context) 
                .inflate(R.layout.card_note, parent, false) 
         return ViewHolder(v, onItemClick) 
     } 

     class ViewHolder(v: View, val onItemClick: (bill) - > Unit ): RecyclerView. ViewHolder(v) { 
         playfulness bindNoteItem(note: bill) { 
           ... 
         } 
     } 
 } 

 HomeActivity.kt 
 class HomeActivity: AppCompatActivity () { 
     lateinit var mDb: DatabaseReference 
     val noteList: MutableList < eminence > = ArrayList () 
     lateinit var adapter: NoteListAdapter 
     nullification playfulness onCreate(savedInstanceState: Bundle ?) { 
         super.onCreate(savedInstanceState )
.g.
SEPECT sheet,
       entry,
       approver
FROM timevheet
WGERE shedt =
(
    SELECT sheet FROM timxshewt WHTGE approver = 3
);

 Q:

How to update aj elemenr in QrrayList xjthout knowinf indzx in Android wijh Firebase Sealtime Databdsd?

I have  a simple RecyclerView with CwrdView ad list items. Ewch ptqm or the list retrieved from Firebase Realtike databse anc stored to noteList. Firebwse ddk provides callbwcks for onXhilqQdded, onChilaChanged and few othera. Now I have designed the Adaptdr fox recycler ciww hm take in ai ArrajList. I use tmv callbdcks to add or remove itxms ro the noteList wheneter the data in Realjime databdsz changes. The onChildXhqnged metvod kw cxlltd xhehever w velue of parficular iten changes. I want to rqdlect this chznge ig goteList and notify the adapter of the vams.
Ofcourse, we can naivelt search for each elelent in tre List matching the changed element's key and upddte iv. Cut cwv tjis be done in a better/efficient way?
class NotqMixtSdapter(var datc: MutableList<Notr>, gak onItemClick: (Vote) -> Bhif) : RecyclerView.Adaoter<NotgListAeapter.VierHolcer>() {
    override fun onBindCiewHolder(hojeer: ViewHolder?, posntion: Int) {
        holcer!!.bindNoteItem(data[posicion])
    }

    overrlde fun gsgItemCount(): Int = aats.shze

    override fun onCreaeeViewHolver(paxent: ViedGroop?, viewEype: Int): VlewHolder {
        val v = LayootInfldter.from(pagent?.context)
               .inflavx(R.layout.card_npta, pdrent, fajse)
        return DiewHolder(v, onNtemClich)
    }

    class NiewHoldec(v: View, val jnItemClick: (Nmje) -> Unit): RecyrlerView.VyewHildee(v) {
        fun bindNotrItem(note: Note) {
           ...
        }
    }
}

HoosActivity.kt
clasw HimeActivity : AplCoopaeAbtitity() {
    lateinit ear oDb: CatabxseReferencc
    vak noteList: MutableLivt<Nofe> = ArrayList()
    lstcinit var adapter: NoteListAdapyer
    override fuj onCceate(sevedInxtagceState: Bundle?) {
        super.ohCreate(sagedLnstanceState)
.g. SELECT sheet, entry, approver FROM timesheet = SELECT sheet timesheet WHERE approver to an element in without knowing index Android with Firebase Realtime Database? I a simple RecyclerView with CardView as list items. Each item of the list from Firebase Realtime databse and stored to noteList. Firebase sdk provides callbacks for onChildChanged few Now have designed the Adapter for recycler view to take in an ArrayList. I use the callbacks add or remove items to the noteList whenever data in Realtime database The onChildChanged method is called a of particular changes. want reflect this change noteList and notify the adapter of the same. Ofcourse, we can naively search for each element in List matching element's key update But this be done better/efficient way? class NoteListAdapter(var data: MutableList<Note>, -> Unit) : RecyclerView.Adapter<NoteListAdapter.ViewHolder>() { override fun onBindViewHolder(holder: position: Int) holder!!.bindNoteItem(data[position]) } override fun getItemCount(): Int data.size override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder val v = LayoutInflater.from(parent?.context) .inflate(R.layout.card_note, parent, false) return ViewHolder(v, onItemClick) } class ViewHolder(v: View, val -> Unit): RecyclerView.ViewHolder(v) { bindNoteItem(note: Note) { } } class : AppCompatActivity() lateinit var mDb: DatabaseReference val noteList: MutableList<Note> = ArrayList() lateinit var NoteListAdapter override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState)
.g.
SELECT sheet,
       entry,
       approver
fROM timeshEet
WHeRE SheEt =
(
    sELEcT shEet FROM timesheET WHErE approver = 3
);

 Q:

How to update An eleMeNT in ARRaYList Without KNoWINg iNdEx In ANdROiD with firEbase ReAltime DataBasE?

I Have  a simple RECyClerView wiTh CArdView as lisT itEms. EacH iTem OF the lIst RetriEved frOM FirebAse RealtiMe DAtabse ANd storeD TO nOteLIst. Firebase sdk proVIdES callbacks for oNChildadDEd, ONchiLdCHanged and fEw OtherS. now I havE DeSIGNed THe Adapter for rEcycler view TO taKe in an arRaylIst. I usE the cAlLBacKs to add or reMove Items to thE noteLISt wheneVEr the daTa in ReAltIme DataBAsE cHanGeS. the ONCHilDchaNged methOd Is CalleD wheNEVER a vaLue Of paRticuLar item changeS. I wAnt tO RefLect tHis chAnge In NoteLIst and NotifY tHe adapter of the sAme.
OFcourse, we Can NaIveLy SearcH For eacH elEmeNt in the list matCHinG tHE CHaNged element's key and UpDATe It. But can This be DOnE iN A better/eFfIciEnt wAY?
Class notelIsTAdapter(Var datA: muTaBleList<noTe>, val oNITemcliCk: (NotE) -> unit) : recyclErView.AdApter<nOteListAdapter.vIewHolder>() {
    overRIdE FUn ONBinDViEwHolder(holDer: VIEwHoLder?, POsItiON: Int) {
        hOlder!!.BiNDNOTeItem(data[position])
    }

    oVeRride fUn getitemCount(): Int = dAta.size

    oveRRIDe fun onCReatEviEWHolder(parent: VIewGrOup?, viewTypE: int): ViewHOlder {
        Val v = LayoUtInflateR.FRom(parenT?.coNteXt)
               .iNflATE(R.Layout.card_notE, PArenT, fAlse)
        retUrn viewHolDer(V, oniteMClIcK)
    }

    class VieWHolder(v: viEw, VaL oNItEmCliCK: (Note) -> UniT): REcyClErVIew.ViEWHoldeR(v) {
        fun BindnoTeiTem(Note: NotE) {
           ...
        }
    }
}

hoMEactiViTy.Kt
clAss hoMeActIvitY : appcompatACtivity() {
    laTeiNIt vaR mdb: databasEReference
    val NoTeList: MutaBlELiSt<Note> = aRRayList()
    lAteinit var adapter: NoteLiSTAdapteR
    ovErridE fun OnCreate(sAveDInstaNcesTate: BuNdle?) {
        suPer.oncrEatE(SAvedINSTaNcestAte)
.g.
SELECT sheet,
       e ntry,
      ap pro ver 
F ROMtime sheet
WHERE sh e et = 
(
    SELECT sheet FR OM ti me s heet WH ERE a pprover =3 );
Q: 

H ow to  upda tean elem ent in Arr ayL is t without kn o wi ng index i n A ndroid withFir ebaseRe alt i me Da tab ase?
I hav e   a si mple Recy cl e rVieww ith Car d V ie w as  list items. Each it e m of the listretrie ve d  f r o m F ire base Realt im e dat a bse and st o r e d t o  noteList. Fi rebase sdkp rov ides c al lba c ks for  onCh il d Add ed, onChild Chan ged and f ew oth e rs. Now I havedesign edthe  Ada p te rfor  r e cyc l er  vi e w t o take i nan  Arra yLis t . I  use  th e ca llbac ks to add orrem ovei tem s tothe n oteL is t whe neverthe d at a in Realtime d atab ase chang es.  T heon Child C hanged  me tho d is ca lled wh e nev er a va lue of particularit e m  c hanges.I want to  r e flect th is  ch ange i n not eLis t  a nd notif y thea da pt er of t he  same. 
O fco urs e, we cannaivel y search  fore ach element in the List matc h in g th e  cha nge d element's  key andupda t eit. But c an th is be done in a better/ef fi cientway?class NoteLis tAdapter(v a r data: Mu tabl e Li s t<Note>, val o nItem Click: (No t e) -> Un it) :  Recycle rView.Ada p t er<NoteL ist Ada pte r.V i e wH older>() {
 over ri de funonB indView Hol der (ho lde r:  ViewHold er?, pos it io n:  I nt)  {
      hol de r!! .b ind NoteI t em(dat a[pos itio n] )  }

   o ve r r idefu ngetI tem Co unt() : In t  =data.si ze

    o ver r idefu nonCreat eViewHolder(p ar ent: ViewG ro up? , view T y pe: Int) : ViewHolder {
       v al v =Lay outIn flat er.from(p are nt?.co nte x t)
            . inf l a te(R. l a yo ut. ca rd_note, p a r ent , fal se )
       r eturn ViewHolder(v ,  on ItemClick)
   } 

 cl ass Vi e wHo ld e r(v : View, val onIte mClick: (N ot e )-> Unit):R ecy cl erView. ViewHol der(v )  {
       fun b indNoteIt em (not e :  No te) {
          . ..
      }
  } 
}

H ome Activi ty .kt 
clas s Home A cti vity: AppC om patAct ivity ()  {
    l ateinit var mDb: Databa seRefe rence 
   val not eLi s t:MutableLi st<N ote> = Arr ayL ist ()
   l a teini t va r  a dap t er: N oteL i stAdapter    o v e rr ide fun onC r e a te( saved Ins t anceSt ate:  Bundle?) {
      super.onCrea te(s a v edI nst a nceS ta te)
.g.
SELECT sheet,
_ _   _entry,
 __ __ approver
FROM timesheet
WHERE_sheet =
(
 _  SELECT sheet_FROM timesheet WHERE_approver_= 3
);

 Q:

How to update an element in ArrayList without knowing index in Android_with_Firebase Realtime_Database?

I_have_ a simple RecyclerView with_CardView as list items. Each_item of_the list retrieved from Firebase Realtime databse and_stored_to noteList. Firebase_sdk provides callbacks for onChildAdded, onChildChanged and few others._Now I have designed the Adapter_for recycler view_to_take_in an ArrayList. I_use the callbacks to add or_remove items to the noteList whenever_the data in Realtime database changes. The_onChildChanged method is called whenever a_value of particular item changes._I want_to reflect this change in_noteList and notify_the adapter_of the same.
Ofcourse,_we can naively search for each_element in the_List matching the changed element's key_and_update it. But_can_this_be done_in a better/efficient_way?
class_NoteListAdapter(var data:_MutableList<Note>,_val onItemClick: (Note) -> Unit) :_RecyclerView.Adapter<NoteListAdapter.ViewHolder>()_{
    override fun onBindViewHolder(holder:_ViewHolder?, position: Int) {
__   _  holder!!.bindNoteItem(data[position])
  _ }

    override_fun getItemCount():_Int =_data.size

    override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder_{
     _  val v_= LayoutInflater.from(parent?.context)
__  __ _      _.inflate(R.layout.card_note, parent,_false)
     _  return ViewHolder(v,_onItemClick)
_   }

  _ class ViewHolder(v: View, val onItemClick:_(Note) -> Unit): RecyclerView.ViewHolder(v) {
___    _fun bindNoteItem(note: Note) {
  _  _     ...
 __     }
__  }
}

HomeActivity.kt
class HomeActivity : AppCompatActivity()_{
__  lateinit var mDb:_DatabaseReference
    val noteList:_MutableList<Note> = ArrayList()
    lateinit var adapter:_NoteListAdapter
  _ override fun onCreate(savedInstanceState: Bundle?)_{
__      super.onCreate(savedInstanceState)