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:
Eric House 2016-07-21 08:47:03 -07:00
parent 176820aac9
commit aef95ae498
4 changed files with 34 additions and 5 deletions

View file

@ -111,7 +111,8 @@ public class DelegateBase implements DlgClickNotify,
protected void onActivityResult( RequestCode requestCode, int resultCode, protected void onActivityResult( RequestCode requestCode, int resultCode,
Intent data ) Intent data )
{ {
DbgUtils.logf( "DelegateBase.onActivityResult(): subclass responsibility!!!" ); DbgUtils.logf( "%s.onActivityResult(): subclass responsibility!!!",
getClass().getSimpleName() );
} }
protected void onResume() protected void onResume()

View file

@ -68,4 +68,11 @@ public class DualpaneDelegate extends DelegateBase {
DbgUtils.logf( "DualpaneDelegate.handleBackPressed() => %b", handled ); DbgUtils.logf( "DualpaneDelegate.handleBackPressed() => %b", handled );
return handled; return handled;
} }
@Override
protected void onActivityResult( RequestCode requestCode, int resultCode, Intent data )
{
MainActivity main = (MainActivity)m_activity;
main.dispatchOnActivityResult( requestCode, resultCode, data );
}
} }

View file

@ -185,14 +185,25 @@ public class MainActivity extends XWActivity
*/ */
protected boolean dispatchBackPressed() protected boolean dispatchBackPressed()
{ {
View child = m_root.getChildAt( m_root.getChildCount() - 1 ); XWFragment frag = getTopFragment();
Fragment frag = getSupportFragmentManager()
.findFragmentById( child.getId() );
boolean handled = null != frag boolean handled = null != frag
&&((XWFragment)frag).getDelegate().handleBackPressed(); && frag.getDelegate().handleBackPressed();
return handled; 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() protected Point getFragmentSize()
{ {
Rect rect = new Rect(); Rect rect = new Rect();
@ -305,6 +316,14 @@ public class MainActivity extends XWActivity
// Dualpane mode stuff // 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. // Walk all Fragment children and if they care notify of change.
private void tellOrientationChanged() private void tellOrientationChanged()
{ {

View file

@ -90,6 +90,8 @@ public class XWFragment extends Fragment implements Delegator {
@Override @Override
public void onResume() public void onResume()
{ {
DbgUtils.logdf( "%s.onResume() called",
this.getClass().getSimpleName() );
super.onResume(); super.onResume();
m_dlgt.onResume(); m_dlgt.onResume();
} }