In AppCompatActivity, I use a RecyclerView to display a list of CardViews with information in them. When you click on the CardView, I am using a DialogFragment to display a TabLayout dialog where each tab is using a RecyclerView to diplay a list of CardViews. The question I have is, how can I pass the List item back to the AppCompatActivity to update the RecyclerView?



MainMenu.java (AppCompatActivity)
Code:
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_menu);

    recyclerView = (RecyclerView) findViewById(R.id.recycleId);
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));

    pointAdapter = new PointAdapter(this, childList);
    recyclerView.setAdapter(pointAdapter);
    pointAdapter.notifyDataSetChanged();

    pointAdapter.setmListener(new PointAdapter.OnItemClickListener() {
        @Override
        public void onItemClicked() {
            FragmentManager manager = ((AppCompatActivity)MainMenu.this).getFragmentManager();
            FragmentTransaction ft = manager.beginTransaction();
            Fragment prev = manager.findFragmentByTag("dialog");
            if(prev != null){
                ft.remove(prev);
            }
            ft.addToBackStack(null);

            TabDialog tabDialog = new TabDialog();
            tabDialog.show(ft, "dialog");
        }
    });
PointAdapter:
Code:
public class PointAdapter extends RecyclerView.Adapter<PointAdapter.ViewHolder> {

public interface OnItemClickListener{
    void onItemClicked();
}

private OnItemClickListener mListener;

private Context context;
private List<Child> childList;
public static final int ADD_POINT_REQUEST = 1;

public PointAdapter(Context context, List<Child> childList){
    this.context = context;
    this.childList = childList;
}

@Override
public PointAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_row, parent, false);
    return new ViewHolder(view, context);
}

@Override
public void onBindViewHolder(PointAdapter.ViewHolder holder, final int position) {

    holder.mainCardView.setOnClickListener(new View.OnClickListener() {
        @Override

            mListener.onItemClicked();
        }
    });

    Child child = childList.get(position);
    holder.cName.setText(child.getChildsName());
    holder.date.setText(child.getDate());
    holder.posPoints.setText("Positive Points: " + child.getPositivePoints());
    holder.negPoints.setText("Negative Points: " + child.getNegativePoints());
    holder.totalPoints.setText("Total: " + child.getPoints().size());
}

@Override
public int getItemCount() {
    return childList == null ? 0 : childList.size();
}

public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{

    public TextView cName;
    public TextView date;
    public TextView posPoints;
    public TextView negPoints;
    public TextView totalPoints;
    public CardView mainCardView;


    public ViewHolder(View itemView, Context ctx){
        super(itemView);

        cName = (TextView) itemView.findViewById(R.id.childsNameId);
        date = (TextView) itemView.findViewById(R.id.dateTextViewId);
        posPoints = (TextView) itemView.findViewById(R.id.positivePointsId);
        negPoints = (TextView) itemView.findViewById(R.id.negativePointsId);
        totalPoints = (TextView) itemView.findViewById(R.id.totalPointsId);
        mainCardView = (CardView) itemView.findViewById(R.id.mainCardView);

    }

    @Override
    public void onClick(View view) {

    }
}

public OnItemClickListener getmListener() {
    return mListener;
}

public void setmListener(OnItemClickListener mListener) {
    this.mListener = mListener;
}
TabDialog.java:
Code:
public class TabDialog extends DialogFragment {

TabLayout tabLayout;
ViewPager viewPager;

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
    getDialog().setCanceledOnTouchOutside(true);
    View rootView = inflater.inflate(R.layout.dialog_layout, container, false);
    tabLayout = (TabLayout) rootView.findViewById(R.id.tabLayout1);
    viewPager = (ViewPager) rootView.findViewById(R.id.masterViewPager);
    TabAdapter adapter = new TabAdapter(getChildFragmentManager());
    adapter.addFragment("Positive", FragmentTabContent.createInstance(populatePositiveList()));
    adapter.addFragment("Negative", FragmentTabContent.createInstance(populateNegativeList()));
    viewPager.setAdapter(adapter);
    tabLayout.setupWithViewPager(viewPager);

    return rootView;
}

// Methods to populate list
TabAdapter.java:
Code:
public class TabAdapter extends FragmentPagerAdapter {

List<Fragment> mFragmentCollection = new ArrayList<>();
List<String> mTitleCollection = new ArrayList<>();

public TabAdapter(FragmentManager fm){
    super(fm);
}

public void addFragment(String title, Fragment fragment){

    mTitleCollection.add(title);
    mFragmentCollection.add(fragment);
}

@Override
public CharSequence getPageTitle(int position){
    return mTitleCollection.get(position);
}

@Override
public int getCount(){
    return mFragmentCollection.size();
}

@Override
public Fragment getItem(int position) {
    return mFragmentCollection.get(position);
}
FragmentTabContent.java:
Code:
public class FragmentTabContent extends Fragment {

private List<Point> pointList = new ArrayList<>();

public static FragmentTabContent createInstance(List<Point> pointList){
    FragmentTabContent fragment = new FragmentTabContent();
    fragment.pointList = pointList;
    return fragment;
}

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.activity_fragment_tab_content, container, false);
    RecyclerView recyclerView = (RecyclerView) v.findViewById(R.id.dialogRecyclerViewId);
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(new LinearLayoutManager(v.getContext()));

    PopupAdapter adapter = new PopupAdapter(v.getContext(), pointList);
    recyclerView.setAdapter(adapter);



    return v;
}
PopupAdapter.java
Code:
public class PopupAdapter extends RecyclerView.Adapter<PopupAdapter.ViewHolder> {

public interface OnPointClickedListener{
    void OnItemClicked();
}

private OnPointClickedListener mListener;

private Context context;
private List<Point> pointsList;
private Child child;
private Point point;

public PopupAdapter(Context context, List<Point> points){
    this.context = context;
    this.pointsList = points;
}

@Override
public PopupAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.point_list_row, parent, false);
    return new ViewHolder(view, context);
}

@Override
public void onBindViewHolder(PopupAdapter.ViewHolder holder, int position) {

    holder.pointCardView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mListener.OnItemClicked();
        }
    });

    Point point = pointsList.get(position);
    holder.image.setImageDrawable(point.getImagePath());
    holder.description.setText(point.getDescription());

}