Skip to content
This repository has been archived by the owner on Nov 8, 2019. It is now read-only.

Going back to previous Activity from full screen mode #128

Closed
digitalbuddha opened this issue Jun 27, 2016 · 10 comments
Closed

Going back to previous Activity from full screen mode #128

digitalbuddha opened this issue Jun 27, 2016 · 10 comments

Comments

@digitalbuddha
Copy link

Based on response on following issue I was able to implement a "always full screen" mode.
#66

For reference I am doing the following

 ((ViewGroup)((ViewGroup)((ViewGroup)((ViewGroup)((ViewGroup)findViewById(R.id.main_layout))
                .getChildAt(0))
                .getChildAt(0))
                .getChildAt(1))
                .getChildAt(2))
                .getChildAt(1)
                .performClick();

Now I'd like to be able to go from the full screen mode directly back to previous activity but cannot find a way to hijack the back button press. I've tried the following to no avail

  @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (Integer.parseInt(android.os.Build.VERSION.SDK) > 5
                && keyCode == KeyEvent.KEYCODE_BACK
                && event.getRepeatCount() == 0) {
            onBackPressed();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }


    @Override
    public void onBackPressed() {
        super.onBackPressed();
        finish();

    }

Any help/suggestions would be appreciated

@hegazy
Copy link

hegazy commented Jul 5, 2016

videoWidgetView.post(new Runnable() {
            @Override
            public void run() {
                videoWidgetView.fullScreenDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                    @Override
                    public void onDismiss(DialogInterface dialog) {
                        videoWidgetView.setVisibility(View.INVISIBLE);
                        finish();
                    }
                });
            }
        });

I'm using this to go back to the previous activity from fullscreen mode. I think it's time to add these options to the library.

@nathanmartz
Copy link

Thanks for posting this workaround. The demand is pretty obvious for programatic control of view modes, so we're planning to add that in the next release.

@hegazy
Copy link

hegazy commented Jul 12, 2016

@nathanmartz That will be very cool!

@dav-cz
Copy link
Contributor

dav-cz commented Aug 5, 2016

With v0.9.0 there's now an official API for this.

@dav-cz dav-cz closed this as completed Aug 5, 2016
@electmk
Copy link

electmk commented Apr 3, 2017

@dav-cz
How to back from the full screen mode directly to previous activity ??

@hegazy
I tried your code with (VrPanoramaView) but i get error in (fullScreenDialog)

@Awsom3D
Copy link

Awsom3D commented Aug 12, 2017

@dav-cz
I don't see how the official API fix this problem.
Exiting the fullscreen mode still does not exit the activity.

@electmk the code from @hegazy worked on older version of the gvr-android-sdk : 1.20.0 for instance.

The new solution is to use the onDisplayModeChanged callback from VrPanoramaEventListener.

@Override
public void onDisplayModeChanged(int newDisplayMode) {
    super.onDisplayModeChanged(newDisplayMode);
    if (newDisplayMode == VrWidgetView.DisplayMode.EMBEDDED) {
        VrPanoramaActivity.this.finish();
    }
}

@electmk
Copy link

electmk commented Aug 22, 2017

@Awsom3D
I got error (Method does not override method from its superclass) when i put the method in VrPanoramaActivity

@Awsom3D
Copy link

Awsom3D commented Aug 22, 2017

@electmk as said before the onDisplayModeChanged callback is from VrPanoramaEventListener, not VrPanoramaActivity.

From your VrPanoramaActivity onCreate you should set a VrPanoramaEventListener on your VrPanoramaView :

panoWidgetView = (VrPanoramaView) findViewById(R.id.pano_view);
panoWidgetView.setEventListener(new ActivityEventListener());

Then from this listener, override the onDisplayModeChanged callback

private class ActivityEventListener extends VrPanoramaEventListener {
  @Override
  public void onDisplayModeChanged(int newDisplayMode) {
  [...]

@electmk
Copy link

electmk commented Aug 22, 2017

@Awsom3D
It's worked .. thank you
But it shows a black screen for seconds before finish .. Can I avoid this?

@Awsom3D
Copy link

Awsom3D commented Aug 23, 2017

@electmk sorry, no clue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants