Android Firebase gets updated, child layout gets called too weird issue

夙愿已清 提交于 2020-05-28 08:23:27

问题


Overview: Using child layout within my MainActivity (to accept and update values into firebase database)

Whenever firebase gets updated, my child layout gets called too (which I am usually launching on tap of button to accept and update data into firebase database)

I've cross-checked, if I don't call updateData() then firebase never gets hit and everything works so smoothly (I mean never launch my child layout unnecessarily)

So, my concern is, how can I control on a launch of child layout, which gets launched whenever firebase gets updated

Calling acceptData() method to accept data from user

    buttonAcceptUpdate.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            acceptData();

        }
    });

Here is the code, I'm using inside acceptData()

private void acceptData() {

    View view = getLayoutInflater().inflate(R.layout.layout_data, null);
    acceptDialog = new Dialog(MainActivity.this);
    acceptDialog.show();
    ......
    btnSaveData = view.findViewById(R.id.buttonSave);

    btnSaveData.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            acceptDialog.dismiss();

            updateData(); // if not calling this method then acceptData layout not getting called

        }
    });

}

Calling updateData() method to update data into Firebase

private void updateData() {

    Map updateHashMap = new HashMap<>();
    updateHashMap.put("address_1", add1);
    updateHashMap.put("address_2", add2);

    mUsersRef.updateChildren(updateHashMap);

}

来源:https://stackoverflow.com/questions/62037592/android-firebase-gets-updated-child-layout-gets-called-too-weird-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!