I set a 500ms cutscene for the fragment, and then made a network request in onViewCreate. When the network request starts, I will display a progress bar, but because the cutscene has not been completed at this time, the progress bar Before the interface is shown
How can I ensure that my method of requesting the network is executed after the cutscene is completed? (without using sleep)
04-23 04:25:21.455 3680-3680/? D/Main6Activity: click:
04-23 04:25:21.462 3680-3680/? D/TestFragment: onAttach: 1492921521462
04-23 04:25:21.464 3680-3680/? D/TestFragment: onCreateView: 1492921521464
04-23 04:25:21.466 3680-3680/? D/TestFragment: onViewCreated: 1492921521466
04-23 04:25:21.466 3680-3680/? D/TestFragment: onActivityCreated: 1492921521466
04-23 04:25:21.466 3680-3680/? D/TestFragment: onStart: 1492921521466
04-23 04:25:21.466 3680-3680/? D/TestFragment: onResume: 1492921521466
postDelayed 500ms before executing network request
If you can monitor the animation, just monitor the animation. If you can't monitor the animation, just postDelayed.
Set a listener for the animation and execute the network request when the animation is completed
Drunk. Have you heard of life cycle?
Try making network requests in the OnActivityCreate() or OnStart() method
Since we cannot monitor the end of the Fragment animation, we can change our thinking and add a listener to the animation, and then set the progress bar to be visible in the onEnd method