Я пытаюсь запустить свое приложение и получаю сообщение об ошибке в заголовке. Я не могу понять, почему я получаю их, как будто они работали раньше.
Ошибка времени выполнения, которую я получаю, находится ниже, не могу понять, почему она не работает, может кто-нибудь помочь мне. Ошибки:
Process: com.example.blogapplication, PID: 22891
java.lang.IllegalStateException: FragmentManager is already executing transactions
at androidx.fragment.app.FragmentManagerImpl.ensureExecReady(FragmentManager.java:2207)
at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2267)
at androidx.fragment.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:814)
at com.google.firebase.firestore.core.ActivityScope.lambda$onFragmentActivityStopCallOnce$1(com.google.firebase:firebase-firestore@@19.0.0:179)
at com.google.firebase.firestore.core.ActivityScope$$Lambda$2.run(Unknown Source:4)
at android.app.Activity.runOnUiThread(Activity.java:6904)
at com.google.firebase.firestore.core.ActivityScope.onFragmentActivityStopCallOnce(com.google.firebase:firebase-firestore@@19.0.0:163)
at com.google.firebase.firestore.core.ActivityScope.bind(com.google.firebase:firebase-firestore@@19.0.0:191)
at com.google.firebase.firestore.Query.addSnapshotListenerInternal(com.google.firebase:firebase-firestore@@19.0.0:923)
at com.google.firebase.firestore.Query.addSnapshotListener(com.google.firebase:firebase-firestore@@19.0.0:883)
at com.google.firebase.firestore.Query.addSnapshotListener(com.google.firebase:firebase-firestore@@19.0.0:824)
at com.example.blogapplication.HomeFragment.onCreateView(HomeFragment.java:80)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2439)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460)
at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:802)
at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625)
at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411)
at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366)
at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273)
at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3273)
at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3229)
at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:201)
at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:620)
at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:178)
at com.example.blogapplication.Menu.onStart(Menu.java:131)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1425)
at android.app.Activity.performStart(Activity.java:7825)
at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3294)
at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
I/ProviderInstaller: Installed default security provider GmsCore_OpenSSL
I/Process: Sending signal. PID: 22891 SIG: 9
Process 22891 terminated.
Домашний фрагмент
Query firstQuery = firebaseFirestore.collection("Posts").orderBy("timestamp", Query.Direction.DESCENDING).limit(3);
firstQuery.addSnapshotListener(getActivity(), new EventListener<QuerySnapshot>()
{
@Override
public void onEvent(QuerySnapshot documentSnapshots, FirebaseFirestoreException e) {
if (!documentSnapshots.isEmpty()) {
if (isFirstPageFirstLoad) {
lastVisible = documentSnapshots.getDocuments().get(documentSnapshots.size() - 1);
blog_list.clear();
}
for (DocumentChange doc : documentSnapshots.getDocumentChanges()) {
if (doc.getType() == DocumentChange.Type.ADDED) {
String blogPostId = doc.getDocument().getId();
BlogPost blogPost = doc.getDocument().toObject(BlogPost.class).withId(blogPostId);
if (isFirstPageFirstLoad) {
blog_list.add(blogPost);
} else {
blog_list.add(0, blogPost);
}
blogRecyclerAdapter.notifyDataSetChanged();
}
}
Меню
private void initializeFragment(){
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.add(R.id.main_container, homeFragment);
fragmentTransaction.add(R.id.main_container, notificationFragment);
fragmentTransaction.add(R.id.main_container, accountFragment);
fragmentTransaction.hide(notificationFragment);
fragmentTransaction.hide(accountFragment);
fragmentTransaction.commit();
}
private void replaceFragment(Fragment fragment, Fragment currentFragment){
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
if(fragment == homeFragment){
fragmentTransaction.hide(accountFragment);
fragmentTransaction.hide(notificationFragment);
}
if(fragment == accountFragment){
fragmentTransaction.hide(homeFragment);
fragmentTransaction.hide(notificationFragment);
}
if(fragment == notificationFragment){
fragmentTransaction.hide(homeFragment);
fragmentTransaction.hide(accountFragment);
}
fragmentTransaction.show(fragment);
fragmentTransaction.replace(R.id.main_container, fragment);
fragmentTransaction.commit();
}
}