-4

I have two fragments in an activity. RecordFragment records audio, RecordingsFragment displays all the record audio. My problem is how do I refresh RecyclerView of RecordingsFragment after I click stop button in RecordFragment.

RecordFragment

RecordingsFragment

This is code for adapter. Utils.getListOfNames() retrives list of files from storage.

mRecyclerView = rootView.findViewById(R.id.recyclerView);
mAdapter = new RecordingsListAdapter(Utils.getListOfNames(), getContext());
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));

This is the onClick of stopButton

Toast.makeText(getContext(), "Stop clicked ", Toast.LENGTH_SHORT).show();
mediaRecorder.stop();
startButton.setVisibility(View.VISIBLE);
stopButton.setVisibility(View.GONE);
Markus Kauppinen
  • 3,025
  • 4
  • 20
  • 30

2 Answers2

0

I hope you know about Broadcast Receivers, if not then read hereAndroid Broadcast Receivers and for detail practical implementation and use local broadcast receivers to do this.

Arfan Mirza
  • 668
  • 1
  • 14
  • 24