У меня есть действие, которое содержит пять фрагментов. Один из фрагментов - это фрагмент уведомления, который имеет представление переработчика и добавляет к нему элементы, теперь у меня есть другой фрагмент, который имеет запрос API и создает уведомление, которое возвращает данные в виде уведомление, я не могу найти способ получить данные из уведомления и добавить их к представлению переработчика, найденному во фрагменте уведомления.
вот мой код уведомления, найденный во фрагменте, который должен добавить данные о представлении переработчика, найденные во фрагменте уведомления
//create an intent to open notification intent
Intent intent=new Intent(getActivity (), NotificationFragmentCict.class);
NotificationFragmentCict fragment = new NotificationFragmentCict ();
FragmentManager fragmentManager = getFragmentManager();
//Replace intent with Bundle and put it in the transaction
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.add(R.id.nav_host_fragment_cict, fragment);
fragmentTransaction.replace(R.id.nav_host_fragment_cict,fragment);
fragmentTransaction.commit();
intent.setAction (Intent.ACTION_MAIN);
long when = System.currentTimeMillis ();
intent.addCategory (Intent.CATEGORY_LAUNCHER);
intent.putExtra ("controlnumber","Controlnumber:" + " " + studentClearance.getControlNumber () );
intent.putExtra ("reason","Reason: Full Transcript Fee");
intent.putExtra ("time"," " +when);
intent.putExtra ("department","From : SUA Bursar");
intent.addFlags (Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent statusPendingIntent = PendingIntent.getActivity (getActivity (),0,intent,PendingIntent.FLAG_UPDATE_CURRENT);
NotificationFragmentCict notificationFragmentCict =new NotificationFragmentCict ();
notificationFragmentCict.fillNotification (R.drawable.bursar, "Bursar", ""+studentClearance.getControlNumber (),"min");
NotificationCompat.Builder builder = new NotificationCompat.Builder (getActivity (), CHANNEL_IDcontrolnumber_Fulltranscript);
builder.setSmallIcon (R.drawable.ic_near_me_black_24dp);
builder.setContentTitle ("Control Number For Full Transcript");
builder.setPriority (NotificationCompat.PRIORITY_DEFAULT);
builder.setAutoCancel (true);
builder.setContentIntent (statusPendingIntent);
Вот мой фрагмент уведомления, который имеет функцию, которая добавляет новый элемент в представление переработчика
public void fillNotification(int mImage, String mtext, String mtext2, String mDate)
{
mRecyclerView.setHasFixedSize(true);
mLayoutManager = new LinearLayoutManager (getContext ());
mAdapter = new NotificationAdapter (notimodels);
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.setAdapter(mAdapter);
notimodels.add (0,new NotificationModel (mImage,mtext,mtext2,mDate));
swipeRefreshLayout.setRefreshing(false);
}
Когда я использую это Уведомление о заполнении для других фрагментов, оно выдает и выдает ошибку, что
Process: com.univibezstudios.ocappservice.ocapp, PID: 23358
java.lang.NullPointerException: Attempt to invoke virtual method 'void androidx.recyclerview.widget.RecyclerView.setHasFixedSize(boolean)' on a null object reference
at com.univibezstudios.ocappservice.ocapp.Fragments.NotificationFragmentCict.fillNotification(NotificationFragmentCict.java:87)
at com.univibezstudios.ocappservice.ocapp.Fragments.AccountFragmentCict$4$1$1.onDataChange(AccountFragmentCict.java:401)