mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-03-06 22:39:41 +08:00
[Android] Bottom tab not update (#275)
Fixes #259 Issue Screen doesn't update when switching between tabs. Problem When ScreenContainer re-added. mFragmentManager is destroyed.
This commit is contained in:
committed by
Michał Osadnik
parent
2b1b726723
commit
ca6319d26e
@@ -235,10 +235,24 @@ public class ScreenContainer<T extends ScreenFragment> extends ViewGroup {
|
||||
return mScreenFragments.contains(screenFragment);
|
||||
}
|
||||
|
||||
protected void ensureFragmentManager() {
|
||||
if (mFragmentManager != null && mFragmentManager.isDestroyed()) {
|
||||
// When fragmentManager is destroyed, try to remove current fragment's views
|
||||
for (int i = 0, size = mScreenFragments.size(); i < size; i++) {
|
||||
ScreenFragment screenFragment = mScreenFragments.get(i);
|
||||
removeView(screenFragment.getScreenRootView());
|
||||
}
|
||||
mFragmentManager = null;
|
||||
mActiveScreenFragments.clear();
|
||||
mNeedUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
mIsAttached = true;
|
||||
ensureFragmentManager();
|
||||
updateIfNeeded();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.swmansion.rnscreens;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
@@ -33,6 +35,10 @@ public class ScreenFragment extends Fragment {
|
||||
return mScreenView;
|
||||
}
|
||||
|
||||
protected ViewGroup getScreenRootView() {
|
||||
return mScreenView;
|
||||
}
|
||||
|
||||
public Screen getScreen() {
|
||||
return mScreenView;
|
||||
}
|
||||
|
||||
@@ -96,6 +96,11 @@ public class ScreenStackFragment extends ScreenFragment {
|
||||
return mScreenRootView;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ViewGroup getScreenRootView() {
|
||||
return mScreenRootView;
|
||||
}
|
||||
|
||||
public boolean isDismissable() {
|
||||
View child = mScreenView.getChildAt(0);
|
||||
if (child instanceof ScreenStackHeaderConfig) {
|
||||
|
||||
Reference in New Issue
Block a user