I am new to Android world. I have main-activity with three Framelayout.
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<FrameLayout
android:id="@+id/react_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
<FrameLayout
android:id="@+id/footer_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<FrameLayout
android:id="@+id/loadingScreen_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/ic_loading">
<ProgressBar
android:id="@+id/loading_spinner"
style="?android:progressBarStyleLarge"
android:layout_width="wrap_content"
android:progressDrawable="@drawable/spinner"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:layout_marginBottom="100dp" />
</FrameLayout>
</merge>
I am using loadingScreen_fragment_container to show the splash screen. I am loading the ReactNative app inside the Android app. Since Android activity is gets called first so i am showing the splash screen from there (Please correct me if this is incorrect.) so that user will not see white blank screen.
So loadingScreen_fragment_container occupies the whole screen with BG image and spinner. Meanwhile everything is loading behind. I am using NativeModules to call Java function from ReacteNative Js code once My app gets its data from service call. JavaFunction Simply hides the loadingScreen_fragment_container FrameLayout.
@ReactMethod
public void HideSplashScreen(){
Fragment splashScreenFragment = fragmentManager.findFragmentById(R.id.loadingScreen_fragment_container);
if(splashScreenFragment != null && !splashScreenFragment.isHidden()) {
fragmentManager.beginTransaction().hide(splashScreenFragment).commit();
fragmentManager.beginTransaction().show(fragmentManager.findFragmentById(R.id.react_fragment_container)).commit();
}
}
Somehow this is not working for me, I can only see BG image and progress-bar. So I have few questions here
- Why Showing different fragment is not working for my case
- Is this a correct way to show the splash screen, as i am waiting for data to available to hide the splashscreen and callback is coming from react native layer.
- Since reactnative app is inside the Java app, so showing the splash screen in Java activity make more sense then in RN layer to avoid showing empty white screen
- Can any one point me any good document/blog for Reactive native threading model with Java app.
Thanks in advance