~eliasnaur/gio

2 2

Re: [PATCH 1/2] app: add RegisterDelegate method on *Window for Android

Gregory Pomerantz
Details
Message ID
<9584b56c-90de-db9c-ab20-1c3ce339a01e@wow.st>
DKIM signature
pass
Download raw message
On 11/21/19 7:43 AM, Elias Naur wrote:

> Good point. That suggests we shouldn't return an error from RegisterDelegate
> at all, and define exceptions as fatal.

I think we can and should return an error in five cases -- 1. there is 
no WIndow.driver (not sure if that is possible now but could be later as 
Gio is restructured for multiple windows), 2. GioView.getContext() 
returns null, 3. the View Context does not have a "getFragmentManager" 
method or we otherwise fail to get a FragmentManager, 4. the provided 
Java class cannot be loaded or instantiated, or 5. the provided class is 
not an instanceof Fragment.

Everything else will happen in the Handler which we can write in such a 
way that it can never throw an exception.

Re: [PATCH 1/2] app: add RegisterDelegate method on *Window for Android

Details
Message ID
<BYLNSX5JN5HC.2R5LFFR3UCZRY@toolbox>
In-Reply-To
<9584b56c-90de-db9c-ab20-1c3ce339a01e@wow.st> (view parent)
DKIM signature
pass
Download raw message
On Thu Nov 21, 2019 at 9:33 AM Gregory Pomerantz wrote:
> On 11/21/19 7:43 AM, Elias Naur wrote:
> 
> > Good point. That suggests we shouldn't return an error from RegisterDelegate
> > at all, and define exceptions as fatal.
> 
> I think we can and should return an error in five cases -- 1. there is 
> no WIndow.driver (not sure if that is possible now but could be later as 
> Gio is restructured for multiple windows), 2. GioView.getContext() 
> returns null, 3. the View Context does not have a "getFragmentManager" 
> method or we otherwise fail to get a FragmentManager, 4. the provided 
> Java class cannot be loaded or instantiated, or 5. the provided class is 
> not an instanceof Fragment.
> 

Unfortunately neither getContext nor getFragmentManager may be called from
outside the UI thread. And even if they could, their results could change
before the handler is run.

Re: [PATCH 1/2] app: add RegisterDelegate method on *Window for Android

Gregory Pomerantz
Details
Message ID
<3f8d0514-0873-fdd6-a5c3-a3e12a8453ce@wow.st>
In-Reply-To
<BYLNSX5JN5HC.2R5LFFR3UCZRY@toolbox> (view parent)
DKIM signature
pass
Download raw message
On 11/21/19 9:54 AM, Elias Naur wrote:
> Unfortunately neither getContext nor getFragmentManager may be called from
> outside the UI thread. And even if they could, their results could change
> before the handler is run.


The consequence of returning errors is that we cannot run on the main UI 
thread. In practice i think this means waiting for StageEvent = 
StageRunning, and then calling RegisterFragment in a goroutine (this 
works for ny openpgp-api implementation).

Also I ended up needing PlatformHandle as I couldn't find any other way 
of getting a JavaVM -- we need it to call methods on our Fragment once 
it has been installed.