add logging; fix NPE

Running into a case where views haven't been added to the layout yet but
I'm searching there for their associated fragments. Fix to NPE stops a
crash, but intents still aren't being handled. I need to try to handle
them later, but am unsure when to start trying.
This commit is contained in:
Eric House 2016-09-05 20:29:16 -07:00
parent bd2fbdeb88
commit 95d147d9c3
2 changed files with 16 additions and 5 deletions

View file

@ -570,11 +570,16 @@ public class DelegateBase implements DlgClickNotify,
protected boolean isVisible() { return m_isVisible; }
protected boolean canHandleNewIntent( Intent intent ) { return false; }
protected boolean canHandleNewIntent( Intent intent )
{
DbgUtils.logdf( "%s.canHandleNewIntent() => false",
getClass().getSimpleName(), intent.toString() );
return false;
}
protected void handleNewIntent( Intent intent ) {
DbgUtils.logf( "%s.handleNewIntent(%s): not handling",
getClass().getSimpleName(), intent.toString() );
DbgUtils.logdf( "%s.handleNewIntent(%s): not handling",
getClass().getSimpleName(), intent.toString() );
}
protected void runWhenActive( Runnable proc )

View file

@ -209,6 +209,9 @@ public class MainActivity extends XWActivity
popIntoView( frag );
frag.getDelegate().handleNewIntent( intent );
}
} else {
DbgUtils.logdf( "no fragment for child %s indx %d",
child.getClass().getSimpleName(), ii );
}
}
@ -364,9 +367,12 @@ public class MainActivity extends XWActivity
private XWFragment getTopFragment()
{
XWFragment frag = null;
View child = m_root.getChildAt( m_root.getChildCount() - 1 );
XWFragment frag = (XWFragment)getSupportFragmentManager()
.findFragmentById( child.getId() );
if ( null != child ) {
frag = (XWFragment)getSupportFragmentManager()
.findFragmentById( child.getId() );
}
return frag;
}