android - Fragment uses cutscenes, how to ensure that a method is executed after the cutscenes are completed?
phpcn_u1582
phpcn_u1582 2017-05-16 13:32:51
0
6
639

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
phpcn_u1582
phpcn_u1582

reply all(6)
習慣沉默

postDelayed 500ms before executing network request

Ty80

If you can monitor the animation, just monitor the animation. If you can't monitor the animation, just postDelayed.

过去多啦不再A梦

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template