From 1c9af1bcfc5d47cf2eb4c39dba6661bf55f326aa Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 25 Aug 2016 21:34:33 -0700 Subject: [PATCH 1/3] fix assertions: load xml widgets on demand --- .../XWords4/src/org/eehouse/android/xw4/Toolbar.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Toolbar.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Toolbar.java index 3d3c79351..58fc7bbdc 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Toolbar.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Toolbar.java @@ -59,8 +59,6 @@ public class Toolbar implements BoardContainer.SizeChangeListener { private DlgDelegate.HasDlgDelegate m_dlgDlgt; private LinearLayout m_layout; private boolean m_visible; - private ScrollView m_scrollVert; - private HorizontalScrollView m_scrollHor; private Map m_onClickListeners; private Map m_onLongClickListeners; @@ -68,12 +66,7 @@ public class Toolbar implements BoardContainer.SizeChangeListener { { m_activity = activity; m_dlgDlgt = dlgDlgt; - m_scrollVert = - (ScrollView)activity.findViewById( R.id.tbar_parent_vert ); - Assert.assertNotNull( m_scrollVert ); - m_scrollHor = - (HorizontalScrollView)activity.findViewById( R.id.tbar_parent_hor ); - Assert.assertNotNull( m_scrollHor ); + BoardContainer.registerSizeChangeListener( this ); } @@ -180,7 +173,8 @@ public class Toolbar implements BoardContainer.SizeChangeListener { m_layout.setOrientation( isPortrait ? LinearLayout.HORIZONTAL : LinearLayout.VERTICAL ); - ViewGroup scroller = isPortrait ? m_scrollHor : m_scrollVert; + int scrollerId = isPortrait ? R.id.tbar_parent_hor : R.id.tbar_parent_vert; + ViewGroup scroller = (ViewGroup)m_activity.findViewById( scrollerId ); if ( null != scroller ) { // Google's had reports of a crash adding second view scroller.removeAllViews(); From d7acdc4a9319ea5885d0bcc6466926412a1f84be Mon Sep 17 00:00:00 2001 From: Eric House Date: Fri, 26 Aug 2016 21:48:52 -0700 Subject: [PATCH 2/3] don't commit fragment transactions until ready Attempt to fix crashes happening when the occasional fragment transaction happens before the OS is ready. Keep a boolean indicating whether we're in that state, and when it's not set create a Runnable to be run next time it is. Temporary Toast lets me know when it's working. --- .../org/eehouse/android/xw4/MainActivity.java | 47 ++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/MainActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/MainActivity.java index 270b10891..a79e13d92 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/MainActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/MainActivity.java @@ -53,6 +53,8 @@ public class MainActivity extends XWActivity private int m_maxPanes; private int m_nextID = 0x00FFFFFF; private Boolean m_isPortrait; + private boolean m_safeToCommit; + private Runnable m_runWhenSafe; // for tracking launchForResult callback recipients private Map> m_pendingCodes @@ -84,8 +86,24 @@ public class MainActivity extends XWActivity getIntent().getExtras(), null ); } } + + setSafeToRun(); } // onCreate + @Override + protected void onSaveInstanceState( Bundle outState ) + { + super.onSaveInstanceState( outState ); + m_safeToCommit = false; + } + + @Override + protected void onPostResume() + { + setSafeToRun(); + super.onPostResume(); + } + // called when we're brought to the front (probably as a result of // notification) @Override @@ -414,8 +432,26 @@ public class MainActivity extends XWActivity addFragmentImpl( fragment, parentName ); } - private void addFragmentImpl( Fragment fragment, String parentName ) + private void addFragmentImpl( final Fragment fragment, + final String parentName ) { + if ( m_safeToCommit ) { + safeAddFragment( fragment, parentName ); + } else { + Assert.assertNull( m_runWhenSafe ); + m_runWhenSafe = new Runnable() { + @Override + public void run() { + safeAddFragment( fragment, parentName ); + } + }; + DbgUtils.showf( this, "Putting off fragment construction" ); + } + } + + private void safeAddFragment( Fragment fragment, String parentName ) + { + Assert.assertTrue( m_safeToCommit ); String newName = fragment.getClass().getSimpleName(); boolean replace = false; FragmentManager fm = getSupportFragmentManager(); @@ -475,4 +511,13 @@ public class MainActivity extends XWActivity // else wrong. // fm.executePendingTransactions(); } + + private void setSafeToRun() + { + m_safeToCommit = true; + if ( null != m_runWhenSafe ) { + m_runWhenSafe.run(); + m_runWhenSafe = null; + } + } } From cd0de1daa77bfd06a71bd9fe871db073bf8b0dcd Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 29 Aug 2016 06:33:27 -0700 Subject: [PATCH 3/3] ready for interim release up version strings and make a toast DEBUG-only --- xwords4/android/XWords4/AndroidManifest.xml | 2 +- xwords4/android/XWords4/assets/changes.html | 7 ++++--- xwords4/android/XWords4/res/values/app_name.xml | 2 +- .../XWords4/src/org/eehouse/android/xw4/MainActivity.java | 4 +++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/xwords4/android/XWords4/AndroidManifest.xml b/xwords4/android/XWords4/AndroidManifest.xml index ce3f269b3..007b6c934 100644 --- a/xwords4/android/XWords4/AndroidManifest.xml +++ b/xwords4/android/XWords4/AndroidManifest.xml @@ -22,7 +22,7 @@ to come from a domain that you own or have control over. --> diff --git a/xwords4/android/XWords4/assets/changes.html b/xwords4/android/XWords4/assets/changes.html index b4e9b83b3..6f0b485f0 100644 --- a/xwords4/android/XWords4/assets/changes.html +++ b/xwords4/android/XWords4/assets/changes.html @@ -13,10 +13,11 @@ -

Crosswords 4.4.109 release

+

Crosswords 4.4.110 release

-

This release adds experimental support for side-by-side views on - tablets.

+

This release fixes a couple of rare crashes added by the last + release. That release's experimental support for side-by-side + views on tablets remains the focus.