search

Home  >  Q&A  >  body text

android - Fragment uses cutscenes, how to ensure that a method is executed after the cutscenes are completed?

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_u1582phpcn_u15822774 days ago620

reply all(6)I'll reply

  • 習慣沉默

    習慣沉默2017-05-16 13:34:51

    postDelayed 500ms before executing network request

    reply
    0
  • PHP中文网

    PHP中文网2017-05-16 13:34:51

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

    reply
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-16 13:34:51

    Set a listener for the animation and execute the network request when the animation is completed

    reply
    0
  • 巴扎黑

    巴扎黑2017-05-16 13:34:51

    Drunk. Have you heard of life cycle?

    reply
    0
  • 为情所困

    为情所困2017-05-16 13:34:51

    Try making network requests in the OnActivityCreate() or OnStart() method

    reply
    0
  • PHP中文网

    PHP中文网2017-05-16 13:34:51

    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

    reply
    0
  • Cancelreply