title: Firebase ChildEventListener onChildChanged triggered twice
body: <p>I'm using firebase to create To-Do android application. I'm use recyclerview and cardview to populate data fro firebase. But some weird things happen when i watch on Android Monitor and see my debug log fires twice <code>onChildChanged</code>:</p>
  
  <pre><code>D/DiaryAdapter: onChildChanged:-KIafq035E-pc6uT3Ej7
  D/DiaryAdapter: onChildChanged:-KIafq035E-pc6uT3Ej7
  </code></pre>
  
  <p>and caused item on recyclerview blink twice (blink efect on item when it's updated)</p>
  
  <p>i put this on MainFragment.java <code>onStart()</code></p>
  
  <pre><code>        // Setup adapter
          diaryAdapter = new DiaryAdapter(getContext(),mDiaryRef);
  
          recyclerDiary.setAdapter(diaryAdapter);
  </code></pre>
  
  <p>On my adapter constructor</p>
  
  <pre><code>public DiaryAdapter(final Context context, DatabaseReference ref) {
   mContex = context;
   mDatabaseRefrence = ref;
  
  
   mChildEventListener = new ChildEventListener() {
    @Override
    public void onChildAdded(DataSnapshot dataSnapshot, String s) {
     //Log.d(TAG, "onChildAdded:" + dataSnapshot.getKey());
  
     Diary diary = dataSnapshot.getValue(Diary.class);
     mDiary.add(diary);
     mDiaryID.add(dataSnapshot.getKey());
     notifyItemInserted(mDiary.size() - 1);
  
    }
  
    @Override
    public void onChildChanged(DataSnapshot dataSnapshot, String s) {
     Log.d(TAG, "onChildChanged:" + dataSnapshot.getKey());
  
     Diary newDiary = dataSnapshot.getValue(Diary.class);
  
     int diaryIndex = mDiaryID.indexOf(dataSnapshot.getKey());
  
     if (diaryIndex &gt; -1) {
      mDiary.set(diaryIndex, newDiary);
      notifyItemChanged(diaryIndex);
     } else {
      Log.w(TAG, "onChildChanged:unknown_child:" + dataSnapshot.getKey());
     }
    }
  
    @Override
    public void onChildRemoved(DataSnapshot dataSnapshot) {
     Log.d(TAG, "onChildRemoved:" + dataSnapshot.getKey());
  
     int diaryIndex = mDiaryID.indexOf(dataSnapshot.getKey());
  
     if (diaryIndex &gt; -1) {
      mDiary.remove(diaryIndex);
      mDiaryID.remove(diaryIndex);
  
      notifyItemRemoved(diaryIndex);
     } else {
      Log.w(TAG, "onChildRemoved:unknown_child:" + dataSnapshot.getKey());
     }
    }
  
    @Override
    public void onChildMoved(DataSnapshot dataSnapshot, String s) {
     Log.d(TAG, "onChildMoved:" + dataSnapshot.getKey());
    }
  
    @Override
    public void onCancelled(DatabaseError databaseError) {
     Log.w(TAG, "postComments:onCancelled", databaseError.toException());
     Toast.makeText(mContex, "Failed to load diary.",
      Toast.LENGTH_SHORT).show();
    }
   };
  
   ref.addChildEventListener(mChildEventListener);
  }
  </code></pre>
  
  <p>I'm following from firebase android sample <a href="https://github.com/firebase/quickstart-android/tree/master/database" rel="nofollow noreferrer">here</a></p>
  
  <p>Edit: Database structure</p>
  
  <pre><code>{
    "diary" : {
      "2Y4XwraNoRdIFPBJY0XxwdPte0H2" : {
        "1437" : {
          "-KIahAPVU_WrmP5rDcAa" : {
            "created" : 1464159484316,
            "infaq" : {
              "selesai" : false
            },
            "ngaji" : {
              "ayatAkhir" : 0,
              "ayatMulai" : 0,
              "selesai" : true,
              "surahAkhir" : 0,
              "surahMulai" : 0
            },
            "puasa" : {
              "sahur" : false,
              "selesai" : true,
              "summary" : ""
            },
            "sholat" : {
              "ashar" : true,
              "dhuhur" : true,
              "done" : true,
              "mIsya" : true,
              "maghrib" : true,
              "subuh" : true
            },
            "summary" : "Puasa kedua Tos",
            "tanggal" : 2,
            "tarawih" : {
              "ringkasan" : "",
              "selesai" : true
            },
            "updated" : 1464186194796
           },
          }
      }
  }
  </code></pre>