From a6205f3dca13f827c309f1e835b8e404da712048 Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 29 May 2014 07:15:34 -0700 Subject: [PATCH] move onBackPressed() into activity superclasses --- .../src/org/eehouse/android/xw4/DelegateBase.java | 1 + .../src/org/eehouse/android/xw4/GamesListActivity.java | 10 ---------- .../src/org/eehouse/android/xw4/GamesListDelegate.java | 2 +- .../src/org/eehouse/android/xw4/StudyListActivity.java | 7 ------- .../src/org/eehouse/android/xw4/StudyListDelegate.java | 3 ++- .../src/org/eehouse/android/xw4/XWActivity.java | 7 +++++++ .../src/org/eehouse/android/xw4/XWListActivity.java | 7 +++++++ .../src/org/eehouse/android/xw4/loc/LocActivity.java | 7 ------- .../eehouse/android/xw4/loc/LocItemEditActivity.java | 7 ------- 9 files changed, 18 insertions(+), 33 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java index 3c57fcfbb..c6ddfb59f 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java @@ -65,6 +65,7 @@ public class DelegateBase implements DlgDelegate.DlgClickNotify, protected void onPause() {} protected void onStop() {} protected void onDestroy() {} + protected boolean onBackPressed() { return false; } protected void prepareDialog( int id, Dialog dialog ) {} // public boolean onOptionsItemSelected( MenuItem item ) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListActivity.java index 515d3b656..0096fe505 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListActivity.java @@ -20,13 +20,10 @@ package org.eehouse.android.xw4; -import android.app.ListActivity; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Bundle; -import android.view.Menu; -import android.view.MenuItem; import org.eehouse.android.xw4.jni.CurGameInfo; @@ -81,13 +78,6 @@ public class GamesListActivity extends XWListActivity { } } - @Override - public void onBackPressed() { - if ( !m_dlgt.onBackPressed() ) { - super.onBackPressed(); - } - } - public static void onGameDictDownload( Context context, Intent intent ) { intent.setClass( context, GamesListActivity.class ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java index f5bfc21ac..bf5d5bc20 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java @@ -429,7 +429,6 @@ public class GamesListDelegate extends ListDelegateBase protected void onWindowFocusChanged( boolean hasFocus ) { - // super.onWindowFocusChanged( hasFocus ); if ( hasFocus ) { updateField(); @@ -604,6 +603,7 @@ public class GamesListDelegate extends ListDelegateBase } } + @Override protected boolean onBackPressed() { boolean handled = 0 < m_selGames.size() || 0 < m_selGroupIDs.size(); if ( handled ) { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/StudyListActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/StudyListActivity.java index 1cd4781b4..9d9557e1c 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/StudyListActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/StudyListActivity.java @@ -39,13 +39,6 @@ public class StudyListActivity extends XWListActivity { super.onCreate( savedInstanceState, m_dlgt ); } - @Override - public void onBackPressed() { - if ( !m_dlgt.backPressed() ) { - super.onBackPressed(); - } - } - public static void launchOrAlert( Context context, int lang, DlgDelegate.HasDlgDelegate dlg ) { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/StudyListDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/StudyListDelegate.java index d9dda4f77..a4eb05c69 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/StudyListDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/StudyListDelegate.java @@ -82,7 +82,8 @@ public class StudyListDelegate extends ListDelegateBase initOrFinish( getIntent() ); } - protected boolean backPressed() + @Override + protected boolean onBackPressed() { boolean handled = 0 < m_checkeds.size(); if ( handled ) { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java index c75cf3ab5..dce0d10e9 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java @@ -72,6 +72,13 @@ public class XWActivity extends Activity { super.onDestroy(); } + @Override + public void onBackPressed() { + if ( !m_dlgt.onBackPressed() ) { + super.onBackPressed(); + } + } + @Override public boolean onCreateOptionsMenu( Menu menu ) { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListActivity.java index 708926272..e4a286d70 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListActivity.java @@ -72,6 +72,13 @@ public class XWListActivity extends ListActivity { super.onDestroy(); } + @Override + public void onBackPressed() { + if ( !m_dlgt.onBackPressed() ) { + super.onBackPressed(); + } + } + @Override public boolean onCreateOptionsMenu( Menu menu ) { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocActivity.java index 458666f19..6010e075a 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocActivity.java @@ -41,13 +41,6 @@ public class LocActivity extends XWListActivity { return m_dlgt.onCreateOptionsMenu( menu ); } - @Override - public void onBackPressed() { - if ( !m_dlgt.onBackPressed() ) { - super.onBackPressed(); - } - } - @Override public void onWindowFocusChanged( boolean hasFocus ) { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocItemEditActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocItemEditActivity.java index 39a87c196..05ccc82f7 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocItemEditActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocItemEditActivity.java @@ -38,11 +38,4 @@ public class LocItemEditActivity extends XWActivity { super.onCreate( savedInstanceState, m_dlgt ); } // onCreate - // Belongs in superclass? - @Override - public void onBackPressed() { - if ( !m_dlgt.backPressed() ) { - super.onBackPressed(); - } - } }