Refresh recyclerview from another fragment, in the same viewpager

0

I have a viewpager that contains 3 fragments, one for transacted transactions, one for canceled transactions and one for open transactions. Each fragment has a recyclerview for displaying the transactions and also, each fragment has a swiperefreshlayout so that the user you can get the latest information from the server. My question is this: How do I update the list of fragment 1 and also the list of fragment 2 and 3 if necessary?

Ex: When updating the open transaction fragment, and verifying that the arrayList has elements less, logically the transaction that was open was for the canceled transaction fragment or made. Assuming there was such a change in the arrayList, I would like to also update fragment 2 and 3 if necessary.

PS: both are in the same viewpager, already tried via interface and could not.

    
asked by anonymous 02.02.2018 / 17:54

1 answer

0

Try to do so, let's assume it is in the open transaction fragment and will update the transaction fragment performed. In the committed transaction fragment you make an update methodAdapter

    private void updateFragment() {

    SeuFragmentTransacaoRealizada fragment =
            (SeuFragmentTransacaoRealizada) getChildFragmentManager().findFragmentByTag("android:switcher:" + R.id.pager + ":" + posicaoTab);

    if (fragment != null) {

        if (fragment.getView() != null) {

            fragment.atualizarAdapter();
        }
    }
}
    
02.02.2018 / 18:40