Languages

Menu
Sites
Language
SceneManager::GetCurrentSceneId() returns a wrong Id

SceneManager::GetCurrentSceneId method returns a last scene's Id

after called SceneManager::GoForward method with animation type.

Is it a bug or am I missing something?

[Class A]…SCENE_A

void ClassA::method() {
    SceneManager* pSceneManager = SceneManager::GetInstance();
    AppAssert(pSceneManager);
    pSceneManager->GoForward(ForwardSceneTransition(SCENE_B, SCENE_TRANSITION_ANIMATION_TYPE_NONE));    // GetCurrentSceneId will return “SCENE_B” at ClassB::OnInitializing.
    pSceneManager->GoForward(ForwardSceneTransition(SCENE_B, SCENE_TRANSITION_ANIMATION_TYPE_ZOOM_IN));    // GetCurrentSceneId will return “SCENE_A" at ClassB::OnInitializing.
}

[Class B]

result ClassB::OnInitializing(void) {
    SceneManager* pSceneManager = SceneManager::GetInstance();
    AppAssert(pSceneManager);
    AppLog(“%ls”, pSceneManager->GetCurrentSceneId().GetPointer());
}

Responses

4 Replies
Gary V

Hi,

Probably a scene is considered "current" until 1.) a new scene has been created and initialized, and 2.) a transition from the current scene to the new scene has been completed. It is probably just a coincidence that SCENE_TRANSITION_ANIMATION_TYPE_NONE gets "completed" even before a new scene has been initialized.

If you need to rely on scene ordering, don't use Form::OnInitializing(), but have a look at ISceneEventListener::OnSceneActivatedN() and ISceneEventListener::OnSceneDeactivated(). OnSceneActivatedN() is always called after Form::OnInitializing().

A related thread:

https://developer.tizen.org/forums/native-application-development/solved-q-on-initial-onsceneactivatedn-on-destroy-onscenedeactivated.

Gary

Yusuke Sugaya

Thank you for the advice Gary.

I'm sorry, It needed more detail about my case.

I know that it could get the correct current scene id at OnSceneActivatedN().

But, ClassB in example code implement a GroupedListView and it means ClassB also implement a IGroupedListViewItemProvider actually.

CreateGroupItem() and GetGroupCount() are called before OnSceneActivatedN() and I need the correct scene id at CreateGroupItem() means before OnSceneActivatedN() is called.

Is that specification?

Yusuke

 

Gary V

Yusuke,

I think there are [at least] two ways to handle this, if I understand correctly. You can create a unique Tizen::Ui::Controls::Form subclass for each unique scene, so you inherently know that FormSceneA corresponds to "SceneA" and FormSceneB corresponds to "SceneB". Otherwise, if you really want to reuse the same FormMyScene for both "SceneA" and "SceneB", just pass Tizen::Ui::Scenes::SceneId to FormMyScene constructor in Tizen::Ui::Scenes::IFormFactory on-create, CreateFormN(const Tizen::Base::String& formId, const Tizen::Ui::Scenes::SceneId& sceneId). Save it in Form::constructor and examine it in Form::OnInitializing().

Gary

Yusuke Sugaya

Really Thank you for giving me the useful advices.

Finally, I chose is that to get the sceneId in OnSceneActivatedN() to know the current scene and get the parameters depend on scene

and then update the list of ListView.

 

Maybe the later suggestion of the 2 ways you suggested is much better than mine.

 

Yusuke