Hello! I write application on fragments, with MVP from Moxy . In the implementation of only one activity, which is a container for all fragments.

When the application starts, the fragment with splash-screen is shown:

  @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(LAYOUT); ButterKnife.bind(this); showSplashFragment(); } @Override public void showSplashFragment() { getSupportFragmentManager() .beginTransaction() .replace(R.id.ltContainer, SplashFragment.newInstance()) .commit(); } 

The essence of the problem is that the fragment appears only after half a second. Before that, just a white screen is shown. Has anyone come across this?

UPD: SlpashFragment

 private static final int LAYOUT = R.layout.fragment_splash; //@formatter:off @InjectPresenter SplashPresenter splashPresenter; @BindView(R.id.tvTimeCounter) TextView tvTimeCounter; @BindView(R.id.progressBar) ProgressBar progressBar; //@formatter:on public static SplashFragment newInstance() { SplashFragment fragment = new SplashFragment(); Bundle args = new Bundle(); fragment.setArguments(args); return fragment; } @Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { View view = inflater.inflate(LAYOUT, container, false); ButterKnife.bind(this, view); showSplashProgress(); splashPresenter.showFragment(); return view; } @Override public void showSplashProgress() { progressBar.setVisibility(View.VISIBLE); } @Override public void showAuthFragment() { ((MainActivity) getActivity()).showAuthFragment(); } @Override public void showMapFragment() { ((MainActivity) getActivity()).showMapFragment(); } @Override public void showReplayError() { // TODO: 22.11.2016 } } 
  • At the end of the showSplashFragment() method, add an entry to the log. This record will be displayed without delay? - post_zeew
  • Yes, the record appears a little bit earlier. Now I’ll post the splash code - no news
  • Show SplashPresenter . - post_zeew
  • I'll be at the computer in an hour, I'll post it. There is a check for the contents of the SharedPreference and starts an asynchronous request to the network. - no news
  • The same problem was before the use of the presenter, by the way - no news

1 answer 1

Because the splash screen should be shown at this moment when the screen is white. At this moment there is a "cold" launch of the application. The picture in the splash screen should be set in the subject. Read more on Habré

  • thank. All perfectly! - no news