mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-04 23:02:02 +01:00
dispatch backPressed to the right-most fragment before, if still
unhandled, letting super interpret it as a pop-fragment action.
This commit is contained in:
parent
4fc2dd97b3
commit
54e5e61e4d
10 changed files with 33 additions and 9 deletions
|
@ -87,7 +87,7 @@ public class DelegateBase implements DlgClickNotify,
|
|||
protected void onStop() {}
|
||||
protected void onDestroy() {}
|
||||
protected void onWindowFocusChanged( boolean hasFocus ) {}
|
||||
protected boolean onBackPressed() { return false; }
|
||||
protected boolean handleBackPressed() { return false; }
|
||||
public void orientationChanged() {}
|
||||
|
||||
protected void requestWindowFeature( int feature ) {}
|
||||
|
|
|
@ -571,7 +571,8 @@ public class DictsDelegate extends ListDelegateBase
|
|||
}
|
||||
}
|
||||
|
||||
protected boolean onBackPressed()
|
||||
@Override
|
||||
protected boolean handleBackPressed()
|
||||
{
|
||||
boolean handled = 0 < m_selDicts.size();
|
||||
if ( handled ) {
|
||||
|
|
|
@ -59,4 +59,13 @@ public class DualpaneDelegate extends DelegateBase {
|
|||
DbgUtils.logf( "DualpaneDelegate.handleNewIntent() => %b", handled );
|
||||
return handled;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean handleBackPressed()
|
||||
{
|
||||
MainActivity main = (MainActivity)m_activity;
|
||||
boolean handled = main.dispatchBackPressed();
|
||||
DbgUtils.logf( "DualpaneDelegate.handleBackPressed() => %b", handled );
|
||||
return handled;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -307,7 +307,7 @@ public class DwnldDelegate extends ListDelegateBase {
|
|||
} // init
|
||||
|
||||
@Override
|
||||
protected boolean onBackPressed()
|
||||
protected boolean handleBackPressed()
|
||||
{
|
||||
// cancel any tasks that remain
|
||||
for ( Iterator<DownloadFilesTask> iter = m_dfts.iterator();
|
||||
|
@ -315,7 +315,7 @@ public class DwnldDelegate extends ListDelegateBase {
|
|||
DownloadFilesTask dft = iter.next();
|
||||
dft.cancel( true );
|
||||
}
|
||||
return super.onBackPressed();
|
||||
return super.handleBackPressed();
|
||||
}
|
||||
|
||||
private void mkListAdapter()
|
||||
|
|
|
@ -755,7 +755,7 @@ public class GameConfigDelegate extends DelegateBase
|
|||
} // onClick
|
||||
|
||||
@Override
|
||||
protected boolean onBackPressed()
|
||||
protected boolean handleBackPressed()
|
||||
{
|
||||
boolean consumed = false;
|
||||
if ( ! isFinishing() ) {
|
||||
|
|
|
@ -1303,7 +1303,7 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
}
|
||||
|
||||
@Override
|
||||
protected boolean onBackPressed()
|
||||
protected boolean handleBackPressed()
|
||||
{
|
||||
boolean handled = 0 < m_selGames.size() || 0 < m_selGroupIDs.size();
|
||||
if ( handled ) {
|
||||
|
|
|
@ -145,6 +145,19 @@ public class MainActivity extends XWActivity
|
|||
return handled;
|
||||
}
|
||||
|
||||
/**
|
||||
* The right-most pane only gets a chance to handle on-back-pressed.
|
||||
*/
|
||||
protected boolean dispatchBackPressed()
|
||||
{
|
||||
View child = m_root.getChildAt( m_root.getChildCount() - 1 );
|
||||
Fragment frag = getSupportFragmentManager()
|
||||
.findFragmentById( child.getId() );
|
||||
boolean handled = ((XWFragment)frag).getDelegate()
|
||||
.handleBackPressed();
|
||||
return handled;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Delegator interface
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -86,7 +86,7 @@ public class StudyListDelegate extends ListDelegateBase
|
|||
}
|
||||
|
||||
@Override
|
||||
protected boolean onBackPressed()
|
||||
protected boolean handleBackPressed()
|
||||
{
|
||||
boolean handled = 0 < m_checkeds.size();
|
||||
if ( handled ) {
|
||||
|
|
|
@ -128,7 +128,7 @@ public class XWActivity extends FragmentActivity implements Delegator {
|
|||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if ( !m_dlgt.onBackPressed() ) {
|
||||
if ( !m_dlgt.handleBackPressed() ) {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,8 @@ public class LocDelegate extends ListDelegateBase
|
|||
m_activity = delegator.getActivity();
|
||||
}
|
||||
|
||||
protected boolean onBackPressed()
|
||||
@Override
|
||||
protected boolean handleBackPressed()
|
||||
{
|
||||
LocUtils.saveLocalData( m_activity );
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue