From 68df61daa8f5e8051f953cb2011e5240b55bba0a Mon Sep 17 00:00:00 2001 From: Eric House Date: Sat, 2 Jul 2016 12:29:16 -0700 Subject: [PATCH] fix crash on old device by using new API conditionally --- .../org/eehouse/android/xw4/ChatDelegate.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatDelegate.java index e87a8bea7..90bc003c7 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatDelegate.java @@ -86,14 +86,18 @@ public class ChatDelegate extends DelegateBase { m_scroll = (ScrollView)findViewById( R.id.scroll ); m_layout = (TableLayout)findViewById( R.id.chat_history ); - m_layout.addOnLayoutChangeListener( new OnLayoutChangeListener() { - @Override - public void onLayoutChange( View vv, int ll, int tt, int rr, - int bb, int ol, int ot, - int or, int ob ) { - scrollDown(); - } - }); + + // OnLayoutChangeListener added in API 11 + if ( 11 <= Integer.valueOf( android.os.Build.VERSION.SDK ) ) { + m_layout.addOnLayoutChangeListener( new OnLayoutChangeListener() { + @Override + public void onLayoutChange( View vv, int ll, int tt, int rr, + int bb, int ol, int ot, + int or, int ob ) { + scrollDown(); + } + }); + } DBUtils.HistoryPair[] pairs = DBUtils.getChatHistory( m_activity, m_rowid, locals ); @@ -110,7 +114,7 @@ public class ChatDelegate extends DelegateBase { // Should really assert.... finish(); } - } + } // init @Override protected void onResume()