mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-08 05:24:39 +01:00
dispatch onActivityResult() from DualpaneDelegate
Inviting didn't work because it's done by a separate activity whose onActivityResult() was dropped because DualpaneDelegate was the recipient. That now handles it by asking MainActivity to sent it to a contained Delegate. Currently will go only to the top (rightmost) one.
This commit is contained in:
parent
176820aac9
commit
aef95ae498
4 changed files with 34 additions and 5 deletions
|
@ -111,7 +111,8 @@ public class DelegateBase implements DlgClickNotify,
|
|||
protected void onActivityResult( RequestCode requestCode, int resultCode,
|
||||
Intent data )
|
||||
{
|
||||
DbgUtils.logf( "DelegateBase.onActivityResult(): subclass responsibility!!!" );
|
||||
DbgUtils.logf( "%s.onActivityResult(): subclass responsibility!!!",
|
||||
getClass().getSimpleName() );
|
||||
}
|
||||
|
||||
protected void onResume()
|
||||
|
|
|
@ -68,4 +68,11 @@ public class DualpaneDelegate extends DelegateBase {
|
|||
DbgUtils.logf( "DualpaneDelegate.handleBackPressed() => %b", handled );
|
||||
return handled;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult( RequestCode requestCode, int resultCode, Intent data )
|
||||
{
|
||||
MainActivity main = (MainActivity)m_activity;
|
||||
main.dispatchOnActivityResult( requestCode, resultCode, data );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,14 +185,25 @@ public class MainActivity extends XWActivity
|
|||
*/
|
||||
protected boolean dispatchBackPressed()
|
||||
{
|
||||
View child = m_root.getChildAt( m_root.getChildCount() - 1 );
|
||||
Fragment frag = getSupportFragmentManager()
|
||||
.findFragmentById( child.getId() );
|
||||
XWFragment frag = getTopFragment();
|
||||
boolean handled = null != frag
|
||||
&&((XWFragment)frag).getDelegate().handleBackPressed();
|
||||
&& frag.getDelegate().handleBackPressed();
|
||||
return handled;
|
||||
}
|
||||
|
||||
protected void dispatchOnActivityResult( RequestCode requestCode,
|
||||
int resultCode, Intent data )
|
||||
{
|
||||
XWFragment frag = getTopFragment();
|
||||
|
||||
if ( null != frag ) {
|
||||
frag.onActivityResult( requestCode.ordinal(), resultCode, data );
|
||||
} else {
|
||||
DbgUtils.logdf( "dispatchOnActivityResult(): can't dispatch %s",
|
||||
requestCode.toString() );
|
||||
}
|
||||
}
|
||||
|
||||
protected Point getFragmentSize()
|
||||
{
|
||||
Rect rect = new Rect();
|
||||
|
@ -305,6 +316,14 @@ public class MainActivity extends XWActivity
|
|||
// Dualpane mode stuff
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private XWFragment getTopFragment()
|
||||
{
|
||||
View child = m_root.getChildAt( m_root.getChildCount() - 1 );
|
||||
XWFragment frag = (XWFragment)getSupportFragmentManager()
|
||||
.findFragmentById( child.getId() );
|
||||
return frag;
|
||||
}
|
||||
|
||||
// Walk all Fragment children and if they care notify of change.
|
||||
private void tellOrientationChanged()
|
||||
{
|
||||
|
|
|
@ -90,6 +90,8 @@ public class XWFragment extends Fragment implements Delegator {
|
|||
@Override
|
||||
public void onResume()
|
||||
{
|
||||
DbgUtils.logdf( "%s.onResume() called",
|
||||
this.getClass().getSimpleName() );
|
||||
super.onResume();
|
||||
m_dlgt.onResume();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue