From 253c0d7496b0530336e9d9537ad597c71be19935 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 10 May 2016 06:40:23 -0700 Subject: [PATCH] turn off saving logs for now; move capture of title to where it's more likely to succeed, and assert that it is. I think this will fix the title-not-reverting problem I've been seeing. --- .../src/org/eehouse/android/xw4/DBUtils.java | 32 ++++++++++--------- .../android/xw4/GamesListDelegate.java | 5 +-- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java index 2c154f928..55fd13c46 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java @@ -67,8 +67,8 @@ public class DBUtils { public static final int GROUPID_UNSPEC = -1; public static final String KEY_NEWGAMECOUNT = "DBUtils.newGameCount"; - // how many log rows to keep? - private static final int LOGLIMIT = 5000; + // how many log rows to keep? (0 means off) + private static final int LOGLIMIT = 0; private static final String DICTS_SEP = ","; @@ -2418,22 +2418,24 @@ public class DBUtils { private static void appendLog( Context context, String msg ) { - ContentValues values = new ContentValues(); - values.put( DBHelper.MESSAGE, msg ); + if ( 0 < LOGLIMIT ) { + ContentValues values = new ContentValues(); + values.put( DBHelper.MESSAGE, msg ); - initDB( context ); - synchronized( s_dbHelper ) { - SQLiteDatabase db = s_dbHelper.getWritableDatabase(); - long rowid = db.insert( DBHelper.TABLE_NAME_LOGS, null, values ); + initDB( context ); + synchronized( s_dbHelper ) { + SQLiteDatabase db = s_dbHelper.getWritableDatabase(); + long rowid = db.insert( DBHelper.TABLE_NAME_LOGS, null, values ); - if ( 0 == (rowid % (LOGLIMIT / 10)) ) { - String where = - String.format( "not rowid in (select rowid from %s order by TIMESTAMP desc limit %d)", - DBHelper.TABLE_NAME_LOGS, LOGLIMIT ); - int nGone = db.delete( DBHelper.TABLE_NAME_LOGS, where, null ); - DbgUtils.logf( false, "appendLog(): deleted %d rows", nGone ); + if ( 0 == (rowid % (LOGLIMIT / 10)) ) { + String where = + String.format( "not rowid in (select rowid from %s order by TIMESTAMP desc limit %d)", + DBHelper.TABLE_NAME_LOGS, LOGLIMIT ); + int nGone = db.delete( DBHelper.TABLE_NAME_LOGS, where, null ); + DbgUtils.logf( false, "appendLog(): deleted %d rows", nGone ); + } + db.close(); } - db.close(); } } 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 21c123812..f33a5f436 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java @@ -918,6 +918,9 @@ public class GamesListDelegate extends ListDelegateBase @Override protected void init( Bundle savedInstanceState ) { + m_origTitle = getTitle(); + Assert.assertTrue( m_origTitle.equals( getString(R.string.app_name) ) ); + m_handler = new Handler(); // Next line useful if contents of DB are crashing app on start // DBUtils.saveDB( m_activity ); @@ -951,8 +954,6 @@ public class GamesListDelegate extends ListDelegateBase tryStartsFromIntent( getIntent() ); getDictForLangIf(); - - m_origTitle = getTitle(); } // init // protected View onCreateView( Bundle savedInstanceState )